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

Method "get_energy" #144

Open
AnnushkaStark opened this issue Dec 27, 2024 · 6 comments
Open

Method "get_energy" #144

AnnushkaStark opened this issue Dec 27, 2024 · 6 comments

Comments

@AnnushkaStark
Copy link

The method of the Tron and AsyncTton class to get power does not work. It does not highlight the IDE and gives the error that the method does not exist

@mbalashovv
Copy link
Contributor

What do you mean by getting power? Do you want to get estimated energy for TRC-20 transfer?

@AnnushkaStark
Copy link
Author

There is a method in the class Tron and AsyncTron but when trying to use this method, an error occurs. The method does not exist.

   async def get_energy(self, address: str) -> int:
        """Query the energy of the account"""
        account_info = await self.get_account_resource(address)
        energy_limit = account_info.get("EnergyLimit", 0)
        energy_used = account_info.get("EnergyUsed", 0)
        return energy_limit - energy_used

    async def get_account_resource(self, addr: TAddress) -> dict:
        """Get resource info of an account."""

        ret = await self.provider.make_request(
            "wallet/getaccountresource",
            {"address": keys.to_base58check_address(addr), "visible": True},
        )
        if ret:
            return ret
        else:
            raise AddressNotFound("account not found on-chain")

@mbalashovv
Copy link
Contributor

It seems that the library itself wasn't updated. A certain commit was pushed to the master branch, but it wasn't released

@AnnushkaStark
Copy link
Author

Yes, it is possible

@MrNaif2018
Copy link
Collaborator

If you need I can cut a release shortly

@AnnushkaStark
Copy link
Author

It's not urgent, I just noticed that there was an inaccuracy, so I opened a discussion)

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

3 participants