0

I have a problem during the call to view the balance of an address. I'm following the various tutorials and the following error is raised: this.rpc.getBalance is not a function and it does not return any value.

1

I think this is related to this issue: https://github.com/ecadlabs/taquito/issues/730

You first need to create an instance of TezosToolkit using the RPC URL of your choice.

example:

import { TezosToolkit } from '@taquito/taquito';

const Tezos = new TezosToolkit('https://api.tez.ie/rpc/edonet');
const balance = await Tezos.tz.getBalance('tz3gP1z15b656zk9WX42bTyCkpKAm6QA6YKo');
console.log(`${balance.toNumber() / 1000000} ꜩ`);

If that doesn't solve the issue, can you paste some of your code here? It might help find out what the problem is.

1
  • Agreed, I'd bet he needs to access the .tz member: rpc.tz.getBalance(). – mpr Jun 2 at 3:20
0

thanks for the help the code works, the only difference from mine was that I called new TezosToolkit ({rpc: 'api_address'}) ... which causes the error. however I entered the code in a try ... catch statement and on the first call it does not read the balance and reports an error: "Request to https://api.tez.ie/rpc/edonet/chains/main/blocks/head / context / contracts // balance failed ". on the other hand, a second call(click on connect button) reads the balance correctly. i put an 'alter-ego' on codesandbox at this address: https://codesandbox.io/s/aged-platform-g4id1?file=/src/App.js

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.