Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ABI error when using HTTPProviver over just nile network #124

Closed
30ThreeDegrees opened this issue Jan 7, 2024 · 2 comments
Closed

ABI error when using HTTPProviver over just nile network #124

30ThreeDegrees opened this issue Jan 7, 2024 · 2 comments

Comments

@30ThreeDegrees
Copy link

Hi there,

I am using this code to find a usdt balance of a wallet

from tronpy import Tron
from tronpy.providers import HTTPProvider

client = Tron(network="nile")


# cntr = client.get_contract("THi2qJf6XmvTJSpZHc17HgQsmJop6kb3ia")

# print(dir(cntr.functions))


# client = Tron(network="nile")

cntr = client.get_contract("TXLAQ63Xg1NAzckPwKHvzw7CSEmLMEqcdj")

tron_account_address = "THYkuRwPKuSM4xbfoYqg8Nyn5UAw5kAVVR"

usdt_balance = cntr.functions.balanceOf(tron_account_address)

print(f"USDT Balance of {tron_account_address}: {usdt_balance / 10**6} USDT")

RESPONSE: USDT Balance of THYkuRwPKuSM4xbfoYqg8Nyn5UAw5kAVVR: 50000.0 USDT

And this works fine but the moment I go to use trongrid creds I get an error saying I cant call a contract without an ABI

from tronpy import Tron
from tronpy.providers import HTTPProvider

client = Tron(
    HTTPProvider(api_key="insert_key"), network="nile"
)


cntr = client.get_contract("TXLAQ63Xg1NAzckPwKHvzw7CSEmLMEqcdj")

tron_account_address = "THYkuRwPKuSM4xbfoYqg8Nyn5UAw5kAVVR"

usdt_balance = cntr.functions.balanceOf(tron_account_address)

print(f"USDT Balance of {tron_account_address}: {usdt_balance / 10**6} USDT")

RESPONSE: raise ValueError("can not call a contract without ABI") ValueError: can not call a contract without ABI

Is anyone able to give me a little bit of guidance on whats happening here without the trongrid api key it works fine but with trongrid its no longe fetching the abi on its own?

@MrNaif2018
Copy link
Collaborator

Works for me without the api key. Maybe your key is invalid?

@MrNaif2018
Copy link
Collaborator

HTTPProvider by default uses mainnet trongrid, but when using network="nile" it doesn't even use trongrid at all. No key is required for testnet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants