Filecoin 백서

Filecoin

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 52쪽 중 12쪽

put something like: ```plaintext { "jsonrpc": "2.0", "result": "0x31157", "id": 1 } ``` You can convert the `result` field from hexadecimal to base 10 in your terminal. Take the `result` output and remove the `0x` from the start. Then use `echo` to output the conversion: ```shell echo $((16#31157)) # 201047 ``` ## Additional Resources * Gas Filecoin improvement proposals (FIPs): * [FIP 0032](https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0032.md) * [FIP 0037](https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0037.md) * [FIP 0054](https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0054.md) * [Primitive Gas Price list](https://github.com/filecoin-project/ref-fvm/blob/master/fvm/src/gas/price_list.rs) [Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/build/architecture/filecoin-evm-runtime/how-gas-works) # Precompiles A precompile refers to a pre-existing piece of code or a smart contract that is already deployed on the Filecoin network for use by developers. The Filecoin virtual machine (FVM) has several pre-compiled contracts called precompiles. Each precompile address starts with `0xfe000...`. Specifically: * [Resolve address `0xfe00..01`](#resolve-address) * [Lookup delegated address `0xfe00..02`](#lookup-delegated-address) * [Call actor by address `0xfe00..03`](#call-actor-by-address) * [Call actor by ID `0xfe00..05`](#call-actor-by-id) ## Resolve Address Address: `0xfe00000000000000000000000000000000000001` Resolves a Filecoin address (e.g., “f01”, “f2abcde”) into a Filecoin actor ID (`uint64`). Every actor in Filecoin has an actor ID. * Input: The Filecoin address in its *bytes* representation. * Output: * If the target actor exists, succeed and return an ABI-encoded actor ID (u64). * If the target actor doesn’t exist, succeed with no return value. * If the supplied address is invalid (cannot be parsed as a Filecoin address), revert. Example: ```solidity (bool success, bytes memory actor_id_bytes) = address(0xfe00000000000000000000000000000000000001).staticcall(fil_address_bytes); require(success, "invalid address"); require(actor_id_bytes.length == 32, "actor not found"); uint64 actor_id = abi.decode(actor_id_bytes); ``` ## Lookup Delegated Address Address: `0xfe00000000000000000000000000000000000002` Looks up the “delegated address” (f4 address) of an actor by ID. This precompile is *usually* used to lookup the Ethereum-style address of an actor by: 1. Looking up the delegated address. 2. Checking that the delegated address is 22 bytes long and starts with `0x040a`. 3. Returning the last 20 bytes (which will be the Ethereum-style address of the target actor). * Input: An ABI-encoded actor ID (u64 encoded as a u256). * Output: * If the supplied actor ID is larger than max u64, revert. * If the target actor exists and has a delegated address, succeed and return the delegated address as raw bytes. * Otherwise, succeed with no return value. Example: ```solidity (bool success, bytes memory delegated_address_bytes) = address(0xfe00000000000000000000000000000000000002).staticcall(abi.encode(uint256(actor_id))); ``` ## Call Actor By Address Address: `0xfe00000000000000000000000000000000000003` Calls the specified actor using the native FVM calling convention by its *Filecoin* address. This precompile must be called with `DELEGATECALL` as the precompile will call the target actor *on behalf of* the currently executing contract. ### Input: ABI Encoded {% code overflow="wrap" %} ```json (uint64 method, uint256 value, uint64 flags, uint64 codec, bytes params, bytes filAddress) ``` {% endcode %} * `method` is the Filecoin method number. The precompile will revert if the method number is not either 0 (bare value transfer) or at least 1024. Methods between 1 and 1023 inclusive are currently restricted (but may be allowed in the future). * `value` is the value to transfer in attoFIL. * `codec` is the IPLD codec of the parameters. This must either be 0x51 or 0x00 (for now) and will revert if passed an illegal codec: * If the parameters are non-empty, they must be CBOR, and the codec must be 0x51. * If the parameters are empty, the codec must be 0x00. * `params` are the CBOR-encoded message parameters, if any. * `filAddress` is the Filecoin address of the caller. ### Output: ABI Encoded ``` (int256 exit_code, uint64 return_codec, bytes return_value) ``` * `exit_code` is one of: * `= 0` to indicate the call exited successfully. * `> 0` to indicate that the target actor *reverted* with the specified `exit_code`. * `< 0` to indicate the call itself failed with the [syscall-error](https://docs.rs/fvm_sdk/0.6.1/fvm_sdk/sys/enum.ErrorNumber.html) `-exit_code`. * `return_codec` codec of returned data. This will be one of (for now): * 0x51 or 0x71 - CBOR * 0x55 - raw (the target actor returned raw data) * 0x00 - nothing (the returned data will be empty as well). {% hint style="danger" %} This precompile only reverts if an input is statically invalid. If the precompile fails to call the target actor for any other reason, it will return a non-zero `exit_code` but will not revert. {% endhint %} Example: ```solidity (bool success, bytes memory data) = address(0xfe00000000000000000000000000000000000003).delegatecall(abi.encode(method, value, flags, codec, params, filAddress)); (int256 exit, uint64 return_codec, bytes memory return_value) = abi.decode(data, (int256, uint64, bytes)); ``` ## Call Actor By ID Address: `0xfe00000000000000000000000000000000000005` This precompile is identical to the “Call Actor By Address” (0xfe00..03) except that it accepts an actor ID (`uint64`) instead of an actor address as the last parameter. That is: ```solidity (uint64 method, uint256 value, uint64 flags, uint64 codec, bytes params, uint64 actorId) ``` Example: ```solidity (bool success, bytes memory data) = address(0xfe00000000000000000000000000000000000005).delegatecall(abi.encode(method, value, flags, codec, params, id)); (int256 exit, uint64 return_codec, bytes memory return_value) = abi.deco ``` [Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/build/architecture/filecoin-evm-runtime/precompiles) # Getting started Start building on Filecoin. Choose a path based on what you want to build — from simple storage integrations to full smart-contract applications. This guide helps you pick the right path based on what you want to build on Filecoin. ## Choose your path ### Store data on Filecoin Filecoin provides multiple storage paths depending on how much control you need. [Filecoin Onchain Cloud (FOC)](/build-on-filecoin/filecoin-onchain-cloud) is the recommended starting point. It provides a complete on-chain storage stack with warm storage, cryptographic verification, and automated payments through the [Synapse SDK](/build-on-filecoin/filecoin-onchain-cloud/synapse-quickstart). If you prefer a managed service, [storage onramps](/getting-started/how-storage-works/storage-onramps) let you store data through simple APIs or web UIs without managing infrastructure. For operators who want to run their own PDP-enabled storage provider, see the [PDP setup guide](/provide-storage/pdp). | Path | Best for | Complexity | | ------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ---------- | | [Filecoin Onchain Cloud (FOC)](/build-on-filecoin/filecoin-onchain-cloud) | Verifiable on-chain storage with FWSS, PDP, and Filecoin Pay via the Synapse SDK | Low | | [Storage onramps](/getting-started/how-storage-works/storage-onramps) | Managed services with simple APIs or drag-and-drop UIs | Low | | [PDP](/provide-storage/pdp) | Run your own PDP-enabled storage provider (part of the FOC stack) | Medium | *For a walkthrough of all storage options, see* [*Upload to Filecoin*](/getting-started/how-storage-works/upload-to-filecoin)*.* ### Deploy smart contracts Filecoin runs an EVM-compatible runtime, so you can write Solidity contracts and deploy them using familiar Ethereum tooling. Choose a [development framework](/build-on-filecoin/development-frameworks) (Remix, Hardhat, or Foundry), get [test tokens](/build-on-filecoin/developing-contracts/get-test-tokens) on Calibration, and deploy your first contract with the [ERC-20 quickstart](/build-on-filecoin/developing-contracts/erc-20-quickstart). Once deployed, [verify your contract](/build-on-filecoin/verification) through a block explorer. Filecoin contracts can also interact with the storage network directly. Use [Filecoin.sol](/build-on-filecoin/developing-contracts/filecoin.sol) to access storage primitives from Solidity, or [call built-in actors](/build-on-filecoin/developing-contracts/call-built-in-actors) to work with miner, market, and power actors on-chain. ### Integrate advanced features After you have a working contract, Filecoin supports deeper integrations. [Oracles](/build-on-filecoin/advanced/oracles) bring off-chain data into your contracts. [Cross-chain bridges](/build-on-filecoin/advanced/cross-chain-bridges) let you move assets between Filecoin and other networks. [FEVM indexers](/build-on-filecoin/advanced/fevm-indexers) provide efficient on-chain data queries without running an archival node. [Decentralized databases](/build-on-filecoin/advanced/decentralized-databases) add structured data storage alongside Filecoin. *Browse more in the* [*Advanced*](/build-on-filecoin/advanced) *section or find solution-focused recipes in the* [*Cookbook*](/build-on-filecoin/cookbook)*.* ## Key resources | Resource | Description | | -------------------------------------------------------------------------------- | --------------------------------------------------- | | [Networks](/networks-and-tools/networks) | Mainnet, Calibration testnet, and local development | | [Metamask setup](/networks-and-tools/assets/metamask-setup) | Connect your wallet to Filecoin | | [FEVM vs Ethereum](/core-concepts/filecoin-evm-runtime/difference-with-ethereum) | Key differences for Ethereum developers | | [How gas works](/core-concepts/filecoin-evm-runtime/how-gas-works) | Filecoin gas model for transaction planning | | [Support](/build-on-filecoin/developing-contracts/support) | Where to get help | [Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/build/getting-started) # Filecoin Onchain Cloud Filecoin Onchain Cloud is a programmable storage, retrieval, and payments stack built on Filecoin. Filecoin Onchain Cloud (FOC) is a programmable storage platform built on the Filecoin Virtual Machine. It combines warm storage, cryptographic storage verification, retrieval, and payments into one developer-facing stack. Use FOC when you want application-controlled storage on Filecoin without building the storage, payment, provider-selection, and proof flows yourself. The primary integration path is the Synapse SDK; this section points to the maintained [FOC quickstart and Synapse docs](/build-on-filecoin/filecoin-onchain-cloud/synapse-quickstart). ## When to use FOC FOC is a good fit when your application needs: * **Programmable storage** that can be controlled from a wallet, backend service, agent, or smart-contract-adjacent workflow. * **Verifiable persistence** through Proof of Data Possession (PDP), so providers regularly prove they still hold the data. * **Automated payments** through Filecoin Pay, so storage providers are paid through on-chain payment rails. * **Retrieval paths** for application data, with Filecoin Beam available for faster data delivery. If you only need a managed IPFS pinning-style workflow, start with [Filecoin Pin](/build-on-filecoin/cookbook/filecoin-pin). If you want to sell FOC storage from your own hardware, the Curio-PDP Docker stack brings up Forest, Yugabyte, and Curio-PDP in one command — about five minutes of setup, then a web guide for wallet, disks, domain, and registration: [Run a PDP provider](/provide-storage/pdp/install-and-run-pdp) · [Curio-PDP](https://docs.curiostorage.org/getting-started/curio-pdp). ## Core components FOC is composed of services that can be used together through the Synapse SDK: | Component | Role | | ------------- | --------------------------------------------------------------------------------------------------------------------------- | | FWSS | Filecoin Warm Storage Service stores data with retrievability-oriented provider selection. | | PDP | Proof of Data Possession verifies that providers still hold stored data without requiring a full download. | | Filecoin Pay | Payment rails fund storage and settle provider payments based on service delivery. | | Filecoin Beam | Retrieval infrastructure for fast data delivery when your application needs it. | | Synapse SDK | TypeScript SDK for funding storage, selecting providers, uploading data, downloading data, and managing storage operations. | ## Developer paths | Path | Use when | Start here | | ------------- | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- | | Synapse SDK | You are building a JavaScript or TypeScript application that stores and retrieves data with FOC. | [FOC quickstart and Synapse docs](/build-on-filecoin/filecoin-onchain-cloud/synapse-quickstart) | | Filecoin Pin | You want a CLI or API-style path for pinning IPFS-compatible content to Filecoin-backed storage. | [Filecoin Pin](/build-on-filecoin/cookbook/filecoin-pin) | | PDP provider | You want to sell FOC storage from your own hardware (≈5 min Docker setup). | [Run a PDP provider](/provide-storage/pdp/install-and-run-pdp) · [Curio-PDP](https://docs.curiostorage.org/getting-started/curio-pdp) | | Full FOC docs | You need the complete FOC guides, API reference, architecture, pricing, or contract references. | [docs.filecoin.cloud](https://docs.filecoin.cloud/) | ## Learn more The FOC documentation is the source of truth for detailed product docs, pricing, API references, and contract addresses: * [FOC quick start](https://docs.filecoin.cloud/getting-started) * [Architecture](https://docs.filecoin.cloud/core-concepts/architecture) * [FWSS overview](https://docs.filecoin.cloud/core-concepts/fwss-overview) * [PDP overview](https://docs.filecoin.cloud/core-concepts/pdp-overview) * [Filecoin Pay overview](https://docs.filecoin.cloud/core-concepts/filecoin-pay-overview) * [Synapse SDK guide](https://docs.filecoin.cloud/developer-guides/synapse) * [Contract addresses](https://docs.filecoin.cloud/resources/contracts) [Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/build/filecoin-onchain-cloud) # Synapse SDK quickstart Start with the maintained Filecoin Onchain Cloud docs for the current Synapse SDK quickstart, funding, upload, and retrieval steps. The Synapse SDK is the main developer interface for Filecoin Onchain Cloud (FOC). The current setup steps, SDK APIs, payment behavior, pricing, and contract references live in the dedicated FOC documentation. To avoid this page drifting from the maintained FOC guides, use it as a routing page instead of a duplicated quickstart. ## Start in the FOC docs * [FOC getting started](https://docs.filecoin.cloud/getting-started) - install the Synapse SDK, connect a wallet, fund storage, upload data, and retrieve it. * [Synapse SDK guide](https://docs.filecoin.cloud/developer-guides/synapse) - integrate the SDK into applications and review the current API surface. * [Storage operations](https://docs.filecoin.cloud/developer-guides/storage/storage-operations) - manage uploads, retrievals, data sets, and storage lifecycle operations. * [Payment operations](https://docs.filecoin.cloud/developer-guides/payments/payment-operations) - understand deposits, approvals, withdrawals, and payment rails. * [Contract addresses](https://docs.filecoin.cloud/resources/contracts) - find current mainnet and testnet contract references. For a CLI-oriented pinning workflow in these docs, use [Filecoin Pin](/build-on-filecoin/cookbook/filecoin-pin). [Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/build/filecoin-onchain-cloud/synapse-quickstart) # Development Frameworks Supported development frameworks for building and deploying smart contracts on Filecoin. Filecoin supports popular Ethereum development frameworks for writing, testing, and deploying smart contracts. Choose the framework that fits your workflow. ## Table of contents * [Remix](/build-on-filecoin/development-frameworks/remix) — browser-based IDE for writing and deploying contracts without local setup * [Hardhat](/build-on-filecoin/development-frameworks/hardhat) — JavaScript framework with the FEVM Hardhat Kit for local development and testing * [Foundry](/build-on-filecoin/development-frameworks/foundry) — fast Rust-based toolkit for contract development, testing, and deployment # Remix The Filecoin EVM runtime allows developers to use Ethereum tooling, like Remix, with the Filecoin network. ## Launch an ERC-20 token As a simple introduction, we’re going to use Remix to create an ERC-20 token on the Filecoin network. In this guide, we’re using the Calibration testnet, but this process is the same for mainnet. This guide assumes you’ve already connected your [MetaMask extension to a Filecoin network](/networks-and-tools/assets/metamask-setup). ### Create a workspace In Remix, workspaces are where you can create a contract, or group of contracts, for each project. Let’s create a new workspace to create our new ERC-20 token. 1. Open [remix.ethereum.org](https://remix.ethereum.org). 2. Click the `+` icon next to **Workspaces** to create a new workspace. 3. In the **Choose a template** dropdown, select **ERC20**. 4. Select the **Mintable** checkbox. 5. Enter a fun name for your token in the **Workspace name** field. Something like `CorgiCoin` works fine. 6. Click **OK** to create your new workspace. ### Customize the contract The contract template we’re using is pretty simple. We just need to modify a couple of variables. 1. Under the **contract** directory, click **MyToken.sol**. 2. In the editor panel, replace `MyToken` with whatever you’d like to name your token. In this example, we’ll use `CorgiCoin`. 3. On the same line, replace the second string with whatever you want the symbol of your token to be. In this example, we’ll use `CRG` That’s all we need to change within this contract. You can see on line 4 that this contract is importing another contract from `@openzeppelin` for us, meaning that we can keep our custom token contract simple. ### Compile 1. Click the green play symbol at the top of the workspace to compile your contract. You can also press `CMD` + `s` on MacOS or `CTRL` + `s` on Linux and Windows. 2. Remix automatically fetches the two `import` contracts from the top of our `.sol` contract. You can see these imported contracts under the `.deps` directory. You can browse the contracts there, but Remix will not save any changes you make. ### Deploy Now that we’ve successfully compiled our contract, we need to deploy it somewhere! This is where our previous MetaMask setup comes into play. 1. Click the **Deploy** tab from the left. 2. Under the **Environment** dropdown, select **Injected Provider - MetaMask**. 3. MetaMask will open a new window confirming that you want to connect your account to Remix. 4. Click **Next**: 5. Click **Connect** to connect your `tFIL` account to Remix. 6. Back in Remix, under the **Account** field, you’ll see that it says s
프로젝트로 돌아가기