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

Implement eth_getTransactionByBlockNumberAndIndex #107

Merged
merged 4 commits into from
Sep 25, 2019

Conversation

austinabell
Copy link

Similar logic to the full tx decoding done in #87

To test:

  1. Run the Ethermint 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 --log_level "main:info,state:info,mempool:info,*:error"

  1. Start rest server with unlocked key to send tx to test functionality
emintcli rest-server --laddr "tcp://localhost:8545" --unlock-key austineth
  1. Send a transaction to test all values in a block:
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

Retrieve transaction by block number and index (replace 0x2 and 0x0):

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByBlockNumberAndIndex","params":["0x2", "0x0"],"id":1}' -H "Content-Type: application/json" http://localhost:8545/rpc
{"jsonrpc":"2.0","id":1,"result":{"blockHash":"0x048091bc7ddc283f77bfbf91d73c44da58c3df8a9cbc867405d8b7f3daada22f","blockNumber":"0x2","from":"0xd06b1d4c999dd69f9e6334baf047e398528bd4a7","gas":"0x76c0","gasPrice":"0x12","hash":"0x1b25646fcda0f30aa352e3d2825d0f5eef6e87d03f34253596b1197b1a7be050","input":"0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675","nonce":"0x0","to":"0xd46e8dd67c5d32be8058bb8eb970870f07244567","transactionIndex":"0x0","value":"0x20","v":"0x2a","r":"0xc34947a181c44a0bf26817682025280f6673ced03af59604ece3a671435b2209","s":"0x3bb128d85d883136b2195fd224581e363105870eb14d1d894487c7a69691357e"}}

and you can check invalid indexes to see it returns null

@austinabell austinabell merged commit 26e90e7 into development Sep 25, 2019
@austinabell austinabell deleted the austin/eth_gtbbni branch September 25, 2019 19:01
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.

2 participants