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';
$scope.$apply();
})
}
})
And this is the html page in which there is an input form for a number:
{{pageTest}}</br>
<div class="row">
<h1>Test</h1>
<form ng-submit="testWrite(test_number1)">
<div class="form-group">
<label for="testNumber1">Hardware</label>
<input type="number" class="form-control" id="testNumber1"
placeholder="ble:..."
ng-model="test_number1">
</div>
<button type="submit" class="btn btn-default">Test</button>
</form>
</div>
</br>
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 :)
gas
, notstartgas
. You wantcontract.testWrite2(testNumber1, {from: web3.eth.accounts[0], gas: 2000000})
– Tjaden Hess♦ Dec 12 '16 at 15:52