Contract Verification

Verify smart contracts inside a Fork

Verifying a contract means making its source code available in that Fork and the compiler settings you used. If you want to delete the source code, delete the associated Fork.

For contracts that have been verified, the simulated transactions can be debugged using the Debug Transaction feature of Phalcon Explorer.

The instructions on how to get the API Key, Fork ID, RPC_ID, Project ID, and FORK_RPC can be found in this document.

We use API_KEY, FORK_ID, RPC_ID, PROJECT_ID, and FORK_RPCin the following to denote the concrete value.

Hardhat

Verifying a contract in Fork is similar to verifying it on Etherscan. Read this manual on Hardhat on contract verification on Etherscan.

You need to change the configuration to verify a contract on Phalcon Fo

module.exports = {
  networks: {
    phalcon: {
      //The Fork RPC URL
      url: "[FORK_URL]"
      accounts: ['private_key']
    }
  },
  etherscan: {
    apiKey: {
      phalcon: "[API_KEY]"
    },
    customChains: [
      {
        network: "phalcon",
        chainId: 1,
        urls: {
          apiURL: "https://api.phalcon.blocksec.com/api/[FORK_RPC_ID]",
          browserURL: "https://app.blocksec.com/fork/scan/[FORK_ID]"
        }
      }
    ]
  },
  solidity: "0.8.17",
};

Then, use the following command to verify the deployed contract.

npx hardhat verify --network phalcon <deployed contract address>  <constructor parameters>

If you have not deployed your contract, use the following command to deploy your contract first.

Copy

npx hardhat run scripts/deploy.ts --network phalcon

Foundry

In Foundry, you can use the verify-contract for verification. Please refer to the document on Foundry.

forge verify-contract \
    --chain-id 1 \
    --num-of-optimizations 200 \
    --watch \
    --verifier-url 'https://api.phalcon.xyz/api/[RPC_ID]'\
    <the_contract_address> \
    <the_contract_code_path> \
    --etherscan-api-key [API_KEY]
  • the_contract_address: The contract address

  • the_contract_code_path: The path of the local contract code, e.g., src/MyToken.sol:MyToken.

The verification process is showing in the terminal.

forge verify-contract --chain-id 1 --num-of-optimizations 200 --watch --verifier-url 'https://api.phalcon.blocksec.com/api/[RPC_ID]' 0x3bd7eFCdd52Fe1E4329CA5D2a86F4c9224Fb27DD 'src/Contract.sol:Contract' --etherscan-api-key [API_KEY]

Start verifying contract `0x3bd7efcdd52fe1e4329ca5d2a86f4c9224fb27dd` deployed on mainnet

Submitting verification for [src/Contract.sol:Contract] "0x3bd7eFCdd52Fe1E4329CA5D2a86F4c9224Fb27DD".
Submitted contract for verification:
	Response: `OK`
	GUID: `ciox2qu87u53h0mdz0vhfcztximzhitkmxkk7gyx8zq1r97lkm`
	URL:
        https://etherscan.io/address/0x3bd7efcdd52fe1e4329ca5d2a86f4c9224fb27dd
Contract verification status:
Response: `OK`
Details: `Pass - Verified`
Contract successfully verified

Truffle

Please refer this document for how to verify the contract using Truffle.

Phalcon Fork provides Etherscan's compatible APIs. One convenient way is to add the Phalcon Fork into verify section of a network.

networks: {
    mainnet: {
      provider: () => new HDWalletProvider([privateKey], [FORK_RPC]),
      network_id: "*", // Match any network id
      gas: 5500000, // Gas limit
      confirmations: 0,
      timeoutBlocks: 200,
      skipDryRun: true,
      verify: {
        apiUrl: 'https://api.phalcon.blocksec.com/api/[RPC_ID]',
        apiKey: '[API_KEY]'
        explorerUrl: 'https://app.blocksec.com/fork/scan/[FORK_ID]/',
      },
    },
}
#truffle run verify YOUR_CONTRACT --network mainnet

Note that the previous configuration is just an example. Since our API is Etherscan compatible, please refer to the development framework document for more information on contract verification.

Verified Contracts

Detailed information on the verified contracts is shown in the Contracts of the Phalcon Fork Details and inside Fork Scan.

Last updated