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
![image](https://private-user-images.githubusercontent.com/35039927/333752825-b7fca77e-9542-42ad-894a-3fe5eb838fed.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMzNzI1ODMsIm5iZiI6MTcyMzM3MjI4MywicGF0aCI6Ii8zNTAzOTkyNy8zMzM3NTI4MjUtYjdmY2E3N2UtOTU0Mi00MmFkLTg5NGEtM2ZlNWViODM4ZmVkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODExVDEwMzEyM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTcyODE5MmRiZWM0MjFjODZlNmQ0NTI0NzcwMTI0OTc4YzcxNzA3NzJhODNlZWE1NTAyZjM2YmY1YTY0YmIxMmEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.8v93kTAK1vh4z9MMcxAXXHsmVJMwWCR3z4zdk1Kqy8c)
Shout out to polarzero who originally built this. See his live version here