Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arc Contract Verification Example

A minimal Hardhat project demonstrating how to deploy and verify a Solidity smart contract on ArcScan, the block explorer for the Arc testnet.

Project Structure

contracts/HelloARC.sol    — the contract
scripts/deploy.js         — deployment script
gw.js                     — utility to generate a fresh wallet
hardhat.config.js         — Hardhat config pointing at Arc testnet
.env                      — private key and RPC URL (never commit this)

Setup

1. Install dependencies

npm install

2. Configure environment

Create a .env file in the project root (one already exists as a template):

PRIVATE_KEY=0x<your-private-key>
ARC_RPC_URL=https://rpc.testnet.arc.network

To generate a fresh wallet:

node gw.js

Copy the printed private key into .env. Then fund the address with testnet USDC from the Arc faucet before deploying.


Deploy

npx hardhat run scripts/deploy.js --network arcTestnet

The output will look like:

Deploying HelloARC to ARC Testnet...
Deployer: 0xYourAddress
Contract deployed to: 0xDeployedContractAddress
ArcScan: https://testnet.arcscan.app/address/0xDeployedContractAddress

Save the contract address — you will need it for verification.


Flatten the Source

ArcScan's manual verification form requires a single self-contained source file. Hardhat's flatten command merges all imports into one file and deduplicates SPDX-License-Identifier headers:

npx hardhat flatten contracts/HelloARC.sol > HelloARC_flat.sol

The flattened file is already included in this repo as HelloARC_flat.sol.


Verify on ArcScan

Open the contract page on ArcScan:

https://testnet.arcscan.app/address/<your-contract-address>

Click ContractVerify and Publish, then fill in the form as follows.

Verification Form Fields

Field Value Where to find it
Contract Address 0x... (your deployed address) Printed by deploy.js at deploy time
Contract Name HelloARC Must match the contract name in HelloARC.sol
Compiler Version v0.8.20+commit.a1b79de6 hardhat.config.jssolidity.version
EVM Version paris hardhat.config.jssettings.evmVersion
Optimization Enabled Yes hardhat.config.jssettings.optimizer.enabled
Optimization Runs 200 hardhat.config.jssettings.optimizer.runs
Source Code (paste full contents of HelloARC_flat.sol) Generated by the flatten command above
Constructor Arguments (ABI-encoded form of "Hello, ARC!") See note below

Constructor Arguments

HelloARC takes one string argument. When deployed via deploy.js, it is called with "Hello, ARC!". ArcScan expects this ABI-encoded as a hex string (without 0x):

0000000000000000000000000000000000000000000000000000000000000020
000000000000000000000000000000000000000000000000000000000000000b
48656c6c6f2c204152432100000000000000000000000000000000000000000

You can generate this for any value using ethers:

const { ethers } = require("ethers");
const encoded = ethers.AbiCoder.defaultAbiCoder().encode(["string"], ["Hello, ARC!"]);
console.log(encoded.slice(2)); // strip leading 0x

If you deployed with a different message, re-encode with that string.

Submit

Click Verify and Publish. If the bytecode matches, ArcScan will mark the contract as verified and display the source code, ABI, and read/write interface on the contract page.


Compiler Settings Reference

These are the exact settings used to compile HelloARC.sol. They must match what you enter in the verification form.

// hardhat.config.js
solidity: {
  version: '0.8.20',
  settings: {
    optimizer: { enabled: true, runs: 200 },
    evmVersion: 'paris',
  },
},

About

How to deploy and verify a Solidity smart contract on ARC Testnet using Hardhat and ArcScan

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages