Can't find documentation on how to use ERC721AQueryable
Martin-Fritsche opened this issue · 8 comments
I'm trying to implement a smart contract using ERC721A. I ran into an error when I tried to implement a walletOf function that used the tokenOfOwnerByIndex(owner, number) method from ERC721Enumerable. From a previous issue, I was directed to use ERC721AQueryable's tokensOfOwner instead. However, I'm still getting errors:
:
DeclarationError: Identifier already declared. --> erc721a/contracts/IERC721A.sol:86:5:
|
86 | struct TokenOwnership {
| ^ (Relevant source part starts here and spans across multiple lines).
Note: The previous declaration is here: --> erc721a/contracts/ERC721A.sol:43:5:
|
43 | struct TokenOwnership {
| ^ (Relevant source part starts here and spans across multiple lines).
DeclarationError: Undeclared identifier. --> erc721a/contracts/extensions/ERC721AQueryable.sol:42:53:
|
42 | if (tokenId < _startTokenId() || tokenId >= _nextTokenId()) {
| ^^^^^^^^^
DeclarationError: Undeclared identifier. Did you mean "_ownershipOf" or "_ownerships"?
--> .deps/npm/erc721a/contracts/extensions/ERC721AQueryable.sol:45:21:
|
45 | ownership = _ownershipAt(tokenId);
| ^^^^^^^^^^^^
DeclarationError: Undeclared identifier. --> .deps/npm/erc721a/contracts/extensions/ERC721AQueryable.sol:93:33:
|
93 | uint256 stopLimit = _nextTokenId();
| ^^^^^^
DeclarationError: Undeclared identifier. Did you mean "_ownershipOf" or "_ownerships"?
--> .deps/npm/erc721a/contracts/extensions/ERC721AQueryable.sol:127:29:
|
127 | ownership = _ownershipAt(i);
| ^^^^^^^^^^^^
DeclarationError: Undeclared identifier. Did you mean "_ownershipOf" or "_ownerships"?
--> .deps/npm/erc721a/contracts/extensions/ERC721AQueryable.sol:164:29:
|
164 | ownership = _ownershipAt(i);
| ^^^^^^^^^^^
THIS IS MY SMART CONTRACT CODE
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "erc721a/contracts/ERC721A.sol"; -- I have tried commenting this out
import "erc721a/contracts/extensions/ERC721AQueryable.sol";
contract MyContract is ERC721A{
constructor() ERC721A("My Contract", "MC"){}
function walletOf() external pure returns(uint256[] memory){
return tokensOfOwner(msg.sender);
}
}
How do I resolve this? What I'm I doing wrong?
I deleted the erc721a directory in the .dep/npm dir and still got an error.
DeclarationError: Undeclared identifier. --> contract-99c206fea4.sol:11:16:
|
11 | return tokensOfOwner(msg.sender);
|
THIS IS THE CODE SMART CONTRACT THAT I'M TESTING WITH
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "erc721a/contracts/ERC721A.sol";
import "erc721a/contracts/extensions/ERC721AQueryable.sol";
contract MyToken is ERC721A {
constructor() ERC721A("MyToken", "MTK") {}
function walletOf() external view returns(uint256[] memory){
return tokensOfOwner(msg.sender);
}
}
Can you point me to an example?
contract MyToken is ERC721A {
should be
contract MyToken is ERC721A, ERC721AQueryable {
Use this.tokensOfOwner
.
Closing now as this seems resolved