The following smart contract function works when called in the Remix-Solidity IDE and connected to testrpc.

function submitAsset(string ownerName, string assetName, string assetDesc, string barcode, string sku, string countryOrigin) public returns (bool success) {
    if (!map_assets[msg.sender].initialized) {
        map_assets[msg.sender] = Asset(msg.sender, ownerName, assetName, assetDesc, barcode, sku, countryOrigin, true);
        noOfAssets = assetAddresses.length;
        AssetSubmitted(msg.sender, ownerName, assetName, assetDesc, barcode, sku, countryOrigin, true);
        return true;
    return false;

However, I get out of gas error when calling from Meteor/web3 app. The followings are the code in my javascript file:

instance.contract.submitAsset(ownerName, assetName, assetDesc, barcode, sku, countryOrigin).call({gas: estimateGas}, function(error, result) {
    if(!error) {
        console.log("yeah!: " + result);
    else {
        console.log("ooops!: " + error);

Please note that the estimated gas is 260385 (referred to the Solidity IDE). So, then I set estimatedGas to be 300000 in the javascript file - just to ensure it will go through. Still to no avail.

Again, I appreciate if anyone could point me to tips/advise. Thank you.


I got it working with the following line,

instance.contract.submitAsset.sendTransaction(prnName, assetName, assetDesc, barcode, sku, countryOrigin, {gas: estimateGas});

contract.methodName.sendTransaction(params, options)
and not


Yes because call and sendTransaction (or send) are different on web3.

call: doc

Will call a “constant” method and execute its smart contract method in the EVM without sending any transaction. Note calling can not alter the smart contract state.

sendTransaction: doc

Will send a transaction to the smart contract and execute its method. Note this can alter the smart contract state.

PS: The doc links point to the web3 1.0, if think in your question you are referring to the web3 < 1.0, the doc is here

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.