# Action Param Serialization

# Transfer (xtransaction_type_transfer)

# Sender Action Param Serialization

sender action type: xaction_type_asset_out

Serialize the values of the parameters "symbol" and "top_num" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
symbol Yes TOP String Token symbol.
top_num Yes - Uint64 Transfer-out amount (>0). The default unit is uTOP.

Sample

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

# Receiver Action Param Serialization

receiver action type: xaction_type_asset_in

Serialize the values of the parameters "symbol" and "top_num" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
symbol Yes TOP String Token symbol.
top_num Yes - Uint64 Transfer-in amount. The default unit is uTOP.

Sample

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

# Vote for Advanced Miners (xtransaction_type_vote)

Please make sure that you have enough unused votes in your account before voting.

Accounts on the chain can vote for advance nodes to obtain dividend:

  • The minimum number of votes voting on a node for the first time is 100 and the subsequent cumulative votes are unlimited.
  • An account can vote for up to 100 nodes currently.
  • After voting on a node, a portion of the reward won by the node will be given to the voter.

# Sender Action Param Serialization

sender action type: xaction_type_source_null

No serialization parameter。

# Receiver Action Param Serialization

receiver ation type: xaction_type_run_contract

Serializes the value of the parameter "vote_infos".

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
vote_infos Yes - Mapstd::String,uint64 Account address of node be voted(String); Amount of votes(Integer).

Sample

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

# Cancel Votes (xtransaction_type_abolish_vote)

A voter may cancel votes at any time that has already been vote on a node.

The number of votes for each cancellation operation is unlimited, but cannot exceed the total number of votes vote on the nodes, otherwise the cancellation operation will fail.

After voting for the node, even if the node is unregistered, the votes will not be returned to your account. You need to initiate the cancellation operation.

You can cancel voting for nodes in bulk.

# Sender Action Param Serialization

sender action type: xaction_type_source_null

No serialization parameter.

# Receiver Action Param Serialization

receiver ation type: xaction_type_run_contract

Serializes the value of the parameter "vote_infos".

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
vote_infos Yes - Mapstd::String,uint64 Account address of node be voted(String);Amount of votes(Integer).

Sample

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

# Lock TOP Token to Exchange for Gas (xtransaction_type_pledge_token_gas)

The exchange ratio for gas is:

Snap55

The value changes by the TOP tokens locked in system.

An ordinary account can't obtain gas more than 200,000 Tgas(on-chain governance parameter) in 24-hour. This roughly equates to 800 transactions.

A contract account can't obtain more than 10,000,000 Tgas (on-chain governance parameter) in a 24-hour. This equates to 40,000 transactions or 4s of CPUT time.

Maximum gas of an account can exchange(24h)=Maximum gas of an account can obtain(24h)-free gas(24h)

# Sender Action Param Serialization

sender action type: xaction_type_source_null

No serialization parameter.

# Receiver Action Param Serialization

receiver ation type: xaction_type_pledge_token

Serialize the values of the parameters "symbol" and "top_num" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
symbol Yes TOP String Token symbol.
top_num Yes - Uint64 Locked TOP tokens. The unit is uTOP.

Sample

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

# Unlock the TOP Token Exchanged for Gas (xtransaction_type_redeem_token_gas)

After initiating the unlock, you have to wait 24 hours and send a transaction (not a query) before the unlocked TOP tokens are received.

# Sender Action Param Serialization

sender action type: xaction_type_source_null

No serialization parameter.

# Receiver Action Param Serialization

receiver action type: xaction_type_redeem_token

Serialize the values of the parameters "symbol" and "top_num" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
symbol Yes TOP String Token symbol.
top_num Yes - Uint64 Unlocked TOP tokens. The unit is uTOP.

Sample

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

# Lock TOP Token to Exchange for Votes (xtransaction_type_pledge_token_vote)

Rules for exchanging votes:

locked TOP tokens=votes_num / [ 1.04^(lock_duration / 30 - 1) ], lock_duration < 570;

locked TOP tokens=vote_num / 2, lock_duration >= 570。

The longer the lock duration is, the fewer TOP tokens are locked for the same number of votes.

# Sender Action Param Serialization

sender action type: xaction_type_source_null

No serialization parameter.

# Receiver Action Param Serialization

receiver action type: xaction_type_pledge_token_vote

Serialize the values of the parameters "vote_num" and "lock_duration" in order.

Serialized Parameters

Parameter Name Required Default Valur Parameter Type Description
vote_num Yes - Uint64 Amount of votes to be exchanged.
lock_duration Yes - Uint16 TOP token lock duration, the unit is "day".
The lock duration must be at least 30 days and must be an integer multiple of 30.

Sample

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

# Unlock the TOP Tokens Exchanged for Votes (xtransaction_type_redeem_token_vote)

During the lock duration, the TOP tokens cannot be unlocked, only the TOP tokens at its expiry can be unlocked.

The TOP tokens that are locked corresponding votes that are already in use cannot be unlocked.

After initiating the unlock process, the locked TOP tokens will be returned to the account immediately.

# Sender Action Param Serialization

sender action type: xaction_type_source_null

# Receiver Action Param Serialization

receiver action type: receiver ation type:xaction_type_pledge_token_vote

Serialize the values of the parameters "vote_num".

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
vote_num Yes - Uint64 Votes amount, unlock the corresponding TOP tokens.

Sample

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

# Run Contract (xtransaction_type_run_contract)

# Run Platform Smart Contract

Running platform smart contract includes:

Method Description
registerNode Register miner.
unregisterNode Unregister miner.
redeemNodeDeposit Redeem miner deposit.
updateNodeInfo Miner type, miner deposit, miner name, and dividend ratio can be updated.
updateNodeType Update miner type.
unstakeDeposit Unstake deposit.
stakeDeposit Stake deposit.
setNodeName Set Miner name.
setDividendRatio Set dividend ratio.
claimNodeReward Claim node reward.
claimVoterDividend Claim voter dividend.
submitProposal Submit proposal.
withdrawProposal Withdraw proposal.
tccVote TCC vote.

# Register Miner

There are five types of miners in TOP Network: edge, validator, advance, archive, and exchange node. You can register as one of the first three types of miners.

Advanced miners can serve as two types of nodes in different networks at the same time: validator and auditor.

The minimum registration deposit for each type of miner is shown in the table below.

Miner Type Minimum Registration Deposit
edge 200,000*10^6 uTOP
validator 500,000*10^6 uTOP
advance 1,000,000*10^6 uTOP

WARNING

After the miner registration (including the first registration and re-registration after unregistration), node process needs to be started before node joining the TOP Network physical Network and entering the candidate pool to wait for the election.

# Sender Action Param Serialization

sender action type:xaction_type_asset_out

Serialize the values of the parameters "symbol" and "top_num" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
symbol Yes TOP String Token symbol.
top_num Yes - Uint64 Registration deposit. The unit is uTOP.

Sample

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# Receiver Action Param Serialization

receiver action type: xaction_type_run_contract

Serialize the values of the parameters "node_type", "nodename" and "node_sign_key" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
register_deposit Yes - Uint64 Miner registration deposit. The unit is uTOP.
miner_type Yes - String There are five types of miners in TOP Network: edge, validator, advance, archive and exchange.
You can register as one of the first three types of miners.
After registering as an advance miner, what kind of node the mine is elected depends on the votes it receives:
If the advance miner is to be elected as auditor node, the votes must be greater than or equal to the actual registration deposit of the miner (Here, the node deposit is calculated by TOP, not uTOP).
When the votes fall below the actual staked deposit, the advance miner can only be elected as validator.
Caution:
Miner's votes must be voted by other nodes or by this node himself.
After registering as the advance miner, if you increase the miner deposit, the miner needs to increase the corresponding votes if it wants to be elected as auditor.
miner_name Yes - String Miner nickname, 4-16 characters, letters, Numbers or underscores.
miner_key No Public key of the account. String The account key pair is used as node_sign_key by default.
It is recommended that you create a asset-free public-private key pair to protect your account assets better, the private key is used to sign the node when it is working after is has been elected into the network.
Create public-private key pair algorithms please refer to Account Protocol.
Please input the corresponding public key, which can be used by other nodes for decryption.
dividend_ratio No 0 Uint32 Advance miners can set dividend ratio for accounts that vote for them. All rewards (work rewards, vote rewards) received by advance miners will be distributed to voters who support them according to the set dividend ratio. dividend ratio ∈[0,100].

Sample

top::base::xstream_t stream_t(top::base::xcontext_t::instance());
            param_t = stream_params(stream_t, node_type, nodename, node_sign_key, dividend_ratio);

# Unregister Miner

The TOP Network nodes need to unregister miner first before exiting the network.

  • Node unregistration needs to initiate by the node voluntarily.

  • After the unregistration , the miner registration deposit will not be immediately returned to the miner account and will be locked for 72 hours.

  • After the expiration of the locked registration deposit, the miner shall redeem the deposit voluntarily, and the system will not automatically return it.

# Sender Action Param Serialization

sender action type: xaction_type_asset_out

Serialize the values of the parameters "symbol" and "top_num" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
symbol Yes TOP String Token symbol.
top_num Yes - Uint64 0

Sample

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# Receiver Action Param Serialization

receiver action type: xaction_type_run_contract

No serialization parameter.

# Redeem Miner Deposit

After the unregistration , the node registration deposit will not be immediately returned to the node account and will be locked down for 72 hours. If the node makes malicious, the lock period will be extended.

After the expiration of the locked registration deposit, the node shall redeem the deposit voluntarily, and the system will not automatically return it.

# Sender Action Param Serialization

sender action type: xaction_type_asset_out

Serialize the values of the parameters "symbol" and "top_num" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
symbol Yes TOP String Token symbol.
top_num Yes - Uint64 0

Sample

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# Receiver Action Param Serialization

receiver action type: xaction_type_run_contract

No serialization parameter.

# Update Miner Information

Update miner type, miner name, miner deposit and dividend ratio at the same time.

# Sender Action Param Serialization

sender action type: xaction_type_asset_out

Serialize the values of the parameters "symbol" and "top_num" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
symbol Yes TOP String Token symbol.
top_num Yes - Uint64 When increasing the miner deposit, amount=node_deposit.
When reducing the miner deposit, top_num=0.

Sample

xaction_asset_param asset_param(this, "", top_num);
std::String param = asset_out_param.create();
# Receiver Action Param Serialization

receiver action type: xaction_type_run_contract

Serialize the parameters in the following table in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
miner_name Yes - String Updated miner name.
increase_or_decrease Yes - String 1--Increase node deposit. 2--Decrease node deposit.
miner_deposit Yes - Uint64 Miner deposit.
dividend_ratio Yes - Uint32 Updated dividend ratio. Value∈[0,100]
miner_type Yes - String Updated miner type: edge, validator and advance.

Sample

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

# Update Miner Type

If the current node deposit is lower than the minimum deposit required for the updated node type, the node type update fails.

# Sender Action Param Serialization

Serialize the values of the parameters "symbol" and "top_num" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
symbol Yes TOP String Token symbol.
top_num Yes - Uint64 0.

Sample

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# Receiver Action Param Serialization

receiver action type: xaction_type_run_contract

Serialize the values of the parameters "node_type" .

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
miner_type Yes - String New miner type: edge, advance or validator.

Sample

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

# Unstake Deposit

You can reduce the miner deposit at any time. Reducing the deposit will not change the type of miner you registered. But the reduction of the deposit will fail if the miner's deposit balance is lower than the minimum deposit requirement for the current type of miner.

# Sender Action Param Serialization

sender action type: xaction_type_asset_out

Serialize the values of the parameters "symbol" and "top_num" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
symbol Yes TOP String Token symbol.
top_num Yes - Uint64 0

Sample

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# Receiver Action Param Serialization

receiver action type: xaction_type_run_contract

Serialize the values of the parameters "top_num".

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
top_num Yes - Uint64 Reduced deposit(uTOP).

Sample

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

# Stake Deposit

You can increase the miner deposit to improve your comprehensive stake at any time.

Increasing the miner deposit does not change the type of miner you have registered.

# Sender Action Param Serialization

sender action type: xaction_type_asset_out

Serialize the values of the parameters "symbol" and "top_num" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
symbol Yes TOP String Token symbol.
top_num Yes - Uint64 Increased deposit. The unit is uTOP.

Sample

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# Receiver Action Param Serialization

receiver action type: xaction_type_run_contract

No serialization parameter.

# Set Miner Name

# Sender Action Param Serialization

sender action type: xaction_type_asset_out

Serialize the values of the parameters "symbol" and "top_num" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
symbol Yes TOP String Token symbol.
top_num Yes - Uint64 0

Sample

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# Receiver Action Param Serialization

receiver action type: xaction_type_run_contract

Serialize the values of the parameters "nodename"

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
miner_name Yes - String Miner nick name,4-16 characters, letters, Numbers or underscores.

Sample

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

# Set Dividend Ratio

Once the dividend ratio is set, all the rewards you received, including the work rewards and your own voting rewards, will be distributed to the voter account that supports you according to the dividend ratio you set.

You can change the dividend ratio every 14 days.

# Sender Action Param Serialization

sender action type: xaction_type_asset_out

Serialize the values of the parameters "symbol" and "top_num" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
symbol Yes TOP String Token symbol.
top_num Yes - Uint64 0

Sample

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# Receiver Action Param Serialization

receiver action type: xaction_type_run_contract

Serialize the values of the parameters "dividend_ratio".

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
dividend_ratio Yes - Uint32 Dividend ratio, value[0,100].

Sample

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

# Claim Node Reward

You can use system queryNodeReward to query the node reward before you claim the node reward.

Node reward can be claimed at most once every 12 hours, and each time the amount of reward should be ≥1,000*10^6 uTOP tokens.

# Sender Action Param Serialization

sender action type: xaction_type_asset_out

Serialize the values of the parameters "symbol" and "top_num" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
symbol Yes TOP String Token symbol.
top_num Yes - Uint64 0

Sample

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# Receiver Action Param Serialization

receiver action type: xaction_type_run_contract

No serialization parameter.

# Claim Voter Dividend

The system will settle voter dividends every 12 hours and automatically distribute voter dividends to the dividend pool.

The voter can apply for withdrawal once within 12 hours, and the withdrawal will be received immediately after the application is initiated.

# Sender Action Param Serialization

sender action type: xaction_type_asset_out

Serialize the values of the parameters "symbol" and "top_num" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
symbol Yes TOP String Token symbol.
top_num Yes - Uint64 0

Sample

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# Receiver Action Param Serialization

receiver action type: xaction_type_run_contract

No serialization parameter.

# Submit Proposal

When governing on the chain, you need to submit an on-chain governance proposal first .

Any user can submit a proposal as long as a certain TOP tokens are pledged.

In addition to the minimum transaction deposit of 100,000 uTOP tokens, the transaction fee of 100*10^6 uTOP tokens shall be deducted for running Beacon system contract transaction.

So make sure you have at least 100.1*10^6 uTOP tokens balance in your account before submitting your proposal.

# On-Chain Governance Parameter Modification Proposals

Support the modification of Beacon transaction fees, account free gas, transaction margin and other On-chain Governance Parameters through proposals.

# Community Fund Management Proposal

The system will issue governance rewards and zero workload rewards to the community fund account, community users can transfer these rewadrs to the burn account via community fund management proposal. Once the proposal has been voted through by TCC, the burn will take effect.

community fund account address: T2000138QMHWxXshXyZa1E48JU1LREu3UrT5KGD2U@0.

burn account address: T!0001Ebj8hBvoLdvcEEUwNZ423zM3Kh9d4nL1Ug.

# Sender Action Param Serialization

sender action type: xaction_type_asset_out

Serialize the values of the parameters "symbol" and "top_num" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
symbol Yes TOP String Token symbol.
top_num Yes - Uint64 Proposal deposit, current is "0".

Sample

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# Receiver Action Param Serialization

receiver action type: xaction_type_run_contract

Serialize the values of the following parameters in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
proposal_type Yes - Uint8 Proposal Type: 1--on-chain governance parameter modification proposal;2--community fund management proposal.
target Yes - String On-Chain Parameter Modification Proposal: Target is on-chain governance parameter, more about on-chain governance parameter please refer to On-Chain Governance Prarameters.
Community Fund Management Proposal: Target is the burn account address: T!0001Ebj8hBvoLdvcEEUwNZ423zM3Kh9d4nL1Ug.
value Yes - String When target is on-chain governance parameter, value=new parameter value.
When target is burn account address, value=transfer amount, the unit is uTOP.
effective_timer_height Yes - Uint64 Proposal effective clock height. If the clock height is less than the clock height at which the proposal was approved, the proposal will take effect immediately.

Sample

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

# Withdraw Proposal

A proposal can only be withdrawn by it's sponsor.

# Sender Action Param Serialization

sender action type: xaction_type_asset_out

Serialize the values of the parameters "symbol" and "top_num" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
symbol Yes TOP String Token symbol.
top_num Yes - Uint64 0

Sample

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# Receiver Action Param Serialization

receiver action type: xaction_type_run_contract

Serialize the values of the parameters "proposal_id".

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
proposal_id Yes - String Proposal ID, can be queried by system queryProposal.

Sample

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

# TCC Vote

You can get detailed information about the proposal before you vote on a proposal.

Only the TCC members have the right to vote on a proposal. Rules for voting on proposals:

The approval of 2/3 of the members is required, and no more than 1/5 of the opposition members.

After the proposal is voted through, a legislative order will be formed and sent to all nodes of the network.

After a proposal is voted through, the system will automatically delete the proposal, unable to query the proposal.

# Sender Action Param Serialization

sender action type: xaction_type_asset_out

Serialize the values of the parameters "symbol" and "amount" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
symbol Yes TOP String Token symbol.
top_num Yes - Uint64 0

Sample

xaction_asset_out_param asset_out_param(this, "", top_num);
std::String param = asset_out_param.create();
# Receiver Action Param Serialization

receiver action type: xaction_type_run_contract

Serialize the values of the parameters "proposal_id" and "opinion" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
proposal_id Yes - String Proposal ID, can be queried by system queryProposal.
opinion Yes - Boolean Vote opinion: true or false.

Sample

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

# Query transfer transaction

# Sender Action Param Serialization

Serialize the values of the parameters "token_name" and "amount" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
token_name Yes TOP String Token symbol.
amount Yes - Uint64 Transfer-out amount (>0). The default unit is uTOP.

Sample

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

# Receiver Action Param Serialization

Serialize the values of the parameters "token_name" and "amount" in order.

Serialized Parameters

Parameter Name Required Default Value Parameter Type Description
token_name Yes TOP String Token symbol.
amount Yes - Uint64 Transfer-in amount. The default unit is uTOP.

Sample

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