3. Contract Interactions

Purchase one or many validators

The purchase function is a payable function. The ETH value required is a multiple of 32 ETH, n*32, n is the number of validators we want to purchase. It returns the ids of purchased vNFTs

function purchase() external payable returns (uint256[] memory)
purchase{value: 32000000000000000000}() // will purchase 1 vNFT and activate 1 validator
purchase{value: 96000000000000000000}() // will purchase 3 vNFTs and activate 3 validators

Fetch all the metadata of a vNFT

The tokenURI function will return an api endpoint containing all the data related to the vNFT and the underlying validator of tokenId, including validator state, generated rewards etc.

function tokenURI(uint256 tokenId) external view virtual returns (string memory)

Rent the NFT

We can set a user by calling the setUser function. The parameters are the tokenId we rent, the address of the user (cannot be the same as the owner) and the timestamp at which the renting expires (cannot be a timestamp in the past or after an already exiting renting period)

function setUser(uint256 tokenId, address user, uint64 expires) external

Get the current vNFT active user

The function userOf returns the current active user of the given vNFT id

function userOf(uint256 tokenId) external view returns (address currentUser)

Get the end of the renting period

The function userExpires returns the timestamp of the end of the renting period

function userExpires(uint256 tokenId) external view returns (uint256)

Get the current vNFT rewards beneficiary

The function beneficiaryOf returns the current rewards beneficiary of the given vNFT id

function beneficiaryOf(uint256 tokenId) external view returns (address beneficiary)

Clear an inactive user

The function clearUsership clear an usership for which the period has ended in order for a given vNFT id. This function is callable only if userExpires(tokenId) ≠ 0 and userExpires(tokenId) ≤ current timestamp

function clearUsership(uint256 tokenId) external returns (uint256 newId)

Request an exit

The exit function will trigger the exit of the given vNFTs ids. A vNFT cannot be exited if userOf(uint256 tokenId) ≠ address(0)

function exit(uint256[] calldata tokenIds) external

Last updated