1

I'm writing a web-based DApp with web3, and am trying to get my JavaScript to deploy a contract.

I've set up the abi, contract, and bytecode as follows:

const trade_abi = [ ... not shown: ABI copied from Remix ...
const trade_contract = web3.eth.contract(trade_abi);
const trade_bytecode = ... not shown: Bytecode copied from Remix

I am trying to deploy the contract ValuED_trade, which is in Solidity 0.5.1 and has the following consrtuctor:

    constructor(address parent_, uint24 ID_, int16 max, int16 price_, string memory content, string memory time) public{

        proposer = msg.sender;
        parent = ValuED(parent_);
        ID = ID_;
        max_seeking = max;
        price = price_;
        proposal_content = content;
        creation_time_ = time;
    }

I then try to create an instance of the contract as follows:

trade_contract.new(
  contract_address, 
  id_, 
  max, 
  amt_offered, 
  reason, 
  (new Date(Date.now())).toString(), 
  {
    from: user.account, 
    gas:840000000, 
    data:trade_bytecode
  }, 
  function(error, result){
    if(error) {
      alert("Error: Was not able to create a contract for this trade :(")
      console.log(error)
    }
    else {
      do_stuff(result) 
    }
})

This resulted in the following error:

MetaMask - RPC Error: Internal JSON-RPC error. 
{code: -32603, message: "Internal JSON-RPC error.", data: {…}, stack: "Error: Error: [ethjs-rpc] rpc error with payload {…method":"eth_sendRawTransaction"} [object Object]"}

I'm running this on a private blockchain with geth 1.9.3-stable.

Can anyone help me get this working?

0

To create a new contract instance pay attention to the uppercase c letter: .Contract() not .contract().
new web3.eth.Contract(jsonInterface[, address][, options])

| improve this answer | |

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.