bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 52쪽 중 43쪽
uide](https://lotus.filecoin.io/lotus/install/prerequisites) to properly install the Lotus applications and launch node. The basic steps are:
* Prepare your hardware by meeting the minimal requirements.
* Install dependencies.
* Start the Lotus daemon and sync the chain by either:
* Syncing from scratch: in your lotus directory run `lotus daemon`
* Syncing from a full snapshot.
* Syncing from minimal snapshot
A snapshot only has the state trees from the recent tipset (2000 epochs) onward and nothing before that tipset, which means it does not have all the historical states of the network. In addition, only a full snapshot has full state trees from a certain tipset.
### Check sync status
You can check the sync status by running `lotus sync status`. You are fully synced when the `Height` difference is `0`. Lotus will output any sync error.
```shell
lotus sync status
> worker 28975:
> Base: [bafy2bzacec2exqtdvxzzvikwg3sg67e57yaocpmrljkfxth3isjmruzd45vsa bafy2bzacecbbqdvidaf56eeth7oul2raycjpddvgtb23ywoyrqyh7ajulepai bafy2bzaceajtc3mgie5b72ivuiv3svwnbfq7kl2gnbni5tqc2ja6zi22vkttu bafy2bzacebf7oavffgiajf5goi6verhepsclhb7pcfwirkptu4dxrdoqshadw bafy2bzaceddtymcr5onnh63uznctks5hujpgzxcd45f5ef7oiuqocpmqs6rh2 bafy2bzacebuqm43mspki4ekdbu6xj663mpkrcoxtdss64t27fo77bg7pzbaia bafy2bzaceaxurgudmnphjcoz5sfad7yd63axyhmretqr5jjmvnicyu7betvvi bafy2bzaceali3oihrslxmnjdu2ysesxradorczjimruxdbkqidtcuag7wlr5a]
> Target: [bafy2bzacedmswd73yn5faqzpbu5ofqinmh6fnzxfvazy52jrfthfhod4ssfgw] (1272951)
> Height diff: 1
> Stage: complete
> Height: 1272951
> Elapsed: 243.770396ms
> worker 28976:
> Base: [bafy2bzacedmswd73yn5faqzpbu5ofqinmh6fnzxfvazy52jrfthfhod4ssfgw]
> Target: [bafy2bzacebxf27yxmzksno5ajkvp6shwojrx5mxsrtmlchrdchaqfg2wo7o3i] (1272951)
> Height diff: 0
> Stage: complete
> Height: 1272951
> Elapsed: 1.00020144s
> worker 28977:
> Base: []
> Target: [] (0)
> Height diff: 0
> Stage: idle
> Height: 0
```
You can run `lotus sync wait` to wait for the sync to be complete. Lotus will output `Done!` once your node is fully synced.
## Basic network technology info
The Filecoin network uses a [Proof of Storage (PoRep)](https://spec.filecoin.io/#section-glossary.proof-of-replication-porep) + [Proof of SpaceTime (PoSt)](https://spec.filecoin.io/#section-glossary.proof-of-spacetime-post) consensus algorithm. Time in the Filecoin network is dissected into [epochs](https://spec.filecoin.io/#section-glossary.epoch) set to 30 seconds. A new set of blocks is produced for every epoch for a [tipset](https://spec.filecoin.io/#section-glossary.tipset). The hard finality of the Filecoin network is 900 epochs.
## Accounts and wallets
Filecoin uses an account-based model. There are 4 types of account prefixes:
* `f0` for ID address
* `f1` for Secp256k1 wallets
* `f2`for [actor](https://spec.filecoin.io/#section-glossary.actor) accounts
* `f3` for BLS wallets
`f1`, `f2`, and `f3` prefixed addresses are called account addresses. An account address is activated when it first receives a transaction. `f0` prefixed addresses are mapped to each active account address.
**Testnet addresses** Within a testnet, the address prefix is `t`. So ID addresses become `t0`, Secp256k1 wallets become `t1`, etc.
## Signatures
Filecoin currently uses two types of signatures:
* ECDSA signatures over the Secp256k1 elliptic curve
* BLS signatures over the BLS12-381 group of curves.
Details and reference implementations can be found [in the Filecoin specification](https://spec.filecoin.io/#section-algorithms.crypto.signatures.signature-types).
## Messages
There are two message types:
* [Signed messages](https://github.com/filecoin-project/lotus/blob/9deda06ec632da3f7a035cc63b9408de72c96f79/chain/types/signedmessage.go#L44)
* [Unsigned messages](https://github.com/filecoin-project/lotus/blob/9deda06ec632da3f7a035cc63b9408de72c96f79/chain/types/message.go#L28).
Messages are fully irreversible at 900 epochs. Waiting 200 epochs for message confirmation is acceptable.
There are multiple gas fees associated with each message. Refer to the [practical guide to gas section of this blog post](https://filecoin.io/blog/filecoin-features-gas-fees/) for details.
An `ExitCode` of `0` in the message receipt indicates that the message was sent successfully.
### Mempool
When a user sends a transaction to the network, it gets placed into the mempool queue. If a transaction doesn’t have enough gas, it stays in the mempool and doesn’t go anywhere. To new users, it looks like this transaction is lost forever. However, users can update the transaction with an updated `GasLimit`, `GasFeeCap`, and/or `GasPremium`. As long as you don’t change anything else in the transaction (`nonse`, `to`, `from`, `value`), then the transaction that is sat in the mempool will get updated with the new gas allowance.
**Expiration**
There is no limit for how long a message can spend in the mempool. However, the mempool does get *cleaned* when there are too many messages in it, starting with the messages with the least gas.
### Automatic gas values
When `GasFeeCap`, `GasPremium` and `MaxFee` are set to `0`, Lotus will do the gas estimation for the message with 25% overestimation for the gas limit based on the current network condition.
Some JavaScript libraries attempt to estimate the gas fees before sending the transaction to the Filecoin network. However, they sometimes underestimate, leading to transactions getting stuck in the mempool. If you are noticing your transactions getting stuck in the mempool after sending them to the network using a JavaScript library, try `GasFeeCap`, `GasPremium`, and `MaxFee` to `0`.
### Filecoin's EVM and Send method number
A summary of the Filecoin's EVM differences with Ethereum is available in the [FEVM - Difference with Ethereum section](/core-concepts/filecoin-evm-runtime/difference-with-ethereum).
{% hint style="danger" %}
Note that when sending funds to a Filecoin EVM recipient address (f410f or 0x), it is recommended to always use the **InvokeEVM** **method 3844450837** to prevent possible loss of funds in case the recipient is a smart contract. The `lotus send 0x` CLI method always defaults to this method number.
{% endhint %}
## Integration
You can interact with the network by using Lotus CLI or using the [JSON-RPC APIs](https://lotus.filecoin.io/reference/basics/overview/). Follow the [API tokens guide](https://lotus.filecoin.io/docs/developers/api-access/) to set up API tokens on your node and grant necessary permissions. To find all CLI usage, run `lotus -h` in your lotus folder.
You can find some other API client libraries developed by the Filecoin community [within the API client libraries page](https://lotus.filecoin.io/docs/developers/api-access/#api-client-libraries).
### API examples
Here are some Curl examples for connecting to a Lotus node using the JSON-RPC API:
[**ChainHead**](https://lotus.filecoin.io/reference/lotus/chain/#chainhead)
```shell
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $(cat ~/.lotus/token)" --data '{
"jsonrpc":"2.0",
"method":"Filecoin.ChainHead",
"params":[
],
"id":0
}' http://127.0.0.1:1234/rpc/v0
```
[**ChainGetTipSetByHeight**](https://lotus.filecoin.io/reference/lotus/chain/#chaingettipset)
```shell
curl -X POST -H "Content-Type: application/json"
-H "Authorization: Bearer $(cat ~/.lotus/token)"
--data '{
"jsonrpc":"2.0",
"method":"Filecoin.ChainGetTipSetByHeight",
"params":[
100000,
[
{
"/":"bafy2bzacecxm6lhhzem3wshktatwzrcqbvc3k3jepzz7a6wqyc7w3fvav256i"
}
]
],
"id":0
}' http://127.0.0.1:1234/rpc/v0
```
`bafy2bzacecxm6lhhzem3wshktatwzrcqbvc3k3jepzz7a6wqyc7w3fvav256i` is the block CID. This field is nullable.
[**ChainGetParentMessages**](https://lotus.filecoin.io/reference/lotus/chain/#chaingetparentmessages)
```shell
curl -X POST -H "Content-Type: application/json"
-H "Authorization: Bearer $(cat ~/.lotus/token)"
--data '{
"jsonrpc":"2.0",
"method":"Filecoin.ChainGetParentMessages",
"params":[
{
"/":"bafy2bzacedplsg3tqrv7e3v5rssvq3qwbd3c6g3en55zpqnyrymexhynz6ixu"
}
],
"id":0
}' http://127.0.0.1:1234/rpc/v0
```
`bafy2bzacedplsg3tqrv7e3v5rssvq3qwbd3c6g3en55zpqnyrymexhynz6ixu` is the block CID. You can pass in any one of the block CIDs included in the desired tipset.
[**WalletNew**](https://lotus.filecoin.io/reference/lotus/wallet/#walletnew)
```shell
curl -X POST -H "Content-Type: application/json"
-H "Authorization: Bearer $(cat ~/.lotus/token)"
--data '{
"jsonrpc":"2.0",
"method":"Filecoin.WalletNew",
"params":[
1
],
"id":1
}' http://127.0.0.1:1234/rpc/v0
```
`1` for Secp2561K account and `2` for BLS account.
[**WalletBalance**](https://lotus.filecoin.io/reference/lotus/wallet/#walletbalance)
```shell
curl -X POST -H "Content-Type: application/json"
-H "Authorization: Bearer $(cat ~/.lotus/token)"
--data '{
"jsonrpc":"2.0",
"method":"Filecoin.WalletBalance",
"params":[
“f1d7x4euqwtlk2bqzhclr6gubkufezgddkqftsnky”
],
"id":1
}' http://127.0.0.1:1234/rpc/v0
```
`f1d7x4euqwtlk2bqzhclr6gubkufezgddkqftsnky` is the account address.
[**MpoolPushMessage**](https://lotus.filecoin.io/reference/lotus/mpool/#mpoolpushmessage)
```shell
curl -X POST -H 'Content-Type: application/json'
-H "Authorization: Bearer $(cat ~/.lotus/token)"
--data '{
"jsonrpc":"2.0",
"method":"Filecoin.MpoolPushMessage",
"params":[
{
"To":"t14pu4ogatxvok5727bd7ikp52mnnpxxxqicwyx7i",
"From":"t3w5afgpwisxkryfb676h7xyku57uupigdh3zdoxj3kyep53hmo5njykfatqx5rga75ra5oucbyczr7lbjaezq",
"Value":"1000000000000000000001",
"Method":0,
"Params":null,
"GasLimit":20000000,
"GasFeeCap":"0",
"GasPremium":"0",
"Nonce":0
},
{
"MaxFee":"0"
}
],
"id":0
}' http://127.0.0.1:1234/rpc/v0
```
`Method` ID of `0` with null `Params` is a balance transfer transaction. When the `GasFeeCap`, `GasPremium` and `MaxFee` is `0`, Lotus will do the gas estimation for the message with a 25% overestimation for the gas limit based on the current network condition. You can change this value via the `GasLimitOverestimation` field.
## FAQ
### How do I sign a message?
Use [WalletSign](https://lotus.filecoin.io/reference/lotus/wallet/#walletsign) to sign the message and send the signed message using [MpoolPush](https://lotus.filecoin.io/reference/lotus/mpool/#mpoolpush).
You may also use this [Filecoin signing tool library](/reference/general/tools).
### How do I retrieve the gas fees of a message?
Call [StateReplay](https://lotus.filecoin.io/reference/lotus/state/#statereplay) and look up the `GasCost` in the response.
### How to get the gas estimation of a message?
You can estimate the gas cost of a message by calling [GasEstimateMessageGas](https://lotus.filecoin.io/reference/lotus/gas/#gasestimatemessagegas). This API estimates the gas limit with a 25% overestimation based on the network condition under the given tipset key. You can change this value via the `GasLimitOverestimation` field.
### How do I ensure that all balances transfer in any messages are captured, including msig transfers?
Call [StateCompute](https://lotus.filecoin.io/reference/lotus/state/#statecompute) or [StateReplay](https://lotus.filecoin.io/reference/lotus/state/#statereplay) and go through all the transactions in the execution trace. Whenever the value `!=0 && exit code == 0`, it indicates a balance transfer has occurred.
### How can I check if my transaction is stuck?
The Lotus RPC method to retrieve the list of transactions waiting on the mempool is `Filecoin.MpoolPending`. The RPC call is:
```json
{
"jsonrpc": "2.0",
"method": "Filecoin.MpoolPending",
"id": 1,
"params": [null]
}
```
If you are using a JavaScript library, the method you need is `mpoolPending`.
## Join the Filecoin Slack
Join the [Filecoin Slack](https://filecoinproject.slack.com/signup) and post any questions you have in there.
## Useful Links
* [Filecoin website](https://filecoin.io)
* [Filecoin Specs](https://spec.filecoin.io)
* [Filecoin Networks](https://status.filecoin.io)
* [Lotus](https://github.com/filecoin-project/lotus) - the reference implementation for the Filecoin network
* [Block Explorers](/networks-and-tools/networks/mainnet/explorers)
[Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/reference/exchanges/exchange-integration)
# Built-in actors
Built-in actors are how the Filecoin network manages and updates global state. This page contains information on how smart contracts can access 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 execution of all actor code.
A basic example of how built-in 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`’s 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:
* Inline data such as current block height.
* A pointer (CID) to the current state tree.
* A pointer (CID) 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) 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 map contain information on:
* The actor the message was sent to
* The actor that sent the message
* Target method to call on 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 network, such as the current epoch, and 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 which 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 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 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 of 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 the Filecoin, 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 w프로젝트로 돌아가기