I am running the following code:

// SPDX-License-Identifier: MIT
   pragma solidity ^0.8.0;

   import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; //file 

   contract KaurCoin is ERC20 {
       constructor() ERC20("KaurCoin", "KaurCoin") {

When I check the balance of the address I deployed from, it gives me the Ether number specified in the code. However, when I try to transfer 1 wei from this address to another address I get the following error: ERC20: transfer amount exceeds balance. How can I correct my code so that the second address receives wei? These functions are being imported from the ERC20 contract from Open Zeppelin.

  • Can you explain what exactly did you do? I followed your steps but it worked for me fine. Commented Jul 14, 2023 at 6:21
  • Your code is correct; I tried it on Remix. However, I believe you might be attempting to transfer from the wrong account. Commented Jul 14, 2023 at 10:18

1 Answer 1


Your given code works fine, if you are using Remix local environment make sure to switch back to the same account you deployed this contract from after copying the other account you want to transfer this amount to.

  • It appears I made a silly mistake not switching back to the account I want to transfer ether from. This worked. Thank you!
    – Beata
    Commented Jul 14, 2023 at 22:38
  • @Beata you are welcome, if it helped please consider accepting it as an answer. Commented Jul 17, 2023 at 20:49

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.