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

getCode in checkForContractAddress fails when block hasn't been mined, causing bad state #1275

Closed
HarryR opened this issue Jan 5, 2018 · 1 comment

Comments

@HarryR
Copy link

HarryR commented Jan 5, 2018

https://github.com/ethereum/web3.js/blob/develop/lib/web3/contract.js#L122

When deploying using Truffle the checkForContractAddress method in Web3 keeps throwing the error "The contract code couldn't be stored..." etc. The contract code is being stored, the transaction is getting mined, but the logic in checkForContractAddress is causing it to think it failed when it hasn't.

I'm using latest Parity on Kovan.

I solved this by specifying the "Default block parameter" to pending, instead of the default latest, e.g.:

contract._eth.getCode(receipt.contractAddress, 'pending', function(e, code){

The problem is that the transaction receipt is being returned, but then the getCode call fails because the transaction hasn't been mined yet. When I add pending to getCode this piece of code works fine.

I don't know if this is specific to Kovan, or Parity, or if adding pending will cause other problems.

I can submit a pull request for this change if you want, or you can tell me things which need to be checked.

Either way - this bug is preventing me from deploying contracts with Truffle. 👿 👿 👿 It works fine with testrpc/ganache though, but only because that has instamine.

@frozeman
Copy link
Contributor

This is because parity is returning receipts, even if the tx is not mined, which is different to geth. i fixed it in develop just now, please use this for now.

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

No branches or pull requests

2 participants