Vessel smart contracts.
- Install Node.js (>= v20)
$ brew install nvm $ nvm install --lts $ nvm use --lts
- Install Foundry compiler
$ curl -L https://foundry.paradigm.xyz | bash $ foundryup
- Install TypeScript and pnpm
$ npm install -g typescript tsx pnpm
- Compile the Solidity cod
$ pnpm run build
- Install script dependencies
$ cd script $ pnpm install
- Create a .env file
$ cp .env.example .env
- Create a config file with the name
.config.{NODE_ENV}.json
. For the defaultNODE_ENV=local
, it should be:$ cp .config.exmaple.json .config.local.json
Ensure all essential configuration variables are correctly filled. These variables are used in both production and test environments.
- DEPLOYER_SK: Private key of deployer EOA.
- ADMIN_ADDRESS: Address of the vault admin, eligible to upgrade the vault and SNARK verifier.
- OPERATOR_ADDRESSES: List of addresses of vault operators, eligible to manage tokens and users, and commit SNARK proofs.
- GITHUB_TOKEN: GitHub token used to download the circuit release containing SNARK verifier bytecode.
- RELEASE_TAG: GitHub release tag identifying the circuit release.
- NODE_RPC_URL: string URL. RPC endpoint of the EVM chain node.
- CHAIN_ID: Integer representing the chain ID.
- MAX_FEE_PER_GAS: Maximum fee per gas (human-readable number) if ENABLE_1559 is true, or gas price if ENABLE_1559 is false.
- MAX_PRIORITY_FEE_PER_GAS: Maximum priority fee per gas (human-readable number) if ENABLE_1559 is true.
- ENABLE_1559: Boolean indicating if EIP-1559 is enabled.
- ENABLE_MULTISIG_ADMIN: Boolean indicating if contract upgrades should propose a multi-sig transaction to the SAFE API URL instead of directly sending a transaction to the node RPC using ADMIN_SK.
- SAFE_TX_SERVICE_URL: SAFE API endpoint, normally requiring the
/api
suffix. - VAULT_PROXY_CONTRACT_ADDRESS: Will be overwritten after running the deploy script.
- PROXY_ADMIN_CONTRACT_ADDRESS: Will be overwritten after running the deploy script.
- OWNER_CONTRACT_ADDRESS: Will be overwritten after running the deploy script.
- ADMIN_SK: Private key of admin EOA, needed only if the admin is an EOA rather than a multi-sig contract, for running the script to upgrade the contract.
To test listing token and registering users in the vault, additional test configuration variables may be used.
Ensure all essential configuration variables are correctly filled. Initially, set dummy values for VAULT_ADDRESS, TOKEN_ADDRESS, and TOKEN_ASSET_ID, they will be automatically set after deploying new contracts.
Build the contracts:
$ forge build
Delete the build artifacts and cache directories:
$ forge clean
Compile the contracts:
$ forge build
Get a test coverage report:
$ forge coverage
Deploy to Anvil:
$ forge script script/Deploy.s.sol --broadcast --fork-url http://localhost:8545
For this script to work, you need to have a MNEMONIC
environment variable set to a valid
BIP39 mnemonic.
For instructions on how to deploy to a testnet or mainnet, check out the Solidity Scripting tutorial.
Format the contracts:
$ forge fmt
Get a gas report:
$ forge test --gas-report
Lint the contracts:
$ pnpm lint
Run the tests:
$ forge test
- Foundry uses git submodules to manage dependencies. For detailed instructions on working with dependencies, please refer to the guide in the book
- You don't have to create a
.env
file, but filling in the environment variables may be useful when debugging and testing against a fork.
- abigger87/femplate
- cleanunicorn/ethereum-smartcontract-template
- foundry-rs/forge-template
- FrankieIsLost/forge-template
SPDX-License-Identifier: Apache-2.0
Copyright 2024 Vessel Team.