Comment interroger la balance d'un cycle de compte KT1 par cycle?
2 réponses
- votes
-
- 2019-01-30
<block_id>
est un hachage ou unniveau debloc à laquelle vous demandez l'équilibre.Si vous souhaitez obtenir un équilibre simple aupoint spécifique du cycle:
(C'estpseudocode,j'espère que vous le comprendre)
var cycle = 60; var p1 = (cycle * 4096 + 1) + 0; //beginning of the cycle var p2 = (cycle * 4096 + 1) + 4095; //end of the cycle var balance_at_p1 = get('/chains/main/blocks/{p1}/context/contracts/KT1.../balance'); var balance_at_p2 = get('/chains/main/blocks/{p2}/context/contracts/KT1.../balance');
Mais si vousessayez d'obtenir un équilibrepour calculer les récompenses de la délégation:
Au début,vous devrieztrouver lebloc d'instantané utilisépour compter les rouleaux. Ensuite,utilisez ceblocpour obtenir l'équilibre comme ci-dessus.
var cycle = 60; var cycle_lvl = cycle * 4096 + 1; var snapshot = get('/chains/main/blocks/{cycle_lvl}/context/raw/json/cycle/{cycle}'); var snapshot_block = ((cycle - 7) * 4096 + 1) + (snapshot.roll_snapshot + 1) * 256 - 1; var balance = get('/chains/main/blocks/{snapshot_block}/context/contracts/KT1.../balance');
<block_id>
- is a hash or a level of the block at which you ask for balance.If you want to get a simple balance at the specific point in the cycle:
(this is pseudocode, I hope you figure it out)
var cycle = 60; var p1 = (cycle * 4096 + 1) + 0; //beginning of the cycle var p2 = (cycle * 4096 + 1) + 4095; //end of the cycle var balance_at_p1 = get('/chains/main/blocks/{p1}/context/contracts/KT1.../balance'); var balance_at_p2 = get('/chains/main/blocks/{p2}/context/contracts/KT1.../balance');
But if you are trying to get a balance for calculating delegation rewards:
At first you should find the snapshot block that was used to count the rolls. Then use this block to get the balance like above.
var cycle = 60; var cycle_lvl = cycle * 4096 + 1; var snapshot = get('/chains/main/blocks/{cycle_lvl}/context/raw/json/cycle/{cycle}'); var snapshot_block = ((cycle - 7) * 4096 + 1) + (snapshot.roll_snapshot + 1) * 256 - 1; var balance = get('/chains/main/blocks/{snapshot_block}/context/contracts/KT1.../balance');
-
- 2019-01-30
Vouspouvez utiliser l'API Tzscanpour ce:/V3/BANKE_HISTORY/KT1 ...,la documentationestici: Balance Historique Doc . Parexemple https://api6.tzscan.io/v3/balance_history/kt1ggujwmqofayrynwamraycvhblzgorlogo
You can use TzScan API for this: /v3/balance_history/KT1..., the documentation is here: balance history doc. For example https://api6.tzscan.io/v3/balance_history/KT1GgUJwMQoFayRYNwamRAYCvHBLzgorLoGo
Y a-t-il un RPC dans Tezos-Client,quipermet d'interroger labalance d'un cycle de compte KT1par cycle?
Je l'aiessayé avec ceci (TZScan Public-Node RPC):
Maisje ne suispas sûr de ce que
<block_id>
signifieet non sûr que ce RPCme conduit àmon résultat.