Hi,
I’m trying to check a token balance from a wallet but I keep getting eth_sendTransaction does not exist error. I don’t want to send something just want to check the balance.
The reason you are getting the error is due to the fact that you are calling the transact() method on your contract which is using send_transcation() under the hood.
Infura does not support the method eth_sendTrasaction eth_sendTransaction | INFURA, hence the error you are receiving even though you are not explicitly calling the method.
An alternative would be to use the call() method instead of transact(). The call method just queries the state of the blockchain without executing a public transaction. Please see the below doc for reference:
Thank you for your answer but I already tried the call() method and it gives me a different error. I searched the web and changed it to transact() because of it.
The error message:
Could not transact with/call contract function, is contract deployed correctly and chain synced?
You are welcome.
That’s strange, because I got your code working using the call() method. I am testing on this Link token contract deployed on Goerli.
You can see that this test address holds 24 Link token and by running your code with the call() method, 24 is displayed. Please see below, just that the result needs formatting:
Or maybe there’s indeed something wrong with the contract you are querying. On which network is it deployed, can you share a link to it? Does the ABI in your snippet belong to the same contract?
Sorry for the late reply. I think there was nothing wrong with my code just like you said. I kept sending the wrong token or chain address. I tried and get the balance at some point but I’m having another error right now. Anyways I think this solves my problem.
Thanks again