/library-example

Running library code in tevm

Primary LanguageJavaScript

lib-example

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.

Requirements

Bun

npm i -g bun && bun upgrade

Installation

bun install

To run

bun run index.js

How it generates bytecode

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.

How it runs solidity

The memoryClient is an in memory instance of the EVM (think anvil) and can execute arbitrary bytecode with the client.script method