I used the below code to send 0.1 DAI from my account to a smart contract:

const tokenTx = await daiTokenContract.approve('accountAddress', ethers.utils.parseEther("0.1"));
await tokenTx.wait();
await daiTokenContract.transferFrom(

this is the contract in etherscan: https://kovan.etherscan.io/address/0xd9f0bb8a0EEfd7d24FE89a89A89a2554117D531d#tokentxns enter image description here

  1. Am unable to see the transferred token in the contract balance(totalSupply etc.).
  2. Even though it is ERC20 token, balanceOf does not include my account address.
  3. How do i get back the transferred 0.1 DAI from the smart contract?


1 Answer 1

  1. Etherscan only show total supply of ether for contracts, tokens are not included.

  2. balanceOf takes an address and returns either the balance or 0, it can not "not have" my address. of course since you transfered the dai to the smart contract and u don't have any more Dai in your wallet, balance of mught show 0 as balance.

  3. You can't transfer back Dai from smart contracts unless the contract itself has the capability to do so, like a method to transfer the tokens to a certain address. it also needs to approce the transfer like you did in your first transfer.

Your Answer

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

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