This repo demonstrates the Tevm Getting Started Guide. Every step of the guide is it's own commit.
- Creating an in-memory EVM with
createMemoryClient
- Making requests to the in-memory EVM with viem actions such as
memoryClient.getBlockNumber
andmemoryClient.getTransactionReceipt
- Querying account information with
memoryClient.tevmGetAccount
- Modifying account information with
memoryClient.tevmSetAccount
- Using the accounts prefunded with
1000 eth
- Executing the EVM and creating a transaction with
memoryClient.tevmCall
- Mining a new block with
memoryClient.tevmMine
- Deploying a contract with
memoryClient.tevmDeploy
- Calling a contract with
meoryClient.tevmContract
- Reducing boilerplate of contract calls in Tevm and Viem with Tevm
Contracts
- Importing contracts into tests and running them as scripts
- Running JavaScript in solidity scripts
There are also commits showing the boilerplate needed to run Tevm in the browser and set up the automatic solidity contract imports.
- src/main.ts demonstrates the most basic tevm features such as modifying accounts deploying and calling contracts and using the viem api.
- src/counter.spec.ts demonstrates more advanced tevm features such as solidity scripting and running javascript in solidity.
This repo is available as a stackblitz here. You will have to enable the local version of typescript after starting the stakblitz. More information is in a comment at the top of src/main.ts
.
For a more advanced example using Tevm and NEXT.js to build a robust transaction simulator app see the NEXT.js example
Shout out to polarzero who originally built this. See his live version here