How can I get MetaMask to use the corresponding token to display balances? - ethereum

I've noticed that anytime I want to test some token, I have to go into MetaMask and a load in the custom address off of etherscan, rather than using the provided tokens found within MetaMask. The picture above shows Dai (with the two Dai labels: the one provided by MetaMask and the one coming from the custom Dai address) within Rinkeby. However, this has been an issue for me whether it was dealing with other ERC20 tokens such as LINK or other networks (e.g. Ropsten and Kovan).
Could I be doing something incorrect when sending tokens? Are the provided token labels just for Mainnet?

Related

NFT from custom ERC-1155 smart contract not displaying correctly on Etherscan for Goerli test net

I have deployed an ERC-1155 smart contract to the Goerli test net at address: 0xE4e0b1FA4b3f4B947A14D429962eD30fEc9b9a96 (Etherscan link)
I performed the first transaction on the smart contract, which transferred an NFT to this address: 0x771d8Ef1FA5b7fDE4cBd88925F21cF97D8b8A46D (Etherscan link).
If I open the ERC1155 Token Txns tab on Etherscan, I see the tokens in my account, however, I do not see a View NFT button next to the token, which is what I see if I were to purchase an NFT from OpenSea.
For context, this is what I would see in Etherscan for an NFT from OpenSea, with the View NFT button:
Here is the URI pointing to the token's metadata on IPFS: https://bafyreige3aa4bqeoy52rswmpkhzrlpitpvsyfp5hpusfuq52wdybuyerfi.ipfs.dweb.link/metadata.json
And here is the token's metadata:
{"name":"Goerli test 6","description":"","image":"https://bafkreidkn5flzjnvcdginsktvzbcrslqd7wrabjavejectvqxi2xq5v6bm.ipfs.dweb.link/"}
Is there anything in particular that must be done on my part so that Etherscan can preview the NFT? Or is it more likely that my smart contract or the metadata format is incorrect?
Your code needs to be published on Etherscan first.

Multiple ERC20 tokens in a DeFi platform

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.

Can we deploy same ERC20-token on different blockchains?

I want to deploy my own ERC-20 token on different blockchains, so is there any possibility to deploy the same token contract on different blockchains. If we do that we can't give the same name and symbol for three blockchains. can anybody tell me what is the solution for this problem? Or can we deploy the contract with the same contract address on three blockchains?
can we deploy the contract with same contract address on three blockchains.
It depends on the network that you're deploying to and the address that you're deploying from. Assuming that the networks of your choice have the same 1) address format and 2) calculation of deployed contract address - then yes, you'll be able to deploy your contract on the same address on multiple networks.
For example Ethereum and BSC do have both of these features. But even though Tron network supports EVM-compatible smart contracts, it has a different way to calculate its addresses, so it won't be possible to deploy your contract on Tron network with the same address as on Ethereum or BSC.
The key to deploy the contract to the same address on multiple networks, is to deploy from the same address, and using the same params:
In case of the regular CREATE opcode, the transaction deploying the contract needs to have the same nonce (and the same from) value across all networks.
Or if you're using the CREATE2 opcode, you need to pass the same contract bytecode, the same salt (to the CREATE2), and again, you need to send the deploying transaction from the same address.
If we do that we can't give the same name and symbol for three blockchains
It is technically possible, so I'm assuming it's "just" a limitation of your business case or some tool that you're using, or a possible simple misunderstanding of how the ERC-20 standard works.
pragma solidity ^0.8;
contract MyToken {
string public constant name = "MyToken";
string public constant symbol = "MyT";
// TODO rest of your token contract source code
}

Can a smart contract automatically send message to an user address in ethereum blockchain

I'm a new beginner in the ethereum Blockchain.
I want to implement a smart contract that verifies the authenticity of a user and then send a message to a cloud service (with is the smart contract creator) in case of positive verification to grant access to the user.
My question is it possible for a smart contract to return results of his methods invocation to another blockchain user and how we can do it?
A smart contract cannot make calls outside of the blockchain. i.e., you cannot have it call an http endpoint or something similar.
In ethereum, the usual way of achieving something like this is:
Have the user make a transaction passing relevant data to your smart contract
The smart contract runs whatever verification logic it must on that data
The smart contract logs an Event
You have an ethereum node that your code connects to and listens for these events.

Contract address collision

So from my understanding when creating a contract the two variables that are used in determining what the address of the contract will be are the msg.sender and the nonce value. So if I create two contracts in the same transaction such as I did with this code https://ropsten.etherscan.io/address/0xcb7d7e99e56406a675173f0ddbde7d8cc3392e5e#code
Why did it generate two contracts at two different addresses, what I though would happen is that they would generate at the same address and the one would simply overwrite the other or something like that.
You're understanding of the contract address determined by the address of the message creator and the nonce is correct. However, in the example you posted, msg.sender is the address of the Test contract.
These are the steps that occured:
You initiated the transaction to deploy Test from your external account (0x98081ce968e5643c15de9c024de96b18be8e5ace). According to the transaction information, the nonce of the account at that time was 639.
This resulted in the Test contract having an address of 0xcb7d7e99e56406a675173f0ddbde7d8cc3392e5e.
During the deployment of Test, the constructor then creates two new contracts through "internal transactions". Divert is deployed from the contract address at 0xcb7d7e99e56406a675173f0ddbde7d8cc3392e5e with nonce=1. OverRide is deployed from the same address with nonce=2.
You can view the details of the internal transaction here.