0

I started the ganache-cli with 'ganache-cli -l 800000000'

I deployed my contract with 'truffle --network development' which is defined in the truffle-config.js file as:

networks: {
    // Useful for testing. The `development` name is special - truffle uses it by default
    // if it's defined here and no other network is specified at the command line.
    // You should run a client (like ganache-cli, geth or parity) in a separate terminal
    // tab if you use this network and you must also set the `host`, `port` and `network_id`
    // options below to some value.
    //
    development: {
     host: "127.0.0.1",     // Localhost (default: none)
     //port: 8545,            // Standard Ethereum port (default: none)
     //gasPrice: 0x01,
     //gas: 470000000,
     port: 8545,            // Standard Ethereum port (default: none)
     network_id: "*",       // Any network (default: none)
    },

My contract runs out of gas on the very first contract call. What do I need to do to fix this?

HD Wallet
==================
Mnemonic:      pond hockey few young elder pave lyrics bargain twenty broken coil group
Base HD Path:  m/44'/60'/0'/0/{account_index}

Gas Price
==================
20000000000

Gas Limit
==================
800000000

2_invoice_tracker.js
====================

   Deploying 'InvoiceTracker'
   --------------------------
   > transaction hash:    0xe1d189e01fcab83903598296e288895e578428332659fa6ef1e5f0da5ee181d4
   > Blocks: 0            Seconds: 0
   > contract address:    0x71f793b0cA149a8FC877522D6891FB3f9092D01f
   > block number:        3
   > block timestamp:     1591887444
   > account:             0x731a5d3CD32a531e5215CFAb7f0B9D413eFB9132
   > balance:             99.94790756
   > gas used:            2373870
   > gas price:           20 gwei
   > value sent:          0 ETH
   > total cost:          0.0474774 ETH


   > Saving migration to chain.
   > Saving artifacts
   -------------------------------------
   > Total cost:           0.0474774 ETH


Summary
=======
> Total deployments:   2
> Final cost:          0.05125242 ETH

This is the output from the ganache-cli:

   eth_sendTransaction

  Transaction: 0x72316a32488d09e25eb79c64fcd73dc96f95b9918a916ea29b0d30320375f8ff
  Contract created: 0xb22c9c54032f45fbd74b944bc67c1f42b6c1bd7e
  Gas usage: 188751
  Block Number: 1
  Block Time: Thu Jun 11 2020 10:57:24 GMT-0400 (Eastern Daylight Time)

eth_getTransactionReceipt
eth_getCode
eth_getTransactionByHash
eth_getBlockByNumber
eth_getBalance
eth_getBlockByNumber
eth_getBlockByNumber
eth_sendTransaction

  Transaction: 0x2d513c6a1d3b2e8a2ea25591dc4b0062ed3f348c33aad3db1ca43f4b90025dfc
  Gas usage: 42001
  Block Number: 2
  Block Time: Thu Jun 11 2020 10:57:24 GMT-0400 (Eastern Daylight Time)

eth_getTransactionReceipt
eth_getBlockByNumber
eth_accounts
net_version
eth_getBlockByNumber
eth_getBlockByNumber
net_version
eth_getBlockByNumber
eth_estimateGas
net_version
eth_blockNumber
eth_getBlockByNumber
eth_sendTransaction

  Transaction: 0xe1d189e01fcab83903598296e288895e578428332659fa6ef1e5f0da5ee181d4
  Contract created: 0x71f793b0ca149a8fc877522d6891fb3f9092d01f
  Gas usage: 2373870
  Block Number: 3
  Block Time: Thu Jun 11 2020 10:57:24 GMT-0400 (Eastern Daylight Time)

eth_getTransactionReceipt
eth_getCode
eth_getTransactionByHash
eth_getBlockByNumber
eth_getBalance
eth_getBlockByNumber
eth_getBlockByNumber
eth_sendTransaction

  Transaction: 0xc089b49e44fc5b0979efcdeae20f935ae4a3ca088274f656b1de4a8066267495
  Gas usage: 27001
  Block Number: 4
  Block Time: Thu Jun 11 2020 10:57:24 GMT-0400 (Eastern Daylight Time)

eth_getTransactionReceipt
eth_call
eth_gasPrice
eth_sendTransaction

  Transaction: 0x76937ebee405e4f6de6ca02aa209fa25579036b60e3ab9de73def64da5e11f49
  Gas usage: 90000
  Block Number: 5
  Block Time: Thu Jun 11 2020 10:58:45 GMT-0400 (Eastern Daylight Time)
  Runtime Error: out of gas
2
  • It is unlikely to run out of gas with more than 100,000,000 gas available, it is more likely a bug in the code that causes a require or assert to fail. What does the code do?
    – Ismael
    Jun 11, 2020 at 16:46
  • agreeing with @Ismael on this. Transactions usually don't run out of gas if there are no bugs in the code. If you give the code here, then maybe we can debug it.
    – vteja711
    Jun 12, 2020 at 5:30

1 Answer 1

0

It turns out that you need to specify the gas on send or call. For example: addClient(clientID, clientName).send({ from: owner, gas: 3000000 }) or getClientCount().call({ from: owner, gas: 3000000 }).

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.