-
Notifications
You must be signed in to change notification settings - Fork 13
BaerChain Contract deployment process
woodbaer edited this page Aug 15, 2019
·
7 revisions
- Parameters explain
from : [40 bytes] The contract deployer address, or the address of the caller when the contract is executed
to : [40 bytes] The deployment contract is filled with zero or null, or the contract address when the contract is executed
value : Number, default 0
data : array structure
> type: a value of 5 indicates the deployment contract, and 6 indicates the invocation contract
> contract: the hash value of the method signature and encoding parameters, which is the 'input' content when the contract is deployed and executed
chainId : chain's Id, consistent with genesis chainId
nonce : +1 is required after each deployment and contract execution
gas : gas integer for transaction execution
gasPrice : the gasPrice integer used for each gas payment
keys : the private key of the transaction signature, that is, the private key of the deployer when the contract is deployed and the private key of the caller when the contract is invoked
- Deployment of contract Json file de_data.json:
{
"source": [
{
"from": "e523e7c59a0725afd08bc9751c89eed6f8e16dec",
"to": "0x0000000000000000000000000000000000000000",
"value": "0",
"data": [
{
"type": 5,
"contract":"0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600a6001819055506103e860028190555061019b806100716000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680638da5cb5b1461005c578063ae28f1ed146100b3578063efcfe81a146100de575b600080fd5b34801561006857600080fd5b506100716100f5565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156100bf57600080fd5b506100c861011a565b6040518082815260200191505060405180910390f35b3480156100ea57600080fd5b506100f3610124565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600254905090565b600160008154600101919050819055507f8fdf6ae92aea1ef806935daa8763c1fdeeb79e0e82fb9c903dde9b215c99180f6001546040518082815260200191505060405180910390a15600a165627a7a72305820e45e4b8d517ad481f830732b42d85a6398c77129957a3a476ff8c5a74061a0e30029"
}
],
"chainId":"1",
"nonce": "0x00",
"gas": "0x138800",
"gasPrice": "0x1388"
}
],
"keys": [
"8RioSGhgNUKFZopC2rR3HRDD78Sc48gci4pkVhsduZve"
]
}- Call the contract Json file ex_data.json
{
"from": "e523e7c59a0725afd0812345679eed6f8e16ded",
"to": "0x2a2f859f2b7d9615e8d72430726310d88a7a07d4",
"value": "0",
"data": [
{
"type": 6,
"contract":"0xefcfe81a"
}
],
"chainId":"1",
"nonce": "0x1",
"gas": "0x138800",
"gasPrice": "0x13880"
}
- remix, the ABI interface and contract binaries are compiled for the web page
- Deploy the compiled contract, copy the input and replace the contract in the 'de_data.json' file above
- Compile the wallet command
cd cpp-lsac/build
make cmdWallwt
- cd build/wallet/cmdWallet ('de_data.json' above and 'ex_data.json' below need to be in this directory or choose your own directory)
- Sample input instructions (address and port as actually entered)
./cmdWallet -j ./de_data.json -s 10.0.6.122:33050
- result
{"id":1,"jsonrpc":"2.0","result":"0xb634ab1697c3f9b8dbc37a56cfc11c4b8dd45452cd2a6b734bd6e5b9f448ad99"}
- Query the result for the transaction hash obtained above
- command
curl -d '{"jsonrpc":"2.0","method":"brc_getTransactionReceipt","params":["0xb634ab1697c3f9b8dbc37a56cfc11c4b8dd45452cd2a6b734bd6e5b9f448ad99"],"id":17}' http://10.0.6.122:33050
- result
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"blockHash": "0xd1722db723bb279c03f473044d4ed0e32244ded6dc352d7aa9b43ac7a9ef5c9d",
"blockNumber": 768,
"contractAddress": "0xe28c6fea67e1e378509704b9842f809e8f2b3af6",
"cumulativeGasUsed": "0x533d9",
"from": "0xcccc7a30bf688c060524dfd759fe2627ed3387bc",
"gasUsed": "0x533d9",
"logs": [],
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"status": "1",
"to": "0x0000000000000000000000000000000000000000",
"transactionHash": "0xb634ab1697c3f9b8dbc37a56cfc11c4b8dd45452cd2a6b734bd6e5b9f448ad99",
"transactionIndex": 0
}
}
- To get the contract address "contractAddress" : "0xe28c6fea67e1e378509704b9842f809e8f2b3af6", used to set the contract execution ex_data. Json to field
- The method of executing contract function can execute the same function on the online editor and get the content of input: 0x45653a6d ("contract": "0x45653a6d")
- command
./cmdWallet -j ./exec_data.json -s 10.0.6.122:33050
- reslult
{
"id":1,
"jsonrpc":"2.0",
"result":"0x64ac6113595819824bd2a1ac0c97da24d998b6c6338a30e877f7ab460b390790"
}
curl -d '{"jsonrpc":"2.0","method":"brc_getTransactionReceipt","params":["0x64ac6113595819824bd2a1ac0c97da24d998b6c6338a30e877f7ab460b390790"],"id":17}' http://10.0.6.122:33050
- result
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"blockHash": "0xfd2ea19c305ee6c882fbb3f63122ea487e8edce5049f5543198e9f09572bbbe3",
"blockNumber": 778,
"contractAddress": "0xdb92c4305cbb536233ba72df3d822f7f5ab611c2",
"cumulativeGasUsed": "0x5f0b",
"from": "0xcccc7a30bf688c060524dfd759fe2627ed3387bc",
"gasUsed": "0x5f0b",
"logs": [{
"address": "0xe28c6fea67e1e378509704b9842f809e8f2b3af6",
"blockHash": "0xfd2ea19c305ee6c882fbb3f63122ea487e8edce5049f5543198e9f09572bbbe3",
"blockNumber": 778,
"data": "0x000000000000000000000000cccc7a30bf688c060524dfd759fe2627ed3387bc0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000c48656c6c6f20576f726c64210000000000000000000000000000000000000000",
"logIndex": 0,
"polarity": false,
"topics": ["0x0df29a50b04a74cb4f41000f60d3d0f03a368c07e08d1ed2989948c1fc7ae508"],
"transactionHash": "0x64ac6113595819824bd2a1ac0c97da24d998b6c6338a30e877f7ab460b390790",
"transactionIndex": 0,
"type": "mined"
}],
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"status": "1",
"to": "0xe28c6fea67e1e378509704b9842f809e8f2b3af6",
"transactionHash": "0x64ac6113595819824bd2a1ac0c97da24d998b6c6338a30e877f7ab460b390790",
"transactionIndex": 0
}
}
- Query execution contract function result (normal function query command)
curl -X POST --data '{"jsonrpc":"2.0","method":"brc_call","params":[{"from":"cccc7a30bf688c060524dfd759fe2627ed3387bc","to":"0xe28c6fea67e1e378509704b9842f809e8f2b3af6","data":"0xc15bae84"}, "latest"],"id":1}' http://10.0.5.40:8111
- result
{
"id": 1,
"jsonrpc": "2.0",
"result": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000c48656c6c6f20576f726c64210000000000000000000000000000000000000000"
}
- As the example in the official document: