[英]Is there a way to get token price on transfer function call?
is it possible to know for which price user is buying/selling token on transfer function call?是否有可能知道用户在 function 调用时以哪个价格购买/出售代币?
I want to store information on the contract for with user bought/sold tokens on the transfer function.我想在转账 function 中存储用户购买/出售代币的合同信息。
No, this is not possible, at least in a token contract, because the token contract only "knows" that the user send or approved tokens and that's all that can know, it could be possible in a dex or cex contract不,这是不可能的,至少在代币合约中是不可能的,因为代币合约只“知道”用户发送或批准的代币,这就是所有可以知道的,在 dex 或 cex 合约中是可能的
Yes it is possible.对的,这是可能的。 this is where oracles comes into play chainlink oracle provide off-chain data like token price feeds in contract in a decentralised way.
这就是预言机发挥作用的地方 chainlink oracle 以去中心化的方式提供链下数据,例如合约中的代币价格馈送。 Here is how you can get token price feed in smart contract in EVM-compatible blockchains
以下是如何在与EVM 兼容的区块链中的智能合约中获取代币价格信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.