Closed jordanmack closed 2 years ago
We tried adding an enumeration value to the parameter list of get_balance
rpc, which can filter Dao cells, similar to the extra
parameter in rpc query_transactions
.
When you pass in "extra": "Dao"
, you can get assets that are only locked in DAO.
Below are 3 examples, please see if they can meet the functional requirements.
withdraw
has been completed, and the lock-in period has passed.
Note the difference between it and ckb browser: Nervos DAO Deposit 0.00000000 CKB
in ckb browserecho '{
"id": 42,
"jsonrpc": "2.0",
"method": "get_balance",
"params": [
{
"item": {
"type": "Address",
"value": "ckt1qpvvtay34wndv9nckl8hah6fzzcltcqwcrx79apwp2a5lkd07fdxxqtvuu3ysunhkq9qs54fgwarl40wq0xv5ps4wzq06"
},
"asset_infos": [
{
"asset_type": "CKB",
"udt_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
],
"extra": "Dao",
"tip_block_number": "0x6604e6"
}
]
}' \
| tr -d '\n' \
| curl -H 'content-type: application/json' -d @- http://127.0.0.1:8116
{
"jsonrpc": "2.0",
"result": {
"balances": [
{
"ownership": "ckt1qpvvtay34wndv9nckl8hah6fzzcltcqwcrx79apwp2a5lkd07fdxxqtvuu3ysunhkq9qs54fgwarl40wq0xv5ps4wzq06",
"asset_info": {
"asset_type": "CKB",
"udt_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
"free": "0x56bcdc2cb9",
"occupied": "0x0",
"frozen": "0x0"
}
],
"tip_block_number": "0x6604e6"
},
"id": 42
}
“original total capacity”:3720 "free": 3725.35733433 "occupied": 0 "frozen": 0
withdrawal
has been completed, and the lock-in period has not yet passed.echo '{
"id": 42,
"jsonrpc": "2.0",
"method": "get_balance",
"params": [
{
"item": {
"type": "Address",
"value": "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqw666wuhvsrj60hpmjyr29y348cuel70fsluaa5p"
},
"asset_infos": [
{
"asset_type": "CKB",
"udt_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
],
"extra": "Dao",
"tip_block_number": "0x6604e6"
}
]
}' \
| tr -d '\n' \
| curl -H 'content-type: application/json' -d @- http://127.0.0.1:8116
{
"jsonrpc": "2.0",
"result": {
"balances": [
{
"ownership": "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqw666wuhvsrj60hpmjyr29y348cuel70fsluaa5p",
"asset_info": {
"asset_type": "CKB",
"udt_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
"free": "0x0",
"occupied": "0x25ff7a600",
"frozen": "0xaedd84882c7"
}
],
"tip_block_number": "0x6604e6"
},
"id": 42
}
“original total capacity“: 120,000 "free": 0 "occupied": 102 "frozen": 120166.52157639
echo '{
"id": 42,
"jsonrpc": "2.0",
"method": "get_balance",
"params": [
{
"item": {
"type": "Address",
"value": "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqghlgmq3hd8eczvd3ms52wker8l5p3qf6gx4vuwv"
},
"asset_infos": [
{
"asset_type": "CKB",
"udt_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
],
"extra": "Dao",
"tip_block_number": "0x65fef0"
}
]
}' \
| tr -d '\n' \
| curl -H 'content-type: application/json' -d @- http://127.0.0.1:8116
{
"jsonrpc": "2.0",
"result": {
"balances": [
{
"ownership": "ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqghlgmq3hd8eczvd3ms52wker8l5p3qf6gx4vuwv",
"asset_info": {
"asset_type": "CKB",
"udt_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
"free": "0x0",
"occupied": "0x25ff7a600",
"frozen": "0xe674ad6a00"
}
],
"tip_block_number": "0x65fef0"
},
"id": 42
}
"original total capacity": 10000
Mercury v0.4.4 has been released and the public service(https://mercury-mainnet.ckbapp.dev/0.4) has been updated.
What would you like to be added:
A way to query for a deposited Nervos DAO balance of an address using the Mercury RPC.
Why is this needed:
Wallets and exchanges that want to support the Nervos DAO would benefit from a way to query for a Nervos DAO balance that they can display to their users.