bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 52쪽 중 45쪽
cked amount for this address.
### WithdrawBalance
```go
func WithdrawBalance(params WithdrawBalanceParams) WithdrawBalanceReturn {}
```
Withdraw the specified amount from the balance held in escrow.
`uint` WithdrawBalanceMethodNum = 2280458852.
Params:
* `struct` WithdrawBalanceParams
* `bytes` ProviderOrClientAddress - the address of the provider or client.
* `int256` TokenAmount - the token amount to withdraw.
Results:
* `struct` WithdrawBalanceReturn
* `int256` AmountWithdraw - the token amount withdrawn.
### PublishStorageDeals
```go
func PublishStorageDeals(params PublishStorageDealsParams) PublishStorageDealsReturn {}
```
Publish a new set of storage deals that are not yet included in a sector.
`uint` PublishStorageDealsMethodNum = 2236929350.
Params:
* `struct` PublishStorageDealsParams
* `struct ClientDealProposal[]` Deals - list of deal proposals signed by a client
* `struct DealProposal` Proposal
* `bytes` PieceCID.
* `uint64` PieceSize - the size of the piece.
* `bool` VerifiedDeal - if the deal is verified or not.
* `bytes` Client - the address of the storage client.
* `bytes` Provider - the address of the storage provider.
* `string` Label - any label that the client chooses for the deal.
* `int64` StartEpoch - the chain epoch to start the deal.
* `int64` EndEpoch - the chain epoch to end the deal.
* `int256` StoragePricePerEpoch - the token amount to pay to the provider per epoch.
* `int256` ProviderCollateral - the token amount as collateral paid by the provider.
* `int256` ClientCollateral - the token amount as collateral paid by the client.
* `bytes` ClientSignature - the signature signed by the client.
Results:
* `struct` PublishStorageDealsReturn
* `uint64[]` IDs - returned storage deal IDs.
* `bytes` ValidDeals - represent all the valid deals.
### GetDealDataCommitment
```go
func GetDealDataCommitment(params GetDealDataCommitmentParams) GetDealDataCommitmentReturn {}
```
Return the data commitment and size of a deal proposal.
`uint` GetDealDataCommitmentMethodNum = 1157985802.
Params:
* `uint64` GetDealDataCommitmentParams - Deal ID.
Results:
* `struct` GetDealDataCommitmentReturn
* `bytes` Data - the data commitment of this deal.
* `uint64` Size - the size of this deal.
### GetDealClient
```go
func GetDealClient(params GetDealClientParams) GetDealClientReturn {}
```
Return the client of the deal proposal.
`uint` GetDealClientMethodNum = 128053329.
Params:
* `uint64` GetDealClientParams - CID of the deal proposal.
Results:
* `bytes` GetDealClientReturn - the wallet address of the client.
### GetDealProvider
```go
func GetDealProvider(params GetDealProviderParams) GetDealProviderReturn {}
```
Return the provider of a deal proposal.
`uint` GetDealProviderMethodNum = 935081690.
Params:
* `uint64` GetDealProviderParams - CID of the deal proposal.
Results:
* `bytes` GetDealProviderReturn - the wallet address of the provider.
### GetDealLabel
```go
func GetDealLabel(params GetDealLabelParams) GetDealLabelReturn {}
```
Return the label of a deal proposal.
`uint` GetDealLabelMethodNum = 46363526.
Params:
* `uint64` GetDealLabelParams - CID of the deal proposal.
Results:
* `string` GetDealLabelReturn - the label of this deal.
### GetDealTerm
```go
func GetDealTerm(params GetDealTermParams) GetDealTermReturn {}
```
Return the start epoch and duration(in epochs) of a deal proposal.
`uint` GetDealTermMethodNum = 163777312.
Params:
* `uint64` GetDealTermParams - CID of the deal proposal.
Results:
* `struct`GetDealTermReturn
* `int64` Start - the chain epoch to start the deal.
* `int64` End - the chain epoch to end the deal.
### GetDealTotalPrice
```go
func GetDealTotalPrice(params GetDealTotalPriceParams) GetDealTotalPriceReturn {}
```
Return the total price that will be paid from the client to the provider for this deal.
`uint` GetDealEpochPriceMethodNum = 4287162428.
Params:
* `uint64` GetDealTotalPriceParams - CID of the deal proposal.
Results:
* `int256` GetDealTotalPriceReturn - the token amount that will be paid by the client to the provider.
### GetDealClientCollateral
```go
func GetDealClientCollateral(params GetDealClientCollateralParams) GetDealClientCollateralReturn {}
```
Return the client collateral requirement for a deal proposal.
`uint` GetDealClientCollateralMethodNum = 200567895.
Params:
* `uint64` GetDealClientCollateralParams - CID of the deal proposal.
Results:
* `int256` GetDealClientCollateralReturn - the token amount as collateral paid by the client.
### GetDealProviderCollateral
```go
func GetDealProviderCollateral(params GetDealProviderCollateralParams) GetDealProviderCollateralReturn {}
```
Return the provided collateral requirement for a deal proposal.
`uint` GetDealProviderCollateralMethodNum = 2986712137.
Params:
* `uint64` GetDealProviderCollateralParams - CID of the deal proposal.
Results:
* `int256` GetDealProviderCollateralReturn - the token amount as collateral paid by the provider.
### GetDealVerified
```go
func GetDealVerified(params GetDealVerifiedParams) GetDealVerifiedReturn {}
```
Return the verified flag for a deal proposal.
`uint` GetDealVerifiedMethodNum = 2627389465.
Params:
* `uint64` GetDealVerifiedParams - CID of the deal proposal.
Results:
* `bool` GetDealVerifiedReturn - if the deal is verified or not.
### GetDealActivation
```go
func GetDealActivation(params GetDealActivationParams) GetDealActivationReturn {}
```
Return the activation state for a deal.
`uint` GetDealActivationParams = 2567238399.
Params:
* `uint64` GetDealVerifiedParams - CID of the deal proposal.
Results:
* `struct` GetDealActivationReturn
* `int64` Activated - Epoch at which the deal was activated, or -1.
* `int64` Terminated -Epoch at which the deal was terminated abnormally, or -1.
## Storage power actor
Storage power actor is responsible for keeping track of the storage power allocated at each storage miner. The ActorCode for the built-in storage power actor is `hex"0004"` which will be used to call methods in the storage power actor. You also need to specify the method number for the method you want to invoke. Please refer to each method for its method number.
### CreateMiner
```go
func CreateMiner(params CreateMinerParams) CreateMinerReturn {}
```
Create a new miner for the owner address and worker address.
`uint` CreateMinerMethodNum = 1173380165.
Params:
* `struct` CreateMinerParams
* `bytes` Owner - the address of the owner.
* `bytes` Worker - the address of the worker.
* `RegisteredPoStProof` WindowPoStProofType - the type of RegisteredPoStProof.
* `bytes` Peer - peerID.
* `bytes[]` Multiaddrs - the multi-address which is used to control the newly created miner.
Results:
* CreateMinerReturn
* `bytes` IDAddress - The canonical ID-based address for the actor.
* `byte`: RobustAddress -A more expensive but re-org-safe address for the newly created actor.
### NetworkRawPower
```go
func NetworkRawPower() NetworkRawPowerReturn {}
```
Return the total raw power of the network.
`uint` NetworkRawPowerMethodNum = 931722534.
Params:
* null
Results:
* `int256` NetworkRawPowerReturn - the raw storage power of the whole network.
### MinerRawPower
```go
func MinerRawPower(params MinerRawPowerParams) MinerRawPowerParams {}
```
Return the raw power claimed by the specified miner and whether the miner has more than the minimum amount of active storage.
`uint` MinerRawPowerMethodNum = 3753401894.
Params:
* MinerRawPowerParams
* `uint64` Miner - Miner ID
Results:
* `struct` MinerRawPowerParams
* `int256` RawBytePower - the row power of the miner.
* `bool` MeetsConsensusMinimum - if the miner power meets the minimum for consensus.
### MinerCount
```go
func MinerCount() MinerCountReturn {}
```
Returns the total number of miners created, regardless of whether or not they have any pledged storage.
`uint` MinerRawPowerMethodNum = 3753401894.
Params:
* null
Results:
* `uint64` MinerCountReturn - the count of the miners that the caller address has.
### MinerConsensusCount
```go
func MinerConsensusCount() MinerConsensusCountReturn {}
```
Returns the total number of miners that have more than the minimum amount of active storage.
`uint` MinerConsensusCountMethodNum = 196739875.
Params:
* null
Results:
* `uint64`MinerConsensusCountReturn - the count of the miners that meet the consensus minimum that the caller address has.
## Verified registry actor
Verified registry actor is responsible for managing verified clients. The ActorCode for the verified registry built-in actor is `hex"0006"` which will be used to call the exported methods in the verified registry built-in actor. You need to specify the method number for the method you want to invoke. Please refer to each method for its method number.
### AddVerifiedClient
```go
func AddVerifiedClient(params AddVerifiedClientParams) EmptyValue {}
```
To add a verified Client address to Filecoin Plus program.
`uint` constant AddVerifierClientMethodNum = 3916220144.
Params:
* `struct` AddVerifierClientParams
* `bytes` Address - the verified client address
* `int256` Allowance - approved DataCap for this verified client
Results:
* `struct` EmptyValue.
### RemoveExpiredAllocations
```go
func RemoveExpiredAllocations(params RemoveExpiredAllocationsParams) RemoveExpiredAllocationsReturn {}
```
Remove the expired DataCap allocations and reclaim those DataCap tokens back to the client. If the allocation amount is not specified, all expired DataCap allocations will be removed.
`uint` RemoveExpiredAllocationsMethodNum = 2873373899.
Params:
* `struct` RemoveExpiredAllocationsParams
* `uint64` Client - the client address to remove the expired tokens from.
* `uint64[]` AllocationIDs - List of allocation IDs to attempt to remove. If empty, this method will remove all eligible expired tokens.
Results:
* `struct` RemoveExpiredAllocationsReturn
* `unit64[]`Considered - Allocation IDs are either specified by the caller or discovered to be expired.
* `BatachReturn` Results - results for each processed allocation.
* `int256` DataCapRecoverd - The amount of DataCap token reclaimed for the client.
### GetClaims
```go
func GetClaims(params GetClaimsParams) GetClaimsReturn {}
```
Return a list of claims corresponding to the requested claim ID for a specific provider.
`uint` GetClaimsMethodNum = 2199871187.
Params:
* `struct`GetClaimsParams
* `uint64` Provider - the provider address.
* `unit64[]` ClaimIDs - A list of Claim IDs for a specific provider.
Results:
* `struct` GetClaimsReturn
* `struct` BatchReturn
* `uint32` SuccessCount - total successes in the batch.
* `struct` FailCode\[] {`uint32` idx, `uint32` code} - list of failure code and index for all failures in batch.
* `struct Claim[]` Claims - list of Claims returned.
* `uint64` Provider - The provider that is storing the data.
* `uint64` Client - The client that originally allocated the DataCap.
* `bytes` Data - Identifier for the data committed.
* `uint64` Size - The size of the data.
* `int64` TermMin - The minimum period after the term starts, during which the provider must commit to storing data.
* `int64` TermMax - The maximum period after the term starts for which the provider can earn Quality Adjusted power for the data.
* `int64` TermStart - the epoch at which the piece was committed.
* `unit64` Sector - ID of the provider’s sector in which the data is committed.
### ExtendClaimTerms
```go
func ExtendClaimTerms(params ExtendClaimTermsParams) ExtendClaimTermsReturn {}
```
Extends the maximum term of some claims up to the largest value they could have been originally allocated. This method can only be called by the claims’ client.
`uint` ExtendClaimTermsMethodNum = 1752273514.
Params:
* `struct` ExtendClaimTermsParams
* `struct ClaimTerm[]` Terms
* `uint64` Provider - The provider address which stores the data.
* `uint64` ClaimID - Claim ID.
* `int64` TermMax - The max chain epoch to extend.
Results:
* `struct` ExtendClaimTermsReturn
* `struct` BatchReturn
* `uint32` SuccessCount - total successes in the batch.
* `struct` FailCodes\[] {`uint32` idx, `uint32` code} - list of failure code and index for all failures in batch.
### RemoveExpiredClaims
```go
func RemoveExpiredClaims(params: RemoveExpiredClaimsParams) RemoveExpiredClaimsReturn {}
```
To remove a claim with its maximum term has elapsed.
`uint` RemoveExpiredClaimsMethodNum = 2873373899.
Params:
* `struct` RemoveExpiredClaimsParams
* `uint64` Provider - the provider address.
* `unit64[]` ClaimIDs - A list of Claim IDs with an expired term. If no claims are specified, all eligible claims will be removed.
Results:
* `struct` RemoveExpiredClaimsReturn
* `uint64[]` Considered - a list of IDs of the claims that were either specified by the caller or discovered to be expired.
* `struct` BatchReturn
* `uint32` SuccessCount - total successes in the batch
* `struct` FailCodes\[] {`uint32` idx, `uint32` code} - list of failure code and index for all failures in batch.
[Was this page helpful?](https://airtable.com/apppq4inOe4gmSSlk/pagoZHC2i1iqgphgl/form?prefill_Page+URL=https://docs.filecoin.io/reference/built-in-actors/protocol-api)
# Filecoin.sol
This page covers the built-in actors Filecoin.sol API.
For conceptual information on built-in actors, including their purposes, how they work and more, see the [conceptual guide](/reference/built-in-actors).
## Prerequisites
Before you can call a built-in actor using the API, you must [import Filecoin.sol using one of the available methods](/build-on-filecoin/developing-contracts/call-built-in-actors#import-filecoinsol).
## Works on
Filecoin.sol is for contracts deployed to Filecoin EVM networks that expose Filecoin built-in actor precompiles. Use the current `filecoin-solidity-api` package on Filecoin mainnet or Calibration testnet, and use the same API surface when testing against a local Filecoin EVM-compatible network.
## Call a built-in actor
For available actors and methods see [Available actors and methods](/build-on-filecoin/developing-contracts/call-built-in-actors#available-actors-and-methods).
Once you’ve either imported particular contracts manually or installed `filecoin-solidity-api` using `npm`, create a callable method to access the built-in actor methods the way you normally would in a Solidity smart contract. Working examples of smart contracts that call built-in actor methods are available below.
* [Account](#call-the-account-actor)
* [DataCap](#call-the-datacap-actor)
* [Miner](#call-the-miner-actor)
* [Storage market](#call-the-storage-market-actor)
* [Storage power](#call-the-storage-power-actor)
* [Verified registry](#call-the-verified-registry-actor)
For conceptual information on built-in actors, including their purposes, how they work and available types, see the [conceptual guide](/reference/built-in-actors).
### Call the account actor
The following example imports the Account actor library and creates a callable method for each of the [available actor methods](#call-the-account-actor). For the full code, see [the GitHub repository](https://github.com/filecoin-project/filecoin-solidity/blob/master/contracts/v0.8/tests/account.test.sol).
```solidity
pragma solidity ^0.8.18;
import "../types/AccountTypes.sol";
import "../types/CommonTypes.sol";
import "../AccountAPI.sol";
import "../utils/UtilsHandlers.sol";
import "../utils/Errors.sol";
contract AccountApiTest {
function authenticate_message(CommonTypes.FilActorId target, AccountTypes.AuthenticateMessageParams memory params) public view {
int256 exit_code = AccountAPI.authenticateMessage(target, params);
Errors.revertOnError(exit_code);
}
function universal_receiver_hook(CommonTypes.FilActorId target, CommonTypes.UniversalReceiverParams memory params) public {
(int256 exit_code, ) = UtilsHandlers.universalReceiverHook(target, params);
Errors.revertOnError(exit_code);
}
}
```
### Call the DataCap actor
The following example imports the DataCap actor library and creates a callable method for each of the [available actor methods](#call-the-datacap-actor). For the full code, see [the GitHub repository](https://github.com/filecoin-project/filecoin-solidity/blob/master/contracts/v0.8/tests/datacap.test.sol).
```solidity
pragma solidity ^0.8.18;
import "../types/DataCapTypes.sol";
import "../types/CommonTypes.sol";
import "../cbor/BigIntCbor.sol";
import "../DataCapAPI.sol";
import "../utils/UtilsHandlers.sol";
import "../utils/Errors.sol";
contract DataCapApiTest {
function name() public view returns (string memory) {
(int256 exit_code, string memory result) = DataCapAPI.name();
Errors.revertOnError(exit_code);
return result;
}
function symbol() public view returns (string memory) {
(int256 exit_code, string memory result) = DataCapAPI.symbol();
Errors.revertOnError(exit_code);
return result;
}
function total_supply() public view returns (CommonTypes.BigInt memory) {
(int256 exit_code, CommonTypes.BigInt memory result) = DataCapAPI.totalSupply();
Errors.revertOnError(exit_code);
return result;
}
function balance(CommonTypes.FilAddress memory addr) public view returns (CommonTypes.BigInt memory) {
(int256 exit_code, CommonTypes.BigInt memory result) = DataCapAPI.balance(addr);
Errors.revertOnError(exit_code);
return result;
}
function allowance(DataCapTypes.GetAllowanceParams memory params) public view returns (CommonTypes.BigInt memory) {
(int256 exit_code, CommonTypes.BigInt memory result) = DataCapAPI.allowance(params);
Errors.revertOnError(exit_code);
return result;
}
function transfer(DataCapTypes.TransferParams memory params) public returns (DataCapTypes.TransferReturn memory) {
(int256 exit_code, DataCapTypes.TransferReturn memory result) = DataCapAPI.transfer(params);
Errors.revertOnError(exit_code);
return result;
}
function transfer_from(DataCapTypes.TransferFromParams memory params) public returns (DataCapTypes.TransferFromReturn memory) {
(int256 exit_code, DataCapTypes.TransferFromReturn memory result) = DataCapAPI.transferFrom(params);
Errors.revertOnError(exit_code);
return result;
}
function increase_allowance(DataCapTypes.IncreaseAllowanceParams memory params) public returns (CommonTypes.BigInt memory) {
(int256 exit_code, CommonTypes.BigInt memory result) = DataCapAPI.increaseAllowance(params);
Errors.revertOnError(exit_code);
return result;
}
function decrease_allowance(DataCapTypes.DecreaseAllowanceParams memory params) public returns (CommonTypes.BigInt memory) {
(int256 exit_code, CommonTypes.BigInt memory result) = DataCapAPI.decreaseAllowance(params);
Errors.revertOnError(exit_code);
return result;
}
function revoke_allowance(CommonTypes.FilAddress memory operator) public returns (CommonTypes.BigInt memory) {
(int256 exit_code, CommonTypes.BigInt memory result) = DataCapAPI.revokeAllowance(operator);
Errors.revertOnError(exit_code);
return result;
}
function burn(CommonTypes.BigInt memory amount) public returns (CommonTypes.BigInt memory) {
(int256 exit_code, CommonTypes.BigInt memory result) = DataCapAPI.burn(amount);
Errors.revertOnError(exit_code);
return result;
}
function burn_from(DataCapTypes.BurnFromParams memory params) public returns (DataCapTypes.BurnFromReturn memory) {
(int256 exit_code, DataCapTypes.BurnFromReturn memory result) = DataCapAPI.burnFrom(params);
Errors.revertOnError(exit_code);
return result;
}
function handle_filecoin_method(uint64 method, uint64 codec, bytes calldata params) public pure {
UtilsHandlers.handleFilecoinMethod(method, codec, params);
}
}
```
### Call the storage market actor
The following example imports the Storage market actor library and creates a callable method for each of the [available actor methods](#call-the-storage-market-actor). For the full code, see [the GitHub repository](https://github.com/filecoin-project/filecoin-solidity/blob/master/프로젝트로 돌아가기