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
        "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??

full error trace

1 Answer 1


Try specifying the gas amount in your contract call:

await sellContract.methods.createUser(...).send({ from: accounts[0], gas: 20000000}) 
  • doing that I now get "Returned error: Exceeds block gas limit" Jan 22, 2019 at 12:28
  • You may need to adjust the gas number for your blockchain's limits, I just put an arbitrary number. Jan 22, 2019 at 12:29
  • I did change the gas limit via: ganache-cli -p 9545 -l 90000000, however I still get the error saying I have exceeded the block gas limit Jan 22, 2019 at 12:32
  • ok I just made it much higher (90000000000000) and it has solved it.. thanks Jan 22, 2019 at 12:33
  • You are doing the wrong thing here. You should not need to update your blockchain's total gas limit, just the amount of gas you specify your transaction can use. I put an arbitrary number (200 million) which is probably way too much for what you need. You should try to estimate the gas costs then submit the transaction with that amount. Jan 22, 2019 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.