This smart contract is a collection controller for NFTs. It features functionalities for:
- Creating collections.
- Setting collection config.
- Minting NFTs for collections.
In particular, Artist can create collections on this contract with various configs like:
- Payment token to mint NFT of the collection.
- Mint capability.
- Time to start and finish minting phase.
Additionally, Artist can change those configs with supported functions in the contract.
User can choose to mint an NFT in a specific collection with a specific price that is set off-chain by the Payment token in collection config. The NFT detail will be passed to the mint function with a signature generated off-chain to verified if that input is satisfactory.
The contract depends on the following OpenZeppelin contracts:
- IERC20Upgradeable
- SafeERC20Upgradeable
- OwnableUpgradeable
- Initializable
- EnumerableSetUpgradeable
- ReentrancyGuardUpgradeable
The contract maintains several state variables:
feeTo
: Address to receive revenueverifier
: Address to verify signaturetotalCollection
: Total number of collections created in the contractcollections
: Mapping of collection index to collection detailslayerHashes
: Mapping of minted layer id hashartistToCollection
: Mapping of owner address to the set of collections they own
The contract includes several events to provide information about important contract state changes:
FeeToAddressChanged
: Triggered when the feeTo address is changedVerifierAddressChanged
: Triggered when the verifier address is changedCollectionCreated
: Triggered when a new collection is createdMintCapUpdated
: Triggered when the mint cap of a collection is updatedStartTimeUpdated
: Triggered when the start time of a collection is updatedEndTimeUpdated
: Triggered when the end time of a collection is updatedNFTMinted
: Triggered when a new NFT is minted
This function is called when the contract is first deployed. It initializes the contract with an address for revenue collection (_feeTo
) and an address for signature verification (_verifier
).
This function creates a new collection of NFTs with the given parameters: keyId
, name
, symbol
, baseUri
, paymentToken
, mintCap
, startTime
, and endTime
.
This function mints a new NFT in the given collection (specified by _collectionId
) with the given _tokenId
.
This function transfers the ownership of an NFT from the current owner to the specified address (_to
).
This function changes the address to receive the revenue (feeTo
).
This function changes the address used for signature verification (verifier
).
This function updates the mintCap
of the specified collection.
This function updates the startTime
of the specified collection.
This function updates the endTime
of the specified collection.
This function verifies the signature
if an user has right to mint an NFT.
This function returns the details of the specified collection.
This function returns the details of the collection with the given _keyId
.
This function returns the collections created by the specified artist.
The contract implement ERC1967 proxy and must be deployed with the initialize function called immediately after deployment to set the feeTo and verifier addresses.
Provide your INFURA_API_KEY
, PRIVATE_KEY
, ETHERSCAN_KEY
in env file as env.sample
Install all packages using
npm install
Or if you are using yarn
yarn
To deploy
npx hardhat run scripts/deploy_all.ts --network <<NETWORK>>
Or if you are using yarn
yarn hardhat run scripts/deploy_all.ts --network <<NETWORK>>
Replace NETWORK
with the name of network you want to deploy to in Hardhat config
After deployed, verify with
npx hardhat run scripts/verify.ts --network <<NETWORK>>
Or if you are using yarn
yarn hardhat run scripts/verify.ts --network <<NETWORK>>
Replace NETWORK
with the name of network you want to deploy to in Hardhat config
npx hardhat test
Or if you are using yarn
yarn hardhat test