1

I am trying to deploy a contract with web3 1.0.0 like:

myContract.deploy({})
.send({
    from: '0x1234567890123456789012345678901234567891',
    gas: 1500000,z
    gasPrice: '20000000000000'
}, function(error, transactionHash){ ... })
.on('error', function(error){ ... })
.on('transactionHash', function(transactionHash){ ... })
.on('receipt', function(receipt){
   console.log(receipt.contractAddress) 
})

and I get the following error:

Script failed: Error: Returned error: invalid argument 0: json: cannot unmarshal hex string without 0x prefix into Go struct field SendTxArgs.data of type hexutil.Bytes

Previously I am using the same address to get the contract, and it is in hex format(0x...).

let contract = new web3.eth.Contract(abi, {from: '0x1234567890123456789012345678901234567891', gas: 47000, data: bytecode});

and it is correct. So I do not know what can be the problem.

1

The problem was creating the contract:

let contract = new web3.eth.Contract(abi, {from: account, gas: 47000, data: bytecode});

It is solved adding '0x' before the bytecode.

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.