Web3js – How to Retrieve Constructor Arguments Used During Contract Deployment

constructorcontract-deploymenttransactionsweb3js

I know how to extract the constructor arguments out of the transaction object returned from a contract-deployment operation.

It is explain in web3.js official documentation here.

But this is not an issue of course, because if I am the one deploying the contract, then I obviously know the constructor arguments beforehand.

I am interested in retrieving the constructor arguments of an already deployed contract, i.e., the constructor arguments used during the deployment of that contract (by someone else).

I have the following at my disposal:

  • The address of the deployed contract
  • The byte-code of the deployed contract
  • The contract-deployment's transaction hash

Can any of the above help me retrieving the constructor arguments of an already deployed contract?

Thank you!

Best Answer

You can get them on Etherscan for any contract, see here for Example. It will take some research about RLP encoding to decode everything into readable text though.

Related Topic