This is a basic example of calling a solidity lib function in javascript using tevm. Note tevm is not yet stable so reach out if you see anything odd.
Bun
npm i -g bun && bun upgrade
bun install
bun run index.js
This repo uses the tevm compiler
to generate bytecode. This happens automatically in index.js via importing a solidity file.
The artifacts are in .tevm/ folder.
The configuration for bun is in bunfig.toml. This tells bun to compile solidity with tevm when it sees a contract import.
Tevm is perfectly usable without doing this via just using the abi and bytecode generated by other tools like foundry.
The memoryClient
is an in memory instance of the EVM (think anvil) and can execute arbitrary bytecode with the client.script
method