Troubleshooting Smart Contract Tests on Ropsten – Transactions Said Success but No Tokens Received

etherjavascriptmetamask

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!!

Best Answer

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.

Related Topic