- Node 18.17.0
git clone git@github.com:monerium/smart-contracts-v2
cd smart-contract-v2
nvm use
npm i -g yarn@1.22.21 # Install yarn
Before you can compile and test the contracts, you need to install the necessary dependencies. Run the following commands:
yarn install
forge installWe use Forge for compiling and testing our smart contracts, and Hardhat for upgradability tests and deployment. Here are the steps to follow:
To compile the contracts, use the Forge command:
forge compileTo run the tests, use the Forge command:
forge testFor Hardhat tests related to upgradability and deployment, use the following command:
npx hardhat testOur smart contract deployment script offers multiple options for deploying tokens. It leverages an optimized approach by using a single implementation contract for all tokens, which is more efficient and cost-effective.
Before running any deployment script, ensure you have the correct environment variables set:
- Copy your .env file to .env.local:
cp .env .env.local- Edit .env.local to include necessary variables
- Source the
.env.localfile to load the environment variables:
source .env.localValidates the implementation contract for upgradability without deploying it.
npm run validateTo deploy all tokens (GBP, ISK, EUR, USD) using a single implementation, use the following command:
forge script script/deploy.s.sol:All --rpc-url $RPC_URL --broadcast --etherscan-api-key $ETHERSCAN_API_KEY --verify -vvvv
for local deployment, the etherscan-api-key flag is unnecessary.
To deploy each token individually, with each its own implementation contract, use the corresponding commands:
forge script script/deploy.s.sol:EUR --rpc-url $RPC_URL --broadcast --etherscan-api-key $ETHERSCAN_API_KEY --verify -vvvvforge script script/deploy.s.sol:GBP --rpc-url $RPC_URL --broadcast --etherscan-api-key $ETHERSCAN_API_KEY --verify -vvvvforge script script/deploy.s.sol:ISK --rpc-url $RPC_URL --broadcast --etherscan-api-key $ETHERSCAN_API_KEY --verify -vvvv
forge script script/deploy.s.sol:USD --rpc-url $RPC_URL --broadcast --etherscan-api-key $ETHERSCAN_API_KEY --verify -vvvv
-
--verify: This flag instructs Forge to verify the contract on platforms like Etherscan, Sourcify, or Blockscout (for supported networks), ensuring that the contract source code is publicly visible and verified.
-
Verbosity (-vvvv): This flag controls the level of detail in the logs and traces output:
- -vv: Displays logs emitted during tests, including assertion errors (expected vs. actual values).
- -vvv: Adds stack traces for failing tests.
- -vvvv: Shows stack traces for all tests and setup traces for failing tests.
- -vvvvv: Always displays full stack traces and setup traces.