bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 52쪽 중 16쪽
he FRC42 hash of `GranularityExported`, it must be updated and redeployed.
* If a contract sends funds to actors that are non-native, Ethereum, or EVM smart contract accounts, it [must use the `call_actor` precompile](#contracts-sending-funds-to-specific-actors).
* If a contract is interacting with built-in actors, it must use the maintained `filecoin-solidity-api` package and the current `contracts/v0.8` imports.
### All contracts
All contracts must do the following:
#### **Accept both `DAG_CBOR (0x71)` and `CBOR (0x51)` in inputs and treat them identically**
Smart contracts should accept both `DAG_CBOR (0x71)` and `CBOR (0x51)` in inputs and treat them identically. Specifically:
* Treat `DAG_CBOR` and `CBOR` as equivalent when returned from the `call_actor` precompile.
* Treat `DAG_CBOR` and `CBOR` as equivalent when received as a parameter to `handle_filecoin_method`.
#### **Use CBOR (0x51) in outputs**
Smart contracts should use `CBOR (0x51)` in outputs. Specifically:
* Always pass `CBOR` to the `call_actor` precompile. `DAG_CBOR` is currently forbidden.
* Always return `CBOR` from `handle_filecoin_method`. `DAG_CBOR` is currently forbidden.
### Contracts using `GranularityExported` hash
The `GranularityExported` method in the Datacap actor was renamed to `Granularity`, so any contracts which use the FRC42 hash of `GranularityExported` (`953701584`) must update the hash to `3936767397` and redeploy.
### Contracts sending funds to specific actors
Any contracts sending funds to actors that are not native accounts (`f1` or `f3` addresses), Ethereum accounts, or EVM smart contracts must now use the `call_actor` precompile. **Solidity’s transfer function will no longer work as that will attempt to invoke the target actor as an EVM contract**.
### Contracts interacting with built-in actors
All contracts interacting with built-in actors must use the maintained [`filecoin-solidity-api` package and its `contracts/v0.8` imports](https://github.com/filecoin-project/filecoin-solidity/tree/master/contracts/v0.8). The IPLD codec used in the `handle_filecoin_method` solidity entrypoint and the `call_actor` should now be `CBOR (0x51)`, not `DAG_CBOR (0x71)`, as previously used. The underlying encoding (i.e. the payload bytes) are the same, but the codec numbers are now different. `DAG_CBOR` support will be re-enabled in the future but the usage of the codec implies additional runtime guarantees that have not yet been implemented.
## Contract Verification
When deploying contracts to mainnet, it is important to verify your contracts to improve transparency, security and trustlessness of the network. The process of verifying your contract involves recompiling your contract’s source code to ensure that the produced bytecode matches the bytecode that is already live on the network since it was deployed.
It is highly recommended for all FVM smart contracts to complete the verification process, soon after deployment.
Developers can easily do so through the following block explorers:
* [Filfox contract verifier](https://filfox.info/en/contract/)
* [Beryx contract verifier](https://beryx.zondax.ch/contract_verifier)
You can find this tutorial in the [FEVM ERC-20 Quickstart](/build-on-filecoin/developing-contracts/erc-20-quickstart).
[Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/build/developing-contracts/best-practices)
# Support
If you need assistance while exploring the Filecoin virtual machine, you can reach out to the team and community using the links on this page.
## Slack
Like many other distributed teams, the Filecoin developer relations, led by the [FIL Builders](https://fil.builders/) team, works mostly on Slack and Discord. You can access the Filecoin Project Slack at [Filecoin Project Slack](https://filecoinproject.slack.com/ssb/redirect) and join the Discord at <https://discord.com/invite/filecoin>.
The following Slack channels are most relevant for Filecoin builders:
* [`#fil-builders`](https://filecoinproject.slack.com/archives/CRK2LKYHW) for building solutions on FVM and Filecoin
* [`#fil-fvm-dev`](https://filecoinproject.slack.com/archives/C029MT4PQB1) for development of the FVM
* [`#fvm-docs`](https://filecoinproject.slack.com/archives/C03MDFERKMJ) for FVM documentation
## Forum
If you just need a general pointer or looking for technical FAQs, you can head over to the [FVM GitHub Discussion tab](https://github.com/filecoin-project/community/discussions/categories/developers).
## Developer grants
The [Filecoin Grant Platform](https://github.com/filecoin-project/devgrants) connects grant makers with builders and researchers in the Filecoin community. Whether you represent a foundation that wants to move the space forward, a company looking to accelerate development on the features your application needs, or a developer team itching to hack on the FVM, [take a look at the supported grant types and available opportunities →](https://github.com/filecoin-project/devgrants)
[Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/build/developing-contracts/support)
# Contract verification
Verify smart contracts on Filecoin using development frameworks or block explorer interfaces.
Contract verification lets users inspect the source code of deployed contracts and confirm they work as intended. This section covers how to verify contracts through both development tools and web interfaces.
## Table of contents
* [Verify using Hardhat](/build-on-filecoin/verification/hardhat) — automate verification from your Hardhat development environment
* [Verify using Foundry](/build-on-filecoin/verification/foundry) — automate verification from your Foundry development environment
* [Verify using Blockscout](/build-on-filecoin/verification/blockscout) — verify contracts through the Blockscout web interface
* [Verify using Filfox](/build-on-filecoin/verification/filfox) — verify contracts through the Filfox web interface
# Verify using Hardhat
Learn how to verify smart contracts on the Filecoin network using Hardhat with various verification services including Blockscout, Sourcify, and Filfox.
This guide shows you how to verify your smart contracts using Hardhat on the Filecoin network.
## Prerequisites
* A Hardhat project set up for Filecoin development. If you don't have one, start with the [FEVM Hardhat Kit](/build-on-filecoin/development-frameworks/hardhat).
* The `@nomicfoundation/hardhat-verify` plugin installed and imported in your Hardhat config.
* A deployed contract address on Filecoin mainnet or Calibration testnet.
* The same Solidity version, optimizer settings, and source tree that were used for deployment.
* Contract constructor arguments, if the contract was deployed with any.
* A Filecoin RPC URL for the target network. Filecoin mainnet uses chain ID `314`; Calibration testnet uses chain ID `314159`.
## Verification Methods
### Blockscout Verification
Blockscout is a popular blockchain explorer that supports contract verification. The FEVM Hardhat Kit already includes the Filecoin networks and verifier configuration. In another Hardhat v2 project, add equivalent configuration to `hardhat.config.ts`:
```typescript
import "@nomicfoundation/hardhat-verify";
import { HardhatUserConfig } from "hardhat/config";
const config: HardhatUserConfig = {
solidity: {
version: "0.8.23",
settings: {
optimizer: {
enabled: true,
runs: 1000,
},
},
},
networks: {
filecoin: {
url: process.env.FILECOIN_RPC_URL ?? "https://api.node.glif.io/rpc/v1",
chainId: 314,
},
calibration: {
url: process.env.CALIBRATION_RPC_URL ?? "https://api.calibration.node.glif.io/rpc/v1",
chainId: 314159,
},
},
etherscan: {
apiKey: {
filecoin: "empty",
calibration: "empty",
},
customChains: [
{
network: "filecoin",
chainId: 314,
urls: {
apiURL: "https://filecoin.blockscout.com/api",
browserURL: "https://filecoin.blockscout.com",
},
},
{
network: "calibration",
chainId: 314159,
urls: {
apiURL: "https://filecoin-testnet.blockscout.com/api",
browserURL: "https://filecoin-testnet.blockscout.com",
},
},
],
}
};
export default config;
```
Set RPC URLs in your shell or `.env` if you do not want to use the example defaults:
```bash
export FILECOIN_RPC_URL=https://api.node.glif.io/rpc/v1
export CALIBRATION_RPC_URL=https://api.calibration.node.glif.io/rpc/v1
```
Compile with the same settings used for deployment, then verify the deployed address. Put constructor arguments after the address and omit them if the constructor had no arguments.
**Verify on Filecoin mainnet:**
```bash
npx hardhat compile
npx hardhat verify --network filecoin 0xYourContractAddress "constructor arg 1"
```
**Verify on Calibration testnet:**
```bash
npx hardhat compile
npx hardhat verify --network calibration 0xYourContractAddress "constructor arg 1"
```
If Hardhat cannot infer which local contract matches the deployed bytecode, pass the fully qualified contract name:
```bash
npx hardhat verify \
--network calibration \
--contract contracts/MyContract.sol:MyContract \
0xYourContractAddress \
"constructor arg 1"
```
### Sourcify Verification
Sourcify provides decentralized contract verification. Include the Blockscout configuration above and add the following Sourcify configuration:
```typescript
const config: HardhatUserConfig = {
sourcify: {
enabled: true, // verifies both on Sourcify and on Blockscout
apiUrl: "https://sourcify.dev/server",
browserUrl: "https://repo.sourcify.dev",
},
};
export default config;
```
This configuration enables dual verification on both Sourcify and Blockscout when running the `npx hardhat verify` task.
If Blockscout verification is also enabled, keep passing constructor arguments when the deployed constructor required them.
For more information, see the [Sourcify documentation](https://docs.sourcify.dev/docs/how-to-verify/).
### Filfox Verification
Filfox is the native Filecoin explorer with dedicated verification support.
**Installation:**
Install the `@fil-b/filfox-verifier` package into your Hardhat project. The FEVM Hardhat Kit already includes this package.
```bash
npm install --save-dev @fil-b/filfox-verifier
```
**Configuration:** Import the plugin in your Hardhat configuration file. This will add the `verifyfilfox` task into your Hardhat project!
```javascript
// hardhat.config.js
require("@fil-b/filfox-verifier/hardhat");
// or in hardhat.config.ts
import "@fil-b/filfox-verifier/hardhat";
```
**Usage:**
```bash
# Verify on Filecoin mainnet
npx hardhat verifyfilfox --address 0xYourContractAddress --network filecoin
# Verify on Calibration testnet
npx hardhat verifyfilfox --address 0xYourContractAddress --network calibration
```
The Filfox Hardhat task requires Node.js 20 or later and a compiled Hardhat project. The verifier can discover supported Hardhat deployment artifacts, including `hardhat-deploy`, Ignition, and standard Hardhat artifacts.
For detailed information, see the [@fil-b/filfox-verifier documentation](https://www.npmjs.com/package/@fil-b/filfox-verifier).
# Verify using Foundry
Learn how to verify smart contracts on the Filecoin network using Foundry with various verification services including Blockscout, Sourcify, and Filfox.
This guide shows you how to verify your smart contracts using Foundry on the Filecoin network.
## Prerequisites
* A Foundry project set up for Filecoin development. If you don't have one, start with the [FEVM Foundry Kit](/build-on-filecoin/development-frameworks/foundry).
* Foundry installed with `forge` and `cast` available in your `PATH`.
* A deployed contract address on Filecoin mainnet or Calibration testnet.
* The same source tree, compiler version, optimizer settings, and `foundry.toml` settings that were used for deployment.
* Contract constructor arguments, if the contract was deployed with any.
* A Filecoin RPC URL for the target network. Filecoin mainnet uses chain ID `314`; Calibration testnet uses chain ID `314159`.
## Verification Methods
Set RPC URLs in your shell before running the examples:
```bash
export FILECOIN_RPC_URL=https://api.node.glif.io/rpc/v1
export CALIBRATION_RPC_URL=https://api.calibration.node.glif.io/rpc/v1
```
### Blockscout Verification
Blockscout is a popular blockchain explorer that supports contract verification.
**Verify on Calibration testnet:**
```bash
forge verify-contract \
--rpc-url "$CALIBRATION_RPC_URL" \
--chain 314159 \
--verifier blockscout \
--verifier-url "https://filecoin-testnet.blockscout.com/api/" \
0xYourContractAddress \
src/MyContract.sol:MyContract
```
**Verify on Filecoin mainnet:**
```bash
forge verify-contract \
--rpc-url "$FILECOIN_RPC_URL" \
--chain 314 \
--verifier blockscout \
--verifier-url "https://filecoin.blockscout.com/api/" \
0xYourContractAddress \
src/MyContract.sol:MyContract
```
For constructors, pass ABI-encoded constructor arguments. The constructor signature and values must match the deployment:
```bash
CONSTRUCTOR_ARGS=$(cast abi-encode "constructor(string,string)" "MyToken" "MYT")
forge verify-contract \
--rpc-url "$CALIBRATION_RPC_URL" \
--chain 314159 \
--verifier blockscout \
--verifier-url "https://filecoin-testnet.blockscout.com/api/" \
--constructor-args "$CONSTRUCTOR_ARGS" \
0xYourContractAddress \
src/MyToken.sol:MyToken
```
If Blockscout reports that the contract is already verified while you are retrying the same address, add `--force --skip-is-verified-check`.
### Sourcify Verification
Sourcify provides decentralized contract verification.
**Verify on Filecoin mainnet:**
```bash
forge verify-contract \
--rpc-url "$FILECOIN_RPC_URL" \
--chain 314 \
--verifier sourcify \
--verifier-url https://sourcify.dev/server/ \
--guess-constructor-args \
0xYourContractAddress \
src/MyToken.sol:MyToken
```
**Verify on Calibration testnet:**
```bash
forge verify-contract \
--rpc-url "$CALIBRATION_RPC_URL" \
--chain 314159 \
--verifier sourcify \
--verifier-url https://sourcify.dev/server/ \
--guess-constructor-args \
0xYourContractAddress \
src/MyToken.sol:MyToken
```
For more information, see the [Sourcify documentation](https://docs.sourcify.dev/docs/how-to-verify/).
### Filfox Verification
Filfox is the native Filecoin explorer with dedicated verification support.
**Installation:**
```bash
npm install --save-dev @fil-b/filfox-verifier
```
**Usage:**
```bash
npx filfox-verifier forge <address> <contract-path> --chain <chainId>
```
**Examples:**
```bash
# Verify on Filecoin mainnet
npx filfox-verifier forge 0xYourContractAddress src/MyContract.sol:MyContract --chain 314
# Verify on Calibration testnet
npx filfox-verifier forge 0xYourContractAddress src/MyContract.sol:MyContract --chain 314159
```
The Filfox verifier requires Node.js 20 or later and a Foundry project with `foundry.toml`. It runs `forge build` and extracts the metadata needed for the Filfox verification request.
For detailed information, see the [@fil-b/filfox-verifier documentation](https://www.npmjs.com/package/@fil-b/filfox-verifier).
# Verify using Blockscout
Step-by-step guide for verifying smart contracts on the Filecoin network using the Blockscout explorer's web interface.
The following guide walks you through the process of contract verification using the [Blockscout](https://filecoin.blockscout.com/) explorer.
## Prerequisites
* A deployed smart contract on Filecoin mainnet or Calibration testnet
* Your contract source code, either as a flattened `.sol` file or the same source files and metadata used at compile time
* The deployed contract address
* The Solidity compiler version used for deployment
* The license, optimization settings, optimizer runs, EVM version, and `viaIR` setting used for deployment
* Constructor arguments, if the contract was deployed with any
## Step-by-Step Verification Process
### Step 1: Prepare Your Contract Source Code
1. **Open Remix IDE** if you are using Blockscout's single-file Solidity verification method:

2. **Flatten your contract:**
* In the **File Explorer** sidebar, under **contracts**, right-click on your contract
* Select **Flatten** from the menu
* This creates a `<contract-name>_flattened.sol` file with all dependencies included
3. **Verify contract details:**
* Ensure the license and Solidity version match your original contract
* Click **Save** to save the flattened contract
4. **Download the flattened contract:**
* Right-click on `<contract-name>_flattened.sol`
* Select **Download** to save the file locally
5. **Gather required information:**
* Contract deployment address
* Contract license type (optional)
* Solidity compiler version used for deployment
* Optimization settings, including enabled/disabled and runs count
* EVM version and `viaIR` setting, if your deployment used non-default values
* ABI-encoded constructor arguments, if your contract constructor used arguments
### Step 2: Submit for Verification
6. **Access Blockscout verification page:**
* For Filecoin mainnet, navigate to [Filecoin Blockscout Contract Verification](https://filecoin.blockscout.com/contract-verification). Mainnet uses chain ID `314`.
* For Calibration testnet, navigate to [Calibration Blockscout Contract Verification](https://filecoin-testnet.blockscout.com/contract-verification). Calibration uses chain ID `314159`.
7. **Fill in contract information:**
* Enter your contract's deployment address
* Select the appropriate license type (optional)
* Choose verification method: `Solidity (Single file)`
* Select the compiler version used for deployment
* Paste the source code from your `<contract-name>_flattened.sol` file
* Configure the `Optimization enabled` checkbox to match your deployment settings
* Enter optimizer runs, constructor arguments, and any advanced compiler settings if the form prompts for them

8. **Submit for verification:**
* Click **Verify & Publish** to submit your contract
### Step 3: Verification Complete
Upon successful verification, Blockscout will display a success message and redirect you to your verified contract dashboard where you can view the source code and interact with your contract.

# Verify using Filfox
Step-by-step guide for verifying smart contracts on the Filecoin network using the Filfox explorer's web interface.
The following guide walks you through the process of contract verification using the [Filfox Contract Verification](https://filfox.info/en/contract) page.
## Prerequisites
* A deployed smart contract on Filecoin mainnet or Calibration testnet
* Your contract source code, either as a flattened `.sol` file or the source files requested by the Filfox form
* The deployed contract address
* The Solidity compiler version used for deployment
* The license, optimization settings, optimizer runs, EVM version, and `viaIR` setting used for deployment
* Constructor arguments, if the contract was deployed with any and the form prompts for them
## Step-by-Step Verification Process
### Step 1: Prepare Your Contract Source Code
1. **Open Remix IDE** if you are preparing a flat프로젝트로 돌아가기