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

453
Visualizações
Web3 Get All Tokens by Wallet Address

I am trying to pull a list of token contracts held by a wallet address, similar to how bscscan does, except programmatically. bscscan.com/apis does not have an endpoint, and web3 seems to only report the ETH balance.

This is possible to achieve, since bscscan reports the list and many token trackers ( such as farmfol.io ) also seem to pull that information. I am just not finding the correct methodology. Any assistance is appreciated!

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

ERC-20 (and ERC-20-like such as TRC-20, BEP-20, etc.) token balance of each address is stored in the contract of the token.

Blockchain explorers scan each transaction for Transfer() events and if the emitter is a token contract, they update the token balances in their separate DB. The balance of all tokens per each address (from this separate DB) is then displayed as the token balance on the address detail page.

Etherscan and BSCScan currently don't provide an API that would return the token balances per address.

In order to get all ERC-20 token balances of an address, the easiest solution (apart from finding an API that returns the data) is to loop through all token contracts (or just the tokens that you're interested in), and call their balanceOf(address) function.

const tokenAddresses = [
    '0x123',
    '0x456',
];
const myAddress = '0x789';

for (let tokenAddress of tokenAddresses) {
    const contract = new web3.eth.Contract(erc20AbiJson, tokenAddress);
    const tokenBalance = await contract.methods.balanceOf(myAddress).call();
}
over 4 years ago · Santiago Trujillo Relatório

0

You can call

https://api.bscscan.com/api?module=account&action=tokentx&address=0x7bb89460599dbf32ee3aa50798bbceae2a5f7f6a&page=1&offset=5&startblock=0&endblock=999999999&sort=asc&apikey=YourApiKeyToken

and parse the result. All your tokens you ever touched will be here.

Reference

over 4 years ago · Santiago Trujillo 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