pragma solidity ^0.4.24; contract Owned { address owner; constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } } //re-define uints below as uint8, uint16, etc. (smallest possible to handle the largest possibilities) //also, remove any variables below that should not go to the BC //probably a better way to store... array? json? //removed: 2nd instance of stackID, created; one instance of lastID, bcID, verify //Solidity supports up to 12 parameters being passed to a function. Getting error: InternalCompilerError: Stack too deep, try removing local variables. Will need to store as array (stacks are stored as array, but individual stack is not, or separate into more than one function. // needs to be re-worked so that stack is stored as individual address instead of pushed to array. then stack values should be stored as array. Maykbe can divide them up when I know exactly what data should be stored. contract StackSample is Owned { Sample[] samples; struct Sample { uint id; uint created; uint prodTypeID; uint stackUnitID; uint unitWeight; uint qtyUnits; uint growerID; uint fieldID; uint yardID; uint year; uint cutID; uint vid1URL; uint visNotes; uint buyPrice; uint sellPrice; uint publishedOn; uint sampleID; uint ftUserID; uint shatterNotes; uint vid2URL; uint tm; uint tdn; uint ash; uint ndf; uint adf; uint cp; uint nitr; uint rfv; uint rfq; uint nel; } function setStack(uint _id, uint _created, uint _prodTypeID, uint _stackUnitID, uint _unitWeight, uint _qtyUnits, uint _growerID, uint _fieldID, uint _yardID, uint _year, uint _cutID, uint _vid1URL, uint _visNotes, uint _buyPrice, uint _sellPrice, uint _publishedOn, uint _sampleID, uint _ftUserID, uint _shatterNotes, uint _vid2URL, uint _tm, uint _tdn, uint _ash, uint _ndf, uint _adf, uint _cp, uint _nitr, uint _rfv, uint _rfq, uint _nel) public { samples.push(Sample( { id: _id, created: _created, prodTypeID: _prodTypeID, stackUnitID: _stackUnitID, unitWeight: _unitWeight, qtyUnits: _qtyUnits, growerID: _growerID, fieldID: _fieldID, yardID: _yardID, year: _year, cutID: _cutID, vid1URL: _vid1URL, visNotes: _visNotes, buyPrice: _buyPrice, sellPrice: _sellPrice, publishedOn: _publishedOn, sampleID: _sampleID, ftUserID: _ftUserID, shatterNotes: _shatterNotes, vid2URL: _vid2URL, tm: _tm, tdn: _tdn, ash: _ash, ndf: _ndf, adf: _adf, cp: _cp, nitr: _nitr, rfv: _rfv, rfq: _rfq, nel: _nel }) ); } //event PublishedStack(address _from, address _to, uint256 stack); //stack will be a sha256? //can use event to replace getter function above. Advantage or disadvantage? either way would be free. function getStack(uint _index) view public returns (uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint) { Sample storage sample = samples[_index]; return(sample.id, sample.created, sample.prodTypeID, sample.stackUnitID, sample.unitWeight, sample.qtyUnits, sample.growerID, sample.fieldID, sample.yardID, sample.year, sample.cutID, sample.vid1URL, sample.visNotes, sample.buyPrice, sample.sellPrice, sample.publishedOn, sample.sampleID, sample.ftUserID, sample.shatterNotes, sample.vid2URL, sample.tm, sample.tdn, sample.ash, sample.ndf, sample.adf, sample.cp, sample.nitr, sample.rfv, sample.rfq, sample.nel); } }
0.4.24