【发布时间】:2021-11-23 12:24:45
【问题描述】:
我有 2 个合同。一种是 ERC721 令牌 (NFTCollectables)。另一个是包含拍卖系统的市场 (NFTMarket)。
拍卖结束后只能由出价最高的人申领。
在进行拍卖时,调用NFTCollectables 合约的transfer 方法将NFT 从市场地址转移到出价最高者的地址。
我不完全理解为什么会出现异常,但它发生在 NFTCollectables 合约的 transfer 方法中/内部。奇怪的是,即使transfer 方法中的最后一行代码也被执行(通过在_transfer(msg.sender, to, nftId) 之后放置require(false, 'test') 进行测试)。但ctr.transfer(auction.highestBid.bidder, auction.nftId) 之后没有任何内容被执行(通过在其后放置require(false, 'test') 进行测试)。
会不会和gas限制有关?
感谢任何想法,谢谢!
NFT 市场
function claimAuction(uint auctionIndex) external {
require(auctionIndex < auctions.length, "no auction");
Auction memory auction = auctions[auctionIndex];
require(block.timestamp <= auction.end, "auction still active");
NFTCollectables ctr = NFTCollectables(nftCollectablesAddress);
ctr.transfer(auction.highestBid.bidder, auction.nftId);
// deleting auction from active auctions list
for (uint i; i < activeAuctionIndexes.length; i++) {
if (activeAuctionIndexes[i] == auctionIndex) {
delete activeAuctionIndexes[i];
break;
}
}
emit AuctionEnd(auction.highestBid.bidder, auction.highestBid.price, auction.nftId);
}
NFTCollectables
function transfer(address payable to, uint nftId) external payable {
require(_exists(nftId), "transfer of non existing token");
require(_isApprovedOrOwner(msg.sender, nftId), "Sender not approved nor owner");
_transfer(msg.sender, to, nftId);
}
【问题讨论】:
-
如果你确定“transfer”的最后一行都被执行了,这意味着你的配置有错误。
标签: blockchain ethereum solidity truffle ganache