# action param 序列化

# 转账(xtransaction_type_transfer)

# sender action param 序列化

sender action type:xaction_type_asset_out

将代币"symbol"、"top_num"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
symbol TOP String 代币 symbol。
top_num - Uint64 转出金额(>0),默认单位:uTOP。

示例

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();

# receiver action param 序列化

receiver action type:xaction_type_asset_in

将代币"symbol"、"top_num"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
symbol TOP String 代币 symbol。
top_num - Uint64 转入金额,默认单位:uTOP。

示例

xaction_asset_out_param asset_out_param(this, "", amount);
std::String param = asset_out_param.create();

# 给高级矿工投票(xtransaction_type_vote)

投票之前请确保您的账户中有足够的未使用的选票,给高级矿工投票,获取收益:

  • 只有高级矿工才能接收投票;
  • 单个账户目前最多允许给10,000个矿工投票;

  • 给矿工投票后,矿工获取的奖励会有一部分分给投票者。

# sender action param 序列化

sender action type:xaction_type_source_null

无序列化参数。

# receiver action param 序列化

receiver ation type:xaction_type_run_contract

将参数"miner_and_votes"的值序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
miner_and_votes - Mapstd::String,uint64 key:接受投票节点账户地址(String); value:投票数量(Integer)。

示例

top::base::xstream_t stream_t(top::base::xcontext_t::instance());
		std::String param_t = stream_params(stream_t, miner_and_votes);

# 取消投票(xtransaction_type_abolish_vote)

投票人可以随时将已经投给矿工的选票取消并收回。

每次取消投票的票数无限制,但时不能高于给矿工投票的总数,否则取消投票将失败。

给矿工投票后,即使注销矿工,选票也不会主动退还至您的账户,需要您主动发起取消投票操作。

您可以批量取消矿工投票。

# sender action param 序列化

sender action type:xaction_type_source_null

无序列化参数。

# receiver action param 序列化

receiver ation type:xaction_type_run_contract

将参数"miner_and_votes"的值序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
miner_and_votes - Mapstd::String,uint64 key:接受投票矿工账户地址; value:取消投票数量。

示例

top::base::xstream_t stream_t(top::base::xcontext_t::instance());
		std::String param_t = stream_params(stream_t, vote_infos);

# 锁定TOP token兑换gas(xtransaction_type_pledge_token_gas)

兑换gas的汇率为:

Snap57

此兑换率随着系统中锁定的TOP tokens变化而变化。

一个普通账户24小时内可以获得的gas不超过200,000Tgas,大约可以发起800条交易。

一个合约账户24小时内可以获得的gas不超过10,000,000Tgas,大约可以执行4万条交易,使用4秒CPU。

账户24小时内最多可兑换的gas=24小时内可以获得的gas上限-24小时内免费gas。

# sender action param 序列化

sender action type:xaction_type_source_null

无序列化参数。

# receiver action param 序列化

receiver ation type:xaction_type_pledge_token

将代币"symbol"、"top_num"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
symbol TOP String 代币symbol。
top_num - Uint64 锁定金额,默认单位:uTOP。

示例

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();

# 解锁兑换gas的TOP token(xtransaction_type_redeem_token_gas)

发起解锁后,需要等待24小时,并由锁定账户发起一笔交易(非查询)后,解锁的金额才会到账。

# sender action param 序列化

sender action type:xaction_type_source_null

无序列化参数。

# receiver action param 序列化

receiver ation type:xaction_type_redeem_token

将代币"symbol"、"top_num"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
symbol TOP String 代币symbol。
top_num - Uint64 解锁金额,默认单位:uTOP。

示例

xaction_asset_out_param asset_out_param(this, "", amount);
std::String param = asset_out_param.create();

# 锁定TOP token兑换选票(xtransaction_type_pledge_token_vote)

兑票规则:
locked TOP tokens=votes_num / [ 1.04^(lock_duration / 30 - 1) ], duration < 570;
locked TOP tokens=vote_num / 2, lock_duration >= 570。
锁定期最少为30天,且必须为30的整数倍。锁定期越长,相同的兑票数量锁定越少的TOP token。

# sender action param 序列化

sender action type:xaction_type_source_null

无序列化参数。

# receiver action param 序列化

receiver ation type:xaction_type_pledge_token_vote

将"vote_num"、"lock_duration"两个参数的值按顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
vote_num - Uint64 兑票数量。
lock_duration - Uint16 TOP token锁定期,锁定期单位:天。
锁定期最少为30天,且必须为30的整数倍。锁定期越长,相同的兑票数量锁定越少的TOP token。

示例

xaction_pledge_token_vote_param pledge_vote_param(this, vote_num, lock_duration);
        std::String param = pledge_vote_param.create();

# 解锁兑换选票的TOP token(xtransaction_type_redeem_token_vote)

锁定期内的TOP token不能解锁,只能解锁到期的TOP token。

已经被使用的选票对应锁定的TOP token不能被解锁。

发起解锁后,解锁的金额会立即到账。

# sender action param 序列化

sender action type:xaction_type_source_null

# receiver action param 序列化

receiver ation type:receiver ation type:xaction_type_pledge_token_vote

将参数"vote_num"的值序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
vote_num - Uint64 赎回票数,解锁对应的TOP token。

示例

top::base::xstream_t stream_t(top::base::xcontext_t::instance());
		std::String param_t = stream_params(stream_t, vote_num);

# 调用合约(xtransaction_type_run_contract)

# 调用系统智能合约

调用系统智能合约包括:

方法名 说明
registerNode 注册矿工。
unregisterNode 注销矿工。
redeemNodeDeposit 赎回矿工保证金。
updateNodeInfo 支持更新矿工类型、矿工保证金、矿工名称和分红比例。
updateNodeType 更新矿工类型。
unstakeDeposit 减少矿工保证金。
stakeDeposit 增加矿工保证金。
setNodeName 设置矿工昵称。
setDividendRatio 设置分红比例。
claimNodeReward 领取矿工奖励。
claimVoterDividend 领取投票者分红。
submitProposal 提交提案。
withdrawProposal 撤回提案。
tccVote TCC表决提案。

# 注册矿工

TOP Network 目前有五种类型的矿工:边缘矿工(edge)、验证矿工(validator)、高级矿工(advance)、存档矿工(archive)和交易所矿工(exchange)。您可以注册成为前三种矿工类型的其中一种。

高级矿工可在不同的网络里同时担任多个节点:验证(validator)、审计(auditor)、存档(archive)。

各类型矿工注册最低保证金如下表所示。

矿工类型 最低注册保证金
边缘矿工(edge) 200,000*10^6 uTOP
验证矿工(validator) 500,000*10^6 uTOP
高级矿工(advance) 1,000,000*10^6 uTOP

注意

矿工注册成功后(包括第一次注册和注销后重新注册),需要启动节点进程,节点才会成功进入候选池,等待选举。

# sender action param 序列化

sender action type:xaction_type_asset_out

将代币"symbol"、"top_num"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
symbol TOP String 代币symbol。
top_num - Uint64 矿工注册保证金,默认单位:uTOP。

示例

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# receiver action param 序列化

receiver action type:xaction_type_run_contract

将"miner_type"、"miner_name"、"miner_key"、"dividend_ratio"参数的值按顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
miner_type - String 矿工类型,包括 edge(边缘矿工)、validator(验证矿工)、advance(高级矿工)、archive(存档矿工)和 exchange(交易所矿工)。
您可以注册成为前三种矿工类型的其中一种。
注册成为高级矿工后,高级矿工被选举为何种节点取决于高级矿工的选票:高级矿工被选举为 auditor 节点,矿工所获得的选票需要大于等于矿工实际质押的保证金。当选票低于实际质押保证金时,高级矿工只能被选为validator节点。
说明:
矿工选票须由接受投票而得,可以由其他矿工投票,也可由本矿工自己投给自己。
提醒:
高级矿工注册后,如使用topio mining addDeposit提高保证金,则矿工想被选举为 auditor 节点,需要增加与提高的保证金相同数目的票数。
miner_name - String 矿工昵称,4-16字符,字母、数字或下划线。
miner_key 账户公钥 String owner key或者worker key的公钥。将此公钥信息登记到区块链系统注册合约中,其他节点可使用此公钥对该矿工的签名区块验签。
dividend_ratio 0 Uint32 高级矿工可为给自己的投票者设置分红比例,高级矿工收到的全部奖励(包括工作奖励和选票奖励)将按照分红比例分发给自己投票的账户。分红比例∈[0,100]。

示例

top::base::xstream_t stream_t(top::base::xcontext_t::instance());
            param_t = stream_params(stream_t, miner_type, miner_name, miner_key, dividend_ratio);

# 注销矿工

TOP Network的矿工注销,节点退出网络,需要矿工先发起注销:

  • 矿工注销需要矿工主动发起。

  • 矿工注销后,矿工注册保证金不会立刻退回到节点账户,会被锁定72小时。

  • 锁定的保证金到期后需要矿工主动赎回保证金,系统不会自动退回。

# sender action param 序列化

sender action type:xaction_type_asset_out

将代币"symbol"、"top_num"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
symbol TOP String 代币symbol。
top_num - Uint64 为"0"。

示例

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# receiver action param 序列化

receiver action type:xaction_type_run_contract

无序列化参数。

# 赎回矿工保证金

矿工注销后,保证金将会被锁定72小时,锁定的保证金到期后需要矿工主动赎回保证金,系统不会自动退回。

# sender action param 序列化

sender action type:xaction_type_asset_out

将代币"symbol"、"top_num"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
symbol TOP String 代币symbol。
top_num - Uint64 为"0"。

示例

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# receiver action param 序列化

receiver action type:xaction_type_run_contract

无序列化参数。

# 更新矿工信息

# sender action param 序列化

sender action type:xaction_type_asset_out

将代币"symbol"、"top_num"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
symbol TOP String 代币symbol。
top_num - Uint64 增加矿工保证金时,top_num为增加的矿工保证金。
减少节点保证金时,top_num=0。

示例

xaction_asset_param asset_param(this, "", top_num);
std::String param = asset_out_param.create();
# receiver action param 序列化

receiver action type:xaction_type_run_contract

将以下参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
miner_name - String 更新后的矿工名称。
increase_or_decrease - Int 1:增加矿工保证金;2:减少矿工保证金。
top_num - Uint64 增加或减少的矿工保证金。
dividend_ratio - Uint32 更新后的分红比例。
miner_type - String 更新后的矿工类型:edge(边缘矿工)、validator(验证矿工)、advance(高级矿工)。

示例

std::String param_t;
		top::base::xstream_t stream_t(top::base::xcontext_t::instance());
        param_t = stream_params(stream_t,miner_name, increase_or_decrease, top_num, dividend_ratio, miner_type);

# 更新矿工类型

# sender action param 序列化

sender action type:xaction_type_asset_out

注意

如果当前矿工账户余额低于更新后节点类型所需的最低保证金,则更新矿工类型失败。

将代币"symbol"、"top_num"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
symbol TOP String 代币symbol。
top_num - Uint64 为"0"。

示例

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# receiver action param 序列化

receiver action type:xaction_type_run_contract

将参数"miner_type"的值序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
miner_type - String 新矿工类型,包括edge(边缘矿工)、advance(高级矿工)、validator(验证矿工)。

示例

 std::String param_t;
		top::base::xstream_t stream_t(top::base::xcontext_t::instance());
        param_t = stream_params(stream_t,miner_type);

# 减少矿工保证金

您可以随时减少质押的保证金,减少保证金不会改变您注册的矿工类型,但是如果质押的保证金低于当前类型矿工注册保证金最低要求,减少保证金将失败。

# sender action param 序列化

sender action type:xaction_type_asset_out

将代币"symbol"、"amount"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
symbol TOP String 代币symbol。
amount - Uint64 为"0"。

示例

xaction_asset_out_param asset_out_param(this, "", amount);
std::String param = asset_out_param.create();
# receiver action param 序列化

receiver action type:xaction_type_run_contract

将参数"top_num"的值序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
top_num - Uint64 减少的保证金,单位uTOP。

示例

 std::String param_t;
		top::base::xstream_t stream_t(top::base::xcontext_t::instance());
        param_t = stream_params(stream_t, top_num);

# 增加矿工保证金

您可以随时为矿工增加保证金,从而提高您节点的综合权益(Comprehensive Stake)。

增加矿工保证金不会改变您注册的矿工类型。

# sender action param 序列化

sender action type:xaction_type_asset_out

将代币"symbol"、"top_num"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
symbol TOP String 代币symbol。
top_num - Uint64 增加的矿工保证金,单位uTOP。

示例

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# receiver action param 序列化

receiver action type:xaction_type_run_contract

无序列化参数。

# 设置矿工昵称

# sender action param 序列化

sender action type:xaction_type_asset_out

将代币"symbol"、"top_num"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
symbol TOP String 代币symbol。
top_num - Uint64 为"0"。

示例

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# receiver action param 序列化

receiver action type:xaction_type_run_contract

将参数"miner_name"的值序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
miner_name - String 新的矿工昵称,4-16字符,字母、数字或下划线。

示例

  std::String param_t;
		top::base::xstream_t stream_t(top::base::xcontext_t::instance());
        param_t = stream_params(stream_t, miner_name);

# 设置分红比例

设置了分红比例,您收到的全部奖励,包括工作奖励和选票奖励,会按照您设置的分红比例分到支持您的投票者账户上。

每14天您可以修改一次分红比例。

# sender action param 序列化

sender action type:xaction_type_asset_out

将代币"symbol"、"top_num"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
symbol TOP String 代币symbol。
top_num - Uint64 为"0"。

示例

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# receiver action param 序列化

receiver action type:xaction_type_run_contract

将参数"dividend_ratio"的值序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
dividend_ratio - Uint32 分红比例,取值范围 [0,100]。

示例

 top::base::xstream_t stream_t(top::base::xcontext_t::instance());
		std::String param_t = stream_params(stream_t, dividend_ratio);

# 领取矿工奖励

每12小时最多领取一次。

# sender action param 序列化

sender action type:xaction_type_asset_out

将代币"symbol"、"top_num"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
symbol TOP String 代币symbol。
top_num - Uint64 为"0"。

示例

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# receiver action param 序列化

receiver action type:xaction_type_run_contract

无序列化参数。

# 领取投票者分红

系统每12小时结算一次投票者分红,将投票人分红自动发放到分红池。

投票人12小时内可以申请提现一次,发起提现申请后立即到账。

# sender action param 序列化

sender action type:xaction_type_asset_out

将代币"symbol"、"top_num"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
symbol TOP String 代币symbol。
top_num - Uint64 为"0"。

示例

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# receiver action param 序列化

receiver action type:xaction_type_run_contract

无序列化参数。

# 提交提案

链上治理时,首先需要提交链上治理提案。

任何用户可以发起提案。

# 链上参数修改提案

通过提案对链上治理参数进行修改。

# 社区基金管理提案

系统将治理奖励和零工作量节点奖励发放至社区基金账户,社区用户可以通过社区基金管理提案将账户中的余额转账至一个销毁账户地址,提案经过TCC表决通过后,销毁即生效。

社区基金账户地址:T2000138QMHWxXshXyZa1E48JU1LREu3UrT5KGD2U@0。

销毁账户地址:T!0001Ebj8hBvoLdvcEEUwNZ423zM3Kh9d4nL1Ug。

# sender action param 序列化

sender action type:xaction_type_asset_out

将代币"symbol"、"top_num"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
symbol TOP String 代币symbol。
top_num - Uint64 提案保证金,单位uTOP。

示例

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# receiver action param 序列化

receiver action type:xaction_type_run_contract

将以下参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
proposal_type - Uint8 提案类型:1--链上治理参数修改提案;2--社区基金管理提案。
target - String 当提案类型为链上治理参数修改提案时,target为链上治理参数名称;
当提案类型为社区基金管理提案时,target为接受转账账户地址,销毁账户地址:T!0001Ebj8hBvoLdvcEEUwNZ423zM3Kh9d4nL1Ug。
value - String 当target为链上治理参数时,value为链上治理参数修改后的值。
当target为接受转账账户地址,value为转账金额,单位uTOP。
effective_timer_height - Uint64 提案通过后生效时钟高度。如生效时钟高度小于提案通过时的时钟高度,那么提案在通过后会立刻生效。

示例

std::String param_t = stream_params(stream_t,
                                      target, value,
                                            proposal_type,
                                      effective_timer_height);

# 撤回提案

提案只能由对应的提案者撤回。

# sender action param 序列化

sender action type:xaction_type_asset_out

将代币"symbol"、"top_num"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
symbol TOP String 代币symbol。
top_num - Uint64 为"0"。

示例

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# receiver action param 序列化

receiver action type:xaction_type_run_contract

将参数"proposal_id"的值序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
proposal_id - String 提案ID,可通过queryProposal查询。

示例

top::base::xstream_t stream_t(top::base::xcontext_t::instance());
		std::String param_t = stream_params(stream_t, proposal_id);

# TCC表决提案

对提案投票前,可先获取提案详细信息了解提案。

只有TCC委员对提案有表决权,表决通过的规则:需2/3的委员通过,且反对委员不超过20%。

提案表决通过后,且没有被否决,将形成立法命令,发给全网节点。

提案被表决通过后,系统将自动删除提案,无法查询提案。

# sender action param 序列化

sender action type:xaction_type_asset_out

将代币"symbol"、"top_num"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
symbol TOP String 代币symbol。
top_num - Uint64 为"0"。

示例

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# receiver action param 序列化

receiver action type:xaction_type_run_contract

将"proposal_id"、"opinion"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
proposal_id - String 提案ID,可通过queryProposal查询。
opinion - Boolean 表决意见:true--赞成;false--反对。

示例

top::base::xstream_t stream_t(top::base::xcontext_t::instance());
		std::String param_t = stream_params(stream_t, proposal_id,account_addr,opinion);

# 查询转账交易

# sender action param 序列化

将代币"token_name"、"amount"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
token_name TOP String 代币 symbol。
amount - Uint64 转出金额(>0),默认单位:uTOP。

示例

{
    "amount": 1000000000000,
    "token_name": "TOP"
}

# receiver action param 序列化

将代币"token_name"、"amount"两个参数的值按照顺序序列化。

参数说明

参数名称 是否必选 默认值 类型 说明
token_name TOP String 代币 symbol。
amount - Uint64 转入金额,默认单位:uTOP。

示例

{
    "amount": 1000000000000,
    "token_name": "TOP"
}