Skip to main content

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

NameTypeDescription
_accessControladdressThe 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

NameTypeDescription
_subscriptionsaddresssubscription 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

NameTypeDescription
tokenIduint256token / nft identifier
nodeIdstringavalanche NodeID (without "NodeID-")

preMint

function preMint(uint256 tokenId) public

Premint a blank NFT

NFT blanks are used to let users import their keys.

Parameters

NameTypeDescription
tokenIduint256token / 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

NameTypeDescription
tokenIduint256token / nft identifier
nodeIdstringavalanche 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

NameTypeDescription
_cautionuint256new 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

NameTypeDescription
useraddress payableuser'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

NameTypeDescription
tokenIduint256token / 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

NameTypeDescription
[0]uint256count The number of preminted tokens

getAvailablePreMintBlank

function getAvailablePreMintBlank() public view returns (uint256)

Get how many preminted blank tokens are availables

Return Values

NameTypeDescription
[0]uint256Count The number of preminted blank tokens

getDepositBalanceOf

function getDepositBalanceOf(address user) public view returns (uint256)

Get how much a user has deposit (avax)

Parameters

NameTypeDescription
useraddressUser's address

Return Values

NameTypeDescription
[0]uint256balance 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

NameTypeDescription
useraddressUser's address

Return Values

NameTypeDescription
[0]uint256balance 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

NameTypeDescription
useraddressUser's address

Return Values

NameTypeDescription
[0]uint256nbDeposit 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

NameTypeDescription
useraddressUser's address

Return Values

NameTypeDescription
[0]boolboolean Returns true if a deposit was used, otherwise false

_baseURI

function _baseURI() internal pure returns (string)

Returns baseURI

Return Values

NameTypeDescription
[0]stringuri Returns baseURI