# Send Transactions
Support sending transactions, including transfer, node staking, node registration, node voting, node claiming rewards, etc.
Before sending transactions,make sure that:
You already have an account on the chain.
Get the identity token by
requestToken
.
# Transaction Costs
In RPC, account balance, transaction deposit,etc.The unit is uTOP, 1TOP=1*10^6 uTOP.
Sending transactions on TOP AI Network chain consumes certain gas resources. If the account balance is greater than or equal to 100*10^6 uTOP, the system will give the account 25,000 Tgas for free.
Each transaction requires at least 100,000 uTOP as the transaction deposit, otherwise the transaction will be discarded.
If the account‘s gas resources are sufficient, the transaction deposit will be returned to your account immediately after the transaction is successful. If the account's gas resources are insufficient to pay the transaction costs, a fee shall be deducted from the transaction deposit to exchange gas resources to pay the transaction costs, and the deducted TOP tokens will be destroyed.
If the transaction deposit is not enough to exchange gas resources, the transaction will eventually fail.
For transactions that running the contracts deployed on the Beacon (registration node-related, proposal related, starting xnode), in addition to the minimum transaction deposit of 100,000 uTOP tokens, the system will automatically deduct the 100*10^6 uTOP tokens as transaction fee from the sender's account and then destroy it.
The resources consumed by transaction, please refer to Resource Model.
More about Beacon contract, please refer to Smart Contract.
# RPC Instructions
Request Method
sendTransaction
Request Parameters
Parameter Name | Parameter Name | Description |
---|---|---|
authorization | String | Transaction body signature. |
ext | String | The reserve filed, default to empty String. |
last_tx_nonce | Uint64 | The nonce of the previous transaction ,used for transaction sorting and removing duplicates. |
note | String | Transaction note. |
premium_price | Uint32 | The reserve filed, default to "0". |
receiver_action_name | String | The name of contract function. The system smart contract function,please refer to Platform Smart Contract API. |
receiver_action_param | String | The transaction receiver action.The serialization of different action perform content please refer to Action Param Serialization. |
receiver_account | String | Transaction receiver account address. |
send_timestamp | Uint64 | Transaction send timestamp. |
sender_action_name | String | The reserve filed, default to empty String. |
sender_action_param | String | The transaction sender action.The serialization of different action perform content please refer to Action Param Serialization. |
sender_account | String | Transaction sender account address. |
tx_deposit | Uint32 | Transaction deposit.The unit is uTOP. |
tx_expire_duration | Uint16 | If the transaction expires, it will be discarded with the default time of 100s. |
tx_hash | String | The hexadecimal of the transaction hash. |
tx_structure_version | String | Transaction structure version.Default to "2".Temporary unused. |
tx_type | Uint16 | Transaction type. Different transaction types have different action param and action type in action. xtransaction_type_run_contract = 3, xtransaction_type_transfer = 4, xtransaction_type_vote = 20, xtransaction_type_abolish_vote = 21, xtransaction_type_pledge_token_gas = 22, xtransaction_type_redeem_token_gas = 23, xtransaction_type_pledge_token_vote = 27, xtransaction_type_redeem_token_vote = 28, |
Response Parameters
Parameter Name | Parameter Type | Description |
---|---|---|
tx_hash | String | The transaction hash which can be used to retrieve the transaction consensus status. |
tx_len | Uint16 | The gas consumed by transaction consensus is related to the transaction size. |
Request Sample
curl -X POST --data 'target_account_addr=T80000a62be6926c19321b644672975e028f875669fb53&body={"params": {"authorization": "0x019c01db8e4fd9cd79e7efdd89f238691345a272836ef2325dd251984028cde98f6f93cd98bda7bfe55fc0b8c5a9e6ab5b0c44342081e92f2b2dd08dfe6f072583", "tx_expire_duration": 100, "send_timestamp": 1638257801, "tx_deposit": 200000, "premium_price": 0, "tx_type": 4, "tx_structure_version": 2, "last_tx_nonce": 1, "ext": "", "note": "fix_account_by_god", "amount": 200300000, "token_name": "", "sender_account": "T80000a62be6926c19321b644672975e028f875669fb53", "sender_action_name": "", "sender_action_param": "", "receiver_account": "T800004978b1ad8b4ae8400cb787ad709b04b331a4a440", "receiver_action_name": "", "receiver_action_param": "", "edge_nodeid": ""}}&method=sendTransaction&sequence_id=4&identity_token=521d0ca2-4679-45ad-9a7f-c30be870bc72&version=1.0&signature=AQQKSIR7VIPLYTGC73IZIQZHHJNM2IOKO4HMMYKTKCNZDGHX5BAA' http://localhost:19081
Response Schema
- Successful
{
"errmsg": "ok",
"errno": 0,
"sequence_id": "2",
"tips": "Please use command 'get transaction' to query transaction status later on!!!",
"tx_hash": "0x34ca8f317107ce6b01c933b017f28e6cf0f84f2e31627a8349f167c1aa9ade10",
"tx_len": 306
}
Useget transaction
to query the transaction details and final consensus status.
- Failed
{
"errmsg": "ok",
"errno": 0,
"sequence_id": "3",
"tips": "Please use command 'get transaction' to query transaction status later on!!!",
"tx_hash": "0xc73f6295bc5b6be1ace273d59504f4c97d1b01cd2d3301c47cf042e28795e35b",
"tx_len": 306
}
In case of a transaction is failed, the transaction consensus final status will not be returned directly, and the transaction details need to be queried by get Transaction
.