Filecoin 백서

Filecoin

원문

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

gent can store data and pay for it directly. No per-transaction approval is required. **Does an agent need to hold and manage FIL and USDFC directly?** Yes, today. An agent's wallet needs FIL (for transaction fees) and USDFC (Filecoin Cloud's storage-payment stablecoin) for payments. Filecoin Pay is where those payments settle; the [Filecoin Pay Console](#filecoin-pay-console) is where a human operator can inspect or adjust what an agent's wallet is authorized to spend. **How does an agent authenticate for payments today?** By running `filecoin-pin login` (or using the `publish` skill in the Quickstart above, which calls it by default), which pairs the agent with a scoped, revocable session key instead of a raw wallet private key: a human approves a one-time pairing link from their wallet, and the agent holds only that limited key afterward. Direct private-key access still works as a fallback for the CLI; see [Filecoin Pay Console](#filecoin-pay-console) below for where session keys are managed. ## Resources ### Filecoin Pin CLI A CLI (and JS library, and GitHub Action) for pinning IPFS-compatible content to Filecoin with verifiable, provider-proven persistence. This is what the quickstart above uses, and it's the right starting point for any agent that just needs to store and retrieve files or datasets. [Filecoin Pin: Getting Started →](https://docs.filecoin.cloud/getting-started/filecoin-pin) ### Filecoin Cloud CLI A community-built CLI (also installable as an agent skill and MCP server) for the broader FC stack: wallet setup, dataset management, and storage-provider queries via the Synapse SDK. Where Filecoin Pin focuses on pinning content, Filecoin Cloud CLI is closer to a general-purpose control surface for FC, and it's built to be driven by an agent directly (`npx skills add FIL-Builders/foc-cli`), not just by a human at a terminal. [Filecoin Cloud CLI →](https://docs.filecoin.cloud/resources/community-projects/#FC-cli) ### Filecoin Pay Console A web console for managing the payment side of FC: connect a wallet to view and manage payment rails, deposits made in USDFC, and the services you've authorized to draw against them. A human operator uses it directly to authorize spending and fund an agent's session; an agent-driven CLI also opens it briefly, for the one-time wallet approval a session-key login requires. The console is currently in beta and interacts directly with the underlying payment contracts. Verify transaction details before confirming anything. {% hint style="info" %} **Session-key login.** Instead of connecting a full wallet, an agent (or the CLI it's driving) can authenticate with a scoped, revocable session key: it opens a one-time pairing link in a browser, a human approves it from their wallet, and the agent receives a key limited to just what it needs. Run this from the [Filecoin Pin CLI](https://github.com/filecoin-project/filecoin-pin) with `filecoin-pin login`, or see the Quickstart above for the packaged agent skill that uses it by default. {% endhint %} [Filecoin Pay Console →](https://pay.filecoin.cloud/console) *** [Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/core-concepts/filecoin-for-agents) # Filecoin Virtual Machine The Filecoin Virtual Machine (FVM) is a runtime environment enabling users to deploy their own smart contracts on the Filecoin blockchain. This page covers the basics of the FVM. NOTE: As of January 2025, for developer support, please visit the [FILB](https://fil.builders/) website. For Filecoin product updates, please visit the [FILOz](https://www.filoz.org/) website or see the Lotus [Github discussion page](https://github.com/filecoin-project/lotus/discussions). ## Introduction Filecoin’s storage and retrieval capabilities can be thought of as the base layer of the Filecoin blockchain, and [FVM](https://fvm.filecoin.io) can be thought of as a layer on top of Filecoin that unlocks programmability on the network (e.g. programmable storage primitives). Whereas other blockchains do have smart contract capabilities, FVM’s smart contracts can use Filecoin storage and retrieval primitives with computational logic conditions. FVM will also enable Layer 2 capabilities, such as “compute over data” and [content delivery networks](https://github.com/filecoin-saturn). Some additional notes about FVM’s technical specifications: * WASM-based: The FVM is a WASM-based polyglot execution environment for IPLD data, meaning that FVM gives developers access to IPFS / IPLD data primitives and can accommodate smart contracts (actors) written in any programming language that compiles to WASM. * FEVM Compatibility: Are you an Ethereum / Solidity developer? You can build the next killer app on FVM and make use of the [Filecoin Solidity library](https://docs.zondax.ch/fevm/filecoin-solidity/). Learn more about how FVM is Ethereum runtime and solidity compatible in the next section. * VM Agnostic: The FVM is built to be VM-agnostic, meaning support for other foreign VMs can be added in the near future. Future versions of FVM can serve as a useful hypervisor enabling cross run-time invocations. FVM brings user programmability to Filecoin, unleashing the enormous potential of an open data economy through various applications. ### Use Cases FVM Actors enable a huge range of use cases to be built on Filecoin. Here are just a few potential examples: * Data Access Control: FVM Actors can enable a client to grant retrieval permission for certain files to a limited set of third-party Filecoin wallet addresses. * DataDAO: FVM Actors can enable the creation of decentralized autonomous organizations where members govern and manage the storage, accessibility, and monetization of certain data sets and pool returns into a shared treasury. * Perpetual Storage: Because all Filecoin storage deals are time-limited, when a client makes a deal with a storage provider to store a data set with them, the client has to begin to consider whether they will want to renew this deal for the next time-period with the same storage provider or seek out other storage providers that may be cheaper. However, FVM enables a client to automatically renew deals or find a cheaper storage provider when the time limit of a given deal has reached maturity. This automated renewal of deals can persist, even in perpetuity, for as many cycles as can be financed by an associated endowment of FIL. FVM Actors enable the creation and management of this endowment. * Replication: In addition to allowing a client to store one data set with one storage provider in perpetuity, FVM Actors enable data resiliency by allowing a client to store one data set once manually and then have the Actor replicate that data with multiple other storage providers automatically. Additional conditions that can be set in an automated replication Actor include choices about the geographic region of the storage providers, latency, and deal price limits. * Leasing: FVM Actors enable a FIL token holder to provide collateral to clients looking to do a storage deal, and be repaid the principal and interest over time. FVM Actors can also trace the borrowing and repayment history of a given client, generating a community-developed reputation score. Additional use cases enabled by FVM include, but are not limited to, tokenized data sets, trustless reputation systems, NFTs, storage bounties and auctions, Layer 2 bridges, futures and derivatives, or conditional leasing. ### Start building on the FVM If you’re ready to start building on the FVM, here are some resources you should explore: * FVM Reference Implementation: The [Github repo](https://github.com/filecoin-project/ref-fvm) containing the reference implementation for FVM. * FVM Quickstart Guide: The Quickstart guide will walk you through deploying your first ERC-20 contract on FVM. In addition to being provided this code, we also walk you through the developer environment set-up. * Developing Contracts: If you are ready to build your dApp on FVM, you can skip ahead and review our [best practices](/build-on-filecoin/developing-contracts/best-practices) section for developing contracts. Here, you can find a guide for the Filecoin solidity libraries, details on tools such as Foundry, Remix, and Hardhat, and tutorials for calling built-in actors and building client contracts. The next page will walk you through the process of deciding whether you need to use FVM’s programmatic storage when building a dApp with storage on Filecoin. [Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/core-concepts/filecoin-virtual-machine) # Actors Actors are smart contracts that run on the Filecoin virtual machine (FVM) and are used to manage, query, and update the state of the Filecoin network. Smart contracts are small, self-executing blocks. For those familiar with the Ethereum virtual machine (EVM), *actors* work similarly to [smart contracts](/core-concepts/filecoin-virtual-machine). In the Filecoin network, there are two types of actors: * [*Built-in actors*](#built-in-actors): Hardcoded programs written ahead of time by network engineers that manage and orchestrate key subprocesses and subsystems in the Filecoin network. * [*User actors*](#user-actors-smart-contracts): Code implemented by **any developer** that interacts with the Filecoin Virtual Machine (FVM). ## Built-in actors Built-in actors are how the Filecoin network manages and updates *global state*. The *global state* of the network at a given epoch can be thought of as the set of blocks agreed upon via network consensus in that epoch. This global state is represented as a *state tree*, which maps an actor to an *actor state*. An *actor state* describes the current conditions for an individual actor, such as its FIL balance and its nonce. In Filecoin, actors trigger a *state transition* by sending a *message*. Each block in the chain can be thought of as a **proposed** global state, where the block selected by network consensus sets the **new** global state. Each block contains a series of messages and a checkpoint of the current global state after the application of those messages. The Filecoin Virtual Machine (FVM) is the Filecoin network component that is in charge of the execution of all actor code. A basic example of how actors are used in Filecoin is the process by which storage providers prove storage and are subsequently rewarded. The process is as follows: 1. The [`StorageMinerActor`](#storagemineractor) processes proof of storage from a storage provider. 2. The storage provider is awarded storage power based on whether the proof is valid or not. 3. The [`StoragePowerActor`](#storagepoweractor) accounts for the storage power. 4. During block validation, the [`StoragePowerActor`](#storagepoweractor) state, which includes information on storage power allocated to each storage provider, is read. 5. Using the state information, the consensus mechanism randomly awards blocks to the storage providers with the most power, and the [`RewardActor`](#rewardactor) sends FIL to storage providers. ### Blocks Each block in the Filecoin chain contains the following: * Inline data such as current block height. * A pointer to the current state tree. * A pointer to the set of messages that, when applied to the network, generated the current state tree. ### State tree A [Merkle Directed Acyclic Graph (Merkle DAG)](/reference/general/glossary#merkle-directed-acyclic-graph) is used to map the state tree and the set of messages. Nodes in the state tree contain information on: * Actors, like FIL balance, nonce, and a pointer (CID) to actor state data. * Messages in the current block ### Messages Like the state tree, a Merkle Directed Acyclic Graph (Merkle DAG) is used to map the set of messages for a given block. Nodes in the messages may contain information on: * The actor the message was sent to * The actor that sent the message * Target method to call on the actor being sent the message * A cryptographic signature for verification * The amount of FIL transferred between actors ### Actor code The code that defines an actor in the Filecoin network is separated into different methods. Messages sent to an actor contain information on which method(s) to call and the input parameters for those methods. Additionally, actor code interacts with a *runtime* object, which contains information on the general state of the network, such as the current epoch, cryptographic signatures, and proof validations. Like smart contracts in other blockchains, actors must pay a *gas fee*, which is some predetermined amount of FIL to offset the cost (network resources used, etc.) of a transaction. Every actor has a Filecoin balance attributed to it, a state pointer, a code that tells the system what type of actor it is, and a nonce, which tracks the number of messages sent by this actor. ### Types of built-in actors The 11 different types of built-in actors are as follows: * [CronActor](#cronactor) * [InitActor](#initactor) * [AccountActor](#accountactor) * [RewardActor](#rewardactor) * [StorageMarketActor](#storagemarketactor) * [StorageMinerActor](#storagemineractor) * [MultisigActor](#multisigactor) * [PaymentChannelActor](#paymentchannelactor) * [StoragePowerActor](#storagepoweractor) * [VerifiedRegistryActor](#verifiedregistryactor) * [SystemActor](#systemactor) #### CronActor The `CronActor` sends messages to the `StoragePowerActor` and `StorageMarketActor` at the end of each epoch. The messages sent by `CronActor` indicate to StoragePowerActor and StorageMarketActor how they should maintain the internal state and process deferred events. This system actor is instantiated in the genesis block and interacts directly with the FVM. #### InitActor The `InitActor` can initialize new actors on the Filecoin network. This system actor is instantiated in the genesis block and maintains a table resolving a public key and temporary actor addresses to their canonical ID addresses. The `InitActor` interacts directly with the FVM. #### AccountActor The `AccountActor` is responsible for user accounts. Account actors are not created by the `InitActor` but by sending a message to a public-key style address. The account actor updates the state tree with a new actor address and interacts directly with the FVM. #### RewardActor The `RewardActor` manages unminted Filecoin tokens and distributes rewards directly to miner actors, where they are locked for vesting. The reward value used for the current epoch is updated at the end of an epoch. The `RewardActor` interacts directly with the FVM. #### StorageMarketActor The `StorageMarketActor` is responsible for processing and managing on-chain deals. This is also the entry point of all storage deals and data into the system. This actor keeps track of storage deals and the locked balances of both the client storing data and the storage provider. When a deal is posted on-chain through the `StorageMarketActor`, the actor will first check if both transacting parties have sufficient balances locked up and include the deal on-chain. Additionally, the `StorageMarketActor` holds *Storage Deal Collateral* provided by the storage provider to collateralize deals. This collateral is returned to the storage provider when all deals in the sector successfully conclude. This actor does not interact directly with the FVM. #### StorageMinerActor The `StorageMinerActor` is created by the `StoragePowerActor` and is responsible for storage mining operations and the collection of mining proofs. This actor is a key part of the Filecoin storage mining subsystem, which ensures a storage miner can effectively commit storage to Filecoin and handles the following: * Committing new storage * Continuously proving storage * Declaring storage faults * Recovering from storage faults This actor does not interact directly with the FVM. #### MultisigActor The `MultisigActor` is responsible for dealing with operations involving the Filecoin wallet and represents a group of transaction signers with a maximum of 256. Signers may be external users or the `MultisigActor` itself. This actor does not interact directly with the FVM. #### PaymentChannelActor The `PaymentChannelActor` creates and manages *payment channels*, a mechanism for off-chain microtransactions for Filecoin dApps to be reconciled on-chain at a later time with less overhead than a standard on-chain transaction and no gas costs. Payment channels are uni-directional and can be funded by adding to their balance. To create a payment channel and deposit fund, a user calls the `PaymentChannelActor`. This actor does not interact directly with the FVM. #### StoragePowerActor The `StoragePowerActor` is responsible for keeping track of the storage power allocated to each storage miner and has the ability to create a `StorageMinerActor`. This actor does not interact directly with the FVM. #### VerifiedRegistryActor The `VerifiedRegistryActor` is responsible for managing Filecoin Plus clients. This actor can add a verified client to the Filecoin Plus program, remove and reclaim expired DataCap allocations, and manage claims. This actor does not interact directly with the FVM. #### SystemActor For more information on `SystemActor`, see the [source code](https://github.com/filecoin-project/specs-actors/blob/master/actors/builtin/system/system_actor.go). ## User actors (smart contracts) A *user actor* is code defined by **any developer** that can interact with the FVM, otherwise known as a *smart contract*. A *smart contract* is a small, self-executing block of custom code that runs on other blockchains, like Ethereum. In the Filecoin network, the term is a synonym for [*user actor*](#user-actors-smart-contracts). You may see the term *smart contract* used in tandem with *user actor*, but there is no difference between the two. With the FVM, actors can be written in Solidity. In future updates, any language that compiles to WASM will be supported. With user actors, users can create and enforce custom rules for storing and accessing data on the network. The FVM is responsible for actors and ensuring that they are executed correctly and securely. [Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/core-concepts/filecoin-virtual-machine/actors) # Addresses A Filecoin address is an identifier that refers to an actor in the Filecoin state. All actors (miner actors, the storage market actor, account actors) have an address. All Filecoin addresses begin with an `f` to indicate the network (Filecoin), followed by any of the address prefix numbers (`0`, `1`, `2`, `3`, `4`) to indicate the address type. There are five address types: <table><thead><tr><th width="161">Address prefix</th><th>Description</th></tr></thead><tbody><tr><td><code>0</code></td><td>An ID address.</td></tr><tr><td><code>1</code></td><td>A <a href="https://en.wikipedia.org/wiki/Secp256k1">SECP256K1</a> public key address.</td></tr><tr><td><code>2</code></td><td>An actor address.</td></tr><tr><td><code>3</code></td><td>A <a href="https://en.wikipedia.org/wiki/BLS_digital_signature">BLS</a> public key address.</td></tr><tr><td><code>4</code></td><td>Extensible, user-defined actor addresses. <code>f410</code> addresses refers to Ethereum-compatible address space, each <code>f410</code> address is equivalent to an <code>0x</code> address.</td></tr></tbody></table> Each of the address types is described below. ## Actor IDs All actors have a short integer assigned to them by `InitActor`, a unique actor that can create *new* actors. This integer that gets assigned is the ID of that actor. An *ID address* is an actor’s ID prefixed with the network identifier and the address type. Actor ID add
프로젝트로 돌아가기