Nayms Smart Contracts v3
This repository contains Nayms V3 smart contracts.
curl -L https://foundry.paradigm.xyz | bash
Install Forge dependencies
Update Rust, Foundry, and Forge dependencies
Prepare the build
Formatter and Linter
yarn to install
package.json which includes our formatter and linter. We will switch over to Foundry's sol formatter and linter once released.
Set your environment variables
.env.example to see some of the environment variables you should have set in
.env in order to run some of the commands.
Current Directory Structure
. ├── cli-tools ├── script │ ├── deployment │ └── utils ├── src │ ├── diamonds │ │ ├── nayms │ │ │ ├── facets │ │ │ ├── interfaces │ │ │ └── libs │ │ └── shared │ │ ├── facets │ │ ├── interfaces │ │ └── libs │ ├── erc20 │ └── utils └── test ├── defaults ├── fixtures └── utils └── users
You can now write scripts with Solidity.
forge script <name of script in script folder>
Give a valid Alchemy Eth mainnet API key in
.env ALCHEMY_ETH_MAINNET_API_KEY, then try running:
Nayms Deployment Flow
Current deployment flow, 2022-09-21:
Simulate the deployment:
make deploy-sim newDiamond=<bool> initNewDiamond=<bool> facetAction=<enum> facetsToCutIn=<string>
||Deploy a new Nayms diamond|
||Read the address from deployedAddresses.json|
||Deploy a new InitDiamond and call
||Does not call
||List of facets to cut into the diamond. For example, facetsToCutIn=
Below are several examples on how you would use the smart deploy scripts.
For a fresh new deployment of the entire project, execute this command:
make deploy-sim newDiamond=true initNewDiamond=true facetAction=0
To upgrade the facets that have been changed since the last deployment, run the following:
make deploy-sim newDiamond=false initNewDiamond=false facetAction=1
To upgrade specific set of facets, run command like this one:
make deploy-sim newDiamond=false initNewDiamond=false facetAction=2 facetsToCutIn="["Market","Entity"]"
⚠️Examples above are dry-run probes, to actually do a deploy remove the
-simsufix from the target name
Running a Local Node
For development purposes, you can run a node locally using foundry's
anvil. It's a simple way to bring up a local node exposing a JSON-RPC endpoint at
http://127.0.0.1:8545. Make sure to start
anvil in one of your terminal windows and in another one run a make target to deploy the Nayms' contracts to it.
Run the local node seeding it with Nayms' shared wallet:
You can also run it in debug mode to get verbose log output:
To do a full deployment run the following command:
make anvil-deploy newDiamond=true initNewDiamond=true facetAction=0
You will most likelly need to deploy a dummy ERC20 token for testing purposes. You can do that by running:
⚠️Anvil state is not preserved between restarts. Everytime you bring it up, it starts fresh. You need to do the deployment and setup all over again!
Output, compare gas snapshots
Build Troubleshooting Tips
In case you run into an issue of
forge not being able to find a compatible version of solidity compiler for one of your contracts/scripts, you may want to install the solidity version manager
svm. To be able to do so, you will need to have Rust installed on your system and with it the acompanying package manager
cargo. Once that is done, to install
svm run the following command:
cargo install svm-rs
To list the available versions of solidity compiler run:
Make sure the version you need is in this list, or choose the closest one and install it:
svm install "0.7.6"
Convenience targets are provided in the Makefile for running a specific test against a forked network.
To run a test against a Goerli fork us the following command passing in the test matching expression i.e.
make test-goerli MT=testStartTokenSale
Similarly a Mainnet fork test can be executed via:
make test-mainnet MT=testStartTokenSale
Staging for Production Deployment Flow
Run integration tests with mainnet forking.
Ensure "initialization" of entire system.
Use deterministic deployment.
Monitor all events, Nayms Diamond transactions, mempool.
Ramesh Nair @hiddentao