0

I'm in the process of verifying my contract on Etherscan. Etherscan asks for ABI-encoded constructor arguments during the verification process, though I was a bit silly and don't quite know what they are.

This is simplified reason why: deployer.deploy(Contract, Date.now()/1000|0 + 36000)

I set the constructor argument to be a function of the current time, though I'm not quite sure when exact time was in seconds. At the moment, I currently have the truffle-generated artifact with me.

How can I get access to the constructor when the contract was deployed? Is there something in the truffle artifact file that could help? Because I know the rough time of when I launched the program, could I potentially brute force contracts to find the same bytecode?

Any help would be greatly appreciated.

0

From a simple inspection truffle's artifacts do not include the constructor parameters. But it does include the contract's bytecode.

If you inspect the transaction that created the contract you will see the bytecode is incorporated as part of the transaction data with some extra bytes at the end, those extra bytes are the construction parameters encoded with ethereum abi.

For example the AugurToken contract https://etherscan.io/address/0xe94327d07fc17907b4db788e5adf2ed424addff6#code in the "Contract Creation Code" if you scroll to the end you will see the same content that is in "Constructor Arguments"

00000000000000000000000048c80f1f4d53d5951e5d5438b54cba84f29f32a5
0000000000000000000000000000000000000000000000000de0b6b3a7640000
000000000000000000000000e1e212c353f7a682693c198ba5ff85849f8300cc

For example the contract https://etherscan.io/address/0x50ce4b73320ee36e307c1551207fd8008f4f38eb#code was create at https://etherscan.io/tx/0xd7a4f8958704be82903ce9bd44a3770e110776bd20ddea672d43bc92d17b4977.

If you compare both the byte code in the code section and the data in the transaction the extra bytes are the parameters send to the constructor

000000000000000000000000000000000000000000000000000000005a72cfef
000000000000000000000000000000000000000000000000000000005ac09180
0000000000000000000000000000000000000000000000000000000000000258
00000000000000000000000000000000000000000000000d8d726b7177a80000
000000000000000000000000000000000000000000001a784379d99db4200000
00000000000000000000000021c6dadc34965da5fd102f68f3f83aea7f7b249f
  • If I'm not wrong, I think that the abi-encoded constructor arguments only show up in the bytecode on Etherscan once someone's verified it. – Nagaganesh Jaladanki Feb 5 '18 at 18:06
  • For instance, this is my contract and I can't find any of my constructor arguments within it (even hex encoded). etherscan.io/address/… – Nagaganesh Jaladanki Feb 5 '18 at 18:06
  • @NagaganeshJaladanki You are correct the bytecode+params is present in the transaction that created the contract. Check input data in etherscan.io/tx/…. – Ismael Feb 5 '18 at 19:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.