I am making a dapp on MultiverseX blockchain. It has a function where user can buy my ESDT by paying with EGLD.
#[endpoint]
#[payable("EGLD")]
fn purchase(&self, amount: BigUint){
require!(amount >= 1000, "Purchase minimum 10 ACCEL");
require!(amount <= 10000, "Maximum purchase limit is 10000 ACCEL")
let caller = self.blockchain().get_caller();
self.send().direct_esdt(&caller, &ACCEL-0fe2ec, &amount);
// self.send().direct_egld(&owner, )
}
I want to apply some logic by which i can set price for my ESDT. One way is hardcoding, but I want to make it realistic. I want to use coinmarket so that it can fetch the price of EGLD in dollar and in the purchase()
I would calculate the price of my token based on the value provided by coinmarket. Can I fetch the value of coinmarket using Rust? If yes then how? If no then please provide me some reference related to it.
If there method is available except coinmarket please mention.
Thank you.