Remix

“交易執行可能會失敗。您要強制發送嗎?VM Exception while processing transaction: out of gas”

  • December 10, 2018

當我想使用testRPCand部署合約時remix,我收到以下錯誤消息:

氣體估計錯誤並顯示以下消息(見下文)。事務執行可能會失敗。是否要強制發送?處理事務時出現 VM 異常:氣體不足

並且它不是通過增加gas limit.

我該如何處理這個問題?

這是 Solidity 程式碼:

   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;
 }
}

在此處輸入圖像描述

我會說你的契約太大了。它可能超過了網路的氣體限制。

由於技術原因,交易有一個 gas 強制 gas 限制,但它也是管理程式碼的一個很好的指南——你不應該有超過限制的合約(好吧,你不能有,所以問題解決了)。如果合約那麼大,那麼它就太大了,出於技術和可維護性的原因需要將其拆分為單獨的合約。

因此,只需將您的契約拆分為多個契約。例如通過功能將其分開 - 如果您有一些儲存內容,您可以創建一個“儲存”契約等等。這對可升級性也有很大幫助。Google會給你一些想法,但這裡有一個關於可升級合約的連結:https ://blog.indorse.io/ethereum-upgradeable-smart-contract-strategies-456350d0557c

引用自:https://ethereum.stackexchange.com/questions/54419