Some features require the user to pay a certain amount of MANA for execution. These features include:
Publishing a collection, which charges the user a fixed amount of MANA depending on the rarities of the items being published with the collection
Claiming a name, where the user is charged a fixed amount of MANA to claim.
Purchasing Third Party item slots, which are charged according to the number of slots bought.
Lately, The community has been using the DAO to define the price in MANA but pegged to the USD dollar. For example, the price per item for publishing a collection has been reduced from 500 MANA to 100 MANA to achieve it.
Chainlink MANA/USD Data Feed allows our contracts to obtain the rate of MANA in USD on both the Ethereum and Polygon chains. This can be used, given an original price in USD, to calculate how much MANA is required by the user to perform a certain transaction.
For more information about Chainlink go check their homepage or their whitepaper.
In summary, Chainlink is a solution in which via Oracles, one can obtain off-chain data in a tamper-proof and still decentralized manner to be used on-chain.
To implement these price feeds we will create a new contract
getRate function. This oracle will be consumed by other contracts which require
the rate of MANA/USD to reflect a price accordingly. This
receive both a Data Feed (Represented as an
by the Chainlink
A contract consuming this oracle can then do the following calculation to obtain and use/return and amount of MANA converted from USD.
uint256 priceInUSD = 100000000000000000000; // 100 USD uint256 rate = oracle.getRate(); // 5000000000000000000 -> 5 USD per MANA uint256 finalPrice = priceInUSD.mul(1 ether).div(rate); // 20000000000000000000 -> 20 MANA