Accessing deployment blocknumber?

I'm trying to access the deployment block number for a proxy deployment. Given code like the following:

const deployment = await upgrades.deployProxy(Contract, { kind: "uups" });
await deployment.deployTransaction.wait(3);

Is there any way to get the deployment block in this same script?

Debugging deployment eg. console.log(deployment) gives me:

  deployTransaction: {
    hash: '0xc6a659bcc3a858a38c3224774128e376e13080f501a465d3496d94a5667dfc0f',
    type: 0,
    accessList: null,
    blockHash: null,
    blockNumber: null,
    transactionIndex: null,
    confirmations: 0,
    from: '0x93A5f58566D436Cae0711xxxxxxxxxxxxxxxxxxx',
    gasPrice: BigNumber { value: "8000000000" },
    gasLimit: BigNumber { value: "406736" },
    to: null,
    value: BigNumber { value: "0" },

I'd like to get blockNumber

Thanks in advance!

You can get the transaction receipt using the hash, then get the block number.

For example with Hardhat and Ethers:

  const deployment = await upgrades.deployProxy(Contract, { kind: "uups" });
  await deployment.deployed();

  const { provider } =;
  const txReceipt = await provider.send('eth_getTransactionReceipt', [deployment.deployTransaction.hash]);
  console.log("Block number: ", txReceipt.blockNumber); // block number in hex format

Worked perfectly. Thanks for the quick response!!

1 Like

@ericglau I recently upgraded my stack an the above is no longer working.

TypeError: Cannot read properties of undefined (reading 'hash')

Having trouble finding any updated documentation.

Thanks in advance.

This might be due to a change in ethers.js v6. Can you try deploymentTransaction() instead of deployTransaction?

Yup. it was a upgrade to ethers v6.