Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

450
Vistas
Getting Error: Returned error: Must be authenticated! , while sending erc20 code using web3.js
const fs = require('fs');
let web3 = new Web3(new Web3.providers.HttpProvider('http:127.0.0.1'))

const abi = fs.readFileSync('erc20_abi.json', 'utf-8')
const contractAddress = '0xB4...'
const privateKey = '...'

let contract = new web3.eth.Contract(JSON.parse(abi), contractAddress);
let transfer = contract.methods.transfer("0xd...", 10);
let encodedABI = transfer.encodeABI();


  var tx = {
    from: "0xF...",
    to: contractAddress,
    gas: 2000000,
    data: encodedABI
  }; 

  web3.eth.accounts.signTransaction(tx, privateKey).then(signed => {
    var tran = web3.eth.sendSignedTransaction(signed.rawTransaction);

    tran.on('confirmation', (confirmationNumber, receipt) => {
      console.log('confirmation: ' + confirmationNumber);
    });

    tran.on('transactionHash', hash => {
      console.log('hash');
      console.log(hash);
    });

    tran.on('receipt', receipt => {
      console.log('reciept');
      console.log(receipt);
    });

    tran.on('error', console.error);
  });

I am using the above code to send ERC20 tokens from account to another account, Its throwing this error

UnhandledPromiseRejectionWarning: Error: Returned error: Must be authenticated

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I have figured it out I am using wrong rpc provider, changing the Rpc provider fixes this issue.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda