How do I find all the ERC-721 tokens held by a certain address? They could potentially come from a variety of sources, not known in advance.
You can check the address at https://etherscan.io/ and see all theERC721 tokens for a specific address.
You can also use the Moralis API to fetch all the ERC721 tokens hold by a particular address.
You can look about it here - https://docs.moralis.io/moralis-dapp/web3-api/nft-api#getalltokenids
search that address at https://etherscan.io/ , it shows all the ERC-721 tokens held by that address and also the latest transactions and the balance
Related
I'm building a DeFi application on Ethereum, and I would like to implement the Deposit function. Everything works fine between ETH and a ERC20 token that I built, but I would like to add some tokens like aToken for AAVE or cTokens for Compound that the user will receive after a Deposit call.
So the question is: is it possible to add a function in my smart contract to create multiple tokens without creating a smart contract for each of them? If not, I have to create a different contract for each token I want to add in my app or there is a best method to do it?
Yes this is possible. You can transfer the tokens to the user's address after the Compound Protocol mint operation. This can be made generic using the ERC-20 transfer interface. Be sure to account the amounts users are due and beware of the reentrancy vulnerability.
I know that an ethereum funds address can hold many types of tokens. If the address is a contract address, can it also hold many types of tokens? or it can only hold the token it defines?
In other words, is it true that any address in ethereum can:
have at most one smart contract attached to it. This allows other users to locate this smart contract.
have arbitrary types of tokens attached to it. The address here allows other smart contract to keep track of the balance this address owns.
^ Is this correct? Thanks.
Both your assumptions are correct.
I'll just clear out the fact that it's not the "owner" address holding the tokens per se. The information which address owns how many tokens (or which tokens, in case of NFTs) is stored on each token contract. Also, blockchain explorers (such as EtherScan or BscScan) aggregate this data in their off-chain databases, so it's easier to search on their site.
Example:
Contract 0x123 (token ABC) holds the information that Address A owns 1 ABC token.
Contract 0x456 (token DEF) holds the information that Address A owns 2 DEF tokens.
A blockchain explorer has all this info aggregated in their off-chain DB, so that users can simply filter "all tokens by Address A" and they don't have to keep querying all token contracts asking "How many of your tokens does Address A own?".
If you are using the ERC-721 standard, what is the prefer method determining which tokens the address owns in a DAPP.
Currently I'm request all the Transfer Events for an address and basically sorting them into transfer in and transfer out, and then using that to determine which tokens the user owns.
Is there a simpler way I missed.
Transfer events may be emitted also by contracts that are not ERC-721 tokens, or some noname tokens that you might not be interested in.
The actual token ownership is stored in the tokens contracts (and not the DAPP contract).
So your current approach is pretty much as straightforward as it can get, if you want to automatically keep track of all tokens that the address currently owns (and some false positives as well).
Note: This is also similar to the approach of Etherscan, which listens to all Transfer event logs and if the sender contract is listed in their database of tokens, they use the event log data to update balances of the sender and recipient.
If you're willing/able to create and maintain a list of tokens that you want to follow, I'd recommend a simpler approach:
Define the list of followed token contract addresses (e.g. ECF or RARI)
For each of these token contracts, call balanceOf(<your_dapp_address>) that returns amount of tokens that the <your_dapp_address> currently owns.
How can I get lists of ERC20, ERC721 and ERC827 tokens in a particular Ethereum wallet address? Also I would like to be able to get the name, symbol, logo, and balance from the main net.
ERC-721 includes an optional interface (optional means the contract implementor can choose if they want to implement it) to enumerate tokens owned by a specific account.
Su Squares implements this feature, but few other contracts do it.
You can use tools like Etherscan, Enjinx Blockchain Explorer or write your own interface to a Ethereum JSON RPC host to collect the data.
I don't think you can do a total data dive per address. I think you have to go the other way around, meaning looking if a contract contains a certain token. For the major tokens like EOS, this should be easy with MEW.
But if you're looking for some obscure tokens such as the ones below, you probably have to add them to MEW manually to check:
Crap Coin (CRP)
Ingrid Is a Horrible Human Coin (iHH)
Banana Coin
As the title suggests - is it possible to send tokens from an ERC20 smart contract address, or is this unit not accessible?
Practical explanation:
A noob misunderstands some instructions and sends some tokens instead to his address to a smart contract address erc20. Is it possible for the programmers of the tokens, to recover those tokens, or are their hands "tied" and none has access to those tokens anymore?
Both contract accounts and external accounts (controlled by humans) have all the same inherent powers. Each can do what the other can.
If you send some ERC-20 token to a contract, it can in theory send it elsewhere, providing it has that functionality already built into-it.