Web3.js: contract.deploy().send() not resolving in beta.48

Created on 15 Mar 2019  路  8Comments  路  Source: ChainSafe/web3.js

Description

I've got a little contract deployment script, which stopped working after upgrading web3 from beta.37 to beta.48. Downgrading helped.
The issue is, that the promise returned by myContract.deploy(args).send(opts) is never resolved.

Issue may be related to #2500.

Expected behavior

The promise should either resolve or reject.

Actual behavior

Waiting for promise indefinitely.

Gists

https://gist.github.com/haggins/2213e5d1852c825869687672a9dff890

Versions

  • web3.js: beta.48
  • nodejs: 10.15
  • ethereum node: ganache-cli 6.2.3
support

Most helpful comment

Thanks for asking! @Pedro-vk
Yes, this is possible with the transactionConfirmationBlocks option of a Web3 module.

All 8 comments

Thanks for creating this issue!

I've tested it with the version beta.48 and it works. I think you forgot to return the response in the async method.

Code:

const contract = new web3.eth.Contract(abi);
contract.transactionConfirmationBlocks = 1;


const deploy = async () => {
  const gas = await contract.deploy({data: web3TokenBytecode}).estimateGas();
  const response = await contract.deploy({data: web3TokenBytecode}).send({
    from: '0xb414031Aa4838A69e27Cb2AE31E709Bcd674F0Cb',
    gas: gas + 1
  });

  console.log('Contract deployed to:', response.address);
  console.log('Contract deployed to:', response.options.address);

  return response;
};

deploy().then((contractClone) => {
  console.log('CLONED-CONTRACT: ', contractClone);

}).catch(console.log);

Response:

Contract deployed to: 0xF250bDB2bFE42e383C38F0CAafeD03545B24F5D6
Contract deployed to: 0xF250bDB2bFE42e383C38F0CAafeD03545B24F5D6
CLONED-CONTRACT: AbstractContract {...}

Hi Samuel,
thanks for your quick response. I've added the return (see gist) but it didn't change anything. Using beta.37 always works, though.

Did you run my gist? Against which ethereum node?

Oh wait - while I was writing my response it finally finished. It just takes a magnitude longer. Is there something new like "resolve after 24 confirmations" or so?
edit: yes - it resolves exactly after 24 confirmations

Ok, we can close this issue.
When I use ganache UI instead of -cli it raises an exception with beta.37 but not with beta.48. This might cause beta.37 to resolve immediately (what I wanted).

TypeError: Cannot read property 'subscriptions' of undefined
    at /node_modules/ganache-core/lib/webSocketServer.js:102:47
    at process.nextTick (/node_modules/ganache-core/lib/provider.js:114:28)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Glad I saw this issue; I was using the latest version beta.52 and I wasn't getting a promise resolved. Downgraded to beta.48 and I got my promise.

I'm having this issue in beta.55 using ganache or ganache-cli. Is possible to resolve after just 1 confirmation?

Thanks for asking! @Pedro-vk
Yes, this is possible with the transactionConfirmationBlocks option of a Web3 module.

Thank you :+1: Is gonna be really helpful for me!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

baxy picture baxy  路  3Comments

praveengupta0895 picture praveengupta0895  路  3Comments

sundbry picture sundbry  路  3Comments

FradSer picture FradSer  路  3Comments

webersson picture webersson  路  3Comments