I am trying to transfer tokens from myEtherWallet and Codebase in C#. I found a code sample https://github.com/maxpaynestory/Nethereum.ERC20.Token.Transfer.Sample/blob/master/EthereumClient.cs and have this code:

var transactionMessage = new TransferFunction()
            FromAddress = accountFrom,
            To = accountTo,
            AmountToSend = tokens
var transferHandler = web.Eth.GetContractTransactionHandler<TransferFunction>();
Task<string> transactionHashTask = transferHandler.SendRequestAsync(transactionMessage, contractAddress);
return await transactionHashTask;

For the contract address I am using the contract address of the token(https://etherscan.io/address/0xb92c39977f18c25121a76748a6cc25c29584a12c).

I keep getting an error "gas required exceeds allowance or always failing transaction" I changed the token amount to be a lot less then the account balance and I have enough ETH in the account to cover gas.

  • 1
    Other than the gas amount, the major reason for this error message, something been thrown from the contract code. Check the contract code and ensure you pass all that require – Rajesh Aug 27 '18 at 4:57
  • Can you please clarify by what you mean by contract code. – Peter Chikov Aug 27 '18 at 5:42
  • 1
    I mean the smart contract code (of the token) from what you are trying to consume the transfer – Rajesh Aug 27 '18 at 6:52
  • Can you please clarify further by what is the smart contract code. I am new to this. – Peter Chikov Aug 28 '18 at 3:22
  • 1
    The parameter that you are using contractAddress which is the smart-code developed and deployed on the blockchain. This will have a few functions in it for others to interact with it. When the validation fails in that smart contract code, it will throw the error as you received. – Rajesh Aug 28 '18 at 4:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.