关于抵押和赎回的方法,拿eosjs举例
https://eosio.github.io/eosjs/guides/2.-Transaction-Examples.html
Stake 抵押
const result = await api.transact({
actions: [{
account: 'eosio',
name: 'delegatebw',
authorization: [{
actor: 'useraaaaaaaa',
permission: 'active',
}],
data: {
from: 'useraaaaaaaa',
receiver: 'useraaaaaaaa',
stake_net_quantity: '1.0000 SYS',
stake_cpu_quantity: '1.0000 SYS',
transfer: false,
}
}]
}, {
blocksBehind: 3,
expireSeconds: 30,
});
Unstake 赎回
const result = await api.transact({
actions: [{
account: 'eosio',
name: 'undelegatebw',
authorization: [{
actor: 'useraaaaaaaa',
permission: 'active',
}],
data: {
from: 'useraaaaaaaa',
receiver: 'useraaaaaaaa',
unstake_net_quantity: '1.0000 SYS',
unstake_cpu_quantity: '1.0000 SYS',
transfer: false,
}
}]
}, {
blocksBehind: 3,
expireSeconds: 30,
});
操作细节看以上demo即可,下面我们说下抵押时transfer
这个参数。
先看合约 (跳转代码)
if ( transfer ) {
from = receiver;
}
如果设置transfer
参数为true
,及把来源的账户修改为接收账户。
也就变成了接收账户自己给自己抵押,由来源账户付钱
查看数据
del_bandwidth_table del_tbl( _self, from.value );
是以来源账户为查询的scope
所以RPC查询如下
post: https://api.eoslaomao.com/v1/chain/get_table_rows
data:
{
"scope": "bcskillsurou",
"code": "eosio",
"table": "delband",
"json": true
}
返回
{
"rows": [
{
"from": "bcskillsurou",
"to": "bcskillsurou",
"net_weight": "0.0046 EOS",
"cpu_weight": "0.0147 EOS"
}
],
"more": false
}
版权属于:区块链中文技术社区 / 转载原创者
本文链接:https://bcskill.com/index.php/archives/718.html
相关技术文章仅限于相关区块链底层技术研究,禁止用于非法用途,后果自负!本站严格遵守一切相关法律政策!