[Ethereum] Constructor Arguments for verification on Etherscan.io

constructorcontract-verification

I want to verify a contract on Etherscan.io, but I am not able to find the correct Constructor Arguments. I tried everything which is explained on StackExchange, but cannot get it to verify…

The contract address is 0x9b81b233235af9024f3cffa33e19de54eee31f44

I used compiler v. 0.4.16, NO optimization

Any help would be higly appreciated

 function TokenERC20(
        uint256 initialSupply,
        string tokenName,
        string tokenSymbol
    ) public {
        totalSupply = initialSupply * 10 ** uint256(decimals);  // Update total supply with the decimal amount
        balanceOf[msg.sender] = totalSupply;                // Give the creator all initial tokens
        name = tokenName;                                   // Set the name for display purposes
        symbol = tokenSymbol;                               // Set the symbol for display purposes
    }

Best Answer

The parameters for the constructor are appended to the contract. If you look at the "Input Data" in the contract creation transaction https://etherscan.io/tx/0x08e63522fb7a4e1a46ee35cfab7767ec98c5d727da897a9c8cfb7e27c15861a0 and scroll to the end your parameters are there.

000000000000000000000000000000000000000000000000000000003b9aca01
0000000000000000000000000000000000000000000000000000000000000060
00000000000000000000000000000000000000000000000000000000000000a0
0000000000000000000000000000000000000000000000000000000000000001
4b00000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000003
e282ad0000000000000000000000000000000000000000000000000000000000

This script will decode the block using the parameters from the constructor and recreate them to be sure

const abi = require('ethereumjs-abi');

function decodeTx() {
  const data = Buffer.from(`000000000000000000000000000000000000000000000000000000003b9aca01000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000014b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003e282ad0000000000000000000000000000000000000000000000000000000000`, 'hex');

  const decoded = abi.rawDecode(['uint256', 'string', 'string'], data);

  console.log(`Decoded: ${JSON.stringify(decoded, null, '  ')}`);

  const params = [
    '0x3b9aca01',
    'K',
    '₭'
  ];

  const encoded = abi.rawEncode(['uint256', 'string', 'string'], params);

  console.log(`Encoded: ${encoded.toString('hex')}`);
}

decodeTx();

The output is

Decoded: [ "3b9aca01", "K", "₭" ]

Encoded: 000000000000000000000000000000000000000000000000000000003b9aca01000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000014b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003e282ad0000000000000000000000000000000000000000000000000000000000

Related Topic