Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

549
Visualizações
Uncaught Error: invalid address when transferring token

When I try to transfer the token from 1 address to another, the error in the title pops up. Here is my relevant JS code: ($("#targetAddr").val() is the address of the target address (in metamask) and $("#amt").val() is the value of the tokens to transfer to.)

tokenContract.transfer($("#targetAddr").val().toString(),$("#amt").val())

I am using a smart contract that is very similar to OpenZepplin's ERC20. Its transfer is similar to ERC20's transfer function. What am I doing wrong?

Below is the code of my token contract setup in javascript:

var tokenContractAddress = token_contract_address;
//coinABI is the ABI from my smart contract.
var tokenContract = web3.eth.contract(coinABI).at(tokenContractAddress);

The address that is in the input is one of the addresses in my metamask account (essentially a valid address)

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You need to construct an actual transaction with web3 or other framework you're using. Here is an example with web3: https://ethereum.stackexchange.com/questions/24828/how-to-send-erc20-token-using-web3-api

If you have a different version, go to their docs: https://web3js.readthedocs.io/en/v1.3.4/index.html

And see methods for sending a transaction to a contract. You need to send a tx to the token contract that will call token's native transfer() method with neede arguments. you will need to sign this transaction and then send it.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda