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

273
Visualizações
.allowance method for importing erc20 token to metamask

I was trying out the .allowance method to import erc20 token in my case PKS to metamask. The issue is I don't get the metamask popup for importing the erc20 token but I get the balances PKS token for the particular account without importing .

need this output before fetching balances : enter image description here Is there anyway to adjust the code it should first ask for import and then fetch the balance ?

here's my code so far and I am calling getErcBal in useEffect :

async function getErcBal(){
        var WEB3 = await connection();
        var currAddr = WEB3.address;
        var web3 = WEB3.web3Conn;
      
        if(WEB3.isMeta){
          setuseraddress(currAddr);
          setContractAdr(dethContractAddr);
            if(dethContractAddr){
                var dethContract = new web3.eth.Contract(DETH, dethContractAddr);
                var getAllowance = await dethContract.methods
                                    .allowance(currAddr, dethContractAddr)
                                    .call();
                }
                var tokenDethBln = await dethContract.methods.balanceOf(currAddr).call();
            }
            var PksVal = 0;
              if (tokenDethBln && tokenDethBln > 0) {
                PksVal = tokenDethBln / 1000000000000000000;
              }
            setPksbalance(PksVal.toFixed(4))
         
          }
      
      }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Allowance method is not for importing funds. allowance function use two addresses, first one is owner address, and second one is spender address. If you previously approved someone to use your funds than only it will return some value other than it will give zero.

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