0

this is my code:

import { ethers } from "ethers";

const bsc_url = 'https://data-seed-prebsc-1-s1.bnbchain.org:8545';

const provider = new ethers.providers.JsonRpcProvider(bsc_url);
console.log("success");

let j = 0

provider.on('pending', async (txHash) => {
    if (txHash) {
        const tx = await provider.getTransaction(txHash)
        provider.removeListener('pending', this)
    }
})

and my error is :

/Users/10070702/Desktop/web3/node_modules/@ethersproject/logger/lib/index.js:238
        var error = new Error(message);
                    ^

Error: invalid hash (argument="value", value={"hash":"0x1cf104070cc1d1bbbe5bffb9d67f0d92833eeff058fae43fe00525fd67c0f331","type":0,"accessList":null,"blockHash":null,"blockNumber":null,"transactionIndex":null,"confirmations":0,"from":"0x31392A5b12445F5792250fa857Bb34a114d224d1","gasPrice":{"type":"BigNumber","hex":"0x028fa6ae00"},"gasLimit":{"type":"BigNumber","hex":"0x010b14"},"to":"0xd9c7A7ea1ab19CD5d8D6FCE224Acccc512A043b1","value":{"type":"BigNumber","hex":"0x0b"},"nonce":750,"data":"0x56591d596f707370000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c447247a786f6ff2e2e6e55d31214bafe2c630b4000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000b","r":"0x9315e74fdb2cc6cbf2cf0e2b57408c1121b04d3a9f9e46129a5ab49b3f7b6b84","s":"0x6dbad63bfdab3d142595b0f1972c669fe6ffbf2d3c272b9d02133639751280e0","v":230,"creates":null,"chainId":97}, code=INVALID_ARGUMENT, version=providers/5.7.2)
    at Logger.makeError (/Users/10070702/Desktop/web3/node_modules/@ethersproject/logger/lib/index.js:238:21)
    at Logger.throwError (/Users/10070702/Desktop/web3/node_modules/@ethersproject/logger/lib/index.js:247:20)
    at Logger.throwArgumentError (/Users/10070702/Desktop/web3/node_modules/@ethersproject/logger/lib/index.js:250:21)
    at Formatter.hex (/Users/10070702/Desktop/web3/node_modules/@ethersproject/providers/lib/formatter.js:178:23)
    at Formatter.hash (/Users/10070702/Desktop/web3/node_modules/@ethersproject/providers/lib/formatter.js:225:27)
    at JsonRpcProvider.<anonymous> (/Users/10070702/Desktop/web3/node_modules/@ethersproject/providers/lib/base-provider.js:2106:68)
    at step (/Users/10070702/Desktop/web3/node_modules/@ethersproject/providers/lib/base-provider.js:48:23)
    at Object.next (/Users/10070702/Desktop/web3/node_modules/@ethersproject/providers/lib/base-provider.js:29:53)
    at fulfilled (/Users/10070702/Desktop/web3/node_modules/@ethersproject/providers/lib/base-provider.js:20:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  reason: 'invalid hash',
  code: 'INVALID_ARGUMENT',
  argument: 'value',
  value: {
    hash: '0x1cf104070cc1d1bbbe5bffb9d67f0d92833eeff058fae43fe00525fd67c0f331',
    type: 0,
    accessList: null,
    blockHash: null,
    blockNumber: null,
    transactionIndex: null,
    confirmations: 0,
    from: '0x31392A5b12445F5792250fa857Bb34a114d224d1',
    gasPrice: BigNumber { _hex: '0x028fa6ae00', _isBigNumber: true },
    gasLimit: BigNumber { _hex: '0x010b14', _isBigNumber: true },
    to: '0xd9c7A7ea1ab19CD5d8D6FCE224Acccc512A043b1',
    value: BigNumber { _hex: '0x0b', _isBigNumber: true },
    nonce: 750,
    data: '0x56591d596f707370000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c447247a786f6ff2e2e6e55d31214bafe2c630b4000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000b',
    r: '0x9315e74fdb2cc6cbf2cf0e2b57408c1121b04d3a9f9e46129a5ab49b3f7b6b84',
    s: '0x6dbad63bfdab3d142595b0f1972c669fe6ffbf2d3c272b9d02133639751280e0',
    v: 230,
    creates: null,
    chainId: 97,
    wait: [Function (anonymous)]
  }
}

Node.js v20.5.1

0

Your Answer

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

Browse other questions tagged or ask your own question.