Skip to content

Instantly share code, notes, and snippets.

@jiOnederfull
Forked from ian0371/23.04-hands-on.md
Created April 6, 2023 11:05
Show Gist options
  • Save jiOnederfull/7df8b9166d7351b15e34570cf64bfb07 to your computer and use it in GitHub Desktop.
Save jiOnederfull/7df8b9166d7351b15e34570cf64bfb07 to your computer and use it in GitHub Desktop.
Klaytn DevMeet 2023.04 hands-on

Klaytn DevMeet 2023.04 hands-on

Prerequisites

Explore hardfork numbers on-chain

# To use curl,
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0", "method":"klay_getChainConfig", "params":["latest"],"id":1}' https://api.baobab.klaytn.net:8651

# To use cast,
cast rpc klay_getChainConfig latest --rpc-url https://api.baobab.klaytn.net:8651

You may use a specific block number in hex rather than "latest".

Explore reward distribution on-chain

# To use curl,
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0", "method":"klay_getRewards", "params":["latest"],"id":1}' https://api.baobab.klaytn.net:8651

# To use cast,
cast rpc klay_getRewards latest --rpc-url https://api.baobab.klaytn.net:8651

Explore staking information on-chain

PoC/KGF addresses change at 119145601

# To use curl,
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0", "method":"klay_getStakingInfo", "params":["0x71a0481"],"id":1}' https://api.baobab.klaytn.net:8651

# To use cast,
cast rpc klay_getRewards 119145601 --rpc-url https://api.baobab.klaytn.net:8651

Explore treasury rebalance memo

contract address (for cypress and baobab): 0xD5ad6D61Dd87EdabE2332607C328f5cc96aeCB95

We can call contracts from block explorers.

View retirees

scope or finder > Read Contract > 6. getRetiredCount and put zero to three to 17. retirees

View newbies

scope or finder > Read Contract > 3. getNewbieCount and put zero to three to 13. newbies

View status

scope or finder > Read Contract > 18. status

  • 0 (Initialized): The initial state of the contract.
  • 1 (Registered): Retirees and Newbies are registered in the blockchain.
  • 2 (Approved): All retirees have been approved.
  • 3 (Finalized): The rebalance has been executed and finalized.

The status shows “2” which means that the retirees have been approved and that the rebalance will be executed once it reaches the reblanceBlockNumber.

View reblanceBlockNumber

scope or finder > Read Contract > 15. rebalanceBlockNumber

Calculating the expected burn amount

Burnt amount = sumOfRetiredBalance – (getTreasuryAmount + newbies' balance)

  • sumOfRetiredBalance: 19. sumOfRetiredBalance
  • getTreasuryAmount: 8. getTreasuryAmount
  • newbies' balance: 0

Do note that the sumOfRetiredBalance will keep increasing until the KIP-103 hardfork occurs as block rewards are still being generated. However, rest assured that the additional block rewards generated will also be burnt during the treasury rebalancing.

Verify treasury rebalance with memo

They can be viewed in Baobab.

scope baobab or finder baobab > Read Contract > 11. memo

memo format:

{
  "retired": {"0x38138d89c321b3b5f421e9452b69cf29e4380bae":117000000000000000000000000000000000000, "0x30208f32c70e8b53a67ea171c8720cbfe32888ff":117000000000000000000000000000000000000},
  "newbie": {"0x0a33a1b99bd67a7189573dd74de80293afdf969a":22500000000000000000000000000000000000, "0xd9de2697000c3665e9c5a71e1bf52aaa44507cc0":22500000000000000000000000000000000000},
  "burnt":72000000000000000000000000000000000000,
  "success":true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment