Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No receipt after contract deploy #2601

Closed
ghost opened this issue Mar 28, 2019 · 16 comments
Closed

No receipt after contract deploy #2601

ghost opened this issue Mar 28, 2019 · 16 comments
Labels
Bug Addressing a bug

Comments

@ghost
Copy link

ghost commented Mar 28, 2019

Description

After deploying a new contract I never receive a receipt object.

const deploy = { abi: [...], bytecode: '0x...' };

const web3 = new Web3 (window ['ethereum']);
const contract = new web3.eth.Contract (deploy.abi);

window ['ethereum'].enable()
    .then (accounts => {

        contract.deploy({
            data: deploy.bytecode,
            arguments: [...]
        })
        .send ({
            from: accounts [0]
        })
        .on ('error',           console.error)
        .on ('transactionHash', console.log)       /* this is working */
        .on ('receipt',         console.log);      /* this never gets executed */

    })
    .catch (console.error);

Expected behavior

Receiving a contract object containing the address of the new contract in .on ('receipt', ....

Actual behavior

Nothing happens (also no error).

On my node I can look up the contract address manually.
The contract gets created.

Versions

  • web3.js: 1.0.0-beta.51 (latest)
  • metamask: 6.3.0 (latest)
  • browser: Chromium
  • ethereum node: instance: Geth/v1.8.23-stable-c9427004/linux-amd64/go1.11.5
@ghost
Copy link
Author

ghost commented Mar 28, 2019

In addition: With web3.js: 1.0.0-beta.46 it's working fine and I get a receipt as well. All other versions after this one are not working.

@nivida
Copy link
Contributor

nivida commented Mar 28, 2019

You have to configure your module correctly for the development environment. I've updated and improved the transaction confirmation workflow in this release.

@nivida nivida added the support label Mar 28, 2019
@ghost
Copy link
Author

ghost commented Mar 28, 2019

Thank's for the quick reply.

You mean this options object?

const options = {
    defaultAccount: '0x0',
    defaultBlock: 'latest',
    defaultGas: 1,
    defaultGasPrice: 0,
    transactionBlockTimeout: 50,
    transactionConfirmationBlocks: 24,
    transactionPollingTimeout: 480,
    transactionSigner: new CustomTransactionSigner()
}

const web3 = new Web3(window ['ethereum'], options);

Are this values not calculated and set by metamask if you do a transaction? This is what they do for you, right? If not, can I just use this default values then?

@princesinha19
Copy link
Contributor

princesinha19 commented Mar 28, 2019

Yes @nivida. This issue is same as the issue #2577. Please check the .on('receipt') event. Why it's not generating the receipt.
I don't know, but it might be issue of Geth as it is working fine with Ganache. Also, after setting options it gets executed but doesn't produces transaction receipt. We only get methods, options etc in receipt.

@hbrs Check the issue #2577 and set the options correctly.

@ghost
Copy link
Author

ghost commented Mar 28, 2019

I changed my code to this below, but still don't get a receipt.

const options = {
    transactionConfirmationBlocks: 1,
    transactionBlockTimeout: 5,
    transactionPollingTimeout: 480
};

const web3 = new Web3 (window ['ethereum'], null, options);

@lucashenning
Copy link

+1 After updating to 1.0.0-beta.51 (latest), the .on('receipt', (txReceipt : TransactionReceipt) event is not triggered anymore. I tested this on Ganache, Quorum, and Ropsten. The confirmation and transactionHash events are triggered correctly.

  • web3.js: 1.0.0-beta.51 (latest)
  • Ganache: Version 2.0.0-beta.2 (2.0.0-beta.2.398)

@dileepfrog
Copy link

Most likely related, awaiting a call to web3.eth.sendSignedTransaction the Promise never resolves in 1.0.0-beta.51. It did resolve correctly on the receipt in 1.0.0-beta.50

@szerintedmi
Copy link

Same here. Here is a failing test to demonstrate the issue with sendTransaction on ganache

@szerintedmi
Copy link

szerintedmi commented Mar 29, 2019

not sure if it's related but it seems not to resolve nor reject on VM error either (running on ganache-cli version 6.4.1).
This test times out on await receipt which is executing a contract tx which reverts.

@ghost
Copy link
Author

ghost commented Apr 7, 2019

update: I tried it today with beta.52 (latest) again and still don't get a receipt.

@nivida
Copy link
Contributor

nivida commented May 2, 2019

@hbrs Thanks for answering here!:)

Did you configure the transaction confirmation workflow as documented in our documentation?

What kind of node are you using and which provider?

@JonahGroendal
Copy link

I tried with beta 55 and web3.eth.sendTransaction() is still not resolving and no receipt. I'm using Infura websocketprovider

@PaulRBerg
Copy link

PaulRBerg commented May 19, 2019

@nivida @JonahGroendal I can confirm that in beta 55 this issue is fixed when setting the options defined above, but I would kindly want to ask for additional information on the docs:

  • What are the default values of transactionConfirmationBlocks, transactionBlockTimeout and transactionPollingTimeout when web3 is and when it is not connected to the mainnet? I couldn't find this anywhere.
  • Why is this happening in the first place? Isn't it possible to set a default confirmation blocks number for any network but the mainnet so that the on("receipt") PromiEvent gets fired?

@PaulRBerg
Copy link

Also, another issue I have is with the synchrony between the receipt PromiEvent and the value returned by web3.eth.getTransactionReceipt. Even if the latter returns a non-null value for a given transaction hash, it can take up to 10 seconds and more for the former PromiEvent to be fired.

Is this related or should I open a new issue?

@JonahGroendal
Copy link

@PaulRBerg It's working for me now after initializing like this:
'''
new Web3(
new Web3.providers.WebsocketProvider("wss://kovan.infura.io/ws/v3"),
undefined,
{ transactionConfirmationBlocks: 1 }
)'''

@guix77
Copy link

guix77 commented May 28, 2019

Default value of transactionConfirmationBlocks is 24 by default: https://github.com/ethereum/web3.js/blob/5683436b1dae70fce72a2ff952736e687998fd7f/packages/web3-core/src/AbstractWeb3Module.js#L53

You might want to just wait or lower it. For those on local dev chains you want transactionConfirmationBlocks = 1 because blocks are not created after the one including the TX, so the receipt is never fired.

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

No branches or pull requests

8 participants