Package Exports
- @iqprotocol/solidity-contracts-nft
- @iqprotocol/solidity-contracts-nft/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@iqprotocol/solidity-contracts-nft) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
IQ Protocol NFT
Docs
Setup
- Clone repository
- Run
yarn
Compilation
yarn compile
Testing
yarn test
Generate docs
pip install -r requirements.txt
yarn hardhato docgen
mkdocs serve
Tasks
Many of the protocol maintenance routines are automated using hardhat tasks. Find the list of available commands by running:
hardhat --help
Deployment
The deployment process is automated via hardhat tasks, which can be found under tasks/deployment
directory.
Process of registration the full dataset required for testing is exampled below.
Dummy Data Generation
In order to simplify testing on testnet networks there is set of tasks, which can be found under tasks/datagen
directory.
Detailed flow (Multiple steps)
- Define protocol tax terms
yarn hardhat datagen:register-protocol-terms --network [network name] --metahub [address]
This will set protocol tax terms to default values 25% for listing fees
and 50% for tournament reward fees
.
Or setup custom fee:
yarn hardhat datagen:register-protocol-terms --network [network name] --metahub [address] --base-tax-rate 10 --reward-tax-rate 15
Where --base-tax-rate
and --reward-tax-rate
parameters are percentage and has maximum value of 100
.
- Grant ACL Wizard roles for default signer
yarn hardhat datagen:grant-acl-roles --network [network name] --metahub [address]
- Deploy mock of Universe Token
yarn hardhat deploy:test:mock:erc721 --network [network name] --name UniverseName --symbol UNIS
- Setup Universe and Warper
yarn hardhat datagen:setup-universe-and-warper --network [network name] --metahub [address] --universe-token [address] --base-token [address] --universe-name UniverseName
This will set universe tax terms to default values 25% for listing fees
and 50% for tournament reward fees
and other parameters for default values.
More details can be found in tasks/datagen/setup-universe-and-warper.ts
file.
Or setup custom parameters (if you already have a warper):
yarn hardhat datagen:setup-universe-and-warper --network [network name] --metahub [address] --universe-token [address] --base-token [address] --universe-name UniverseName --existing-warper-address [address] --base-tax-rate 20 --reward-tax-rate 40 --payment-tokens ["0x0000000000000000000000000000000000000000"] --warper-name WarperName --warper-preset-id 0x0000000000000000000000000000000000000000 --warper-init-data 0x0000000000000000000000000000000000000000 --warper-paused false
- Mint tokens
yarn hardhat datagen:mint-tokens --network [network name] --metahub [address] --universe-token [address] --nft-collection-size 2
- Creating listing
yarn hardhat datagen:list --network [network name] --metahub [address] --universe-token [address] --universe-id 1 --token-id 1
Or setup custom parameters:
yarn hardhat datagen:list --network [network name] --metahub [address] --universe-token [address] --universe-id 1 --token-id 1 --base-fee 100 --reward-fee 25 --max-lock-period 36000 --immediate-payout false --configurator [address]
- Creating renting
yarn hardhat datagen:rent --network [network name] --metahub [address] --listing-id 1 --listing-terms-id 1 --warper [addresss] --payment-token [addresss]
Or setup custom parameters:
yarn hardhat datagen:rent --network [network name] --metahub [address] --listing-id 1 --listing-terms-id 1 --warper [addresss] --payment-token [addresss] --rental-period 36000
Simple flow (2 steps)
- Deploy mock of Universe Token
yarn hardhat deploy:test:mock:erc721 --network [network name] --name UniverseName --symbol UNIS
- Deploy mock of Universe Token
yarn hardhat datagen:initialize --network [network name] --metahub [address] --base-token [address] --universe-token [address]
Testing purposes (for testnet deployments)
- A payment token:
yarn hardhat --network [network name] deploy:mock:ERC20 --name USDC --symbol USDC
- An NFT collection:
yarn hardhat --network [network name] deploy:mock:ERC721-internal-tests --name TEST --symbol TT
Initial deployment
The following command sequence will deploy the protocol from scratch. This process covers the deployment of all core contracts and initial configuration.
- Create a
.env
file that resembles the.env.example
file in the current directory. - Execute the script
yarn hardhat --network [network name] deploy:initial-deployment --base-token [address] --protocol-external-fees-collector [address]
Upgrades
Beware: Upgrading smart contracts requires extra caution, as this can lead to data loss and break the protocol.
Some protocol contracts are upgradeable. This allows extending functionality and fixing the security issues.
The upgradeability process can be automated via hardhat tasks. You can find some examples of upgrade tasks under tasks/upgrades
directory.
In order to reduce the risks, the protocol relies on OZ Upgrades Plugin for deploying and upgrading contracts.
Publish to NPM
- manually update the version in
package.json
- yarn build
- yarn run publish
Manual contract verification
- Every time the deployment command is executed, a new set of deployment artifacts is created under
deployments/<network>
. Thedeployments/<network>/solcInputs
directory will contain a new Standard JSON-input file which can be used for contract verification. - Verifying Metahub requires extra care. It uses dynamically linked libraries, but those do not get attached to the deployment artifact. It means that you need to edit this JSON field manually and add the deployed library addresses:
...
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"storageLayout",
"abi",
"evm.bytecode",
"evm.deployedBytecode",
"evm.methodIdentifiers",
"metadata",
"devdoc",
"userdoc",
"evm.gasEstimates"
],
"": [
"ast"
]
}
},
"metadata": {
"useLiteralContent": true
},
// This is the part you need to add manually
"libraries": {
"contracts/renting/Rentings.sol": {
// The addresses get logged to the terminal when deploying the Metahub contract.
"Rentings": "0xF6188F991962dBcEF5621312515BeEE566989Df0"
},
"contracts/listing/Listings.sol": {
"Listings": "0xd0bdF81Aca69FC6B28de655c0464451f25A0cdfA"
},
"contracts/asset/Assets.sol": {
"Assets": "0x4778CE9b59c5E9e287Ed50f4671c98F4b7557A72"
},
"contracts/warper/Warpers.sol": {
"Warpers": "0x529Bd1D28bECeC204a817D2dE6530638A8AEda72"
},
"contracts/accounting/Accounts.sol": {
"Accounts": "0xD40925d61751BDFab9ff4b163a3793177EbDc0AA"
}
}
}
...