Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

272
Views
Web3.js: Invalid Sender

I'm trying to make a program to bulk transfer all nft's from one wallet to another. However, I can't seem to make the signing process work. I'm trying to use a piece of code from this tutorial on how to do this, but it is giving me an error saying:

Error: Returned error: invalid sender
    at Object.ErrorResponse (C:\Users\x\Desktop)
    at C:\Users\x\Desktop\nft-transfer\node_modules\web3-core-requestmanager\lib\index.js:300:36
    at XMLHttpRequest.request.onreadystatechange (C:\Users\Gibbo\Desktop\nft-transfer\node_modules\web3-providers-http\lib\index.js:98:13)

Code:

async function transfer(token, tokenId) {
    const contract = new web3.eth.Contract(abi, token);
    const nonce = await web3.eth.getTransactionCount(publicKey);
    try {
        const tx = {
            from: publicKey,
            to: token,
            gas: web3.utils.toHex(gasPrice),
            value: 0,
            chainId: 4,
            nonce: nonce,
            chain: "rinkeby",
            baseChain: "rinkeby",
            hardfork: "berlin",
            data: contract.methods
                .transferFrom(publicKey, toAddress, tokenId)
                .encodeABI(),
        };

        const signedTx = await web3.eth.accounts.signTransaction(tx, privateKey);

        const hash = await sendTx(signedTx);
        return hash;

    } catch (e) {
        console.log(e)
    }
}

const sendTx = (signedTx) =>
  new Promise((resolve, reject) => {
    web3.eth.sendSignedTransaction(signedTx.rawTransaction, (err, hash) => {
      if (!err) {
        console.log('The hash of your transaction is: ', hash);
        return resolve(hash);
      }

      console.log(
        'Something went wrong when submitting your transaction:',
        err,
      );
      return reject(err);
    });
  });

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!