1

I have a working example how to allow user to transfer eth, how to let him transfer bsc, or thorchain or someother network?

This is how I 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();
      }
}

THis is how I can transfer eth tokens:

const tx2 = {

  from: "0xbc28Ea04101F03aA7a94C1379bc3AB32E65e62d3", // Required
  to: "0x89D24A7b4cCB1b6fAA2625Fe562bDd9A23260359", // Required (for non contract deployments)
  data: "0x", // Required
  // gasPrice: "0x02540be400", // Optional
  // gas: "0x9c40", // Optional
  // value: "0x00", // Optional
  // nonce: "0x0114", // Optional
};

// Send transaction
self.connector
  .sendTransaction(tx2)
  .then((result) => {
    // Returns transaction id (hash)
    console.log(result);
  })
  .catch((error) => {
    // Error returned when rejected
    console.error(error);
  });

This is the code works ONLY for eth transactions

How to specify other chain ? (for example thorchain or binance smart chain or btc chain )?

I've tried to use trust_signTransaction but this didn't help, details here: https://stackoverflow.com/questions/69493167/trust-wallet-dapp-connect-and-sign-transfer-message

1 Answer 1

0

How to specify other chain ?

There is no API for wallets to specify another chain. The only way for this to happen is that you detect the chain by chainId and then ask the user to switch the chain.

You can get the chainId with web3.eth.getChainId() method. The list of supported chain ids can be found in Chainlist.

1
  • you didn't get my question bro) I need a sample of code to transfer for example on chain bsc (if bsc is connected) you answered some other question I didn't ask Commented Oct 18, 2021 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.