I am running the following code in web3 the backend is a node running parity --testnet -j -w --jsonrpc-interface all.

My web3 code

  // data.contracts.TestContract is the results of 
  // solc test-contract.sol --json-combine abi,asm, etc...  
  var abi = data.contracts.TestContract.abi;
  var TestContract = eth.contract(JSON.parse(abi));
  var myTest = TestContract.new({
    data: "0x" + data.contracts.TestContract.bin, // binary data for contract
    gas: 300000,
    from: someAddressWithEther,
  }, function (err, myContract) {
    // from offical docs at https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethcontract
    if(!err) {
      // e.g. check tx hash on the first call (transaction send)
      if(!myContract.address) {
        console.info("transactionHash", myContract.transactionHash) // The hash of the transaction, which deploys the contract
        // check address on the second call (contract deployed)
      } else {
        console.info("theAddress", myContract.address) // the contract address

The results

The console.info with the transaction hash returns

transactionHash 0x0000000000000000000000000000000000000000000000000000000000000000

Which doesn't seem like a valid transactionHash. The theAddress line never seems to run.

My questions

I am not sure why I would get the 0x0...0 hash? Is there some error in this code that i am not seeing? How long should i wait for the address?

Also wouldn't mind comment pointing to a full description, ideally with full source examples on how to properly deploy from the web3?

  • 2
    Is your account unlocked? Try --unlock {address} --password {passwordfile}
    Jun 28 '16 at 23:55
  • Did you check the gas? Can you check the value of error in the callback?
    – Ismael
    Jun 29 '16 at 7:43
  • 1
    @BokkyPooBah that seems to have done the trick. Thank you.
    – Victory
    Jun 29 '16 at 8:47

In order to publish you need to unlock the account to send the gas. Use

parity --testnet -j -w \
   --jsonrpc-interface \
   --unlock 0x123... --password password-file.txt

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.