简体   繁体   English

有没有办法在转账 function 调用时获得代币价格?

[英]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.

相关问题 如何调用 getLatestPrice function Chainlink 喂价 - How to Call getLatestPrice function Chainlink Price Feed 在传递函数中使用自定义参数创建ERC20令牌 - create ERC20 token with custom parameters in transfer function “eosio.token”智能合约的转账功能无效 - Transfer function for “eosio.token” smart contract is not working 有没有办法在 Solidity 的转移函数中检查买卖? - Is there a way to check sells and buys in transfer function on Solidity? 如何修改 ERC20 代币的转账 function 以便每次代币转账收取 0.0004 以太币的费用 - How to modify a transfer function of an ERC20 token so that it takes a fee equal to 0.0004 ether for every token transfer 以去中心化方式从 Chainlink 访问代币历史价格数据的最佳方式是什么? - What is the best way to access historical price data from Chainlink on a token in a decentralised manner? 从合约中转移代币 - transfer token out of contract 我们可以在实施ERC721令牌的同时将应付款修改器添加到转移功能吗? - Can we add payable modifier to transfer function while implementing ERC721 token? Uniswap:如何使用 API 读取代币价格 - Uniswap: How to read token price with API Ethers.js 代币价格走势图 - Ethers.js token price chart
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM