【发布时间】:2022-12-12 20:35:36
【问题描述】:
我正在创建一个智能合约,用户可以在其中创建 NFT 抽奖活动。我将使用 Chainlink VRF 来获得可证明的公平结果。为此,创建抽奖活动的用户需要向合约提供 LINK 代币。我正在尝试使用津贴转移这些代币。
function initRaffle(address _tokenContract, uint256 _tokenId, uint256 _ticketPrice) external {
require(_ticketPrice > 0, "Ticket price must be bigger than 0");
require(LINKToken.balanceOf(msg.sender) >= ChainlinkFee, "Insufficient LINK supplied");
require(LINKToken.allowance(msg.sender, address(this)) >= ChainlinkFee, "Allowance failed");
运行 initRaffle 结果为 Allowance failed。我已经检查过,LINKToken.balanceOf(msg.sender) 大于费用,所以这应该不是问题所在。 LINKToken.balanceOf(address(this)) 为 0。
出了什么问题?以及我如何创建一个工作函数让用户将(费用金额)链接令牌转移到合同。
【问题讨论】:
标签: ethereum blockchain solidity smartcontracts chainlink