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

Delegating energy using permission from another wallet #139

Open
ghost opened this issue Sep 8, 2024 · 0 comments
Open

Delegating energy using permission from another wallet #139

ghost opened this issue Sep 8, 2024 · 0 comments

Comments

@ghost
Copy link

ghost commented Sep 8, 2024

I have two wallets

  1. bot's wallet: the one with the Private Key for the delegation.
  2. sender's wallet: I want to delegate energy from this wallet but I don't want to use the Private Key instead I gave permission to delegate energy to the bot wallet from this one.

The code roughly looks like this but it always returns tronpy.exceptions.BadKey: ('provided private key is not in the permission list', 'provided BOT_WALLET_ADDRESS', "required {'operations': '7fff1fc0033ec307000000000000000000000000000000000000000000000000', 'keys': [{'address': 'some_address_here', 'weight': 1}], 'threshold': 1, 'id': 2, 'type': 'Active', 'permission_name': 'active'}")

client = Tron(HTTPProvider(api_key="API_KEY"))
priv_key = PrivateKey(bytes.fromhex("BOT_WALLET_PRIVATE_KEY"))

txn = (
    client.trx.delegate_resource(owner=SENDER_WALLET, receiver=RECEIVER_WALLET, balance=1, resource="ENERGY")
    .permission_id(2)
    .build()
    .sign(priv_key)
    .broadcast()
)
txn.wait()

I have also tried with with_owner(SENDER_WALLET) and owner=BOT_WALLET but nothing seems to work.

What's wrong with the code? and is it even possible though the API to delegate energy from another wallet assuming it gave permission to the bot's wallet?

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

0 participants