Verify through Foundry

SocialScan supports verifying smart contracts through Foundry, please refer to https://book.getfoundry.sh/reference/forge/forge-verify-contract for more information.

You must include the following args

contract_address

Your contract address to verify

contract_name

Your contract name to verify

compiler_version

Compiler version, e.g. v0.8.25+commit.b61c2a91

chain

Put your chain id (Not required)

verifier-url

verifier

Use "blockscout" or "etherscan"

etherscan-api-key

If you use "etherscan" as a verifier, you need to put a random string here

Example

# Compile your smart contract first
forge build

# Verify a flattened contract 
forge verify-contract <contract_address> <contract_name> \
--compiler-version <compiler_version> \
--flatten \
--verifier-url <api_host>/v1/explorer/command_api/contract \
--verifier blockscout

# Verify a contract with JSON standard input
forge verify-contract \
<contract_address> <contract_name> \
--watch \
--compiler-version <compiler_version> \
--constructor-args $(cast abi-encode "constructor(string,string)" "TEST" "ST2") \
--verifier-url <api_host>/v1/explorer/command_api/contract \
--verifier blockscout

# Verify a contract use "etherscan" verifier
forge verify-contract \
<contract_address> <contract_name> \
--chain <chain_id> \
--watch --etherscan-api-key test \
--verifier-url <api_host>/v1/explorer/command_api/contract \
--verifier etherscan

# Expected output
Start verifying contract `<contract_address>` deployed on <chain_name>

Submitting verification for [<contract_name>] <contract_address>.
Submitted contract for verification:
        Response: `Contract successfully verified`
        GUID: `a40a619266ea0d581e6373c52754e4a4ef6333bc8581b9d2a02d6174b3316f39`
        URL: <explorer_host>/address/<contract_address>
Contract verification status:
Response: `OK`
Details: `Pass - Verified`
Contract successfully verified

Deploying 2048 Game Contract on Monad Testnet with Foundry

This guide walks you through deploying and verifying a 2048 game smart contract on the Monad testnet using Foundry.

Prerequisites

Before starting, ensure you have:

  • Foundry installed

  • A wallet with Monad testnet coin

  • Your private key

  • Git installed on your system

Step 1: Clone the Repository

Step 2: Build the Contract

Compile the smart contract using Foundry's forge tool:

Expected output:

Step 3: Deploy the Contract

Deploy the compiled contract to Monad testnet:

Expected output:

Step 4: Verify the Contract

Verify your deployed contract on the Monad block explorer:

Command breakdown:

  • forge verify-contract: Foundry's contract verification command

  • contract_address: Your deployed contract address

  • src/Monad2048.sol:Monad2048: Path to source file and contract name

  • --chain 10143: Monad testnet chain ID

  • --verifier blockscout: Use Blockscout as the verification service

  • --verifier-url: API endpoint for Monad testnet verification

Expected output:

Verification Result

https://monad-testnet.socialscan.io/address/0x15cd4b493fc9d58c7f3be47693c99d51c93467b7#contract

Last updated

Was this helpful?