1

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 uints as byte arrays and converting them to uint. Is there any reason why the error mentioned in the title appears though?

5
  • And where in that code are you actually encountering the error? You're using the BigNumber library for dealing with large numbers, so the outputs of those should be strings, not actual Javascript Number variables. Jun 8 '17 at 21:53
  • It may have something to do with this: github.com/ethereum/wiki/wiki/…
    – 0xcaff
    Jun 9 '17 at 0:15
  • @MidnightLightning The error is thrown at the assignment of the tx variable.
    – DevNebulae
    Jun 9 '17 at 6:14
  • @0xcaff I am already using big numbers, even the base number is a BigNumber.
    – DevNebulae
    Jun 9 '17 at 6:15
  • stackoverflow.com/questions/54128954/… <- Hello I have the same Problem. Could someone help me here Jan 16 '19 at 8:33
1

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 example 1000000, it works perfectly fine. It just had to do that I was supplying the gas parameter such a high value that it didn't know what to do with it.

0

Agree with DevNebulae. In many blogs I've found it was a Truffle version problem. Truffle v5 would make problems of this type. They suggest to downgrade to truffle@4.1.15.

This has not been so for me. I have continue to use truffle v5. I've resolved by checking my gas limit when I sent a transaction. gasLimit: web3.utils.toHex( gas_limit ),//The maximum gas provided for this transaction (gas limit)

Node: v8.11.4 Truffle: 5.0.12 Web3: 1.0.0-beta.52 Truffle-contract: 4.0.11 Truffle-interface-adapter@0.1.2 │ └── web3@1.0.0-beta.37 └── web3@1.0.0-beta.37 Ganache-cli: v6.4.3 (ganache-core: 2.5.5) Ethereumjs-tx: 1.3.4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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