Monday, 24 April 2017

Ethereum's transaction doesn't work properly

I have deployed a simple smart contract and it works fine (I can interact with), but I have some problems with a given transaction, which have to update the contract storage (mapping types).

In my node.js server:

var instance = contr.instance(); 
imageTransaction = instance.setPictureHash(0, 1, {from: web3.eth.accounts[0], gas: 4500000});

I've also defined the solidity function in the contract abi:

var contract_abi = {"constant":false,"inputs":  [{"name":"keyNumber","type":"uint256"},>{"name":"packtypeValue","type":"uint256"},{"name":"picturehashValue","type":"string"}],"name":"setPictureHash","outputs":[],"type":"function"}

And in the smart contract:

mapping(uint => pictureStruct[]) public pictures; 
struct pictureStruct{ uint timestamp; uint packType; } function setPictureHash(uint keyNumber, uint packtypeValue) { uint timestampValue = now; pictures[keyNumber].push(pictureStruct({timestamp : timestampValue, packType : packtypeValue}));

The transactionReceipt return as gasUsed the same value set for the transaction (I think it's a problem of out of gas, even though I have others transaction similar to it and they work) and the storage has not changed.

Which could be the issue? I have tried some solutions, but nothing works.



via Matteo Pelissier

No comments:

Post a Comment