Filecoin Docs
BasicsStorage providersNodesNetworksSmart contractsReference
  • Welcome to Filecoin Docs
  • Basics
    • What is Filecoin
      • Crypto-economics
      • Blockchain
      • Storage model
      • Storage market
      • Retrieval market
      • Programming on Filecoin
      • Networks
    • The blockchain
      • Actors
      • Addresses
      • Blocks and tipsets
      • Consensus
      • Drand
      • Proofs
    • Assets
      • The FIL token
      • Wallets
      • Metamask setup
      • Get FIL
      • Transfer FIL
    • Interplanetary consensus
    • How storage works
      • Filecoin plus
      • Storage onramps
      • Filecoin and IPFS
    • How retrieval works
      • Basic retrieval
      • Serving retrievals
      • Saturn
    • Project and community
      • Forums and FIPs
      • Filecoin compared to
      • Filecoin FAQs
      • Related projects
      • Social media
      • The Filecoin project
      • Ways to contribute
  • Storage providers
    • Basics
      • Quickstart guide
    • Filecoin economics
      • Storage proving
      • FIL collateral
      • Block rewards
      • Slashing
      • Committed capacity
    • Filecoin deals
      • Storage deals
      • Verified deals
      • Filecoin programs and tools
      • Snap deals
      • Charging for data
      • Auxiliary services
      • Return-on-investment
    • Architecture
      • Software components
      • Storage provider automation
      • Sealing pipeline
      • Sealing rate
      • Sealing-as-a-service
      • Network indexer
    • Infrastructure
      • Storage
      • Network
      • Backup and disaster recovery
      • Reference architectures
    • Skills
      • Linux
      • Network
      • Security
      • Storage
      • Sales
      • Industry
    • PDP
      • Prerequisites
      • Install & Run Lotus
      • Install & Run YugabyteDB
      • Install & Run Curio
      • Enable PDP
      • Use PDP
  • Nodes
    • Implementations
      • Lotus
      • Venus
    • Full-nodes
      • Pre-requisites
      • Basic setup
      • Node providers
    • Lite-nodes
      • Spin up a lite-node
  • Smart contracts
    • Fundamentals
      • The Filecoin Virtual Machine
      • Filecoin EVM runtime
      • ERC-20 quickstart
      • Roadmap
      • Support
      • FAQs
    • Filecoin EVM-runtime
      • Actor types
      • Address types
      • FILForwarder
      • Difference with Ethereum
      • How gas works
      • Precompiles
    • Programmatic storage
      • Aggregated deal-making
      • Direct deal-making
      • Cross-Chain Data Bridge(CCDB)
      • Data replication, renewal and repair (RaaS)
      • RaaS interfaces
    • Developing contracts
      • Get test tokens
      • Remix
      • Hardhat
      • Foundry
      • Solidity libraries
      • Call built-in actors
      • Filecoin.sol
      • Direct deal-making with Client contract
      • Using RaaS
      • Verify a contract
      • Best practices
    • Advanced
      • Wrapped FIL
      • Oracles
      • Multicall
      • Multisig
      • FEVM Indexers
      • Cross-chain bridges
      • Aggregated deal-making
      • Contract automation
      • Relay
  • Networks
    • Mainnet
      • Explorers
      • RPCs
      • Network performance
    • Calibration
      • Explorers
      • RPCs
    • Local testnet
      • Get test tokens
    • Deprecated networks
  • Reference
    • General
      • Glossary
      • Specifications
      • Tools
    • Exchanges
      • Exchange integration
    • Built-in actors
      • Protocol API
      • Filecoin.sol
    • JSON-RPC
      • Auth
      • Chain
      • Client
      • Create
      • Eth
      • Gas
      • I
      • Log
      • Market
      • Miner
      • Mpool
      • Msig
      • Net
      • Node
      • Paych
      • Raft
      • Start
      • State
      • Sync
      • Wallet
      • Web3
  • Builder Cookbook
    • Overview
    • Table of Contents
    • Data Storage
      • Store Data
      • Retrieve Data
      • Privacy & Access Control
    • dApps
      • Chain-Data Query
      • Oracles
      • Cross-Chain Bridges
      • Decentralized Database
Powered by GitBook
LogoLogo

Basics

  • Overview
  • Crypto-economics
  • Storage model
  • Reference

Developers

  • The FVM
  • EVM-runtime
  • Quickstart
  • Transfer FIL

Contact

  • GitHub
  • Slack
  • Twitter
On this page
  • APIs compared
  • Protocol API
  • Filecoin.sol
  • Available actors and methods
  • Import filecoin.sol
  • Call a built-in actor

Was this helpful?

Edit on GitHub
Export as PDF
  1. Smart contracts
  2. Developing contracts

Call built-in actors

Filecoin built-in actors can be invoked in a smart contract using either the Protocol API or the Filecoin.sol library. This page provides instructions on how to use each method.

PreviousSolidity librariesNextFilecoin.sol

Last updated 3 months ago

Was this helpful?

For conceptual information on built-in actors, including their purposes, how they work and available types, see the

Built-in actors can be invoked using the Protocol JSON-RPC API or the Zondax filecoin.sol API.

APIs compared

The Protocol JSON-RPC API:

  • Is maintained by Protocol Labs (PL).

  • Uses JSON-RPC, a standardized way to encode remote procedure calls in JSON that can be transported using HTTP or WebSockets.

  • Provides a language agnostic interface for Filecoin functionality.

  • Allows applications to access Filecoin functionality using HTTP or WebSockets calls to a Filecoin node, like the Lotus daemon.

  • Requires authentication for some API calls.

  • Serves as the foundation for language-specific libraries (some of which are maintained by organizations other than PL) such as .

The Zondax filecoin.sol API:

  • Supports .

Protocol API

Smart contracts can directly access built-in actors and methods using the Protocol API. Links to the reference guides for each of the available actor methods is listed below:

Filecoin.sol

Smart contracts can access built-in actor methods with the filecoin.sol library, a set of Solidity libraries that allow Solidity smart contracts to seamlessly call methods of Filecoin built-in actors. The filecoin.sol library supports cross-platform calls to real Filecoin built-in actors. This section contains information on the actors and methods available from filecoin.sol, along with installation instructions and working examples of smart contracts that call built-in actor methods.

To invoke built-in actor methods using filecoin.sol, follow these steps:

Available actors and methods

The majority of the Account, DataCap, Storage Market, Miner, Storage Owner and Verified Registry actor methods are supported and are listed below. Cron, Payment Channel, Reward and System actor methods are currently not supported.

Account

Method
Supported?

AuthenticateMessage

✔️

Constructor

✖️

PubkeyAddress

✖️

UniversalReceiverHook

✔️

DataCap

Method
Supported?

Allowance

✔️

BalanceOf

✔️

Burn

✔️

BurnFrom

✔️

Constructor

✖️

DecreaseAllowance

✔️

Destroy

✖️

IncreaseAllowance

✔️

Mint

✖️

Name

✔️

RevokeAllowance

✔️

Symbol

✔️

TotalSupply

✔️

Transfer

✔️

TransferFrom

✔️

Miner

Method
Supported?

ApplyRewards

✖️

ChangeBeneficiary

✔️

ChangeMultiaddrs

✔️

ChangeOwnerAddress

✔️

ChangePeerID

✔️

ChangeWorkerAddress

✔️

CheckSectorProven

✖️

CompactPartitions

✖️

CompactSectorNumbers

✖️

ConfirmSectorProofsValid

✖️

ConfirmUpdateWorkerKey

✖️

Constructor

✖️

ControlAddresses

✖️

DeclareFaults

✖️

DeclareFaultsRecovered

✖️

DisputeWindowedPoSt

✖️

ExtendSectorExpiration

✖️

ExtendSectorExpiration2

✖️

GetAvailableBalance

✔️

GetBeneficiary

✔️

GetOwner

✔️

GetSectorSize

✔️

GetVestingFunds

✔️

IsControllingAddress

✔️

OnDeferredCronEvent

✖️

PreCommitSector

✖️

PreCommitSectorBatch

✖️

PreCommitSectorBatch2

✖️

ProveCommitAggregate

✖️

ProveCommitSector

✖️

ProveReplicaUpdates

✖️

ProveReplicaUpdates2

✖️

Read fee debt

✖️

Read initial pledge total

✖️

Read peer ID, multiaddr

✔️

Read pre-commit deposit

✖️

RepayDebt

✔️

ReportConsensusFault

✖️

SubmitWindowedPoSt

✖️

TerminateSectors

✖️

WithdrawBalance

✔️

Multisig

Method
Supported?

AddSigner

✔️

Approve

✔️

Cancel

✔️

ChangeNumApprovalsThreshold

✖️

Constructor

✖️

List signers and threshold

✖️

LockBalance

✔️

Propose

✔️

RemoveSigner

✔️

SwapSigner

✔️

UniversalReceiverHook

✔️

Storage market

Method
Supported?

ActivateDeals

✖️

AddBalance

✔️

ComputeDataCommitment

✖️

Constructor

✖️

CronTick

✖️

GetBalance

✔️

GetDealActivation

✔️

GetDealClient

✔️

GetDealClientCollateral

✔️

GetDealDataCommitment

✔️

GetDealEpochPrice

✔️

GetDealLabel

✔️

GetDealProvider

✔️

GetDealProviderCollateral

✔️

GetDealTerm

✔️

GetDealVerified

✔️

OnMinerSectorsTerminate

✖️

PublishStorageDeals

✔️

VerifyDealsForActivation

✖️

WithdrawBalance

✔️

Storage power

Method
Supported?

Compute pledge collateral for new sector

✖️

Constructor

✖️

CreateMiner

✔️

CurrentTotalPower

✖️

EnrollCronEvent

✖️

Get miner count, consensus count

✔️

Get miner’s QA power

✖️

Get network bytes committed?

✖️

Get network epoch pledge collateral

✖️

Get network epoch QA power

✖️

Get network total pledge collateral?

✖️

MinerRawPower

✔️

NetworkRawPower

✔️

OnEpochTickEnd

✖️

SubmitPoRepForBulkVerify

✖️

UpdateClaimedPower

✖️

UpdatePledgeTotal

✖️

Verified registry

Method
Supported?

AddVerifiedClient

✔️

AddVerifier

✖️

ClaimAllocations

✖️

Constructor

✖️

ExtendClaimTerms

✔️

GetClaims

✔️

List claims

✖️

List/check verifiers

✖️

List/get allocations

✖️

RemoveExpiredAllocations

✔️

RemoveExpiredClaims

✔️

RemoveVerifiedClientDataCap

✖️

RemoveVerifier

✖️

UniversalReceiverHook

✔️

Import filecoin.sol

Import filecoin.sol with npm

  1. Install filecoin.sol:

yarn add @zondax/filecoin.sol

Until mid-2023, Zondax was the legacy maintainer of Filecoin.sol. Protocol Labs took over the project, and are in the process of moving NPM packages over to the protocollabs NPM account.

Import filecoin.sol manually

  1. Navigate to your smart contract project folder <my-project>:

cd my-project
  1. Create a folder named libs:

mkdir libs
  1. Move into the libs directory:

cd libs

Call a built-in actor

Review the .

.

.

The filecoin.sol library is embeddable into your smart contract, which means it does not need be present on chain first. Instead, you can just import the library and call the available methods. The filecoin.sol library can be or into your contract. The npm-based import is simpler, and is recommended.

Install if you don’t have it installed.

Copy the Zondax contracts with the methods you wish to call from into libs.

Once you’ve either imported particular contracts manually or simply installed filecoin.sol 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 in the .

available actors and methods
Import filecoin.sol
Call a built-in actor
added via npm
manually imported
yarn
the contracts folder
Was this page helpful?
conceptual guide
filecoin.js
some but not all of the built-in actors and their methods
Account actor
Datacap
Miner
Multisig
Storage market actor
Storage power actor
Verified registry actor
reference guide