ethereum / sourcify

Decentralized Solidity contract source code verification service
https://sourcify.dev
MIT License
782 stars 395 forks source link

Add NRG Testnet and Mainnet support #563

Closed zalam003 closed 2 years ago

zalam003 commented 3 years ago

Please add support for:

sourcify-chains.ts

"39797": {
        "supported": true,
        "monitored": false,
        "contractFetchAddress": "https://explorer.energi.network/" + BLOCKSCOUT_SUFFIX,
        "txRegex": getBlockscoutRegex()
    },
"49797": {
        "supported": true,
        "monitored": false,
        "contractFetchAddress": "https://explorer.test.energi.network/" + BLOCKSCOUT_SUFFIX,
        "txRegex": getBlockscoutRegex()
    },

constants.ts

export const CHAIN_OPTIONS = [
    {value: "mainnet", label: "Ethereum Mainnet", id: 1},
    {value: "ropsten", label: "Ropsten", id: 3},
    {value: "rinkeby", label: "Rinkeby", id: 4},
    {value: "kovan", label: "Kovan", id: 42},
    {value: "goerli", label: "Görli", id: 5},
    {value: "xdai", label: "xDai", id: 100},
    {value: "sokol", label: "Sokol", id: 77},
    {value: "binance smart chain mainnet", label: "Binance Smart Chain Mainnet", id: 56},
    {value: "binance smart chain testnet", label: "Binance Smart Chain Testnet", id: 97},
    {value: "energi mainnet", label: "Energi Mainnet", id: 39797},
    {value: "energi testnet", label: "Energi Testnet", id: 49797},
    {value: "matic mainnet", label: "Polygon (previously Matic)", id: 137},
    {value: "mumbai testnet", label: "Mumbai Testnet (Polygon/Matic)", id: 80001},
    {value: "celo mainnet", label: "Celo Mainnet", id: 42220},
    {value: "alfajores testnet", label: "Celo Alfajores Testnet", id: 44787},
    {value: "baklava testnet", label: "Celo Baklava Testnet", id: 62320},
    {value: "avalanche testnet", label: "Avalanche Fuji Testnet", id: 43113},
    {value: "avalanche mainnet", label: "Avalanche Mainnet", id: 43114},
    {value: "arbitrum one", label: "Arbitrum Mainnet", id: 42161},
    {value: "arbitrum rinkeby", label: "Arbitrum Testnet Rinkeby", id: 421611},
    {value: "telos mainnet", label: "Telos EVM Mainnet", id: 40},
    {value: "telos testnet", label: "Telos EVM Testnet", id: 41},
    {value: "ubiq", label: "Ubiq", id: 8},
    {value: "oneledger testnet", label: "OneLedger Testnet Frankenstein", id: 4216137055},
    {value: "syscoin testnet", label: "Syscoin Tanenbaum Testnet", id: 5700},
];

0xA55F26319462355474A9F2c8790860776a329aA4 - Energi mainnet source code for WNRG

metadata.txt

Testnet token address for wnrg: 0x184F7b12f29d675f34ff816528ADBfd0E0501Ad4

View in Huly HI-249

kuzdogan commented 2 years ago

Hello

We were able to look into this just now, sorry for the delay.

I was unfortunately not able to verify the contracts. The deployed and recompiled bytecode don't match on both cases. I am giving the source code provided and the metadata for ======= contracts/wnrg.sol:WNRGGovernedERC20Proxy ======= which seems to be the main contract per blockexplorer: https://explorer.test.energi.network/address/0x184F7b12f29d675f34ff816528ADBfd0E0501Ad4/contracts.

I see the evm settings on the blockexplorer are different than in the provided metadata. evmVersion, optimization etc. Is this metadata accurately the deployed one or is it generated later? Ideally you should provide the one when deployed or try recompiling and generating the metadata with correct evm settings.

zalam003 commented 2 years ago

@kuzdogan The metadata provided is for mainnet. https://explorer.energi.network/address/0xA55F26319462355474A9F2c8790860776a329aA4/contracts

If you need testnet data, let me know. I only provided a testnet address per request.

kuzdogan commented 2 years ago

As I said, both mainnet and testnet contracts fail to verify. I.e. the contract provided does not compile to the same bytecode as both 0xA55F26319462355474A9F2c8790860776a329aA4 on mainnet and 0x184F7b12f29d675f34ff816528ADBfd0E0501Ad4 for testnet. The reason is likely the compilation settings are not matching. I can see they differ in the metadata and on the blockexplorer. For instance optimizer marked disabled on metadata and enabled on blockexplorer.

Please either compile the contract with the matching evm settings and provide that metadata, or provide another test contract (for both mainnet and testnet).

zalam003 commented 2 years ago

@kuzdogan Here are updated files for mainnet. Let me know if these works:

I used solc --metadata --metadata-literal flatten_sc.sol to generate the metadata.txt file

kuzdogan commented 2 years ago

Sorry but this doesn't work either. I am getting the same error.

zalam003 commented 2 years ago

@kuzdogan There is an issue with the token I gave you. I would appreciate if you could try this 🤞

kuzdogan commented 2 years ago

The verification fails + it is not possible to get full matches with flattened source files anyway. Closing. Please follow the instructions in docs https://docs.sourcify.dev/docs/chain-support/