Remix Error – The Transaction Execution Will Likely Fail Due to Out of Gas

gasgas-limitout-of-gasremixtestrpc

When I want to deploy a contract using testRPC and remix, I receive the following error message:

Gas estimation errored with the following message (see below). The
transaction execution will likely fail. Do you want to force sending?
VM Exception while processing transaction: out of gas

And it's not fixed by increasing the gas limit.

How can I manage this issue ?

Here is the Solidity code :

    pragma solidity 0.4.24; 

contract AM {
    using SafeMath for uint256;

    struct StateStruct {

        mapping(bytes32 => bytes32) subSt;
    }

    struct AStruct {
        StateStruct st;
        address owner; 
        bool isAs;
        bytes32 rev;
        bytes32 act;
        bytes32 pl;
        bytes32 actSt;
        bytes32 asSte;
        bool isOw;
    }

    mapping(uint256 => AStruct) asStr;
    uint256[] public aList;

    uint256 public _public_id = 0;

    mapping(address => uint) public balance;
    mapping(uint256 => mapping (address => mapping(address => bool))) public isPDM;
    mapping(uint256 => mapping (address => bool)) public isPDU;


    event LNAF(address sender, uint256 indexed _id, bytes32 subStsTypes, bytes32 subSatesValues, address owner, bytes32 _asSte);


    event LNAFPay(address sender, uint256 indexed _id, bytes32 subStsTypes, bytes32 subSatesValues, address owner, bytes32 _asSte, uint256 _token);


    event LCASF(address sender, uint256 indexed _id, bytes32 subStsTypes, bytes32 subSatesValues, bytes32 _asSte);


    event LNANF(address sender, uint256 indexed _id, bytes32 _rev,  address _owner); 


    event LNANFPay(address sender, uint256 indexed _id, bytes32 _rev,  address _owner, uint256 _token); 


    event LCASNF(address sender, uint256 indexed _id, bytes32 _rev);


    event LNAOA(uint256 indexed _id, bytes32 _act, bytes32 _pl, bytes32 _actSt,  address _owner);


    event LNAOAPay(uint256 indexed _id, bytes32 _act, bytes32 _pl, bytes32 _actSt,  address _owner, uint256 _token);


    event LCASOA(address sender, uint256 indexed _public_id, bytes32 _act, bytes32 _pl, bytes32 _actSt); 


    event LCAO(address sender, uint256 indexed _id, address newOwner);


    event LCASFPay(address sender, uint256 indexed _id, bytes32 subStsTypes, bytes32 subSatesValues, bytes32 _asSte, uint256 _token);


    event LCASNFPay(address sender, uint256 indexed _id, bytes32 _rev, uint256 _token);


    function isAs(uint256 _id) public view returns(bool isIndeed) {
        return asStr[_id].isAs;
    }

    function isOw(uint256 _id, address _pl) public view returns(bool isIndeed) {
        if(asStr[_id].owner == _pl)
            return true;
        else
            return false;
    }

    function plPM(uint256 _id, address _pl, uint256 _token)  public  returns(bool isIndeed) {

        require(_token > balance[_pl]);

        address _owner;

        _owner = asStr[_id].owner;

        balance[_owner] = balance[_owner].add(_token);

        balance[_pl] = balance[_pl].sub(_token);

        isPDM[_id][_pl][_owner] = true;

            return true;
    }

    function plPU(uint256 _id, address _pl, uint256 _token)  public  returns(bool isIndeed) {

        balance[_pl] = balance[_pl].sub(_token);

        isPDU[_id][_pl] = true;

            return true;
    }

    function updateBalance(address _pl, uint256 newBalance) public {
        balance[_pl] = newBalance;
    }

    function getAC() public view returns(uint count) {
        return aList.length;
    }

    function newAFMID(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, address _owner, bytes32 _asSte) public returns(bool success) {
        require(!isAs(_id));

        uint256 counter=0;
        for(counter; counter < numberOfSubStates; counter++) {

            asStr[_id].st.subSt[subStsTypes[counter]] = subSatesValues[counter];

            emit LNAF(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), address(_owner), bytes32(_asSte));

        }

        asStr[_id].owner = _owner;
        asStr[_id].isAs = true;
        asStr[_id].asSte = _asSte;

        aList.push(_id);

        return true;
    }

    function newAFMIDpayU(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, address _owner, bytes32 _asSte, uint256 _token) public returns(bool success) {
        require(!isAs(_id));

        plPU(_id, msg.sender, _token);

        require(isPDU[_id][msg.sender]);

        uint256 counter=0;
        for(counter; counter < numberOfSubStates; counter++) {

            asStr[_id].st.subSt[subStsTypes[counter]] = subSatesValues[counter];

            emit LNAFPay(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), address(_owner), bytes32(_asSte), uint256(_token));

        }

        asStr[_id].owner = _owner;
        asStr[_id].isAs = true;
        asStr[_id].asSte = _asSte;

        aList.push(_id);

        return true;
    }

    function newAFMIDonlyLog(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, address _owner, bytes32 _asSte) public returns(bool success) {
        require(!isAs(_id));

        uint256 counter=0;
        for(counter; counter < numberOfSubStates; counter++) {

            emit LNAF(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), address(_owner), bytes32(_asSte));

        }

        asStr[_id].owner = _owner;
        asStr[_id].isAs = true;
        asStr[_id].asSte = _asSte;

        aList.push(_id);

        return true;
    }

    function newAFMIDonlyLogPayU(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, address _owner, bytes32 _asSte, uint256 _token) public returns(bool success) {
        require(!isAs(_id));

        plPU(_id, msg.sender, _token);

        require(isPDU[_id][msg.sender]);

        uint256 counter=0;
        for(counter; counter < numberOfSubStates; counter++) {

            emit LNAFPay(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), address(_owner), bytes32(_asSte), uint256(_token));

        }

        asStr[_id].owner = _owner;
        asStr[_id].isAs = true;
        asStr[_id].asSte = _asSte;

        aList.push(_id);

        return true;
    }

    function newAssetFieldAutoID(uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, address _owner, bytes32 _asSte) public returns(bool success) {
        require(!isAs(_public_id));

        uint256 counter=0;
        for(counter; counter < numberOfSubStates; counter++) {

            asStr[_public_id].st.subSt[subStsTypes[counter]] = subSatesValues[counter];

            emit LNAF(address(msg.sender), uint256(_public_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), address(_owner), bytes32(_asSte));

        }

        asStr[_public_id].owner = _owner;
        asStr[_public_id].isAs = true;
        asStr[_public_id].asSte = _asSte;

        aList.push(_public_id);

        _public_id = _public_id + 1;

        return true;
    }

    function newAFAIDpayU(uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, address _owner, bytes32 _asSte, uint256 _token) public returns(bool success) {
        require(!isAs(_public_id));

        plPU(_public_id, msg.sender, _token);

        require(isPDU[_public_id][msg.sender]);

        uint256 counter=0;
        for(counter; counter < numberOfSubStates; counter++) {

            asStr[_public_id].st.subSt[subStsTypes[counter]] = subSatesValues[counter];

            emit LNAFPay(address(msg.sender), uint256(_public_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), address(_owner), bytes32(_asSte), uint256(_token));

        }

        asStr[_public_id].owner = _owner;
        asStr[_public_id].isAs = true;
        asStr[_public_id].asSte = _asSte;

        aList.push(_public_id);

        _public_id = _public_id + 1;

        return true;
    }

    function newAssetFieldAutoIDonlyLog(uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, address _owner, bytes32 _asSte) public returns(bool success) {
        require(!isAs(_public_id));

        uint256 counter=0;
        for(counter; counter < numberOfSubStates; counter++) {

            emit LNAF(address(msg.sender), uint256(_public_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), address(_owner), bytes32(_asSte));

        }

        asStr[_public_id].owner = _owner;
        asStr[_public_id].isAs = true;
        asStr[_public_id].asSte = _asSte;

        aList.push(_public_id);

        _public_id = _public_id + 1;

        return true;
    }

    function newAFieldAutoIDonlyLogPayU(uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, address _owner, bytes32 _asSte, uint256 _token) public returns(bool success) {
        require(!isAs(_public_id));

        plPU(_public_id, msg.sender, _token);

        require(isPDU[_public_id][msg.sender]);

        uint256 counter=0;
        for(counter; counter < numberOfSubStates; counter++) {

            emit LNAFPay(address(msg.sender), uint256(_public_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), address(_owner), bytes32(_asSte), uint256(_token));

        }

        asStr[_public_id].owner = _owner;
        asStr[_public_id].isAs = true;
        asStr[_public_id].asSte = _asSte;

        aList.push(_public_id);

        _public_id = _public_id + 1;

        return true;
    }

    function newANoFMID(uint256 _id, bytes32 _rev,  address _owner, bytes32 _asSte) public returns(bool success) {
        require(!isAs(_id));

        asStr[_id].owner = _owner;
        asStr[_id].isAs = true;
        asStr[_id].asSte = _asSte;

        asStr[_id].rev = _rev;

        emit LNANF(address(msg.sender), uint256(_id), bytes32(_rev), address(_owner));

        aList.push(_id);

        return true;
    }

    function newANoFMIDpayU(uint256 _id, bytes32 _rev,  address _owner, bytes32 _asSte, uint256 _token) public returns(bool success) {
        require(!isAs(_id));

        plPU(_id, msg.sender, _token);

        require(isPDU[_id][msg.sender]);

        asStr[_id].owner = _owner;
        asStr[_id].isAs = true;
        asStr[_id].asSte = _asSte;

        asStr[_id].rev = _rev;

        emit LNANFPay(address(msg.sender), uint256(_id), bytes32(_rev), address(_owner), uint256(_token));

        aList.push(_id);

        return true;
    }

    function newANoFMIDonlyLog(uint256 _id, bytes32 _rev,  address _owner, bytes32 _asSte) public returns(bool success) {
        require(!isAs(_id));

        asStr[_id].owner = _owner;
        asStr[_id].isAs = true;
        asStr[_id].asSte = _asSte;

        emit LNANF(address(msg.sender), uint256(_id), bytes32(_rev), address(_owner));

        aList.push(_id);

        return true;
    }

    function newANoFMIDonlyLogPayU(uint256 _id, bytes32 _rev,  address _owner, bytes32 _asSte, uint256 _token) public returns(bool success) {
        require(!isAs(_id));

        plPU(_id, msg.sender, _token);

        require(isPDU[_id][msg.sender]);

        asStr[_id].owner = _owner;
        asStr[_id].isAs = true;
        asStr[_id].asSte = _asSte;

        emit LNANFPay(address(msg.sender), uint256(_id), bytes32(_rev), address(_owner), uint256(_token));

        aList.push(_id);

        return true;
    }

    function newAssetNoFieldAutoID(bytes32 _rev,  address _owner, bytes32 _asSte) public returns(bool success) {
        require(isAs(_public_id));

        asStr[_public_id].owner = _owner;
        asStr[_public_id].isAs = true;
        asStr[_public_id].asSte = _asSte;

        asStr[_public_id].rev = _rev;

        emit LNANF(address(msg.sender), uint256(_public_id), bytes32(_rev), address(_owner));

        aList.push(_public_id);

        _public_id = _public_id + 1;

        return true;
    }

    function newANoFieldAutoIDpayUni(bytes32 _rev,  address _owner, bytes32 _asSte, uint256 _token) public returns(bool success) {
        require(isAs(_public_id));

        plPU(_public_id, msg.sender, _token);

        require(isPDU[_public_id][msg.sender]);

        asStr[_public_id].owner = _owner;
        asStr[_public_id].isAs = true;
        asStr[_public_id].asSte = _asSte;

        asStr[_public_id].rev = _rev;

        emit LNANFPay(address(msg.sender), uint256(_public_id), bytes32(_rev), address(_owner), uint256(_token));

        aList.push(_public_id);

        _public_id = _public_id + 1;

        return true;
    }

    function newANoFieldAutoIDonlyLog(bytes32 _rev,  address _owner, bytes32 _asSte) public returns(bool success) {
        require(isAs(_public_id));

        asStr[_public_id].owner = _owner;
        asStr[_public_id].isAs = true;
        asStr[_public_id].asSte = _asSte;

        emit LNANF(address(msg.sender), uint256(_public_id), bytes32(_rev), address(_owner));

        aList.push(_public_id);

        _public_id = _public_id + 1;

        return true;
    }

    function newANoFieldAutoIDonlyLogPayU(bytes32 _rev,  address _owner, bytes32 _asSte, uint256 _token) public returns(bool success) {
        require(isAs(_public_id));

        plPU(_public_id, msg.sender, _token);

        require(isPDU[_public_id][msg.sender]);

        asStr[_public_id].owner = _owner;
        asStr[_public_id].isAs = true;
        asStr[_public_id].asSte = _asSte;

        emit LNANFPay(address(msg.sender), uint256(_public_id), bytes32(_rev), address(_owner), uint256(_token));

        aList.push(_public_id);

        _public_id = _public_id + 1;

        return true;
    }

    function newAOneActManID(uint256 _id, bytes32 _act, bytes32 _pl, bytes32 _actSt,  address _owner, bytes32 _asSte) public returns(bool success) {
        require(!isAs(_id));

        asStr[_id].owner = _owner;
        asStr[_id].isAs = true;
        asStr[_id].asSte = _asSte;

        asStr[_id].act = _act;
        asStr[_id].pl = _pl;
        asStr[_id].actSt = _actSt;

        aList.push(_id);

        emit LNAOA(uint256(_id), bytes32(_act), bytes32(_pl), bytes32(_actSt), address(_owner));

        return true;
    }

    function newAOneActManIDpayU(uint256 _id, bytes32 _act, bytes32 _pl, bytes32 _actSt,  address _owner, bytes32 _asSte, uint256 _token) public returns(bool success) {
        require(!isAs(_id));

        plPU(_id, msg.sender, _token);

        require(isPDU[_id][msg.sender]);

        asStr[_id].owner = _owner;
        asStr[_id].isAs = true;
        asStr[_id].asSte = _asSte;

        asStr[_id].act = _act;
        asStr[_id].pl = _pl;
        asStr[_id].actSt = _actSt;

        aList.push(_id);

        emit LNAOAPay(uint256(_id), bytes32(_act), bytes32(_pl), bytes32(_actSt), address(_owner), uint256(_token));

        return true;
    }

    function newAOneActionAID(bytes32 _act, bytes32 _pl, bytes32 _actSt,  address _owner, bytes32 _asSte) public returns(bool success) {
        require(!isAs(_public_id));

        asStr[_public_id].owner = _owner;
        asStr[_public_id].isAs = true;
        asStr[_public_id].asSte = _asSte;

        asStr[_public_id].act = _act;
        asStr[_public_id].pl = _pl;
        asStr[_public_id].actSt = _actSt;


        aList.push(_public_id);

        emit LNAOA(uint256(_public_id), bytes32(_act), bytes32(_pl), bytes32(_actSt), address(_owner));

        _public_id = _public_id + 1;

        return true;
    }

    function newAOneActAIDpayUnil(bytes32 _act, bytes32 _pl, bytes32 _actSt,  address _owner, bytes32 _asSte, uint256 _token) public returns(bool success) {
        require(!isAs(_public_id));

        plPU(_public_id, msg.sender, _token);

        require(isPDU[_public_id][msg.sender]);

        asStr[_public_id].owner = _owner;
        asStr[_public_id].isAs = true;
        asStr[_public_id].asSte = _asSte;

        asStr[_public_id].act = _act;
        asStr[_public_id].pl = _pl;
        asStr[_public_id].actSt = _actSt;


        aList.push(_public_id);

        emit LNAOAPay(uint256(_public_id), bytes32(_act), bytes32(_pl), bytes32(_actSt), address(_owner), uint256(_token));

        _public_id = _public_id + 1;

        return true;
    }

    function changeASField(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte) public returns(bool success) {
        require(isAs(_id));

        uint256 counter=0;
        for(counter; counter < numberOfSubStates; counter++) {

            asStr[_id].st.subSt[subStsTypes[counter]] = subSatesValues[counter];

            emit LCASF(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte));

        }

        return true;
    }

    function changeASFPer(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte) public returns(bool success) {
        require(isAs(_id));
        require(isOw(_id, msg.sender));

        uint256 counter=0;
        for(counter; counter < numberOfSubStates; counter++) {

            asStr[_id].st.subSt[subStsTypes[counter]] = subSatesValues[counter];

            emit LCASF(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte));

        }

        return true;
    }

    function changeASFieldOnlyL(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte) public returns(bool success) {
        require(isAs(_id));

        uint256 counter=0;
        for(counter; counter < numberOfSubStates; counter++) {

            emit LCASF(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte));

        }

        return true;
    }

    function changeASFieldOnlyLPer(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte) public returns(bool success) {
        require(isAs(_id));
        require(isOw(_id, msg.sender));

        uint256 counter=0;
        for(counter; counter < numberOfSubStates; counter++) {

            emit LCASF(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte));

        }

        return true;
    }

    function changeAssetStateNoF(uint256 _id, bytes32 _rev) public returns(bool success) {
        require(isAs(_id));

        asStr[_id].rev = _rev;

        emit LCASNF(address(msg.sender), uint256(_id), bytes32(_rev));

        return true;
    }

    function changeAStateNoFPer(uint256 _id, bytes32 _rev) public returns(bool success) {
        require(isAs(_id));
        require(isOw(_id, msg.sender));

        asStr[_id].rev = _rev;

        emit LCASNF(address(msg.sender), uint256(_id), bytes32(_rev));

        return true;
    }

    function changeAStateNoFOnlyLog(uint256 _id, bytes32 _rev) public returns(bool success) {
        require(isAs(_id));

        emit LCASNF(address(msg.sender), uint256(_id), bytes32(_rev));

        return true;
    }

    function changeAStateNoFOnlyLogPer(uint256 _id, bytes32 _rev) public returns(bool success) {
        require(isAs(_id));
        require(isOw(_id, msg.sender));

        emit LCASNF(address(msg.sender), uint256(_id), bytes32(_rev));

        return true;
    }

    function changeASFieldPayMu(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte, uint256 _token) public returns(bool success) {
        require(isAs(_id));

        address _owner;
        _owner = asStr[_id].owner;

        plPM(_id, msg.sender, _token);

        require(isPDM[_id][msg.sender][_owner]);

        uint256 counter=0;
        for(counter; counter < numberOfSubStates; counter++) {

            asStr[_id].st.subSt[subStsTypes[counter]] = subSatesValues[counter];

            emit LCASFPay(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte), uint256(_token));

        }

        isPDM[_id][msg.sender][_owner] = false;

        return true;
    }

    function changeASFieldPayMuPer(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte, uint256 _token) public returns(bool success) {
        require(isAs(_id));
        require(isOw(_id, msg.sender));

        address _owner;
        _owner = asStr[_id].owner;

        plPM(_id, msg.sender, _token);

        require(isPDM[_id][msg.sender][_owner]);

        uint256 counter=0;
        for(counter; counter < numberOfSubStates; counter++) {

            asStr[_id].st.subSt[subStsTypes[counter]] = subSatesValues[counter];

            emit LCASFPay(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte), uint256(_token));

        }

        isPDM[_id][msg.sender][_owner] = false;

        return true;
    }

    function changeASFieldPayUn(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte, uint256 _token) public returns(bool success) {
        require(isAs(_id));

        plPU(_id, msg.sender, _token);

        require(isPDU[_id][msg.sender]);

        uint256 counter=0;
        for(counter; counter < numberOfSubStates; counter++) {

            asStr[_id].st.subSt[subStsTypes[counter]] = subSatesValues[counter];

            emit LCASFPay(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte), uint256(_token));

        }

        isPDU[_id][msg.sender] = false;

        return true;
    }

    function changeASFieldPayUnPer(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte, uint256 _token) public returns(bool success) {
        require(isAs(_id));
        require(isOw(_id, msg.sender));

        plPU(_id, msg.sender, _token);

        require(isPDU[_id][msg.sender]);

        uint256 counter=0;
        for(counter; counter < numberOfSubStates; counter++) {

            asStr[_id].st.subSt[subStsTypes[counter]] = subSatesValues[counter];

            emit LCASFPay(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte), uint256(_token));

        }

        isPDU[_id][msg.sender] = false;

        return true;
    }

    function changeASFieldOnlyLPayMu(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte, uint256 _token) public returns(bool success) {
        require(isAs(_id));

        address _owner;
        _owner = asStr[_id].owner;

        plPM(_id, msg.sender, _token);

        require(isPDM[_id][msg.sender][_owner]);

        uint256 counter=0;
        for(counter; counter < numberOfSubStates; counter++) {

            emit LCASFPay(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte), uint256(_token));

        }

        return true;
    }

    function changeASFieldOnlyLPayMuPer(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte, uint256 _token) public returns(bool success) {
        require(isAs(_id));
        require(isOw(_id, msg.sender));

        address _owner;
        _owner = asStr[_id].owner;

        plPM(_id, msg.sender, _token);

        require(isPDM[_id][msg.sender][_owner]);

        uint256 counter=0;
        for(counter; counter < numberOfSubStates; counter++) {

            emit LCASFPay(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte), uint256(_token));

        }

        return true;
    }

    function changeASFieldOnlyLPayUn(uint256 _id, uint256 numberOfSubStates, bytes32[50] subStsTypes, bytes32[50] subSatesValues, bytes32 _asSte, uint256 _token) public returns(bool success) {
        require(isAs(_id));

        plPU(_id, msg.sender, _token);

        require(isPDU[_id][msg.sender]);

        uint256 counter=0;
        for(counter; counter < numberOfSubStates; counter++) {

            emit LCASFPay(address(msg.sender), uint256(_id), bytes32(subStsTypes[counter]), bytes32(subSatesValues[counter]), bytes32(_asSte), uint256(_token));

        }

        return true;
    }
}

/////////////////////////////////////////////////////////////////

library SafeMath {

  function sub(uint256 a, uint256 b) internal pure returns (uint256) {
    assert(b <= a);
    return a - b;
  }

  function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
    c = a + b;
    assert(c >= a);
    return c;
  }
}

enter image description here

Best Answer

I would say your contract is simply too big. It probably exceeds the gas limits of networks.

Transactions have a gas enforced gas limit because of technical reasons, but it's also a very good guideline for managing your code - you should never have contracts that exceeds the limit (well, you can't have, so problem solved). If a contract is that big, it's too big and needs to be split into separate contracts for technical and maintainability reasons.

So just split your contract into multiple contracts. Separate it for example by functionality - if you have some storage contents you can create a 'storage' contract and so on. That also helps a lot for upgradability. Google will give you ideas, but here's one link about upgradable contracts: https://blog.indorse.io/ethereum-upgradeable-smart-contract-strategies-456350d0557c

Related Topic