πERC721 Integration
This page demonstrates how an ERC721 smart contract can integrate the NFTDelegation.com smart contract during their minting.
Steps:
Import Interfaces within your smart contract
import "./INFTDelegationRead.sol";Declare the Read Interface variable as below:
INFTDelegationRead public dmcRead;Add a control mechanism as follows to check the minting process and block the Delegators' addresses for minting more than one time.
mapping (address => bool) public checkDelegatorMints;Modify your ERC721 constructor as below. When deploying the smart contract input the NFTDelegation smart contract address 0x2202CB9c00487e7e8EF21e6d8E914B32e709f43d within your constructor.
constructor(address _delegationManagementContract, string memory name, string memory symbol) ERC721(name, symbol) {
dmc = INFTDelegationRead(_delegationManagementContract);
}Suggested Options for minting
Option A:
Modify the minting function to take into consideration the retrieveDelegators() function from the NFTDelegation.com Smart Contract based on 'Any Collection' and 'All Use Cases'.
By calling this function all Delegators of the msg.sender are retrieved, the tokens are minted and they are sent to each one of the Delegators.
function mintTokensForAllDelegators() public payable {
// add your minting requirements and control mechanisms
// to use NFTDelegation.com Smart Contract please add the code below
address[] memory dmcDelegators;
// use the collection and use case that you would like to retrieve delegators, in this case is 'Any Collection' and 'All Use Cases'
dmcDelegators = dmc.retrieveDelegators(msg.sender, 0x8888888888888888888888888888888888888888, 1);
// minting process
for(uint i = 0; i <= dmcDelegators.length-1; i++) {
uint mintIndex = totalSupply();
// control mechanisms to prevent wallets on minting again using the same delegators addresses
if (checkDelegatorMints[dmcDelegators[i]] == false) {
_safeMint(dmcDelegators[i], mintIndex);
checkDelegatorMints[dmcDelegators[i]] = true;
} else {}
}
}Option B:
Minting function modifications that takes into consideration the retrieveGlobalStatusOfDelegation() function from the NFTDelegation.com Smart Contract based on 'Any Collection' and 'All Use Cases'.
During Option B the function awaits for one parameter, address _vault. If a delegation between the _vault address and the msg.sender exists the token will be minted and sent to the _vault address.
Option C:
Minting function modifications that takes into consideration the retrieveGlobalStatusOfDelegation() function from the NFTDelegation.com Smart Contract based on 'Any Collection' and 'All Use Cases'.
During Option C the function awaits for two parameters, address _vault and address _mintToAddress . If a delegation between the _vault address and the msg.sender exists the token will be minted and sent to the _mintToAddress address that can be different than the _vault.
Please note that this is a sample smart contract for demonstrating the usage of NFTDelegation within an ERC721 contract.
Source Code
Extension A: Mint based on smart contract's max Allowance
Modify the smart contract to allow a delegated address to mint on behalf of the Delegator address the max tokens allowed. In this case the minting is not 1 token per Delegator Address but more based on the maxAllowance number set on the smart contract.
Modifications:
Add a uint256 variable and a mapping that will be used to count the number of successful mints per address.
Modify the constructor as below and add a value for the maxAllowance variable.
Modify the minting function as below:
Extension B: Mint based on Merkle Proofs
Modify the smart contract to allow the delegated address to mint on behalf of the Delegator Address when the Delegator Address has an allowlist. The amount of tokens minted per Delegator Address varies.
Example:
0x5B38Da6a701c568545dCfcB03FcB875f56beddC4
1
0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2
2
0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db
3
Modifications:
Import the MerkleProof library
Add a bytes32 variable for the MerkleRoot and a mapping that will be used to count the number of successful mints per address.
Modify the constructor so as to accept a Merkle Root as an input.
Modify the minting function as below:
Last updated