【发布时间】:2022-11-12 00:08:11
【问题描述】:
我正在处理 NFT 拍卖合同。我正在努力实现 1. NFT 转让给最高出价者。 2. 最高出价者对上一个 NFT 所有者或拍卖创建者的出价。 3. 发送给合约所有者的小平台切割。
当我手动做事时,所有这些工作都很顺利。但是当我尝试使用链环自动化来实现这一点时,它失败了。
据我了解,由于allowance 问题,它失败了。我的问题是,是否有可能使用链环自动化来实现这一目标?如果是,那么如何?
当 NFT 所有者列出他的 NFT 进行拍卖时,他正在向合约地址提供 NFT 转账津贴。
function checkUpkeep(bytes calldata /* checkData */) external view override returns(bool upkeepNeeded, bytes memory performData) {
for(uint i=0; i < auctionIDs.length; i++){
if(auctions[auctionIDs[i]].endTime != 0 && block.timestamp > auctions[auctionIDs[i]].endTime){
upkeepNeeded = true;
performData = abi.encodePacked(uint256(auctionIDs[i]));
}
}
return (upkeepNeeded, performData);
}
function performUpkeep(bytes calldata performData) external override nonReentrant {
uint256 auction_id = abi.decode(performData, (uint256));
if(auctions[auction_id].endTime != 0 && block.timestamp > auctions[auction_id].endTime){
auctions[auction_id].listed = false;
safeTransferFrom(podcastId[auctions[auction_id].podcastId].nftOwner, bidders[auction_id].highestBidder, podcastId[auctions[auction_id].podcastId].tokenId);
uint256 platformCut = (platformFee * bidders[auction_id].highestBid)/100;
uint256 NftOwnerCut = bidders[auction_id].highestBid - platformCut;
(bool pass, ) = platformFeeRecipient.call{value: platformCut}("");
require(pass, "platformFee Transfer failed");
(bool success, ) = (podcastId[auctions[auction_id].podcastId].nftOwner).call{value: NftOwnerCut}("");
require(success, "NftOwnerCut Transfer Failed");
podcastId[auctions[auction_id].podcastId].nftOwner = bidders[auction_id].highestBidder;
emit AuctionResulted(auction_id, bidders[auction_id].highestBidder, bidders[auction_id].highestBid);
bidders[auction_id].highestBid = 0;
auctions[auction_id].endTime = 0;
}
}
完整代码/合同:https://mumbai.polygonscan.com/address/0x7e2DA19C130cb3B483FA7f17C45c70716ABF5Fe8
Chainlink upKeep:https://automation.chain.link/mumbai/21891159634677518530356555981285976030474691922841692133624884405593696766700
请帮忙,谢谢。
【问题讨论】:
标签: ethereum solidity nft chainlink chainlink-keepers