Initial commit
This commit is contained in:
54
README.md
Normal file
54
README.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# Viem Lecture
|
||||
|
||||
This project uses [viem](https://viem.sh/) for TypeScript/JavaScript Ethereum interactions.
|
||||
|
||||
|
||||
|
||||
## Getting started
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Writing scripts
|
||||
|
||||
Put your scripts in the **`scripts/`** directory.
|
||||
|
||||
To run a script:
|
||||
|
||||
```bash
|
||||
# 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:
|
||||
|
||||
```bash
|
||||
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:
|
||||
|
||||
```js
|
||||
const { name } = await prompts([{
|
||||
name: 'name',
|
||||
type: 'text',
|
||||
message: 'Enter your name: '
|
||||
}])
|
||||
```
|
||||
Reference in New Issue
Block a user