NFT Royalty Sale
Nft Royalty Sale is a contract for selling royalty NFTs (non-fungible tokens). It is a contract that manages the sale of royalty NFTs, which represent a percentage of future sales of a particular product or asset. It provides functions for creating and managing the sale of royalty NFTs, including functions for setting the price and percentage of royalties, as well as functions for buying and selling royalty NFTs. The contract also includes functionality for automating the sale of royalties, using the Chainlink network to retrieve real-time data on the sales of the underlying product or asset.
The contract contains several structs and mappings to store data about the royalty NFTs and their sales. The Royalty struct stores information about a particular royalty NFT, including the maximum number of NFTs that can be sold, the price of each NFT, the percentage of royalties represented by each NFT, and the artist's name and product name. The contract also includes mappings to track the balance of royalty NFTs for each address, as well as a mapping to track which NFTs are owned by each address.
struct Royalty {
uint256 maxMintAmount;
uint256 maxSupply;
uint256 cost;
uint256 percentage;
string creatorName;
string name;
string initBaseURI;
string symbol;
address creator;
address factoryAddress;
}
struct NodeDetails {
address oracle;
string jobId;
}
function initialize(uint256 _maxSupply, uint256 _maxMintAmount, uint256 _cost, uint256 _percentage, string _name, string _symbol, string _initBaseURI, string _creatorName, address _creator, address _factroyAddress, address _owner) public
function start() external
this function is called by the contract owner to start the royalty sale
this function can only be called once and it cretes the NFT contract
function setupAutomationV2(uint256 _updateInterval, address _royaltyAdapter, address _oracle, string _jobId) external
this function is called by Picardy Royalty Registrar when registering automation and sets up the automation
This function is called by picardy royalty registrar, PS: royalty adapter contract needs LINK for automation to work
Parameters
Name | Type | Description |
---|---|---|
_updateInterval | uint256 | update interval for the automation |
_royaltyAdapter | address | address of Picardy Royalty Adapter |
_oracle | address | address of the oracle |
_jobId | string | job id for the oracle |
function toggleAutomation() external
this function is called by the contract owner to pause automation
this function can only be called by the contract owner and picardy royalty registrar
function checkUpkeep(bytes) external view returns (bool upkeepNeeded, bytes performData)
This function is used by chainlink keepers to check if the requirements for upkeep are met
this function can only be called by chainlink keepers
function performUpkeep(bytes) external
This function is used by chainlink keepers to perform upkeep if checkUpkeep() returns true
this function can be called by anyone. checkUpkeep() parameters again to avoid unautorized call.
function buyRoyalty(uint256 _mintAmount, address _holder) external payable
This function can be called by anyone and is a payable function to buy royalty token in ETH
Parameters
Name | Type | Description |
---|---|---|
_mintAmount | uint256 | amount of royalty token to be minted |
_holder | address | address of the royalty token holder |
function updateRoyalty(uint256 _amount, address tokenAddress) external
This function can only be called by the royaltySale owner or payMaster contract to pay royalty in ERC20.
this function can only be called by the contract owner or payMaster contract
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | amount of ERC20 tokens to be paid back to royalty holders |
tokenAddress | address | address of the ERC20 token |
function getUpdateRoyaltyCaller() internal view returns (address)
helper function that makes sure the caller is the owner or payMaster contract
function toggleRoyaltySale() external
This function changes the state of the royalty sale and should only be called by the owner
function pauseTokenBase() external
his function is used to pause the ERC721 token base contract
this function can only be called by the contract owner
function unPauseTokenBase() external
his function is used to unPause the ERC721 token base contract
this function can only be called by the contract owner
function getTimeLeft() external view returns (uint256)
function withdraw() external
This function is used to withdraw the funds from the royalty sale contract and should only be called by the owner
function withdrawRoyalty(uint256 _amount, address _holder) external
This function is used to withdraw the royalty. It can only be called by the royalty token holder
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | amount of royalty token to be withdrawn |
_holder | address | address of the royalty token holder |
function withdrawERC20Royalty(uint256 _amount, address _holder, address _tokenAddress) external
This function is used to withdraw the royalty in ERC20. It can only be called by the royalty token holder
Parameters
Name | Type | Description |
---|---|---|
_amount | uint256 | amount of royalty token to be withdrawn |
_holder | address | address of the royalty token holder |
_tokenAddress | address | |
function changeUpdateInterval(uint256 _updateInterval) external
This function is uded to change the update interval of the royalty automation
Parameters
Name | Type | Description |
---|---|---|
_updateInterval | uint256 | new update interval |
function pause() public
This function is used to pause the royalty sale contract and should only be called by the owner
function unpause() public
This function is used to unpause the royalty sale contract and should only be called by the owner
function transferOwnership(address newOwner) public
this function is used to transfer ownership of the sale contract to a new owner and should only be called by the owner
function updateNodeDetails(address _oracle, string _jobId) external
This function is used to change the oracle address and jobId of the chainlink node for custom job id
this function can only be called by the contract owner. (See docs for custom automation)
Parameters
Name | Type | Description |
---|---|---|
_oracle | address | new oracle address |
_jobId | string | new jobId |
function getTokensId(address _addr) external returns (uint256[])
function getERC20RoyaltyBalance(address _holder, address _tokenAddress) external view returns (uint256)
function getTokenDetails() external view returns (uint256, uint256, uint256, string, string, string)
function getCreator() external view returns (address)
function getRoyaltyTokenAddress() external view returns (address)
function getOwner() external view returns (address)
function getRoyaltyPercentage() external view returns (uint256)
function _getTokenIds(address addr) internal returns (uint256[])
function checkAutomation() external view returns (bool)
Last modified 1mo ago