I have the following code for a bnb transaction, which is working on metamask, but now on trust wallet

    window.addEventListener('load', async () => {
    if (window.ethereum) {
      window.web3 = new Web3(ethereum);
      try {
        await window.ethereum.enable();
      } catch (err) {
        $('#status').html('User denied account access', err)
    } else if (window.ethereum) {
  web3 = new Web3(window.ethereum);
} else {
  // Code for HttpProvider remains unchanged
await window.ethereum.send('eth_requestAccounts');

  const initPayButton = () => {
    $('#PayButton').click(() => {
      // paymentAddress is where funds will be send to
      const paymentAddress = 'MyWallet'
      const amountEth = 0.05*document.getElementById('Q1').value

        from: ethereum.selectedAddress,
        gas: gas,
        gasLimit: gasLimit,
        to: paymentAddress,
        value: web3.utils.toWei(String(amountEth), 'ether')
      }, (err, transactionId) => {
        if (err) {
          console.log('Payment failed', err)
          $('#status').html('Payment failed')
        } else {
          console.log('Payment successful', transactionId)
          $('#status').html('Payment successful')

Could someone help me to find why it is working on metamask but no on trust wallet?

1 Answer 1


I found on web3js.

Try this

const web3 = new Web3(Web3.givenProvider || new Web3.providers.HttpProvider('http://localhost:8545'));



with your RPCurl like:


or you can use walletconnect

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.