I am trying to execute a transaction on the blockchain by adding an item to a mapping with the following Javascript code. Keep in mind that it is executed from Polymer.
var id = Math.random().toString(36).substr(2, 10);
var receiver = this.assetOwner;
console.log(this.assetsBlockchain);
var asset = this.assetsBlockchain[0].address;
var start = this.web3.toBigNumber(1000).dividedBy(1000).plus(3600);
var end = this.web3.toBigNumber(1000).dividedBy(1000).plus(10800);
var factory = this.web3.eth.contract(this.rentalRequestFactoryABI.abi).at(this.rentalRequestFactoryAddress);
var tx = factory.createRentalRequest(id, receiver, asset, start, end, {
from: this.mobilist,
gas: this.web3.toWei(0.5, "ether")
});
console.log(tx);
The createRentalRequest
function in the smart contract is as follows:
function createRentalRequest(bytes32 _id, address _receiver, address _asset, uint _start, uint _end) returns (bool) {
RentalRequest memory request;
request.receiver = _receiver;
request.asset = _asset;
request.start = _start;
request.end = _end;
request.accepted = false;
request.rejected = false;
requests[_id] = request;
Notify(msg.sender, _receiver, _asset);
return true;
}
A solution which I am going to try is to accept the uint
s as byte
arrays and converting them to uint
. Is there any reason why the error mentioned in the title appears though?
Best Answer
I found the problem after long debating and searching. The problem relies in the
gas
field of the transaction. When changed to a smaller number, for example1000000
, it works perfectly fine. It just had to do that I was supplying thegas
parameter such a high value that it didn't know what to do with it.