Nayms V3 smart contract repository.
curl -L https://foundry.paradigm.xyz | bash
Install Forge dependencies
Update Rust, Foundry, and Forge dependencies
In order to test the Nayms platform, first build the platforms that Nayms composes with, such as Uniswap v3:
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
. ├── contracts │ ├── diamonds │ │ ├── nayms │ │ │ ├── facets │ │ │ ├── interfaces │ │ │ └── libs │ │ └── shared │ │ ├── facets │ │ ├── interfaces │ │ └── libs │ ├── ERC20 │ └── utils ├── docs │ └── adr |── lib ├── scripts ├── src │ └── test │ └── utils │ └── users └── test
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
- Create3 Nayms system deployment contract
- Deploy all facets
- Deploy Nayms Diamond using create3 Nayms system deployment contract
- Call the method
diamondCut()from the Nayms Diamond and cut in facets. Also, in the same call with the 2nd and 3rd parameter on the
diamondCut()method, pass in the
InitDiamondcontract address with a signed transaction calling the
InitDiamond.sol. See this being done in, for example,
Deploy a specific contract:
make deploy-<NETWORK_NAME> contract=<CONTRACT_NAME>
NETWORK_NAME can be:
Run tests using Forge
We test with mainnet forking.
We have test defaults in
./test/defaults/. Defaults follow a hierarchy:
D00: Global configuration
D01: Nayms protocol deployment
D02: Testing defaults such as deploying test tokens and giving addresses starting balances
D03: Protocol level defaults such as setting Nayms internal IDs
Tests follow a hierarchy:
T01: Test defaults, deployment
T02: RBAC, Admin functions
T03: Token transfer level
T03SystemFacet - test creating entities
T04: Business functions
Tests should be fixed in order of the hierarchy (T01 first).
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"
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.
Louper Diamond Inspector - Etherscan for Diamonds
Ramesh Nair @hiddentao