Viem Lecture
This project uses viem for TypeScript/JavaScript Ethereum interactions.
Getting started
npm install
Writing scripts
Put your scripts in the scripts/ directory.
To run a script:
# If you have a newer version of Node
node scripts/your-script.ts
# TypeScript (using tsx)
npx tsx scripts/your-script.ts
Environment variables
To read variables from a .env file when running a script:
node --env-file=.env scripts/your-script.ts
The script will have access to all variables defined in .env via process.env.VARIABLE_NAME.
Prompts
To read user input from the console, you can use the prompts library:
const { name } = await prompts([{
name: 'name',
type: 'text',
message: 'Enter your name: '
}])
Description
Languages
TypeScript
100%