How to fetch/calculate all account's staking and delegations? #114
-
I'd like to implement by code a function that gets an account address and returns all its stakes and delegations? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
To manage and calculate an account's staking and delegations within the Aptos blockchain, you may need to implement custom logic. This involves searching through an account's transaction history to identify which delegation pools it has interacted with. For small-scale implementations, a brute force search could suffice. Here's a code snippet using the SDK:
For information regarding delegations, the documentation provides insights into the various view functions accessible via the SDK. You could also use the indexer directly too. Here's a potential approach:
|
Beta Was this translation helpful? Give feedback.
To manage and calculate an account's staking and delegations within the Aptos blockchain, you may need to implement custom logic. This involves searching through an account's transaction history to identify which delegation pools it has interacted with. For small-scale implementations, a brute force search could suffice. Here's a code snippet using the SDK:
await aptos.getAccountTransactions({ accountAddress: "0x123" })
For information regarding delegations, the documentation provides insights into the various view functions accessible via the SDK. You could also use the indexer directly too.
Here's a potential approach:
Checking for Delegation Pool Existence
Utilize the
delegation_pool…