0

I'm trying to take my first steps in the blockchain, and sometimes I stuck with some very weird issue (for me), this is one of them.

I've deployed a very simple SmallContract that inherit from @openzeppelin/[email protected]/token/ERC20/ERC20.sol, just to create a custom ERC20 token for testing.

This contract has a function named "mint()" that should return to my wallet 10 custom tokens.

pragma solidity >=0.6.0 <0.8.0;

import "@openzeppelin/[email protected]/token/ERC20/ERC20.sol";

contract Token is ERC20 {

  constructor () ERC20("Issimissimo", "DS") {
    _setupDecimals(2);
    _mint(msg.sender, 10 * (10 ** uint256(decimals())));
  }

  function mint() public returns (bool) {
    _mint( msg.sender, 1000 );
    return true;
  }
}

I've deployed this contract on Ropsten, and I've tested in Unity (without Metamask, just using my private key) and it work, I receive the token in my wallet.

Now I'm trying do the same in JS, with "ethers" library, connecting to Metamask. Well, I successfully connect to my Metamask account on Robsten, I successfully call the "mint" function, and I receive the message that the transaction is completed (I can also see on etherscan that everyhing was fine --- Status: Success), but I didn't receive any custom token in my Metamask wallet...

How is possible? I guess that if I did some error in my JS code I would not receive the transaction confirmation message, and on Etherscan I should see some error... isn't it? Maybe the Ropsten network can fail?

P.S. If can help this is the link of the transaction on etherscan https://ropsten.etherscan.io/tx/0xf7a2f2e112f7808431ab0e1ecf5e1dbd868a6ad21d205464660aed9920fddcea

Sorry but I'm very new to everything...

Many thanks for your help!!

1 Answer 1

0

Go to your metamask wallet, change your network to 'Ropsten Network', then click on link called Import tokens and put into Token Contract Address textbox the address of your ERC20 smart contract in this case this value: 0x345fe1f0BbB9673b0844F6405FFC0e867d9591a1.

enter image description here

After this operation, you can click on button called Add Custom Token and you'll see your tokens into your wallet.

1
  • Damn... you are totally right! I've changed a bit the function of the contract and I've deployed a new one a couple of days ago... so the token name is the same, but the contract address is changed, so I have to import the token again! Indeed now I can see in my wallet 2 tokens with the same name... Ok, this was my first thought when I've seen that every time you change the contract and you deploy it, it's address change. Is there a way to avoid this mess? Jun 29, 2022 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.