Skip to main content

8. Transaction Interface

Transaction Interface


Transfer

POST chain_sendTransaction (Transfer tokens)
Parameters
nametypedata typedescription
fromrequiredstringSender
torequiredstringReceiver
valuerequiredstring (hex)Amount
slicenorequiredstring (hex)Metaspace number
Responses
http codecontent-typeresponse
0application/json{"txhash":"..."}

Response Fields:

  • txhash - Transaction hash
Example cURL
{
"jsonrpc": "3.0",
"method": "chain_sendTransaction",
"params": [{
"from": "0xc3b6472d6370eaf4eb58fff19ce1724c9d61892c",
"to": "0x6268af5542c4b0ccbb650a0aaccbfcdfbabf6b52",
"value": "0x2E90EDD00",
"sliceno": "0x1"
}, "", "encryp=none"],
"id": "d2c8fe196f9f8d8ace952e9e"
}
Response Example
{
"jsonrpc": "3.0",
"id": "d2c8fe196f9f8d8ace952e9e",
"result": {
"ret": "0",
"err": "",
"content": {
"txhash": "0x6885997ca51fa08ffded573088b0c5c294652ec842ac7f3182d32e30ce261025"
}
}
}

Distribute Transactions

POST chain_airDrop (Batch transfer)
Parameters
nametypedata typedescription
allocaterequiredstringBatch transfer content (base64 encoded JSON)
slicenorequiredintMetaspace number

Content Format (before base64 encoding):

{
"from": "0x4ace8d71fd08d72b467cabc607d9fe1adfc28a75",
"total": 100,
"dest": [{
"addr": "0x35f4646842fc5Fe208b7D3fab125C8542be88324",
"nums": 60
},{
"addr": "0xc94196d73E8eA564b1c753e07814Ee5635de7045",
"nums": 40
}]
}
Responses
http codecontent-typeresponse
0application/json{"txhash":"..."}

Response Fields:

  • txhash - Transaction hash
Example cURL
{
"jsonrpc": "3.0",
"method": "chain_airDrop",
"params": ["opcode=allocate&allocate=&sliceno=1", "encryp=none"],
"id": "d2c8fe196f9f8d8ace952e9e"
}
Response Example
{
"jsonrpc": "3.0",
"id": "d2c8fe196f9f8d8ace952e9e",
"result": {
"ret": "0",
"err": "",
"content": {
"txhash": "0x6885997ca51fa08ffded573088b0c5c294652ec842ac7f3182d32e30ce261025"
}
}
}

Deploy Contract

POST chain_sendTransaction (Deploy smart contract)

Programming Language: Solidity
Compilation Version: 0.8.1

Parameters
nametypedata typedescription
fromrequiredstringCurrent logged-in account address
datarequiredstring (hex)Contract hex content
slicenorequiredstring (hex)Metaspace number
Responses
http codecontent-typeresponse
0application/json{"txhash":"..."}

Response Fields:

  • txhash - Transaction hash
Example cURL
{
"jsonrpc": "3.0",
"method": "chain_sendTransaction",
"params": [{
"from": "0x2c8e94bbe17cec95f21dfdb55e334cfd4effcd9d",
"data": "0x6008......",
"sliceno": "0x1"
}, "", "encryp=none"],
"id": "a3d18f63c99c7660c87c5f3e"
}
Response Example
{
"jsonrpc": "3.0",
"id": "d2c8fe196f9f8d8ace952e9e",
"result": {
"ret": "0",
"err": "",
"content": {
"txhash": "0x6885997ca51fa08ffded573088b0c5c294652ec842ac7f3182d32e30ce261025"
}
}
}

Execute Contract

POST chain_sendTransaction (Execute contract function)
Parameters
nametypedata typedescription
fromrequiredstringCurrent logged-in account address
torequiredstringContract address
datarequiredstring (hex)Hex content (function code and parameters)
slicenorequiredstring (hex)Metaspace number
Responses
http codecontent-typeresponse
0application/json{"txhash":"..."}

Response Fields:

  • txhash - Transaction hash
Example cURL
{
"jsonrpc": "3.0",
"method": "chain_sendTransaction",
"params": [{
"from": "0x2c8e94bbe17cec95f21dfdb55e334cfd4effcd9d",
"to": "0x61b3d1759e4d3bd238a2730cb1621fa542a771fd",
"data": "0x60086678",
"sliceno": "0x1"
}, "", "encryp=none"],
"id": "a3d18f63c99c7660c87c5f3e"
}
Response Example
{
"jsonrpc": "3.0",
"id": "d2c8fe196f9f8d8ace952e9e",
"result": {
"ret": "0",
"err": "",
"content": {
"txhash": "0x6885997ca51fa08ffded573088b0c5c294652ec842ac7f3182d32e30ce261025"
}
}
}

Contract Function Code Query

POST chain_queryFuntionCode (Query function code)
Parameters
nametypedata typedescription
paramsrequiredstringFunction name
Responses
http codecontent-typeresponse
0application/json{"info":"..."}

Response Fields:

  • info - Function code
Example cURL
{
"jsonrpc": "3.0",
"method": "chain_queryFuntionCode",
"params": ["getTYpe()"],
"id": "1"
}
Response Example
{
"jsonrpc": "3.0",
"id": "1",
"result": {
"ret": "0",
"err": "",
"content": {
"info": "0xae591f49"
}
}
}