This page demonstrates how the NFTDelegation.com smart contract can be integrated to make external calls.
Steps:
Import Interfaces within your smart contract
import "./INFTDelegationRead.sol";
Declare the Read Interface variable as below:
INFTDelegationRead public dmcRead;
Modify your constructor as below. When deploying the smart contract input the NFTDelegation smart contract address 0x2202CB9c00487e7e8EF21e6d8E914B32e709f43d within your constructor.
The retrieveDelegators() function returns an array of Delegators for the function caller address (msg.sender) based on 'Any Collection' and 'All Use Cases'.
function retrieveDelegators() public view returns(address[] memory) {
return dmcRead.retrieveDelegators(msg.sender, 0x8888888888888888888888888888888888888888, 1);
}
The checkMintingStatus(_vault) function checks the minting eligibility status for the function caller (msg.sender) by providing a Delegator's address as an input. This function is based on 'Any Collection' and 'Minting Use Case #2' and returns a bool status (true/false).
function checkMintingStatus(address _vault) public view returns(bool) {
return dmcRead.retrieveGlobalStatusOfDelegation(_vault, 0x8888888888888888888888888888888888888888, msg.sender, 2);
}
The retrieveTokenStatus(_vault, _tokenid) function checks if a delegation was registered from the a Delegator to the function caller (msg.sender) for an individual token id on a specific usecase on a specific collection and returns a bool status (true/false).
function retrieveTokenStatus(address _vault, uint256 _tokenid) public view returns(bool) {
return dmcRead.retrieveTokenStatus(_vault, 0x33fd426905f149f8376e227d0c9d3340aad17af1, msg.sender, 1, _tokenid);
}
Please note that you can customize the demo functions for the collection or usecase that you are interested in.
Full Source Code
// SPDX-License-Identifier: MIT
import "./INFTDelegationRead.sol";
pragma solidity ^0.8.18;
contract NFTDelegationDEMO {
INFTDelegationRead public dmcRead;
constructor(address _NFTdelegationManagementContract) {
dmcRead = INFTDelegationRead(_NFTdelegationManagementContract);
}
// Sample function for retrieving the delegators of msg.sender on Any collection for Any Use case
function retrieveDelegators() public view returns(address[] memory) {
return dmcRead.retrieveDelegators(msg.sender, 0x8888888888888888888888888888888888888888, 1);
}
// Sample function for retrieving the delegation status of msg.sender given a Delegator address
function checkMintingStatus(address _vault) public view returns(bool) {
return dmcRead.retrieveGlobalStatusOfDelegation(_vault, 0x8888888888888888888888888888888888888888, msg.sender, 2);
}
// Sample function for retrieving the token status given a delegator address
function retrieveTokenStatus(address _vault, uint256 _tokenid) public view returns(bool) {
return dmcRead.retrieveTokenStatus(_vault, 0x8888888888888888888888888888888888888888, msg.sender, 1, _tokenid);
}
}