Deploy a contract
Learn how to deploy a contract to the FVM using one of many different tools and workflows.
On this page
THIS SECTION IS UNDER DEVELOPMENT
We’re still working on this section. Feel free to dive into the docs, but keep in mind that things will likely change pretty often.
Remix
You can quickly deploy a contract with Remix, the browser-based IDE maintained by the Ethereum Foundation.
Go to remix.ethereum.org.
Create a new Blank workspace:
Create a new file called
contract.sol
.Write or paste your contract into the new file. When pasting, you may receive a warning about crypto scams.
Compile your contract by either pressing
CTRL
+s
, clicking on the Save button, or by selecting the Compile tab and clicking Compile contract.sol.Select the Deploy tab:
Select your network from the Environment tab. If you want to deploy your contract to the Hyperspace testnet, follow the Add to MetaMask guide:
Click Deploy:
If everything was successful, you will see a success message at the bottom of the IDE window:
Done!
Hardhat
You can deploy a contract using Hardhat. We’re going to use the FEVM Hardhat Kit repository in the Filecoin Project GitHub organization to get started quickly.
Prerequisites
You must have the following installed:
You should also have an address on the Filecoin Hyperspace testnet. See the Add to MetaMask page for information on how to get an address. You also need test-FIL tFIL
in your wallet. See the Use a Faucet page for information on how to get test funds.
Steps
Clone the
filecoin-project/FEVM-Hardhat-Kit
repository and move into theFEVM-Hardhat-Kit
directory:git clone https://github.com/filecoin-project/FEVM-Hardhat-Kit.git cd FEVM-Hardhat-Kit
Install the project dependencies with Yarn:
yarn install
Export your private key from MetaMask. See the MetaMask documentation to find out how to export your private key.
In your terminal, create an environment variable called
PRIVATE_KEY
and paste in the private key from MetaMask:export PRIVATE_KEY='eed8e9d727a647f7302bab440d405ea87d36726e7d9f233ab3ff88036cfbce9c'
Inside the
contracts
folder in a contract calledSimpleCoin.sol
. Deploy this contract using Hardhat:yarn hardhat deploy
... Compiled 1 Solidity file successfully Wallet Ethereum Address: 0x119bB8b0e3C3E5A1f2b608265342E3ef52c29594 Wallet f4Address: f410fcgn3rmhdyps2d4vwbatfgqxd55jmffmunzmqczq deploying "SimpleCoin" (tx: 0x2a2c50f8e34b582845e1f1991bc16cc6202caddc726af4737e2f5a9f47739ff4)...: deployed at 0x73867E39f7492a2ee2EBECBDF9c9FbcCabe4b760 with 17522415 gas ✨ Done in 79.61s.
The deployment process should take a couple of minutes. Once the contract has been successfully deployed, Hardhat will give you a contract address you can use to interact with the contract.
You can now interact with your contract using the contract address given by Hardhat.
Done!