0
// contract is storing ABI
 var instance = contract.new(
    "0x12", // bytes32
    "0x12", // bytes32
    [],   // array of addresses
    11,  // uint
    11,  // uint
    "0x0aB245c1d6Da5e7CAe0c9607b5bFA2747574c2b1", // another contract address
    "0xb513bF478caD09db7754A6139616ba5514f3a068", // another contract address
    {from:web3.eth.defaultAccount, gas : 5000000}, function(error, result){
  if(!error){     
    console.log(result);
  } else {
    console.log(error);
  }
})

I am able to deploy my contract in remix and not via web3.js. i have increased the gas limit but nothing works.

The total number of arguments are also correct. Basically, i have to pass arguments to constructor to deploy the Smart contract. That is why i have used "new"

P.S

function Product(bytes32 _name, bytes32 _additionalInformation, 
      address[] _parentProducts, int _lon, int _lat, address _DATABASE_CONTRACT, address _PRODUCT_FACTORY) {
name = _name;
isConsumed = false;
parentProducts = _parentProducts;
additionalInformation = _additionalInformation;

DATABASE_CONTRACT = _DATABASE_CONTRACT;
PRODUCT_FACTORY = _PRODUCT_FACTORY;

Action memory creation;
creation.handler = msg.sender;
creation.description = "Product creation";
creation.lon = _lon;
creation.lat = _lat;
creation.timestamp = now;
creation.blockNumber = block.number;

actions.push(creation);

Database database = Database(DATABASE_CONTRACT);
database.storeProductReference(this);
 }
  • please add your smart contract constructor code and error log for more clarification. – Mahesh Rajput Feb 7 at 7:51
  • @MaheshRajput done – DAOdAppDev Feb 7 at 7:53
  • The 'out of gas' error is most likely misleading. You have at least one error in your code, at Database database = Database(...), where you should create the Database instance using new. Also, since you haven't posted your Database contract, it is impossible to say how it impacts the behavior. For all we know, its constructor might be causing the problem. – goodvibration Feb 7 at 8:10
  • Also, please note that in your deployment code, you should cast the bytes32 arguments from ascii to hex. The syntax for this is slightly different between web3.js v0.x and web3.js v1.x, so without knowing which version you're using, I cannot tell you which syntax you should apply. – goodvibration Feb 7 at 8:12
  • @goodvibration there is no problem with the contract code orelse i would NOT have been able to deploy on Ropsten or in any environment via REMIX. The problem is with web3.js, i am not able to deploy via web3.js – DAOdAppDev Feb 7 at 8:50

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.