为什么我的事务在调用另一个合同函数时恢复? [英] Why does my transaction revert when calling another contract function?
本文介绍了为什么我的事务在调用另一个合同函数时恢复?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试调用部署在Etherum上的NFT协定中的一个函数,另一个协定在Remix中,旨在将其部署在Polygon上。
这是我要调用的NFT函数:
function allGenzeesOfWallet(address owner)
public
view
returns (uint256[] memory)
{
uint256 tokenCount = balanceOf(owner);
uint256[] memory tokensId = new uint256[](tokenCount);
for (uint256 i; i < tokenCount; i++) {
tokensId[i] = tokenOfOwnerByIndex(owner, i);
}
return tokensId;
}
这是我写的与之互动的新合同:
interface IGenzees {
function allGenzeesOfWallet(address owner) external view returns(uint[] memory);
}
contract CallNFT {
IGenzees public NFTcontract;
constructor () {
NFTcontract = IGenzees(0x201675fBFAAAC3A51371E4C31FF73Ac14ceE2A5A);
}
function getNoNFTsOwned(address user) public view returns(uint[] memory) {
return NFTcontract.allGenzeesOfWallet(user);
}
function setNFTcontract(address addr) external { // Set NFT contract
NFTcontract = IGenzees(addr);
}
}
但当我调用getNoNFTsOwned函数时,控制台显示:
call to CallNFT.getNoNFTsOwned errored: VM error: revert.
我做错了什么?
推荐答案
Remix VM和以太大型网是两个独立的网络。无法从一个网络与另一个网络达成部署在另一个网络上的协定。
您可以从大型网设置本地分叉,这样您就可以有效地从Remix VM与您的大型网协定的本地副本进行交互。您可以在this answer中找到更多信息。注意:它不会影响实际的大型机,只会影响大型机的本地副本。
这篇关于为什么我的事务在调用另一个合同函数时恢复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文