Skip to content
This repository was archived by the owner on Nov 30, 2021. It is now read-only.

Conversation

@austinabell
Copy link

@austinabell austinabell commented Sep 19, 2019

  • Implements Implement eth_sendTransaction #36 eth_sendTransaction
  • Added flag to output ETH address to be used more easily with RPC requests and CLI queries
  • Added account mutex lock to RPC API context to avoid duplicate data returns (in the case of this PR, nonce values)

The rpc call works such that if any value is not provided in args, the value will be defaulted. The only ones that are defaulted statically currently are gas price (blocked by same issue as #24) and gas limit (blocked also by not having gas price and will do after tx simulating in #38).

to run node:

make install 
rm -rf ~/.emint*
emintd init moniker --chain-id 3
emintcli config chain-id 3
emintcli config output json
emintcli config indent true
emintcli config trust-node true
emintcli keys add austin
testpass
testpass
emintcli emintkeys add austineth
testpass
testpass
emintd add-genesis-account $(emintcli keys show austin -a) 1000photon,100000000stake
emintd add-genesis-account $(emintcli emintkeys show austineth -a) 100000000photon,100000000stake
emintd gentx --name austin
testpass
emintd collect-gentxs
emintd validate-genesis
emintd start --pruning=nothing --rpc.unsafe

start server and unlock key for from address of transaction:

emintcli rest-server --laddr "tcp://localhost:8545" --unlock-key austineth

Send request with all parameters:

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{"from":"0x'$(echo -n $(emintcli emintkeys show austineth -w))'","to":"0xd46e8dd67c5d32be8058bb8eb970870f07244567","gas":"0x76c0","gasPrice":"0x12","value":"0x20","data":"0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"}],"id":1}' -H "Content-Type: application/json" http://localhost:8545/rpc
## {"jsonrpc":"2.0","id":1,"result":"0x224948f3a29a8a6e555d93611ddbd28b524ef09c6461dbef506220dcfbaee7d0"}

Or with only from and to and let values be defaulted:

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{"from":"0x'$(echo -n $(emintcli emintkeys show austineth -w))'","to":"0xd46e8dd67c5d32be8058bb8eb970870f07244567"}],"id":1}' -H "Content-Type: application/json" http://localhost:8545/rpc
## {"jsonrpc":"2.0","id":1,"result":"0x85017e8159a89117c5bfb951808c2a7df55416e381353ea263297d74d3260881"}

Edit: Oh and a contract creation for good measure:

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{"from":"0x'$(echo -n $(emintcli emintkeys show austineth -w))'","data":"0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675","gas":"0x76c0"}],"id":1}' -H "Content-Type: application/json" http://localhost:8545/rpc
## {"jsonrpc":"2.0","id":1,"result":"0x6783f8c8b76e9aa1e2ee940df3bc3dc062e43e6691d2c8aaabb361edec1a53bb"}

@austinabell
Copy link
Author

got this strange issue with it reporting an invalid tx for creates:

I[2019-09-19|15:02:42.950] Added good transaction                       module=mempool tx=D25DD1310439BAC1E3BB0C29BD364229A6D65EC9B68F51115D1383AAB68D620E res="&{CheckTx:log:\"[{\\\"msg_index\\\":0,\\\"success\\\":true,\\\"log\\\":\\\"\\\"}]\" gas_used:1258 events:<type:\"message\" attributes:<key:\"action\" value:\"ethereum_tx\" > > }" height=36 total=1
I[2019-09-19|15:02:44.521] Executed block                               module=state height=37 validTxs=0 invalidTxs=1
I[2019-09-19|15:02:44.531] Committed state                              module=state height=37 txs=1 appHash=8F3EC2A3FA631B609141452F5C05EAA613A27C538E5F57AFC64E4FD3FA915EAE

@austinabell austinabell merged commit 28aaba0 into development Sep 20, 2019
@austinabell austinabell deleted the austin/eth_sendTransaction branch September 20, 2019 13:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants