Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Documentation: contract.deploy.estimateGas arguments and return type incorrect #2543

Closed
ghost opened this issue Mar 20, 2019 · 4 comments
Closed
Labels
Bug Addressing a bug

Comments

@ghost
Copy link

ghost commented Mar 20, 2019

Description

If you want to estimate the gas of an contract you need to pass an callback to the function according to the documentation: https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#deploy.

But this is not working. The function returns a promise instead.

Expected behavior

Documentation says:

// Gas estimation
myContract.deploy({
    data: '0x12345...',
    arguments: [123, 'My String']
})
.estimateGas((err, gas) => {
    console.log(gas);
});

Actual behavior

estimateGas returns a promise and doesn't accept a callback. The following code is working:

myContract.deploy ({
    data: myBytecode,
    arguments: ['arg1']
})
.estimateGas ()
.then (console.log);

Error Logs

Uncaught (in promise) DOMException: Failed to execute 'postMessage' on 'Window': (e, g) => console.log (g) could not be cloned.

Versions

  • web3.js: web3.beta.46
  • browser: Chromium
@nivida
Copy link
Contributor

nivida commented Mar 20, 2019

Does this error still occur with the latest version of Web3.js? (1.0.0-beta.50)

@ghost
Copy link
Author

ghost commented Mar 21, 2019

@nivida I tried it today with 1.0.0-beta.50 and got the same behaviour.

@nivida nivida added Bug Addressing a bug Discussion and removed more information needed labels Mar 25, 2019
@nivida
Copy link
Contributor

nivida commented Mar 25, 2019

We have planned to remove the callback support until the stable release. Any further discussion about the callback support can be held here: #2224

@nivida
Copy link
Contributor

nivida commented May 2, 2019

The reason for the closing of this issue is explained in the referenced PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Addressing a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant