diff --git a/src/macro/kvstore/core/evm_utils.cc b/src/macro/kvstore/core/evm_utils.cc index 9c5fee51..533a8661 100644 --- a/src/macro/kvstore/core/evm_utils.cc +++ b/src/macro/kvstore/core/evm_utils.cc @@ -1,6 +1,5 @@ #include "evm_utils.h" #include - namespace BBUtils { namespace EVMUtils { @@ -19,7 +18,7 @@ const std::string SEND_TXN_PREFIX = "{\ \"jsonrpc\": \"2.0\", \ \"method\": \"eth_sendTransaction\", \ - \"params\": [{ \"gas\": \"100000\", \ + \"params\": [{ \"gas\": \"0x100000\", \ \"gasPrice\": \"0x0\", \ \"from\": \""; @@ -27,7 +26,7 @@ const std::string CALL_PREFIX = "{\ \"jsonrpc\": \"2.0\", \ \"method\": \"eth_call\", \ - \"params\": [{ \"gas\": \"100000\",\ + \"params\": [{ \"gas\": \"0x100000\",\ \"gasPrice\": \"0x0\", \ \"from\": \""; @@ -73,7 +72,7 @@ const std::string GET_ACCOUNTS = const std::string DEPLOY_SMARTCONTRACT_PREFIX = " {\"jsonrpc\":\"2.0\",\ \"method\":\"eth_sendTransaction\",\ - \"params\": [{ \"gas\": \"100000\",\ + \"params\": [{ \"gas\": \"0x100000\",\ \"gasPrice\": \"0x0\", \ \"from\": \""; @@ -327,6 +326,7 @@ std::string deploy_smart_contract(const std::string &endpoint, std::string lookup_smart_contract_address_or_die(const std::string &endpoint, const std::string &receipt) { + //TODO: retry when result equal null auto r = send_jsonrpc_request(endpoint, REQUEST_HEADERS, GET_SMART_CONTRACT_ADDRESS_PREFIX + receipt + GET_SMART_CONTRACT_ADDRESS_SUFFIX); diff --git a/src/macro/kvstore/db/README.md b/src/macro/kvstore/db/README.md index c24918d8..e8692443 100644 --- a/src/macro/kvstore/db/README.md +++ b/src/macro/kvstore/db/README.md @@ -3,13 +3,15 @@ At first, need to do these following three steps to deploy a smart contract ## ``````` # get ethereum account -curl localhost:8545 -X POST --data '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}' +curl localhost:8505 -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}' # deploy the kvstore smart contract -curl localhost:8545 -X POST --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{"from": "0xf3755719b435bd56d292ed8302115ae895095afd", "data": "6060604052610398806100126000396000f360606040526000357c010000000000000000000000000000000000000000000000000000000090048063693ec85e14610047578063e942b5161461010e57610042565b610002565b34610002576100a06004808035906020019082018035906020019191908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509090919050506101b0565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156101005780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34610002576101ae6004808035906020019082018035906020019191908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050909091908035906020019082018035906020019191908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509090919050506102aa565b005b6020604051908101604052806000815260200150600060005082604051808280519060200190808383829060006004602084601f0104600302600f01f15090500191505090815260200160405180910390206000508054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102995780601f1061026e57610100808354040283529160200191610299565b820191906000526020600020905b81548152906001019060200180831161027c57829003601f168201915b505050505090506102a5565b919050565b80600060005083604051808280519060200190808383829060006004602084601f0104600302600f01f15090500191505090815260200160405180910390206000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061033557805160ff1916838001178555610366565b82800160010185558215610366579182015b82811115610365578251826000505591602001919060010190610347565b5b5090506103919190610373565b8082111561038d5760008181506000905550600101610373565b5090565b50505b505056"}],"id":1}' +curl localhost:8505 -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{"from": "0x4596d8ec539b21635a10a577754a521395ebeeb9", "data": "0x6060604052610398806100126000396000f360606040526000357c010000000000000000000000000000000000000000000000000000000090048063693ec85e14610047578063e942b5161461010e57610042565b610002565b34610002576100a06004808035906020019082018035906020019191908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509090919050506101b0565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156101005780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34610002576101ae6004808035906020019082018035906020019191908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050909091908035906020019082018035906020019191908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509090919050506102aa565b005b6020604051908101604052806000815260200150600060005082604051808280519060200190808383829060006004602084601f0104600302600f01f15090500191505090815260200160405180910390206000508054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102995780601f1061026e57610100808354040283529160200191610299565b820191906000526020600020905b81548152906001019060200180831161027c57829003601f168201915b505050505090506102a5565b919050565b80600060005083604051808280519060200190808383829060006004602084601f0104600302600f01f15090500191505090815260200160405180910390206000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061033557805160ff1916838001178555610366565b82800160010185558215610366579182015b82811115610365578251826000505591602001919060010190610347565b5b5090506103919190610373565b8082111561038d5760008181506000905550600101610373565b5090565b50505b505056"}],"id":1}' + +curl localhost:8505 -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params": [{ "gas": "0x100000","gasPrice": "0x0","from": "0x4596d8ec539b21635a10a577754a521395ebeeb9","data": "0x6060604052610398806100126000396000f360606040526000357c010000000000000000000000000000000000000000000000000000000090048063693ec85e14610047578063e942b5161461010e57610042565b610002565b34610002576100a06004808035906020019082018035906020019191908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509090919050506101b0565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156101005780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34610002576101ae6004808035906020019082018035906020019191908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050909091908035906020019082018035906020019191908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509090919050506102aa565b005b6020604051908101604052806000815260200150600060005082604051808280519060200190808383829060006004602084601f0104600302600f01f15090500191505090815260200160405180910390206000508054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102995780601f1061026e57610100808354040283529160200191610299565b820191906000526020600020905b81548152906001019060200180831161027c57829003601f168201915b505050505090506102a5565b919050565b80600060005083604051808280519060200190808383829060006004602084601f0104600302600f01f15090500191505090815260200160405180910390206000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061033557805160ff1916838001178555610366565b82800160010185558215610366579182015b82811115610365578251826000505591602001919060010190610347565b5b5090506103919190610373565b8082111561038d5760008181506000905550600101610373565b5090565b50505b505056"}],"id":1}' # get receipt (smart contract address) -curl localhost:8545 -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0x215ea2ded36769e6736a36a2eb3115d08578b58b4a8799eefa812fc81e1fee5c"],"id":1}' +curl localhost:8505 -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0xd37b952ebbb1186805682c74ace31e6c32ebe3e9c8a674ce2db67a6e569d5cea"],"id":1}' ``````` In the first step, get a account address. This address need to put in the "from" field in second step. The second step is to deploy / activate a smart contract.