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.

NftRoyaltySaleV2

Royalty

struct Royalty {
  uint256 maxMintAmount;
  uint256 maxSupply;
  uint256 cost;
  uint256 percentage;
  string creatorName;
  string name;
  string initBaseURI;
  string symbol;
  address creator;
  address factoryAddress;
}

NodeDetails

struct NodeDetails {
  address oracle;
  string jobId;
}

initialize

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

start

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

setupAutomationV2

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

toggleAutomation

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

checkUpkeep

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

performUpkeep

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.

buyRoyalty

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

updateRoyalty

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

getUpdateRoyaltyCaller

function getUpdateRoyaltyCaller() internal view returns (address)

helper function that makes sure the caller is the owner or payMaster contract

toggleRoyaltySale

function toggleRoyaltySale() external

This function changes the state of the royalty sale and should only be called by the owner

pauseTokenBase

function pauseTokenBase() external

his function is used to pause the ERC721 token base contract

this function can only be called by the contract owner

unPauseTokenBase

function unPauseTokenBase() external

his function is used to unPause the ERC721 token base contract

this function can only be called by the contract owner

getTimeLeft

function getTimeLeft() external view returns (uint256)

withdraw

function withdraw() external

This function is used to withdraw the funds from the royalty sale contract and should only be called by the owner

withdrawRoyalty

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

withdrawERC20Royalty

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

changeUpdateInterval

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

pause

function pause() public

This function is used to pause the royalty sale contract and should only be called by the owner

unpause

function unpause() public

This function is used to unpause the royalty sale contract and should only be called by the owner

transferOwnership

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

updateNodeDetails

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

getTokensId

function getTokensId(address _addr) external returns (uint256[])

getERC20RoyaltyBalance

function getERC20RoyaltyBalance(address _holder, address _tokenAddress) external view returns (uint256)

getTokenDetails

function getTokenDetails() external view returns (uint256, uint256, uint256, string, string, string)

getCreator

function getCreator() external view returns (address)

getRoyaltyTokenAddress

function getRoyaltyTokenAddress() external view returns (address)

getOwner

function getOwner() external view returns (address)

getRoyaltyPercentage

function getRoyaltyPercentage() external view returns (uint256)

_getTokenIds

function _getTokenIds(address addr) internal returns (uint256[])

checkAutomation

function checkAutomation() external view returns (bool)

Last updated