Estoy tratando de hacer un programa para transferir a granel todos los nft de una billetera a otra. Sin embargo, parece que no puedo hacer que el proceso de firma funcione. Estoy tratando de usar un fragmento de código de este tutorial sobre cómo hacer esto, pero me da un error que dice:
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)Código:
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); }); });