0

I have the following function that keeps getting a warning relating to high gas costs. Im assuming that it because Im using

string & uint

but I may be wrong. I looking for a bit of advice on how to structure this to reduce the possible gas costs, it will only ever be me running this particular function.

function AddNewLand(string _geoPoint1, string _geoPoint2, string _geoPoint3, string _geoPoint4, uint _totalinterest, uint _purchasePrice) public { if(ownerAddress == msg.sender){ Land memory _land = Land({ geoPoint1: _geoPoint1, geoPoint2: _geoPoint2, geoPoint3: _geoPoint3, geoPoint4: _geoPoint4, creationTime: uint64(now), totalInterest: _totalinterest, remainingInterest: _totalinterest, purchasePrice: 1000 }); uint256 landID = landRegister.push(_land) - 1; newLandAdded(landID); }else { error("Only the contract owner can add a new of land."); } } 

This is the message I am getting

enter image description here

1 Answer 1

1

I believe the issue is that you're accepting strings and storing them. A string can be of arbitrary length, so the gas for this function is unbounded.

That doesn't mean there's a problem, though. When someone actually makes a transaction, they have specific values that they're passing, and they'll get a reasonable gas limit.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.