I'm trying to deploy a new contract with metamask (in my javascript frontend app). The problem is that, when the receipt is returned, the address is "undefined" since, I suppose, the transaction is not already mined and so the address not exists yet. The deploying result is:

Contract {_eth: Eth, transactionHash: 
 address: undefined, abi: Array(22)}
 abi:(22) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
 address: undefined
 transactionHash :"0x9e3866f52f274874d96bf60932c03d9849ccdb2cef97c010d6b84c5b529768de"
 _eth: Eth {_requestManager: RequestManager, getBalance: ƒ, getStorageAt: ƒ, getCode: ƒ, getBlock: ƒ, …}

Moreover, if I try to access to the mining state into _eth > mining the output is:

[Exception: Error: The MetaMask Web3 object does not support synchronous methods like eth_mining without a callback parameter. See https://github.com/MetaMask/faq/blob/master/DEVELOPERS.md#dizzy-all-async

The Javascript code is:

deployContent = (name, author, genre, cost) => {
  return new Promise((succ, rej) => {
   this.web3.eth.contract(Content.abi).new(name, author, genre, cost, {gas: 400000}, 
    (err, res) => {if(!err)succ(res); else rej(err);});

deployAndPublish = async (name, author, genre, cost) => {
    let contRes = await this.deployContent(name, author, genre, cost);
    // I need the address here in order to push it into an array

Any idea how to wait for the address?

1 Answer 1


you can always use an event listener for that. here is a proper example: https://medium.com/@marcusmolchany/the-easiest-way-to-deploy-smart-contracts-on-ethereum-65f69ac9a627

  • You can also use Remix to deploy your contract. Jun 16, 2018 at 11:30
  • The problem is that the constructor parameters are read from the UI Jun 16, 2018 at 11:34
  • Moreover, I cannot watch an event if I don't know the address... Jun 16, 2018 at 11:38
  • 1
    Yes, I get the transaction receipt but the address is undefined (not already mined) Jun 16, 2018 at 11:42
  • 1
    I'm Developing a frontend with react, that runs in a browser using metamask injection. The web3 version is 0.20 Jun 16, 2018 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.