当我从其他合同中调用ERC20合同中的传输功能时,错误,但是可以使用薄荷/燃烧
我写了2个合同
- ERC20
- ERC721,并具有其他功能以购买。
当调用“ MarketBuy”功能时,它可以将NFT转移给买家,并且可以 从ERC20合同中调用Burn。但是当我将“烧伤”功能更改为 然后“转移 /转移”然后出现像这样的错误< / p>
交易到NFT2。 错误:VM错误:还原。
还将交易恢复为初始状态。笔记: 如果您发送值和值,则应支付调用函数 您的发送应小于当前余额。调试 交易以获取更多信息。
代码。
...
function marketBuy(uint _tokenId) public returns (bool) {
address _buyer = msg.sender;
uint _price = marketItem[_tokenId].price;
IERC20(ERC20Token).approve(marketItem[_tokenId].seller, _price);
IERC20(ERC20Token).transferFrom(_buyer, marketItem[_tokenId].seller, _price);
transferFrom(marketItem[_tokenId].seller, _buyer, _tokenId);
marketItem[_tokenId].seller = _buyer;
marketItem[_tokenId].isSold = true;
return true;
}
....
这是我不知道如何解决此问题的
I write 2 contracts
- ERC20
- ERC721 with additional function for buy it.
when call "marketBuy" function it can transfer NFT to buyer and can
call burn from ERC20 contract. But when I change "burn" function to
"transfer / transferFrom" then appear error like thistransact to NFT2.marketBuy pending ... transact to NFT2.marketBuy
errored: VM error: revert.revert The transaction has been reverted to the initial state. Note:
The called function should be payable if you send value and the value
you send should be less than your current balance. Debug the
transaction to get more information.
This is the code
...
function marketBuy(uint _tokenId) public returns (bool) {
address _buyer = msg.sender;
uint _price = marketItem[_tokenId].price;
IERC20(ERC20Token).approve(marketItem[_tokenId].seller, _price);
IERC20(ERC20Token).transferFrom(_buyer, marketItem[_tokenId].seller, _price);
transferFrom(marketItem[_tokenId].seller, _buyer, _tokenId);
marketItem[_tokenId].seller = _buyer;
marketItem[_tokenId].isSold = true;
return true;
}
....
I don't know how to solve this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于此行,
呼叫者是合同本身,不是买家。
因此,买方需要在ERC-20合同中手动调用
转移
函数For this line
the caller is the contract itself, it isn't the buyer.
So the buyer needs to call the
transfer
function manually on the ERC-20 contract