I am trying to develop a simple wallet type contract but having troubles deploying it. I am trying to deploy it using the method described here. I am using truffle and web3 along with Metamask. Now, here's what I have for deploying the contract:

var contract = web3.eth.contract(abi);

instance = contract.new({
          from: web3.eth.accounts[0],
          data: <bytecode>,
          gas: 10000000
      }, function (e, contract){
          console.log(e, contract);
          if (typeof contract.address !== 'undefined') {
              console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);

Transaction goes through fine but the contract address remains undefined for some reason. I want to be able to call contract functions. I have tried deploying it straight from Browser-Solidity with no luck.

Can anyone help me figure out what's going on? Also, is there any better way of doing this? Any suggestions are welcome!

  • There's a little more context that would help here. How are you creating the contract instance? – DanF Dec 10 '17 at 2:58
  • Ah yes, forgot about that. Added now. I am using what is described on the wiki and other places. I get two callbacks, in the first one transaction hash and address both are undefined and in the second one, only address is undefined. On the docs it says that the address should be defined in the second callback but that's not working for me. – Naman Dec 11 '17 at 23:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.