0

我像这样连接信任钱包:

//**Connect wallet:**
    import WalletConnect from "@walletconnect/client";
    import QRCodeModal from "@walletconnect/qrcode-modal";    
    const connector = new WalletConnect({
            bridge: "https://bridge.walletconnect.org", // Required
            qrcodeModal: QRCodeModal,
          });    
     document.onreadystatechange = () => {
                // Create a connector          
          // Check if connection is already established
          if (!connector.connected) {
            // create new session
            connector.createSession();
          }
    }

当钱包连接时,我尝试签署转移消息以转移硬币(我尝试过使用 binance 链和 thorchain - 不工作)

这是我如何签署 msg的示例:

const network = 931; // thorchain(rune)
        const tx = {
          fee: {
            amounts: [
              {
                denom: "rune",
                amount: "0.01"
              }
            ],
            gas: "2000000"
          },
          memo:"test",
          "messages":[{
              "sendCoinsMessage": {
              fromAddress: 'thor1mkda02h8hsevykxwnnxs93tgtvgtz5djxteat0',
              toAddress: "thor1mkda02h8hsevykxwnnxs93tgtvgtz5djxteat0",
              amounts: [
                {
                  denom: "rune",
                  amount: "1"
                }
              ],
            }
          }]//end
        };

然后我格式化请求并签名:

    const request = self.connector._formatRequest({
        method: 'trust_signTransaction',
        params: [
            {
                network,
                transaction: JSON.stringify(tx),
            },
        ],
    });

    connector
      ._sendCallRequest(request)
      .then(result => {
        // Returns transaction signed in json or encoded format
        console.log(result);
      })
      .catch(error => {
        // Error returned when rejected
        console.log('error')
        console.error(error);
      });

},

这是我在我的信任钱包中看到的: 在此处输入图像描述

作为回应,我从控制台得到:

{"mode":"block","tx":{"fee":{"amount":[],"gas":"0"},"memo":"","msg":[],"signatures":[{"pub_key":{"type":"tendermint/PubKeySecp256k1","value":"A2yB9NhfIeEwTEDbs0ssZQcqtL/OWGuHqooeFllERot3"},"signature":"+kO2W2MfcSBwgLUF3zJUQK4e01YvIGXK8juzojEkE/RrVgrZJPRsthweuto4FJ1QK/MjUWuGlJiC+MjktlBexA=="}]}}

但是交易没有发送到区块链(如果我去区块链浏览器,我不会找到它)同样你可以在控制台费用和气体的响应中注意到总是 0

我该怎么办?

UPD 我也尝试过方法 trust_sendTransaction 而不是 trust_signTransaction 但没有帮助

4

0 回答 0