bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 52쪽 중 13쪽
omething like `0x11F... (5 ether)`. This value is 5 `tFIL`, but Remix doesn’t support the Filecoin network, so it doesn’t understand what `tFIL` is. This isn’t a problem; it’s just a little quirk of using Remix.
7. Under the **Contract** dropdown, ensure the contract you created is selected.
8. Click **Deploy**.
9. MetaMask will open a window and ask you to confirm the transaction. Scroll down and click **Confirm** to have MetaMask deploy the contract. If you’re deploying to mainnet, we advise you to [adjust your gas fees](#adjusting-your-gas-fees) for a cheaper deployment.
10. Back in Remix, a message at the bottom of the screen shows that the creation of your token is pending.
11. Wait around 90 seconds for the deployment to complete.
On the Filecoin network, a new set of blocks, also called a tipset, is created every thirty seconds. When deploying a contract, the transaction needs to be received by the network, and then the network needs to confirm the contract. This process takes around one to two tipsets to process – or around 60 to 90 seconds.
## Use your contract
Now that we’ve compiled and deployed the contract, it’s time to actually interact with it!
### Mint your tokens
Let’s call a method within the deployed contract to mint some tokens.
1. Back in Remix, open the **Deployed Contracts** dropdown, within the **Deploy** sidebar tab.
2. Expand the `mint` method. You must fill in two fields here: `to` and `amount`.
3. The `to` field specifies which address you want these initial tokens sent to. Open MetaMask, copy your address, and paste it into this field.
4. The `amount` field expects the token’s smallest unit, not a `FIL` amount. The OpenZeppelin ERC-20 template uses 18 decimals by default, so minting `100` whole tokens means entering `100` followed by 18 zeros: `100000000000000000000`.
5. Click **Transact**.
6. MetaMask will open a window and ask you to confirm the transaction:
Again, you must wait for the network to process the transaction, which should take about 90 seconds. You can move on to the next section while you’re waiting.
### Add to MetaMask
Currently, MetaMask has no idea what our token is or what it even does. We can fix this by explicitly telling MetaMask the address of our contract.
1. Go back to Remix and open the **Deploy** sidebar tab.
2. Under **Deployed Contracts**, you should see your contract address at the top. Click the copy icon to copy the address to your clipboard.
3. Open MetaMask, select **Assets**, and click **Import your tokens.**
4. In the **Token contract address** field, paste the contract address you just copied from Remix and then click **Add custom token**. MetaMask should autofill the rest of the information based on what it can find from the Filecoin network.
5. Click **Import token**:
6. You should now be able to see that you have 100 of your tokens within your MetaMask wallet!
And that’s it! Deploying an ERC-20 token on Filecoin is simple!
### Adjusting your gas fees
Remix uses a default of 2.5 nanoFIL per gas as a priority fee, which is usually too high for the Filecoin network. If you don’t adjust this, you may end up overpaying when deploying to mainnet. We recommend that you switch from the site-suggested gas fees to oracle-supplied gas fees when deploying your contract.
1. When the deployment transaction confirmation pop-up window shows up, click on **Site suggested**.
2. Switch to **Market**, **Aggressive**, or **Low**. The **Market** option is generally suitable for most situations.
[Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/build/development-frameworks/remix)
# Hardhat
Hardhat is an open-source development environment designed to provide developers with a flexible and extensible framework for building, testing, and deploying smart contracts.
While originally created for the Ethereum blockchain, the Filecoin Ethereum Virtual Machine runtime (FEVM) allows Hardhat to be used to develop and deploy smart contracts on the Filecoin network.
## Quickstart
The [FEVM Hardhat kit](https://github.com/filecoin-project/FEVM-Hardhat-Kit) is a starter hardhat project for developing, deploying, and testing Solidity smart contracts on the Filecoin network. It functions in the same way as other Hardhat development kits. Check out the quickstart below to test it out!
### Prerequisites
This guide assumes you have the following installed:
* [Git](https://git-scm.com/)
* [Node.js](https://nodejs.org/) and [Yarn](https://yarnpkg.com/)
* A Filecoin address stored in [MetaMask](/networks-and-tools/assets/metamask-setup)
* Calibration testnet `tFIL` or mainnet `FIL` for the account you will deploy from
### Environment setup
First, we need to grab the starter kit and install the dependencies.
1. Clone the Hardhat starter kit and move into the new `fevm-hardhat-kit` directory:
```shell
git clone --recurse-submodules https://github.com/filecoin-project/fevm-hardhat-kit.git
cd fevm-hardhat-kit
```
2. Use Yarn to install the project’s dependencies:
```shell
yarn install
```
3. Create your `.env` file and replace the placeholder private key:
```shell
cp .env.example .env
```
```shell
PRIVATE_KEY=your_private_key_here
```
{% hint style="info" %}
Always be careful when dealing with your private key. Double-check that you’re not hardcoding it anywhere or committing it to Git. Remember: anyone with access to your private key has complete control over your funds.
{% endhint %}
4. Get the addresses associated with the private key from Hardhat:
```shell
yarn hardhat get-address
```
The command output is environment-dependent. It prints the Ethereum-style `0x` address and the Filecoin `f4` address for the private key in `.env`. Use the Ethereum-style address with the Calibration faucet and most FEVM tools.
Now that we’ve got the kit set up, we can start using it to develop and deploy our contracts.
### Manage the contracts
There are two main types of contracts:
* Basic Solidity examples: Simple contracts to show off basic Solidity.
* Filecoin API Examples: Contracts that demo how to use the Filecoin APIs in Solidity to access storage deals and other Filecoin-specific functions.
Make sure that your account has funds. You won’t be able to deploy any contracts without `FIL` or `tFIL`.
1. Run `hardhat deploy` to deploy the kit contracts. The current kit defaults to the Calibration network:
```shell
yarn hardhat deploy
```
Deployment is network-dependent and may attempt Blockscout and Filfox verification after broadcasting. To deploy without verifier calls, set the kit’s skip flags:
```shell
IGNORE_FILFOX_VERIFICATION=true IGNORE_BLOCKSCOUT_VERIFICATION=true yarn hardhat deploy
```
2. Interact with the contracts using the available functions within the `tasks` folder. For example, you can get the balance of the `simple-coin` contract by calling the `get-balance` function:
```shell
export CONTRACT_ADDRESS=0xYourDeployedSimpleCoinAddress
export ACCOUNT_ADDRESS=0xYourEthereumStyleAccountAddress
yarn hardhat get-balance --contract "$CONTRACT_ADDRESS" --account "$ACCOUNT_ADDRESS"
```
## Hardhat docs
You can view the official Hardhat documentation over at [`hardhat.org/docs`](https://hardhat.org/docs).
[Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/build/development-frameworks/hardhat)
# Foundry
Foundry is a fast toolkit for application development written in Rust equipped with a testing framework, as well as utilities for interacting with smart contracts and getting chain data.
The [FEVM Foundry Kit](https://github.com/filecoin-project/fevm-foundry-kit) is a Foundry template for Filecoin EVM projects. It includes Solidity examples, Filecoin API examples, Foundry remappings, and verification tooling for Filecoin explorers.
## Prerequisites
You must have the following installed:
* [Git](https://git-scm.com/)
* [Node.js](https://nodejs.org/) and npm
* [Foundry](https://getfoundry.sh/)
You should also have an address on the Filecoin Calibration testnet. See the [MetaMask setup page](/networks-and-tools/assets/metamask-setup) for information on how to get an address. You also need test `tFIL` in your wallet.
## Steps
1. Clone the `filecoin-project/fevm-foundry-kit` repository and move into the `fevm-foundry-kit` directory:
```shell
git clone https://github.com/filecoin-project/fevm-foundry-kit
cd fevm-foundry-kit
```
2. Build the contracts and install the project’s npm dependencies:
```shell
forge build
npm install
```
3. Export your private key from MetaMask. See the [MetaMask documentation](https://support.metamask.io/configure/accounts/how-to-export-an-accounts-private-key/) to find out how to export your private key.
4. Create your env file by running:
```shell
cp .env.example .env
```
5. In your newly created `.env`, replace `PRIVATE_KEY` with the private key exported from MetaMask. Keep the Calibration RPC URL or replace it with your preferred Filecoin Calibration RPC endpoint:
```bash
PRIVATE_KEY=your_private_key_here
CALIBRATIONNET_RPC_URL=https://api.calibration.node.glif.io/rpc/v1
```
6. Load the variables in your current shell before running deployment commands:
```shell
source .env
```
{% hint style="info" %}
Never commit `.env` files or real private keys. Anyone with access to the private key can spend funds from the account.
{% endhint %}
7. Deploy the kit’s `DealClient` example contract to Calibration:
```shell
forge create \
--rpc-url "$CALIBRATIONNET_RPC_URL" \
--private-key "$PRIVATE_KEY" \
--broadcast \
src/basic-deal-client/DealClient.sol:DealClient
```
The deployment output is environment-dependent. Record the `Deployed to` address from Foundry’s output; you will need it for contract interactions and verification.
8. You can now interact with your contract using the contract address given by Foundry.
Done! For more information, see the [Foundry book](https://book.getfoundry.sh/).
[Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/build/development-frameworks/foundry)
# Developing contracts
Write, deploy, and test smart contracts on the Filecoin Virtual Machine.
This section covers how to build dApps by writing smart contracts on the Filecoin Virtual Machine.
## Table of contents
* [Get test tokens](/build-on-filecoin/developing-contracts/get-test-tokens) — obtain tFIL from a faucet for testing on Calibration
* [ERC-20 quickstart](/build-on-filecoin/developing-contracts/erc-20-quickstart) — deploy your first ERC-20 token on Filecoin
* [Call built-in actors](/build-on-filecoin/developing-contracts/call-built-in-actors) — interact with Filecoin system actors from your contracts
* [Filecoin.sol](/build-on-filecoin/developing-contracts/filecoin.sol) — Solidity libraries for accessing Filecoin storage primitives
* [Solidity libraries](/build-on-filecoin/developing-contracts/solidity-libraries) — third-party contract templates and libraries
* [Best practices](/build-on-filecoin/developing-contracts/best-practices) — guidelines for building reliable FVM dApps
* [Support](/build-on-filecoin/developing-contracts/support) — where to get help with contract development
[Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/build/developing-contracts)
# Get test tokens
Test funds are available to developers so that they can test their smart contracts and applications within the confines of a test network. This page covers how to get test funds.
## Calibration testnet
MetaMask is one of the easier ways to manage addresses on the Calibration testnet. MetaMask displays Filecoin EVM accounts in Ethereum `0x` format; on Filecoin testnets those accounts map to delegated `t4` [addresses](/core-concepts/filecoin-evm-runtime/address-types). Follow the [MetaMask setup guide](/networks-and-tools/assets/metamask-setup) if you haven’t set up an address in your MetaMask wallet yet.
1. In your browser, open MetaMask and copy your address to your clipboard.
2. Go to [faucet.calibnet.chainsafe-fil.io](https://faucet.calibnet.chainsafe-fil.io/funds.html) and click **Send Funds**.
3. Paste your address into the address field and click **Send funds**:

4. The webpage will give you a transaction ID:

5. You can copy this ID into a block explorer to track the progress of your transaction:

That’s all there is to it! Getting `tFIL` is easy!
## Local testnet
Before we begin, you must have a local testnet running. Follow the [Run a local network guide](/networks-and-tools/networks/local-testnet) if you haven’t got a local testnet set up yet. Run the commands below from the directory that contains your local `lotus` binary, and replace the placeholder addresses with addresses from your local node.
1. Change directory to where you created the `lotus` and `lotus-miner` binaries. If you followed the [Run a local network guide](/networks-and-tools/networks/local-testnet) these binaries will be in `~/lotus-devnet`:
```shell
cd ~/lotus-devnet
```
2. View the wallets available on this node with `lotus wallet list`:
```shell
./lotus wallet list
```
3. Create the send request with `lotus send`, supplying a funded local wallet as the `--from` address, the receiving address, and the amount of FIL you want to send:
```shell
./lotus send --from <FUNDED_LOCAL_ADDRESS> <TO_ADDRESS> <VALUE>
```
To create a delegated address for local Filecoin EVM testing, run:
```shell
./lotus wallet new delegated
```
4. Check the balance of your receiving address with `lotus wallet balance`:
```shell
./lotus wallet balance <ADDRESS>
```
If you want to manage your local testnet tokens in MetaMask, use a delegated address and [connect MetaMask to your local testnet](/networks-and-tools/assets/metamask-setup) to see the new balance within the MetaMask extension.
[Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/build/developing-contracts/get-test-tokens)
# ERC-20 quickstart
In this quickstart tutorial we’ll walk through how to deploy your first smart-contract to the Filecoin network.
We’re going to install a browser-based wallet called MetaMask, create a new wallet address, supply some test currency to that wallet, and then use a browser-based development environment called Remix to deploy a smart contract to the Filecoin network. We’re going to be creating an ERC-20 token in this quickstart. The ERC-20 contract is used a lot in representing a massive array of tokens across multiple blockchains, primarily the Ethereum blockchain.
{% hint style="info" %}
If you’re an Ethereum developer, check out the [FEVM Hardhat kit](/build-on-filecoin/development-frameworks/hardhat).
{% endhint %}
## Accounts and assets
We’re going to be using MetaMask, a cryptocurrency wallet that lives in your browser making it very easy for users to interact with web3-based sites!
### Create a wallet
Before we can interact with the Filecoin network, we need funds. But before we can get any funds, we need somewhere to put them!
1. Open your browser and visit the [MetaMask website](https://metamask.io/).
2. Install the wallet by clicking the **Download for** button. MetaMask is available for Brave, Chrome, Edge, Firefox, and Opera.
3. Once you have installed MetaMask, it will open a **Get started** window.

4. Click **Create a new wallet**.
5. Enter a password to secure your MetaMask wallet. You will need to enter this password every time you use the wallet.

6. Follow the prompts until you get to the **Secret Recovery Phrase** window. Read the information about what this *recovery phrase* is on this page.
7. Eventually you should get to the *Wallet creation success* page!

8. Once you’ve done that, you should have your account set up!

### Switch networks
You may notice that we are currently connected to the **Ethereum Mainnet**. We need to point MetaMask to the Filecoin network, specifically the [Calibration testnet](/networks-and-tools/networks/calibration). We’ll use a website called [chainlist.org](https://chainlist.org) to give MetaMask the information it needs quickly.
1. Go to [chainlist.org](https://chainlist.org).
2. Enable the **Testnets** toggle and enter `Filecoin` into the search bar.

3. Scroll down to find the **Filecoin – Calibration** **testnet**.
4. In MetaMask click **Next**.

5. Click **Connect.**
6. Click **Approve** when prompted to *Allow this site to add a network.*
7. Click **Switch network** when prompted by MetaMask.
8. Open MetaMask from the browser extensions tab:

9. You should see the *Filecoin Calibration* testnet listed at the top.
Nice! Now we’ve got the Filecoin Calibration testnet set up within MetaMask. You’ll프로젝트로 돌아가기