简体   繁体   中英

Get a list of all erc721 tokens on an address

I'm trying to make a program that transfers all non fungible tokens (erc-721) to a different address. I already have the transfer part set up. But I have no clue how to get all the tokens/nft contracts from an address as I wasn't able to find anything online.

I tried

    const myContract = new web3.eth.Contract(abi, token);
    let balance = await myContract.methods.balanceOf(address)//.call();

but for that, you'd still need the contract address. Is there any way to do what I'm trying to? Just to get all the tokens from the public (and or private) key?

No, since every token is managed by different contracts, you'll need to know the addressed of those contracts and call balanceOf(address) .

There are APIs that list the most common tokens ( contract addresses ), but they do not include all of them.

Or call a method on the user's wallet ( you'll need to call different methods depending on which wallet is the user connected with ) that could provide the current tokens that user has regitered on their wallet, and thats IF that wallet supports this function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM