{"id":13654478,"url":"https://github.com/filecoin-project/fevm-foundry-kit","last_synced_at":"2025-04-23T09:33:31.072Z","repository":{"id":106382825,"uuid":"575543377","full_name":"filecoin-project/fevm-foundry-kit","owner":"filecoin-project","description":"A starter foundry project for developing, deploying, and testing Solidity smart contracts on the FEVM (Ethereum Virtual Machine on Filecoin)","archived":false,"fork":false,"pushed_at":"2023-10-16T15:33:58.000Z","size":3437,"stargazers_count":24,"open_issues_count":5,"forks_count":10,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-11-10T06:32:28.620Z","etag":null,"topics":["filecoin","foundry","rust","solidity"],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/filecoin-project.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-07T18:45:09.000Z","updated_at":"2024-11-06T20:44:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"1967af54-2f66-4ee8-831f-c9f27bc68fb1","html_url":"https://github.com/filecoin-project/fevm-foundry-kit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filecoin-project%2Ffevm-foundry-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filecoin-project%2Ffevm-foundry-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filecoin-project%2Ffevm-foundry-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filecoin-project%2Ffevm-foundry-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/filecoin-project","download_url":"https://codeload.github.com/filecoin-project/fevm-foundry-kit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250407708,"owners_count":21425549,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["filecoin","foundry","rust","solidity"],"created_at":"2024-08-02T03:00:34.416Z","updated_at":"2025-04-23T09:33:29.377Z","avatar_url":"https://github.com/filecoin-project.png","language":"Solidity","funding_links":[],"categories":["FVM(Filecoin Virtual Machine)"],"sub_categories":["🏫 FVM starter kits"],"readme":"# FEVM Foundry Kit\n\nThis is a template for foundry that provides the basic scaffolding for quickly getting started with new projects. \n\n## Download Foundry\n\nYou can find the instructions to download Foundry in the [official Foundry repo](https://github.com/foundry-rs/foundry#installation). \n\n## Cloning the Repo\n\nOpen up your terminal (or command prompt) and navigate to a directory you would like to store this code on. Once there type in the following command:\n\n\n```\ngit clone https://github.com/filecoin-project/fevm-foundry-kit\ncd fevm-foundry-kit\nyarn install\n```\n\nThis will clone the hardhat kit onto your computer, switch directories into the newly installed kit, and install the dependencies the kit needs to work.\n\n## Get a Private Key\n\nYou can get a private key from a wallet provider [such as Metamask](https://metamask.zendesk.com/hc/en-us/articles/360015289632-How-to-export-an-account-s-private-key).\n\n\n## Add your Private Key as an Environment Variable\n\nAdd your private key as an environment variable by running this command:\n\n```\nexport PRIVATE_KEY='abcdef'\n```\n\nAlternatively, to avoid having to do that every time, create a .env file in the root directory of the project (you can use .env.example to do so easily) and add the following line:\n\n```\nPRIVATE_KEY=abcdef\nCALIBRATIONNET_RPC_URL=https://api.calibration.node.glif.io/rpc/v1\n```\n\nand then, open a new terminal and run the following command:\n\n```\nsource .env\n```\n\nIf you use a .env file, don't commit and push any changes to .env files that may contain sensitive information, such as a private key! If this information reaches a public GitHub repository, someone can use it to check if you have any Mainnet funds in that wallet address, and steal them!\n\n\n## Fund the Deployer Address\n\nGo to the [Calibrationnet testnet faucet](https://faucet.calibration.fildev.network), and paste in the Ethereum address from the previous step. This will send some calibrationnet testnet FIL to the account.\n\n## Deploy the Contracts\n\nCurrently there are 3 main types of contracts:\n\n* Basic Solidity Examples: Simple contracts to show off basic solidity\n\n* Filecoin API Examples: Contracts that demo how to use the Filecoin APIs in Solidity to access storage deals and other Filecoin specific functions.\n\n* Basic Deal Client: A contract that demos how to create Filecoin storage deals within Solidity smart contracts. See below to learn more.\n\n\nType in the following command in the terminal to deploy a contract. Keep in mind that you can swap out the contract path and name for whichever one of your choosing:\n\n```\nforge build\nforge create --rpc-url https://api.calibration.node.glif.io/rpc/v1 --private-key $PRIVATE_KEY --contracts /src/SimpleCoin.sol SimpleCoin\n```\n\nThis will deploy the SimpleCoin contract to the Calibrationnet testnet. You can find the contract address in the terminal output:\n\n```\nDeployer: 0x42C930A33280a7218bc924732d67dd84D6247Af4\nDeployed to: 0x859723aA05F8B0C10215C31E50d9647AD7c82C82\nTransaction hash: 0x74071603994339f01b745e304c10f1bd97cfba4003d7a447977de1c89b478c7d\n```\n\nNow try doing the same with the Deal Client:\n\n```\nforge create --rpc-url https://api.calibration.node.glif.io/rpc/v1 --private-key $PRIVATE_KEY --contracts src/client-contract/DealClient.sol DealClient\n```\n\nA common issue that you may see is a failure due to gas:\n\n```\n(code: 1, message: verify msg failed: message will not be included in a block: 'GasLimit' field cannot be less than the cost of storing a message on chain 152605 \u003c 288863, data: None)\n```\n\nSimply pass in a higher gas limit to fix this (either via. a higher gas estimate multiplier or a fixed gas limit):\n\n```\nforge create --rpc-url https://api.calibration.node.glif.io/rpc/v1 --private-key $PRIVATE_KEY --contracts src/client-contract/DealClient.sol DealClient -g 1000\n```\n\n## Interact with the Contracts\n\nYou can interact with contracts via forge scripts scripts, found in the 'scripts' folder. For example, to interact with the SimpleCoin contract:\n\nType in the following command in the terminal:\n\n```\nforge script script/SimpleCoin.s.sol:MyScript --rpc-url https://api.calibration.node.glif.io/rpc/v1 --broadcast --skip-simulation\n```\n\nYou can also interact with contracts via the terminal/command line using the [Foundry cast tool](https://book.getfoundry.sh/cast/#overview-of-cast).\n\n## Empty Transaction Reciepts\nSome users are facing the issue of an empty receipt for your txn on testnet but the txn shows that it has gone through successfully on explorers.\n```\nError: \nReceived an empty receipt for 0xe661e7a4e5ec511c93c2b966ae382da9267c5ad217d9b5ec75de3ce3ab848608\n```\n\nOR facing an error message that txn has dropped from mempool, but again, txn shows up on explorer.\n\n```\nError: \nTransaction dropped from the mempool: 0x9b293d053a0c148677b46425f143fd46dd58d13b47251208d68c458653f30038\n```\n\nTry these fixes:\n- Increase the amount of times for retrying the tx, perhaps through the `—resume` flag. Ideally setting it to ~10, which you can specify with `--retries`. \n- Alternatively, try using ethers-rs to handle contract transactions. there is a [send_tx](https://github.com/filecoin-saturn/rs-fevm-utils/blob/5c850005bbe50d7547d2585173ab2bd39c47c011/src/lib.rs#LL215C4-L215C4) function in there that allows you to override the default no of retries.\n\n## Filecoin APIs\n\nThe primary advantage of the FEVM over other EVM based chains is the ability to access and program around Filecoin storage deals. This can be done in the FEVM via the [Filecoin.sol library maintained by Zondax](https://github.com/Zondax/filecoin-solidity). **Note this library is currently in BETA**. It is unaudited, and the APIs will likely be changing with time. This repo will be updated as soon as possible when a breaking change occurs.\n\nThe library is included in this kit as an NPM package and will automatically be downloaded when you perform the `yarn` command (don't confuse these with the included mocks)!\n\nCurrently you will find a getter contract that calls the getter methods on the MarketAPI to get storage deal data and store that data. To do this you will need *dealIDs* which you can [find here on FilFox](https://calibration.filfox.info/en/deal).\n\n### Preparing Data for Storage\n\nBefore storing a file with a storage provider, it needs to be prepared by turning it into a .car file and the metadata must be recorded. To do this locally, you can use [this tool](https://github.com/filecoin-project/fevm-hardhat-kit/tree/main/tools), written in the language Go, which can do this for you. You can also use the [FVM Data Depot website](https://data.lighthouse.storage/) will automatically convert files to the .car format, output all the necessary metadata, and act as an HTTP retrieval point for the storage providers.\n\n### Client Contract - Making Storage Deals in Solidity\n\nUnder contracts, within the `basic-deal-client` sub-directory, you will find a file called `DealClient.sol`. This is an example contract that uses the Filecoin.sol API's to create storage deals via Solidity smart contracts on Filecoin. This works by emitting a Solidity event that [Boost storage providers](https://boost.filecoin.io/) can listen to. To learn more about this contract feel free to [checkout the app kit repo](https://github.com/filecoin-project/fvm-starter-kit-deal-making) which includes a detailed readme and a frontend.\n\n### Bounty Contract\n\nUnder contracts, within the `filecoin-api-examples` sub-directory, you will find a file called `deal-rewarder.sol`. This is a basic example contract that uses the Filecoin.sol API's to create bounties for specific data to be stored on the Filecoin blockchain. This is intended to be an example to illustrate how you can use the Filecoin APIs to do some cool functionality. To learn more about this contract feel free to [checkout the original Foundry project](https://github.com/lotus-web3/deal-bounty-contract) which includes a detailed readme.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffilecoin-project%2Ffevm-foundry-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffilecoin-project%2Ffevm-foundry-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffilecoin-project%2Ffevm-foundry-kit/lists"}