I'm working on that smart contract :

pragma solidity ^0.4.24;

import 'openzeppelin-solidity/contracts/ownership/Ownable.sol';
import 'openzeppelin-solidity/contracts/math/SafeMath.sol';

import './Grocery.sol';

contract GroceryFactory is Ownable {
    using SafeMath for uint256;

    address[] public m_arGroceries;
    address public m_aMaintenanceAddress;
    address public m_aFeesAddress;
    uint256 public m_uPrice;

    constructor(address maintenanceAddress, address feesAddress, uint256 price) public payable{
        m_aMaintenanceAddress = maintenanceAddress;
        m_aFeesAddress = feesAddress;
        m_uPrice = price;

    function getMaintenanceAddress() public onlyOwner view returns(address){
        return m_aMaintenanceAddress;

    function setMaintenanceAddress(address maintenanceAddress)public onlyOwner {
        m_aMaintenanceAddress = maintenanceAddress;

    function getFeesAddress() public onlyOwner view returns(address){
        return m_aFeesAddress;

    function setFeesAddress(address feesAddress)public onlyOwner {
        m_aFeesAddress = feesAddress;

    function setPrice(uint256 price) public onlyOwner {
        m_uPrice = price;

    function getPrice() public view returns(uint256){
        return m_uPrice;

    function getGroceriesCount() public onlyOwner view returns(uint){
        return m_arGroceries.length;

    function getPools() public onlyOwner view returns(address[]){
        return m_arGroceries;

    function () external payable {

    function createGrocery() public payable returns(address){
        require(msg.sender != address(0), "Owner is null");
        require(msg.value == getPrice(), "Please send the deployment price");
        require(m_aMaintenanceAddress != address(0), "Maintenance address is null");
        require(m_aFeesAddress != address(0), "Fees address is null");

        address owner = msg.sender;

        Grocery groc = new Grocery(owner, m_aMaintenanceAddress);


        return pool;

    function transferFees() private{
        uint256 balance = address(this).balance;

        if(balance > 0){

The debugger inside truffle keeps failing here:

53: 54: function () external payable { 55:
createGrocery(); ^^^^^^^^^^^^

debug(development:0xb14493e4...)> o

Transaction halted with a RUNTIME ERROR


What can I do ?

  • try to increase gas limit ... – Ha ĐANG Aug 25 '18 at 15:44
  • If it isn't just a gas miscalculation, three code possibilities jump out. There are four requires. The first one is unnecessary because msg.sender cannot be 0. We don't know if the third and fourth requirements are met because they seem to relate to deployment details. Consider moving those to the constructor so an invalid configuration cannot exist. Then, it goes on to create a Grocery. Grocery's constructor must succeed or else an error will bubble up. The code isn't included. I would look there for possible error conditions there as well. – Rob Hitchens Aug 26 '18 at 5:26
  • You were right. I had an error in Grocery's constructor and it was failing my factory. Thank you so much for help! – Teldar Aug 27 '18 at 18:01

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.