NodeID NFT Contract
This Smart Contract is an ERC721 "NFT" Contract representing the ownership of a NodeID.
Events
NewPremintedNFT
event NewPremintedNFT(uint256 _tokenId, string _nodeId)
NewMintedNFT
event NewMintedNFT(uint256 _tokenId, address _owner, string _nodeId)
BurnNFT
event BurnNFT(uint256 _tokenId)
Variables
Deposit
struct Deposit {
bool isUsed;
uint256 value;
}
nodeIds
mapping(uint256 => string) nodeIds
Each NFT as its own NodeID
preMintedTokenId
uint256[] preMintedTokenId
Preminted NFT
preMintedBlankTokenId
uint256[] preMintedBlankTokenId
Preminted blank NFT used to import a staker.key/staker.crt
cautionPrice
uint256 cautionPrice
Deposit price in avax
Functions
initialize
function initialize(address _accessControl) public
Public initializer with published default settings
Parameters
Name | Type | Description |
---|---|---|
_accessControl | address | The c-chain address of access control contract |
deposit
function deposit() public payable
To deposit caution before calling mint or mintblank function
setSubscriptions
function setSubscriptions(address _subscriptions) public
Set subcriptions contract address
Parameters
Name | Type | Description |
---|---|---|
_subscriptions | address | subscription contract address |
preMint
function preMint(uint256 tokenId, string nodeId) public
Premint an nft with a nodeid
Only addresses with the role MINTER_ROLE can use this function
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | token / nft identifier |
nodeId | string | avalanche NodeID (without "NodeID-") |
preMint
function preMint(uint256 tokenId) public
Premint a blank NFT
NFT blanks are used to let users import their keys.
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | token / nft identifier |
setNodeID
function setNodeID(uint256 tokenId, string nodeId) public
This function defines the nodeid of a blank token. Must be called by ooNodz backend after it has received the staker.key and fully secured it.
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | token / nft identifier |
nodeId | string | avalanche NodeID (without "NodeID-") |
setCautionPrice
function setCautionPrice(uint256 _caution) public
Deposit price could be raised or lowered
The deposit is used as protection against attacks. The aim is to prevent a malicious actor from collecting all NFTs that have no commercial value.
Parameters
Name | Type | Description |
---|---|---|
_caution | uint256 | new deposit price (example: 2000000000000000000 equals 2 avax) |
refund
function refund(address payable user) public
Refund one deposit after a user completes its subscription
Public function as we allow billing to refund one user off the actual process
Parameters
Name | Type | Description |
---|---|---|
user | address payable | user's address |
burn
function burn(uint256 tokenId) public
Burn specified tokenId
Only owner / approved account or address with role BURNER_ROLE can use this function
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | token / nft identifier |
mint
function mint() public
Allows users to mint a nodeid nft
mintBlank
function mintBlank() public
Allows users to mint a blank nft (used only to import an existing staker.key)
getAvailablePreMint
function getAvailablePreMint() public view returns (uint256)
Get how many preminted tokens are availables
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | count The number of preminted tokens |
getAvailablePreMintBlank
function getAvailablePreMintBlank() public view returns (uint256)
Get how many preminted blank tokens are availables
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | Count The number of preminted blank tokens |
getDepositBalanceOf
function getDepositBalanceOf(address user) public view returns (uint256)
Get how much a user has deposit (avax)
Parameters
Name | Type | Description |
---|---|---|
user | address | User's address |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | balance The number of avax a user has deposited |
getClaimableBalanceOf
function getClaimableBalanceOf(address user) public view returns (uint256)
Get how much a user can claim (avax)
Parameters
Name | Type | Description |
---|---|---|
user | address | User's address |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | balance The number of avax a user can claim |
getFreeDepositOf
function getFreeDepositOf(address user) public view returns (uint256)
Get how many deposit(s) a user has paid and not used
Variable nbDeposit is the deposit price multiplier. getFreeDepositOf(user) * cautionPrice = getDepositBalanceOf(user) - getClaimableBalanceOf(user)
Parameters
Name | Type | Description |
---|---|---|
user | address | User's address |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | nbDeposit The number of available deposits. In other words, the number of nft a user can request. |
consumeDepositOf
function consumeDepositOf(address user) internal returns (bool)
Consumes one user deposit
Parameters
Name | Type | Description |
---|---|---|
user | address | User's address |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | boolean Returns true if a deposit was used, otherwise false |
_baseURI
function _baseURI() internal pure returns (string)
Returns baseURI
Return Values
Name | Type | Description |
---|---|---|
[0] | string | uri Returns baseURI |