@integraledger/verify-cli
v0.2.2
Published
CLI tool for verifying smart contracts and registering them on the Integra marketplace
Maintainers
Readme
@integraledger/verify-cli
CLI tool for verifying smart contracts and registering them on the Integra marketplace.
Installation
# Run directly with npx (no installation required)
npx @integraledger/verify-cli <address> --chain <chainId>
# Or install globally
npm install -g @integraledger/verify-cliUsage
Basic Usage
Navigate to your Hardhat or Foundry project directory and run:
# Auto-detect framework and verify
npx @integra/verify-cli 0x1234567890abcdef1234567890abcdef12345678 --chain 1
# Specify a build-info file manually
npx @integra/verify-cli 0x1234... --chain 1 --build-info ./artifacts/build-info/abc123.json
# Specify the contract to verify
npx @integra/verify-cli 0x1234... --chain 1 --contract contracts/Token.sol:Token
# Include creation transaction hash
npx @integra/verify-cli 0x1234... --chain 1 --tx-hash 0xabcd...Options
| Option | Description |
|--------|-------------|
| -c, --chain <chainId> | Chain ID (required). E.g., 1 for Ethereum mainnet, 137 for Polygon |
| -b, --build-info <path> | Path to build-info JSON file. Auto-detected if not specified |
| -C, --contract <identifier> | Contract identifier. Interactive selection if not specified |
| -t, --tx-hash <hash> | Creation transaction hash (optional, improves matching) |
| --api-url <url> | Custom verification API URL |
| --ui-url <url> | Custom UI URL for marketplace registration |
| --no-browser | Don't open browser after verification |
Common Chain IDs
| Chain | ID | |-------|-----| | Ethereum Mainnet | 1 | | Ethereum Sepolia | 11155111 | | Polygon | 137 | | Arbitrum One | 42161 | | Optimism | 10 | | Base | 8453 |
How It Works
- Framework Detection: Automatically detects if you're using Hardhat or Foundry
- Artifact Discovery: Finds build-info files in the standard locations
- Contract Selection: If multiple contracts exist, prompts you to select one
- Verification: Submits the contract for verification
- Browser Handoff: Opens the Integra marketplace UI to complete registration
Example Session
$ npx @integra/verify-cli 0x1234...5678 --chain 1
🔐 Integra Verify CLI
✔ Detected hardhat project
📁 Using: artifacts/build-info/abc123def456.json
✔ Build-info loaded (15 sources, 8 contracts, compiler 0.8.19+commit.7dd6d404)
? Select contract to verify: (Use arrow keys)
❯ contracts/Token.sol:Token
contracts/Vault.sol:Vault
contracts/Helper.sol:Helper
📋 Verification Details:
Chain ID: 1
Address: 0x1234...5678
Contract: contracts/Token.sol:Token
Compiler: 0.8.19+commit.7dd6d404
✔ Verification submitted (Job ID: abc-123-def)
✔ Verification successful! 🎯 exact_match
🌐 Opening browser for marketplace registration...
https://verify.trustwithintegra.com/metadata?verificationId=abc-123-def&chainId=1&address=0x1234...5678
✓ Complete your registration in the browser.Programmatic Usage
You can also use the verification functions programmatically:
import {
detectFramework,
readBuildInfo,
extractStandardJson,
extractCompilerVersion,
submitVerification,
pollVerificationStatus,
} from '@integraledger/verify-cli';
// Detect framework
const detection = detectFramework();
console.log(detection.framework); // 'hardhat' or 'foundry'
// Read build-info
const buildInfo = readBuildInfo('./artifacts/build-info/xxx.json');
const stdJson = extractStandardJson(buildInfo);
const compiler = extractCompilerVersion(buildInfo);
// Submit verification
const { verificationId } = await submitVerification(
'https://api.trustwithintegra.com/v1/verify',
'1',
'0x1234...',
stdJson,
compiler,
'contracts/Token.sol:Token'
);
// Poll for completion
const status = await pollVerificationStatus(apiUrl, verificationId);
console.log(status.contract?.match); // 'exact_match' or 'match'Requirements
- Node.js 18+
- A compiled Hardhat or Foundry project (run
npx hardhat compileorforge buildfirst)
License
MIT
