Error: VM Exception while executing transaction: out of gas

glowkeeperglowkeeper Member Posts: 12
n00b to smart contracts, so please be gentle ;) Any help and/or explanation as to how to overcome the issue and what I'm doing wrong would be very gratefully received.

I'm having trouble deploying a contract to testrpc using truffle.

$ tuffle deploy
...
Error deploying LFC:

Error: VM Exception while executing transaction: out of gas

Here's my contract:

import "Mortal.sol";
import "Exchanger.sol";
import "ExternalStorage.sol";
import "DepositDB.sol";
import "ForexDB.sol";
import "OrderDB.sol";
import "ContractManagerDB.sol";

contract LFC is Mortal {

bytes3 private constant defaultBaseCurrency = "Eth";

bytes32 private constant orderName = "Order DB";
bytes32 private constant forexName = "Forex DB";
bytes32 private constant depositName = "Deposit DB";

Exchanger private exchanger;
ExternalStorage private storageContract;
OrderDB private orderDB;
DepositDB private depositDB;
ForexDB private forexDB;
ContractManagerDB private contractManagerDB;

//event ExchangerCreated(address ex, uint now);

function createExchanger() public {
exchanger = new Exchanger();
}

function createStorage() public onlyOwner {
storageContract = new ExternalStorage();
storageContract.changeOwner(exchanger);
}

function createContractManager() public onlyOwner {
contractManagerDB = new ContractManagerDB();
contractManagerDB.setStorage(storageContract);
contractManagerDB.changeOwner(address(exchanger));
exchanger.setContractManager(contractManagerDB);
}

function createOrderContract() public onlyOwner {
orderDB = new OrderDB();
orderDB.setStorage(storageContract);
orderDB.changeOwner(address(exchanger));
//storageContract.setAddressValue(sha3(managerName,orderName),orderDB);
}

function createForexContract() public onlyOwner {
forexDB = new ForexDB();
forexDB.setStorage(storageContract);
forexDB.changeOwner(address(exchanger));
//storageContract.setAddressValue(sha3(managerName,forexName),forexDB);
}

function createDepositContract() public onlyOwner {
depositDB = new DepositDB();
depositDB.setStorage(storageContract);
depositDB.changeOwner(address(exchanger));
//storageContract.setAddressValue(sha3(managerName,depositDBName),depositDB);
}

function addAdmin() public onlyOwner {
storageContract.addAdmin(exchanger);
storageContract.addAdmin(depositDB);
storageContract.addAdmin(forexDB);
storageContract.addAdmin(orderDB);
storageContract.addAdmin(contractManagerDB);
}

function addContracts() public {
contractManagerDB.addContract(orderName,orderDB);
contractManagerDB.addContract(forexName,forexDB);
contractManagerDB.addContract(depositName,depositDB);
exchanger.setNames(orderName,forexName,depositName);
}

function setForexBase() public {
forexDB.setBase(defaultBaseCurrency);
}

function getExchanger() public constant returns (address) {
return exchanger;
}
}

Comments

  • desktopdandesktopdan Member Posts: 15
    edited October 2016
    Out of gas normally means you haven't passed in a high enough gas limit to execute the transaction.

    When you create a contract you do something like

    myContract.new([some params],
    {
    from: eth.accounts[0],
    data: something.code, // [from the compiled source]
    gas: 3000000
    }
    The "gas" variable is the amount of gas you are willing to spend to execute the contract. If it takes more gas than you have allowed, you will get the "out of gas" error.

    If you are interested, I wrote this blog post to explain gas
    http://remebit.com/ethereum-gas-for-dummies/
    Post edited by desktopdan on
Sign In or Register to comment.