Utility repository for building and deploying smart contracts.
We will use deno, a modern alternative to Node that can work with TypeScript out of the box. You can install it by running:
curl -fsSL https://deno.land/install.sh | sh
We can now compile the contracts located in the contracts/
directory:
deno task build [--filter <contract-name>] [--clean]
This does the following:
- Compile the bytecode for each contract into
codgen/bytecode/*
- Generate the abi for each contract into
codgen/abi/*.ts
and the indexcodegen/abis.ts
Before you can deploy contracts, let's copy the .env.example
file to .env
and fill in the required environment variables.
cp .env.example .env
Update tools/deploy.ts
to include new contracts you want to deploy.
Make sure to specify the constructor arguments and the value, if needed.
To deploy to Westend Testnet, you will need to specify the TESTNET_PRIVATE_KEY
.
Check the instructions here to connect with your wallet and request funds.
For local development, checkout the instructions here to setup and start a local chain.
Note: You can also test against
geth
, the deployment code, will detect the chain and deploy the right bytecode (evm or pvm).
Local deployments will use the account
0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
already configured in your.env
file, This account is pre-funded at genesis, so you can use it to deploy contracts.
Now that you have the environment variables setup, ensure that your chain is running and deploy the contracts by running:
deno task deploy [--filter <contract-name>]
This command will update the codegen/addresses.ts
file with the deployed contract addresses, so that you can easily reference them in your apps.
There is an example cli in the cli
directory that you can run to interact with the deployed contracts.
./cli/dao-hack.ts
- Asset Hub documentation to learn more about building Smart Contracts on Asset Hub.
- viem documentation to learn more about the library used to interact with EVM contracts.