Crestal Omnichain Smart Contracts
Install Foundry.
Update Foundry to latest version:
foundryup
Add
~/.foundry/bin
to$PATH
if command is not found.
Install OpenZeppelin contracts:
forge install foundry-rs/forge-std
forge install OpenZeppelin/openzeppelin-foundry-upgrades
forge install OpenZeppelin/openzeppelin-contracts-upgradeable
Update dependencies (for an existing project):
forge update
Install OpenZeppelin Upgrades CLI:
npm install @openzeppelin/upgrades-core
This only needs to be set up during initialization for each Foundry project. Keeping it as reference.
(Optional) Recommend installing solc-select to manage Solidity compiler versions.
(Optional) Security tools
Install pipx.
pipx install slither-analyzer
pipx install mythril
Format source files:
forge fmt
Build contracts:
forge clean
forge build
Test contracts:
forge test
Security checks:
make slither
make mythril
Generate abi (for external access):
make abi
Start local node in a separate window:
anvil
Deploy (copy private key from anvil
output):
PRIVATE_KEY=xxx make deploy
Upgrade to latest version (copy proxy address from deployed output):
PRIVATE_KEY=xxx PROXY_ADDRESS=xxx make upgrade
Upgrade to particular version, one V+ at a time (copy proxy address from deployed output):
PRIVATE_KEY=xxx PROXY_ADDRESS=xxx UPGRADE_TO=Vx make upgrade
Sanity check:
PROXY_ADDRESS=xxx make check
Deploy:
PRIVATE_KEY=xxx RPC_URL=https://xxx make deploy
Upgrade (copy proxy address from deployed output):
PRIVATE_KEY=xxx RPC_URL=https://xxx PROXY_ADDRESS=xxx UPGRADE_TO=Vx make upgrade
Sanity check:
PROXY_ADDRESS=xxx RPC_URL=https://xxx make check
Put all env-related variables in a per chain .env.chain
file then use the following:
ENV_FILE=.env.chain make deploy