Transfer method is not working, I am getting a returned error - "Gas Required"

I have deployed a successful smart contract based on openzeppelin. I have tried to get ticker name and total supply of contract, It seems working well. When I am transferring tokens to another address, I am getting following issue
RETURNED ERROR :- GAS REQUIRED. EXCEED ALLOWANCE 9947373 or always failing transaction

:computer: Environment

Solidity:- v0.5.0
Token is on mainnet and I am usign mainnet infura.

:memo:Details

I have tried various ways to transfer token from contract to other eth address. But I am getting an issue that “Gas Required”.
I have deployed this contract using metamask. Though when I tried to add token using custom search and put contract address, Balance of token is showing 0.
I have tried with myetherwallet and a custom php code as well, I am getting supply and ticker successfully but not able to transfer tokens.

Here is my contract :-


Please see contract code here

I can share private key as well to test transaction.

:1234: Code to reproduce

Private key: - DB943CF265CD54E8094D91A2011918BE3BB2D25834A47923BCF7813A735B8A69

Creator Address:-
0x9B261C4E25fF80Ce50cabf8B75a680a5c42aAc62

Contract Address :-
0x3cefda19201598e51c19ea21cb339b2cdc015c34

Contract ABI :-

[{“constant”:true,“inputs”:,“name”:“name”,“outputs”:[{“name”:"",“type”:“string”}],“payable”:false,“stateMutability”:“view”,“type”:“function”},{“constant”:false,“inputs”:[{“name”:“spender”,“type”:“address”},{“name”:“amount”,“type”:“uint256”}],“name”:“approve”,“outputs”:[{“name”:"",“type”:“bool”}],“payable”:false,“stateMutability”:“nonpayable”,“type”:“function”},{“constant”:true,“inputs”:,“name”:“totalSupply”,“outputs”:[{“name”:"",“type”:“uint256”}],“payable”:false,“stateMutability”:“view”,“type”:“function”},{“constant”:false,“inputs”:[{“name”:“sender”,“type”:“address”},{“name”:“recipient”,“type”:“address”},{“name”:“amount”,“type”:“uint256”}],“name”:“transferFrom”,“outputs”:[{“name”:"",“type”:“bool”}],“payable”:false,“stateMutability”:“nonpayable”,“type”:“function”},{“constant”:true,“inputs”:,“name”:“decimals”,“outputs”:[{“name”:"",“type”:“uint8”}],“payable”:false,“stateMutability”:“view”,“type”:“function”},{“constant”:false,“inputs”:[{“name”:“spender”,“type”:“address”},{“name”:“addedValue”,“type”:“uint256”}],“name”:“increaseAllowance”,“outputs”:[{“name”:"",“type”:“bool”}],“payable”:false,“stateMutability”:“nonpayable”,“type”:“function”},{“constant”:true,“inputs”:[{“name”:“account”,“type”:“address”}],“name”:“balanceOf”,“outputs”:[{“name”:"",“type”:“uint256”}],“payable”:false,“stateMutability”:“view”,“type”:“function”},{“constant”:true,“inputs”:,“name”:“ticker”,“outputs”:[{“name”:"",“type”:“string”}],“payable”:false,“stateMutability”:“view”,“type”:“function”},{“constant”:false,“inputs”:[{“name”:“spender”,“type”:“address”},{“name”:“subtractedValue”,“type”:“uint256”}],“name”:“decreaseAllowance”,“outputs”:[{“name”:"",“type”:“bool”}],“payable”:false,“stateMutability”:“nonpayable”,“type”:“function”},{“constant”:false,“inputs”:[{“name”:“recipient”,“type”:“address”},{“name”:“amount”,“type”:“uint256”}],“name”:“transfer”,“outputs”:[{“name”:"",“type”:“bool”}],“payable”:false,“stateMutability”:“nonpayable”,“type”:“function”},{“constant”:true,“inputs”:[{“name”:“owner”,“type”:“address”},{“name”:“spender”,“type”:“address”}],“name”:“allowance”,“outputs”:[{“name”:"",“type”:“uint256”}],“payable”:false,“stateMutability”:“view”,“type”:“function”},{“anonymous”:false,“inputs”:[{“indexed”:true,“name”:“from”,“type”:“address”},{“indexed”:true,“name”:“to”,“type”:“address”},{“indexed”:false,“name”:“value”,“type”:“uint256”}],“name”:“Transfer”,“type”:“event”},{“anonymous”:false,“inputs”:[{“indexed”:true,“name”:“owner”,“type”:“address”},{“indexed”:true,“name”:“spender”,“type”:“address”},{“indexed”:false,“name”:“value”,“type”:“uint256”}],“name”:“Approval”,“type”:“event”}]

I am using above details to transfer tokens, But always getting an error. Later on I want to interact this token with website and transfer tokens dynamically.

Kindly help !!

When I am trying to transfer coins using php code, I am getting issue 'Nonce too low"

Can anyone help ? I really appreciate

1 Like

Hi @dinis174,

Looking at your code, you have set a total supply of tokens but didn’t assign any tokens to any account, nor do you have a way to mint any tokens. When you try to call transfer it fails due to having a balance of 0.

I assume you deployed your token using Remix.

You may want to look at the following example and try deploying to a public testnet:

Hello Abcoathup, Thank you for prompt reply!

I really appreciate your help. I simply deploy contract and try to assign token to Token creator address by adding contract address in to custom search of “ADD TOKEN”. By default 0 token added. So I am helpless here.

When I am trying to 'Transfer token from remix, I am getting following issue
“Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
gas required exceeds allowance (8000029) or always failing transaction”

I know you are super busy, kindly help me out with it. I am in trouble right now.

1 Like

Hi @dinis174,

Your current smart contract doesn’t assign any tokens to anyone. Rather than fix it, I recommend starting with the OpenZeppelin Contracts ERC20 implementation. A good place to start it to deploy the simple example to a public testnet and experiment with that:

Hello @abcoathup, Hope you are well!

I am able to run this smart contract and make transactions successfully. Everything is working perfectly now. Tokens are transferring to other addresses as well.
I am just getting one last issue that, Contract balance address is still remain same on etherscan.io.

Eg: Initial supply was 10,000,000. I have sent 1000 tokens successfully. So on etherscan it should show 9999000

Can you please suggest, How can I do it?

1 Like

Hi @dinis174,

If you transfer tokens, then the total supply doesn’t change, only the addresses that hold those tokens.

If you share your contract address (and which network), I can show you how to see this on Etherscan.

Hello @abcoathup, Thank you for writing back!

You are right, Contract is showing transfer token perfectly. Can you please let know if still there is any way so that I can update Total Supply.

I look forward to your response.

1 Like

Hi @dinis174,

To create an ERC20 that you can increase the total supply you can inherit from ERC20Mintable