I'm trying something with Ethereum and my current testing environment is Truffle.

In the smart contract I have a struct with 5 fields (bytes32, bytes32, bytes32, address, bool). If a call a function (that has as parameters the first three bytes32) that writes in an array of struct within Truffle everything works fine (and then I'm also able to read the values, get them by index using a mapping and so on).

Now I've some problem when dealing with AngularJS and the GUI. If I create a page with an input form for writin a bytes32 on a bytes32 variable in the contract everything works. The problems arises when I pass some arguments (1, 2 or 3) and then write inside the array of struct. I got an out of gas expection.

Do you have any insights on way there could be some problems? I'm sure the transaction doesn't consume all gas (and I've tried to increase the limit) because in Truffle console everything works fine.

Thanks for your time

-------- UPDATE

I think that a possible solution could be to set for the single call of the function an higher startgas than the default one. The limit I've first increased was the BGL.

contract.testWrite2(testNumber1, {from: web3.eth.accounts[0]})

This is the code for calling the testWrite2 function of my contract passing one parameter and using the account 0. How can I set the startgas for this simple invocation?

contract.testWrite2(testNumber1, {from: web3.eth.accounts[0], startgas: 200000})

This unfortunately doens't seem to work. The strange thing is that from truffle console all the functions are working correctly, while from the GUI they're not.

The code of the controller that's managing the GUI is this

    app.controller("TestController", function($scope) {
        $scope.pageTest = "Welcome to the Test page";
        $scope.testWr = 'None';

        $scope.testWrite = function(testNumber1) {
        var contract = Authentication.deployed();
        contract.testWrite2(testNumber1, {from: web3.eth.accounts[0]}).then(function() {
          $scope.testWr = 'success';


And this is the html page in which there is an input form for a number:


<div class="row">
        <form ng-submit="testWrite(test_number1)">
            <div class="form-group">
                <label for="testNumber1">Hardware</label>
                <input type="number" class="form-control" id="testNumber1"
            <button type="submit" class="btn btn-default">Test</button>

Write status: {{testWr}}

To test it out, I wanted to call the function and then simply change the variable testWr on the HTML page.

Thanks to everybody that will help me :)

  • 2
    Share some code. Have you put ether on the accounts you are using?
    – BennyM
    Nov 30, 2016 at 12:51
  • @BennyM I've added other explanations and some code :) Sorry for the delay but I've spent time over some documentation before continuing with the implementation!
    – gatb27
    Dec 12, 2016 at 15:28
  • 1
    200k isn't really that much gas. Have you tried 2 million? Also, the variable is called gas, not startgas. You want contract.testWrite2(testNumber1, {from: web3.eth.accounts[0], gas: 2000000}) Dec 12, 2016 at 15:52
  • @TjadenHess I've solved the problem! I've used startgas because I've seen it somewhere, while with gas it's working fine and I need only 160k of gas for the transaction! Thanks for the support :)
    – gatb27
    Dec 13, 2016 at 10:16

1 Answer 1


Thanks to @TjadenHess I've found the solution: the variable to use inside the function call is gas and not startgas.

Now everything is working fine and I need 160k for the transaction to be completed.

Your Answer

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

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