How to solve “sender doesn't have enough funds to send tx” error in Ethereum?

0 votes

I am trying to write an Ethereum contract and I am able to migrate the contract without any problem, but I am facing a problem that I don’t understand. I am not able to buy tokens because gas price is high. I don’t understand what is wrong. Please help.


const TestTokenCrowdsale = artifacts.require('./TestTokenCrowdsale.sol');

var walletAddress =


const duration = {

    seconds: function(val) { return val},

    minutes: function(val) { return val * this.seconds(60) },

    hours:   function(val) { return val * this.minutes(60) },

    days:    function(val) { return val * this.hours(24) },

    weeks:   function(val) { return val * this.days(7) },

    years:   function(val) { return val * this.days(365)}


module.exports = function(deployer) {

  const startTime = 1515896330 + duration.minutes(5);

  const endTime = startTime + duration.minutes(20);

  const rate = new web3.BigNumber(2);

  const cap = new web3.BigNumber(1000000000000000000);

  const tokenAddress = '****';

  deployer.deploy(TestTokenCrowdsale, startTime, endTime, rate, cap, walletAddress, tokenAddress);



pragma solidity ^0.4.18;

import 'zeppelin-solidity/contracts/crowdsale/CappedCrowdsale.sol';

import './TestToken.sol';

contract TestTokenCrowdsale is CappedCrowdsale {

  address public tokenAddress;

  FrontierToken public testToken;


   * @dev Crowdsale initializer.

   * @param _startTime -> Crowdsale start time in UNIX seconds.

   * @param _endTime -> Crowdsale end time in UNIX seconds.

   * @param _rate -> TST/ETH exchange rate.

   * @param _cap -> Fund cap in Wei.

   * @param _wallet -> Wallet to collect Ether.

   * @param _tokenAddress -> Deployed TestToken address.


  function TestTokenCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _cap, address _wallet, address _tokenAddress)


    Crowdsale(_startTime, _endTime, _rate, _wallet) public {

    tokenAddress = _tokenAddress;

    token = createTokenContract();


  function createTokenContract() internal returns (MintableToken) {

    testToken = TestToken(tokenAddress);

    return TestToken(tokenAddress);




pragma solidity ^0.4.18;

import 'zeppelin-solidity/contracts/token/MintableToken.sol';

import 'zeppelin-solidity/contracts/token/BurnableToken.sol';

contract FrontierToken is MintableToken, BurnableToken {

  string public name = "Test Token";

  string public symbol = "TST";

  uint8 public decimals = 18;


The error I am getting is as follows:

truffle(develop)> c.buyTokens("0x627306090abab3a6e1400e9345bc60c78a8bef57", {value: 0.00000000000001})

Error: Error: sender doesn't have enough funds to send tx. The upfront cost is: 1188468318377797839569896498995073345436650825553660099636 and the sender's account only has: 99249141200000000000

at runCall (/usr/local/lib/node_modules/truffle/build/chain.bundled.js:67228:10)

at /usr/local/lib/node_modules/truffle/build/chain.bundled.js:14393:24

at replenish (/usr/local/lib/node_modules/truffle/build/chain.bundled.js:11525:17)

at iterateeCallback (/usr/local/lib/node_modules/truffle/build/chain.bundled.js:11510:17)

at /usr/local/lib/node_modules/truffle/build/chain.bundled.js:11485:16

at /usr/local/lib/node_modules/truffle/build/chain.bundled.js:14398:13

at /usr/local/lib/node_modules/truffle/build/chain.bundled.js:63440:16

at replenish (/usr/local/lib/node_modules/truffle/build/chain.bundled.js:63387:25)

at /usr/local/lib/node_modules/truffle/build/chain.bundled.js:63396:9

at eachLimit (/usr/local/lib/node_modules/truffle/build/chain.bundled.js:63320:36)

at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:41484:16)

at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:329530:36

at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:325200:9

at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:328229:7)

at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176415:18)

at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176705:12)

at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176860:12)

at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176820:24)

at emitNone (events.js:110:20)

at IncomingMessage.emit (events.js:207:7)

Jul 27, 2018 in Blockchain by digger
• 26,660 points

1 answer to this question.

0 votes

There’s a mistake in your code. You have to use web3.utils.toWei(0.00000000000001, 'ether') code to send your value properly.

You can use the following code:

pragma solidity ^0.4.18;

contract Test {

  uint256 public balance;

  function somePayable() public payable {

    balance = msg.value;



It should solve your error.

answered Jul 27, 2018 by slayer
• 29,260 points

Related Questions In Blockchain

0 votes
1 answer

How do I send back ethers to the sender of the tokens in a smart contract?

Whenever a smart contract receives ether via ...READ MORE

answered May 30, 2018 in Blockchain by Perry
• 17,090 points
0 votes
1 answer

How to solve EACCES:permission denied error in Hyperledger Composer?

It seems like there is no required ...READ MORE

answered Jul 11, 2018 in Blockchain by digger
• 26,660 points
+2 votes
1 answer
0 votes
1 answer

How to solve “insufficient funds for gas * price + value” error?

Change the following line Credentials credentials = Credentials.create(firstAccount); To ...READ MORE

answered Aug 1, 2018 in Blockchain by slayer
• 29,260 points
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,810 points
0 votes
1 answer
+1 vote
5 answers

How to solve "truffle: command not found" error in blockchain?

First try restarting the system and then ...READ MORE

answered Jul 16, 2018 in Blockchain by slayer
• 29,260 points
0 votes
1 answer

How to solve "error trying install composer runtime" in Hyperledger composer?

I think the docker-compose tool is not ...READ MORE

answered Jul 17, 2018 in Blockchain by slayer
• 29,260 points