【发布时间】:2021-12-28 17:18:15
【问题描述】:
所以,我创建了一个合约,该合约具有返回与调用者关联的 NFT 的方法。
function getOwnerByIndex(uint index) public view {
tokenOfOwnerByIndex(address(msg.sender), index);
}
从脚本调用它
const NFTContract = await hre.ethers.getContractFactory("NFTContract");
const nftContract = await NFTContract.deploy();
await nftContract.deployed();
console.log("Contract deployed to:", nftContract.address);
await nftContract.mintToken();
await nftContract.mintToken();
const res = await nftContract.getBalanceOf();
console.log(res) // BigNumber { value: "2" }
const j = await nftContract.getOwnerByIndex(0);
console.log(j) // []
}
它返回一个空数组。我想索引 0 应该可以工作。
【问题讨论】:
标签: javascript ethereum solidity