-
Notifications
You must be signed in to change notification settings - Fork 13
BaerChain autoTransaction
weidong edited this page Apr 7, 2020
·
3 revisions
1. Instructions for automatic transfer of cookies Back Dir
- Transfer json file(transaction_auto.json)
{
"source":[
{
"from":"0x695193772208fb21b8cae0096ddea871d74e82cb",
"to":"0x00000000000000000000000000000000766f7465",
"value":"0x0",
"data":[
{
"type":9,
"m_autoExType":1,
"m_autoExNum":"0x5f5e100",
"m_transferNum":"0x2540be400",
"m_from":"0x695193772208fb21b8cae0096ddea871d74e82cb",
"m_to":"0x74ad8b5c9ef47a8cc01cb1cf7da7510b54e8318f"
}
],
"chainId":"0x1",
"nonce":"0x1",
"gas":"0x13800",
"gasPrice":"0x5"
}
],
"keys":[
"8DxYCrGwN95oiQwebaspHBRCxprWG3ZV1pNYLh37uBuq"
]
}- Parameter Description Back Dir
from : string,Transaction originating address
to : string,Fixed address, cannot be changed
value : string,Hexadecimal, the default is 0x0
data : Automatically exchange cookie transfer transaction data, array structure
> type : int,The transaction identification number, fixed at 9, means a transfer transaction that automatically redeems cookies
> m_autoExType : int,Types of automatically redeemed cookies
> When m_autoExType is 1, it means that the transaction initiating address specifies that it uses BRC to exchange cookies, and the transaction fee is paid by itself
> When m_autoExType is 2, it means that the transaction originating address specifies the transfer address to use BRC to exchange cookies, and the transaction fee is paid by the transfer address
> m_autoExNum : string,Hexadecimal, the number of BRCs used to exchange cookies
> m_transferNum : string,Hexadecimal, indicating the number of BRC transfers
> m_from : string,The address that initiated the transaction, which is the above from address
> m_to : string,Address to accept transfer
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, gas integer provided for transaction execution
gasPrice : string,Hexadecimal, for each gasPrice integer paying gas
keys :Transaction originating address private key
2. Query before transfer Back to Contents
- Query instruction
- Query the balance of address 0x695193772208fb21b8cae0096ddea871d74e82cb
curl -d '{"jsonrpc":"2.0","id":9,"method":"brc_getBalance","params":["0x695193772208fb21b8cae0096ddea871d74e82cb","latest"]}' http://127.0.0.1:8111
- Query result
{
"id": 9,
"jsonrpc": "2.0",
"result": {
"Address": "0x695193772208fb21b8cae0096ddea871d74e82cb",
"BRC": "0x174876e800", => Converted to decimal, and the precision of 8 digits shows that the address has 1000 BRC
"FBRC": "0x0",
"FBalance": "0x0",
"balance": "0x0", => It can be seen that there is no cookie at this address
"ballot": "0x0",
"cookieinsummury": "0x0",
"nonce": "0x0",
"poll": "0x0",
"vote": null
}
}
3. Transfer method of automatic redemption cookie 1 Back Dir
- That is, the transfer with m_autoExType 1
{
"source":[
{
"from":"0x695193772208fb21b8cae0096ddea871d74e82cb",
"to":"0x00000000000000000000000000000000766f7465",
"value":"0x0",
"data":[
{
"type":9,
"m_autoExType":1, => The type is 1, it can be known that the transaction initiating address uses BRC to exchange cookies, and the transaction initiating address pays the processing fee
"m_autoExNum":"0x5f5e100", => Converted to decimal, and 8-digit precision indicates that the transaction initiating address uses 1 BRC to exchange cookies
"m_transferNum":"0x2540be400", => Converted to decimal, and 8-bit precision can be known as transfer 100 BRC
"m_from":"0x695193772208fb21b8cae0096ddea871d74e82cb",
"m_to":"0x74ad8b5c9ef47a8cc01cb1cf7da7510b54e8318f"
}
],
"chainId":"0x1",
"nonce":"0x1",
"gas":"0x13800",
"gasPrice":"0x5"
}
],
"keys":[
"8DxYCrGwN95oiQwebaspHBRCxprWG3ZV1pNYLh37uBuq"
]
}
Note: Address 0x695193772208fb21b8cae0096ddea871d74e82cb transfers to address 0x74ad8b5c9ef47a8cc01cb1cf7da7510b54e8318f
- Execute instruction Back Dir
./cmdWallet -j ./transaction_auto.json -s 127.0.0.1:8111
- 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
- Query result Back Dir
- Use the brc_getBalance interface to query
{
"id": 9,
"jsonrpc": "2.0",
"result": {
"Address": "0x695193772208fb21b8cae0096ddea871d74e82cb", => Transaction originating address
"BRC": "0x14ee752300", => Converted to decimal, and 8-bit precision is available, the transaction originating address currently has 899 BRCs. From the transfer just now, it can be seen that 100 BRCs were used for transfers, and 1 BRC was used to exchange cookies. , After the transaction is now 899
"FBRC": "0x0",
"FBalance": "0x0",
"balance": "0x5f1afb8", => Converted to decimal, and 8-digit precision is available, the transaction originating address now has 0.9972524 cookies (after deducting the handling fee)
"ballot": "0x0",
"cookieinsummury": "0x0",
"nonce": "0x1",
"poll": "0x0",
"vote": null
}
}
{
"id": 9,
"jsonrpc": "2.0",
"result": {
"Address": "0x74ad8b5c9ef47a8cc01cb1cf7da7510b54e8318f", => Transfer address
"BRC": "0x2540be400", => Converted to decimal, and 8-digit accuracy is available, the transfer address currently has 100 BRCs, and the number of transfers can be seen from the above transfer situation.
"FBRC": "0x0",
"FBalance": "0x0",
"balance": "0x0", => Existing cookie is 0, and the amount is consistent according to the above transfer situation
"ballot": "0x0",
"cookieinsummury": "0x0",
"nonce": "0x0",
"poll": "0x0",
"vote": null
}
}
4. Transfer method for automatic redemption of cookies 2 Back Dir
- That is, the transfer with m_autoExType 2
{
"source":[
{
"from":"0x695193772208fb21b8cae0096ddea871d74e82cb",
"to":"0x00000000000000000000000000000000766f7465",
"value":"0x0",
"data":[
{
"type":9,
"m_autoExType":2, => Type 2, you can know that the designated transfer address for the transaction initiating address uses BRC to exchange cookies, and the transfer address pays the processing fee
"m_autoExNum":"0x5f5e100", => Converted to decimal, and the accuracy of 8 digits shows that the designated transfer address uses 1 BRC to exchange cookies
"m_transferNum":"0x2540be400", => Converted to decimal, and 8-bit precision can be known as transfer 100 BRC
"m_from":"0x695193772208fb21b8cae0096ddea871d74e82cb",
"m_to":"0x74ad8b5c9ef47a8cc01cb1cf7da7510b54e8318f"
}
],
"chainId":"0x1",
"nonce":"0x1",
"gas":"0x13800",
"gasPrice":"0x5"
}
],
"keys":[
"8DxYCrGwN95oiQwebaspHBRCxprWG3ZV1pNYLh37uBuq"
]
}
Note: Address 0x695193772208fb21b8cae0096ddea871d74e82cb transfers to address 0x74ad8b5c9ef47a8cc01cb1cf7da7510b54e8318f
- Execute instruction Back Dir
./cmdWallet -j ./transaction_auto.json -s 127.0.0.1:8111
- 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.
- Query result Back Dir
- Use the brc_getBalance interface to query
{
"id": 9,
"jsonrpc": "2.0",
"result": {
"Address": "0x695193772208fb21b8cae0096ddea871d74e82cb", => Transaction originating address
"BRC": "0x129a693f00", => Converted to decimal, and 8-bit precision is available, the transaction initiation address currently has 799 BRCs, because 100 BRCs were transferred just now, so after the transaction, the previous 899 BRCs are now changed to 799 BRC
"FBRC": "0x0",
"FBalance": "0x0",
"balance": "0x5f1afb8", => Converted to decimal, with 8-digit precision available, the transaction originating address currently has 0.9972524 cookies, the number remains unchanged
"ballot": "0x0",
"cookieinsummury": "0x0",
"nonce": "0x2",
"poll": "0x0",
"vote": null
}
}
{
"id": 9,
"jsonrpc": "2.0",
"result": {
"Address": "0x74ad8b5c9ef47a8cc01cb1cf7da7510b54e8318f", => Transfer address
"BRC": "0x4a221e700", => Converted to decimal, and 8-digit precision is available, the transfer address currently has 199 BRCs, because although the transaction address transfers 100 BRCs again to the address that accepts the transfer, it also specifies that it costs 1 BRC to exchange cookies, so There are 199 BRCs in the transfer address
"FBRC": "0x0",
"FBalance": "0x0",
"balance": "0x5f1afb8", => Converted to decimal, and 8-digit precision is available, there are 0.9972524 cookies in the transferred address (after payment of transaction fees)
"ballot": "0x0",
"cookieinsummury": "0x0",
"nonce": "0x0",
"poll": "0x0",
"vote": null
}
}
- Remarks: The above transaction data are test data, the actual situation and processing fees are subject to the actual