Estoy tratando de transferir un token erc-721 entre diferentes billeteras. Ambos están conectados a la red ropsten y deberían tener fondos suficientes (0,08 y 0,1 eth) para realizar una transacción. Sin embargo, todavía recibo un error que dice que
Algo salió mal al enviar su transacción: Error: Error devuelto: fondos insuficientes para gas * precio + valor
Miré las otras preguntas con respecto a esto, pero no encontré mucho útil.
Código:
async function transfer(token, tokenId) { const contract = new web3.eth.Contract(abi, token); try { const tx = { from: publicKey, to: token, gas: 30000, value: 0, chain: "rinkeby", baseChain: "rinkeby", hardfork: "berlin", data: contract.methods .transferFrom(publicKey, toAddress, tokenId) .encodeABI(), }; const signed = await web3.eth.accounts.signTransaction(tx, privateKey); const hash = await sendTx(signed);intente especificar el precio del gas que desea usar también,
me gusta,
'gasPrice': web3.toWei('5','gwei')tu codigo:
async function transfer(token, tokenId) { const contract = new web3.eth.Contract(abi, token); try { const tx = { from: publicKey, to: token, gas: 30000, gasPrice: web3.toWei('5','gwei'), value: 0, chain: "rinkeby", baseChain: "rinkeby", hardfork: "berlin", data: contract.methods .transferFrom(publicKey, toAddress, tokenId) .encodeABI(), }; const signed = await web3.eth.accounts.signTransaction(tx, privateKey); const hash = await sendTx(signed);por supuesto, necesitaría ajustar el precio del gas de acuerdo con la red