I am calling the contract function below however I get an error: "VM Exception while processing transaction: out of gas". To test I have simplified the function so it only saves a user's name however I still get the error so I know it is not due to an actual out of gas reason but more due to an error. Running on Ganache.
function createUser(
address _address,
string memory _name,
string memory _companyName,
int _numYearsExperience,
int _pricePerHour,
string memory _specialisation,
string memory _summary,
int _numAdsViewed,
int _numAdsPurchased
) public
{
address _userAddress = _address;
// Storage for list of users
User storage user = users[_userAddress];
// Check that the user did not already exist
require(
!user.set,
"User already exists!"
);
//Store the user
users[_userAddress] = User({
name: _name,
companyName: _companyName,
numYearsExperience: _numYearsExperience,
pricePerHour: _pricePerHour,
specialisation: _specialisation,
summary: _summary,
set: true,
numAdsViewed: _numAdsViewed,
numAdsPurchased: _numAdsPurchased
});
}
This is the calling code... (JS)
var info = data[i]
var name = String(info.name)
var companyName = String(info.companyName)
var pricePerHour = parseInt(info.pricePerHour);
var yearsExperience = parseInt(info.yearsExperience);
var specialisation = String(info.specialisation)
var summary = String(info.summary)
var address = info.address;
var maxCPT = parseInt(info.maxCPT);
await sellContract.methods.createUser(address, name, companyName, yearsExperience, pricePerHour, specialisation, summary, 0, 0).send({ from: accounts[0]})
Anyone know what's going wrong??