-
Notifications
You must be signed in to change notification settings - Fork 13
BaerChain BRC Transcation
weidong edited this page Apr 8, 2020
·
4 revisions
- Request Json file(transfer1_data.json)
{
"source":[
{
"from":"0xc6f73c3b14456434c7db388bcb4fd47377c0d738",
"to":"0x00000000000000000000000000000000766f7465",
"value":"0x0",
"data":[
{
"type":2,
"m_from":"0xc6f73c3b14456434c7db388bcb4fd47377c0d738",
"m_to":"0x042610e447c94ff0824b7aa89fab123930edc805",
"m_transcation_type":1,
"m_transcation_numbers":"0x5f5e100"
}
],
"chainId":"0x1",
"nonce":"0x0",
"gas":"0x13880",
"gasPrice":"0x5"
}
],
"keys":[
"8kZJMg3BfpkD6yzWh84N2ACPZaqWSZof1G23YQ7PD3u6"
]
}
2. Transfer method 2 Back Dir
- Request Json file(transfer2_data.json)
{
"source":[
{
"from":"0xc6f73c3b14456434c7db388bcb4fd47377c0d738",
"to":"0x042610e447c94ff0824b7aa89fab123930edc805",
"value":"0x5f5e100",
"data":[],
"chainId":"0x1",
"nonce":"0x1",
"gas":"0x13880",
"gasPrice":"0x5"
}
],
"keys":[
"8kZJMg3BfpkD6yzWh84N2ACPZaqWSZof1G23YQ7PD3u6"
]
}
3. Transfer method 3 Back Dir
- Request Json file(transfer3_data.json), Batch transfer, this time contains 2 transfer data, data can not exceed 50 transfer data at most
{
"source":[
{
"from":"0xc6f73c3b14456434c7db388bcb4fd47377c0d738",
"to":"0x00000000000000000000000000000000766f7465",
"value":"0x0",
"data":[
{
"type":2,
"m_from":"0xc6f73c3b14456434c7db388bcb4fd47377c0d738",
"m_to":"0x042610e447c94ff0824b7aa89fab123930edc805",
"m_transcation_type":1,
"m_transcation_numbers":"0x5f5e100"
},
{
"type":2,
"m_from":"0xc6f73c3b14456434c7db388bcb4fd47377c0d738",
"m_to":"0xeee227766ba28fa6abc9ec8fea0c56188bbd54c5",
"m_transcation_type":1,
"m_transcation_numbers":"0x5f5e100"
}
],
"chainId":"0x1",
"nonce":"0x2",
"gas":"0x138080",
"gasPrice":"0x5"
}
],
"keys":[
"8kZJMg3BfpkD6yzWh84N2ACPZaqWSZof1G23YQ7PD3u6"
]
}
Remarks : > When to fill in another address, and data is not empty, the default to is the contract address of the call, and transfer the value from value (if value also has value) from to into to, generally prohibit this operation
> If the value has a value and the data also has data, the transfer is subject to the transfer of the data
- params description Back Dir
from : string, Transaction originating address
to : string, Fixed address, cannot be changed
value : string, Hexadecimal, when transfer methods 1 and 3 are "0x0", when transfer method 2 is the number of BRC transfers
data : Transfer transaction data, array structure, if transfer method 2, it will be empty
> type : int, Transaction identification number, fixed at 2, indicating brcTranscation transfer transaction
> m_from : string, The address to initiate the transfer is the same as the address of the transaction initiator
> m_to : string, Address to accept transfer
> m_transcation_type : int, Fixed at 1
> m_transcation_numbers : string, Hexadecimal, the number of transfers, the default is hexadecimal
chainId : string, Hexadecimal, chain ID, must be the same as chain creation chainId
nonce : string, Hexadecimal, nonce value, +1 after each execution
gas : string, Hexadecimal, the gas integer provided for transaction execution
gasPrice : string, Hexadecimal, for each gasPrice integer paid for gas
- Note: For the transfer operation, the precision is 8-bit precision, that is, if you need to transfer 1 BRC, it is 100000000, and the hexadecimal value is: 0x5f5e100, that is, the value of m_transcation_numbers needs to be filled in: "0x5f5e100"
4. Example of transfer process Back Dir
- 4.1 Query before transfer
curl -d '{"jsonrpc":"2.0","id":9,"method":"brc_getBalance","params":["c6f73c3b14456434c7db388bcb4fd47377c0d738","-1"]}' 127.0.0.1:36100
curl -d '{"jsonrpc":"2.0","id":9,"method":"brc_getBalance","params":["042610e447c94ff0824b7aa89fab123930edc805","-1"]}' 127.0.0.1:36100
- search result
{
"id":9,
"jsonrpc":"2.0",
"result":
{
"Address":"0xc6f73c3b14456434c7db388bcb4fd47377c0d738",
"BRC":"0x1f711def073e900000",
"FBRC":"0x0",
"FBalance":"0x0",
"balance":"0xa4d88ddd94000",
"ballot":"0x0",
"cookieinsummury": "0x0",
"nonce":"0x0",
"poll":"0x0",
"vote":null
}
}
{
"id":9,
"jsonrpc":"2.0",
"result":
{
"Address":"0x042610e447c94ff0824b7aa89fab123930edc805",
"BRC":"0x1f711def073e900000",
"FBRC":"0x0",
"FBalance":"0x0",
"balance":"0xa4d88ddd94000",
"ballot":"0x0",
"cookieinsummury": "0x0",
"nonce":"0x0",
"poll":"0x0",
"vote":null
}
}
Address: 0xc6f73c3b14456434c7db388bcb4fd47377c0d738 The number of BRC is "BRC": "0x1f711def073e900000"
Address: 0x042610e447c94ff0824b7aa89fab123930edc805 The number of BRC is "BRC": "0x1f711def073e900000"
-
4.2 Test transfer 1 minimum unit BRC Back Dir
- Execution instruction example (the same for all three methods)
../cmdWallet -j ./1_transfer_data.json -s 127.0.0.1:36100- cmdWallet: Perform file acquisition
cd cpp-lsac/build : Enter the directory cmake .. : Execute instruction make : Execute instruction cd cpp-lsac/build/wallet/cmdWallet : You can find the cmdWallet executable file just compiled in this directory -
Return result hash
{"id":1,"jsonrpc":"2.0","result":"0x3d55b1004e779b7533aaa6c06835538ff1ad9b0701f5531a322f9903acea1b08"}
Indicates successful transfer
- Query transfer results
{
"id":9,
"jsonrpc":"2.0",
"result":
{
"Address":"0xc6f73c3b14456434c7db388bcb4fd47377c0d738",
"BRC":"0x1f711def073e8fffff",
"FBRC":"0x0",
"FBalance":"0x0",
"balance":"0xa4d88d6ffb5c0",
"ballot":"0x0",
"cookieinsummury": "0x0",
"nonce":"0x1",
"poll":"0x0",
"vote":null
}
}
{
"id":9,
"jsonrpc":"2.0",
"result":
{
"Address":"0x042610e447c94ff0824b7aa89fab123930edc805",
"BRC":"0x1f711def073e900001",
"FBRC":"0x0",
"FBalance":"0x0",
"balance":"0xa4d88ddd94000",
"ballot":"0x0",
"cookieinsummury": "0x0",
"nonce":"0x0",
"poll":"0x0",
"vote":null
}
}
Address: 0xc6f73c3b14456434c7db388bcb4fd47377c0d738 The number of BRC is "BRC": "0x1f711def073e8fffff", reduce by 1 minimum unit BRC,
Address: 0x042610e447c94ff0824b7aa89fab123930edc805 The number of BRC is "BRC": "0x1f711def073e900001", add 1 minimum unit BRC,
Indicate successful transfer