Temper your expectations - Ethereum Transaction Simulator
Temper your expectations - Ethereum Transaction Simulator
Temper is an Ethereum Transaction Simulator. It provides a super simple HTTP API which simulates a given transaction request against a local EVM.
Simulates a single transaction against a local EVM.
See the full request and response types below.
Example body:
…Example response:
{
"gasUsed": 214622,
"blockNumber": 16784600,
"success": true,
"trace": { ... },
"logs": [ ... ],
"exitReason": "Return"
}Notes:
blockNumber can be omitted and the latest block will be used, however providing a blockNumber is recommended where possible to use the cache.Simulates a bundle of transactions in order against the same EVM.
See the full request and response types below.
Example body:
…Example response:
[{
"gasUsed": 214622,
"blockNumber": 16784600,
"success": true,
"trace": { ... },
"logs": [ ... ],
"exitReason": "Return"
}]Notes:
chainId must be the same in all transactions.blockNumber can be included and incremented when a multi-block simulation is required, or omitted in all transactions to use latest.Starts a new stateful simulation, allowing you to persist the state of a single EVM across multiple subsequent simulation requests.
See the full request and response types below.
Example body:
[
{
"chainId": 1,
"gasLimit": 500000,
"blockNumber": 16784600
}
]Example response:
[{
"statefulSimulationId": "aeb708a5-81d7-4126-a0b5-0f2a78b3830e",
}]Simulates a bundle of transactions in order against the EVM referred to by the UUID in the URL. After the result is obtained, the EVM state will be retained for subsequent requests.
See the full request and response types below.
Example body:
…Example response:
[{
"gasUsed": 214622,
"blockNumber": 16784600,
"success": true,
"trace": { ... },
"logs": [ ... ],
"exitReason": "Return"
}]Notes:
chainId must be the same in all transactions.blockNumber can be included and incremented when a multi-block simulation is required, or omitted in all transactions to use latest.Ends a current stateful simulation, freeing associated memory.
See the full request and response types below.
Example response:
{
"success": true
}If you set an API_KEY environment variable then all calls to the API must be accompanied by a X-API-KEY header which contains this API Key.
Copy .env.example to .env, fill out required values and run:
$ cargo runIf you want the server to restart on any code changes run:
$ cargo watch -x runRun:
$ cargo testbody.json contains a simple request in the root of the project so once the API is running you can just run:
$ curl -H "Content-Type: application/json" --data @tests/body.json http://localhost:8080/api/v1/simulateIf you have jq installed, you can run this to see pretty traces:
$ curl -H "Content-Type: application/json" --data @tests/body.json http://localhost:8080/api/v1/simulate | jq -r ".formattedTrace"…No open issues yet, or sync has not completed.