Skip to content

Instantly share code, notes, and snippets.

@tomusdrw
Last active October 8, 2017 19:48
Show Gist options
  • Select an option

  • Save tomusdrw/a613b863237139ceecb295c27ce6fc09 to your computer and use it in GitHub Desktop.

Select an option

Save tomusdrw/a613b863237139ceecb295c27ce6fc09 to your computer and use it in GitHub Desktop.

Try to break transaction scheduler

Last one thing is not yet implemented - transactions should be allowed only for certified accounts. (so right now it's possible to spam the service by sending transactions from newly created accounts)

How to do it?

Prepare a pre-signed transaction (the one in example sends 0.01ETH to my account with 20 shannon gas price and 150k gas). Feel free to experiment with some other values/gas/gasPrices and data fields.

# I really recommend httpie tool :)
$ http localhost:8545 jsonrpc=2.0 id=1 method=eth_signTransaction \
  params:='[{"from":"<youraddress>","to":"0x009D7053Fb15023F7090a15e52Eb71DF2d0a0f37","value":"0x2386f26fc10000","gasPrice":"0x4a817c800","gas":"0x249f0"}]'
  
  
# or with curl
$ curl -X POST -H "Content-Type:application/json" \
  --data '{"jsonrpc":"2.0","id":1,"method":"eth_signTransaction","params":[{"from":"<youraddress>","to":"0x009D7053Fb15023F7090a15e52Eb71DF2d0a0f37","value":"0x2386f26fc10000","gasPrice":"0x4a817c800","gas":"0x249f0"}]}' \
  localhost:8545

You will get something like that in response:

HTTP/1.1 200 OK
Content-Type: application/json
Date: Thu, 05 Oct 2017 20:47:49 GMT
Transfer-Encoding: chunked

{
    "id": 1, 
    "jsonrpc": "2.0", 
    "result": {
        "raw": "0xf86c2a8504a817c800830249f094009d7053fb15023f7090a15e52eb71df2d0a0f37872386f26fc100008078a0d3f1112a742881c700f082ebf78fe39d3638cd194931d7590cad015edc1050a7a07eac9d6e524f808021155f5f52841905ce54187fef2b31277a20a4e123e524b6", 
        "tx": {
          ...
        }
    }
}

Copy raw and submit it to the scheduler together with block number when it should be released.

$ http https://txsched-kovan.parity.io/ jsonrpc=2.0 id=1 method=scheduleTransaction params:='[4166924,"0xf86..b6"]'

# or with curl
$ curl -X POST -H "Content-Type:application/json" \
  --data '{"jsonrpc":"2.0","id":1,"method":"scheduleTransaction","params":[4166924,"0xf86..b6"]}' \
  https://txsched-kovan.parity.io/

Some notes

  • You need to send the transaction at least 5 blocks in advance and no more than 100k blocks in advance.
  • There is a minimal gas price requirement of 20gwei and maximal gas limit of 100k.
  • You can schedule up to 5 transaction per sender.
  • You can only schedule transaction with nonce greater or equal to current nonce.
  • The account needs to have sufficient balance when scheduling transaction.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment