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
  • OpenZeppelin
  • Benefits
  • Using OpenZeppelin with FVM
  • Example using an ERC-20 contract
  • Additional resources
  • DappSys
  • 0x protocol

Was this helpful?

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

Solidity libraries

With Filecoin Virtual Machine (FVM), Solidity developers can use existing libraries listed on this page in their FVM smart contracts.

PreviousFoundryNextCall built-in actors

Last updated 6 months ago

Was this helpful?

OpenZeppelin

provides a library of battle-tested smart contract templates, including widely used implementations of ERC token standards. For a guided example that implements an ERC20 token on the Filecoin network, see .

Benefits

OpenZeppelin offers the following to smart contract developers:

  • Implementations of standards like ERC20, ERC721, and ERC1155.

  • Flexible access control schemes like Ownable, AccessControl, and onlyRole.

  • Useful and secure utilities for signature verification, SafeMath, etc..

Token standards, such as , are the most widely used smart contract libraries from OpenZeppelin. These contracts, listed below, implement both fungible and non-fungible tokens:

  • is the simplest and most widespread token standard for fungible assets.

  • is the standard solution for non-fungible tokens and is often used for collectibles and games.

  • provides a richer standard for fungible tokens, supporting new use cases and backwards compatibility with ERC20.

  • is a new standard for multi-tokens, where a single contract represents multiple fungible and non-fungible tokens, and operations are batched for increased gas efficiency.

Using OpenZeppelin with FVM

The general procedure for using OpenZeppelin with FVM is as follows:

  1. Install OpenZeppelin. For example, using npm:

npm install @openzeppelin/contracts
  1. Import the specific library you want to use.

  2. In your smart contract, inherit the library.

Example using an ERC-20 contract

Prerequisites

Let’s take an ERC20 contract as an example to write and deploy it on the Calibration testnet using Remix & MetaMask:

  • Remix.

  • MetaMask.

Procedure

  1. Next to Workspaces, click the + icon to create a new workspace.

  2. In the Choose a template dropdown, select ERC20 along with the Mintable checkbox

  3. Click OK.

  4. In the contract directory, open MyToken.sol.

  5. Set the token <name> and <symbol>:

// contracts/GLDToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MyToken is ERC20 {
   constructor(uint256 initialSupply) ERC20(<name>, <symbol>) {
      _mint(msg.sender, initialSupply);
   }
}
  1. Next, compile and deploy the contract on Filecoin.

  2. At the top of the workspace, click the green play symbol to compile the contract.

  3. Once the contract compiles, open the Deploy tab on the left.

  4. Under the Environment dropdown, select Injected Provider - MetaMask.

  5. In the MetaMask popup window, select Confirmed connection.

  6. Click Deploy, and confirm the transaction on MetaMask. Your token contract will be deployed to the Calibration testnet once the network confirms the transaction.

  7. In Remix, open the Deployed Contracts dropdown.

  8. In the mint method, set:

    • to to your wallet address.

    • amount to 1000000000000000000 (1 FIL).

  9. Click Transact.

  10. In MetaMask, confirm the transaction.

Once the network processes the transaction, the token is minted and sent to your network address. Congratulations, you’ve completed the tutorial!

Additional resources

Learn more about OpenZeppelin with the following resources:

DappSys

The DappSys library provides safe, simple, and flexible Ethereum contract building blocks for common Ethereum and Solidity use cases.

0x protocol

The 0x protocol library provides a set of secure smart contracts that facilitate peer-to-peer exchange of Ethereum-based assets.

Thanks to the FVM, your contract can be integrated and deployed on the Filecoin network with OpenZeppelin inheritance. For a guided example that implements an ERC20 token on the Filecoin network, see .

In the following tutorial, you’ll write and deploy a smart contract that implements the on the Calibration testnet using Remix and MetaMask:

.

Test tokens (tFIL) .

In this procedure, you will create, deploy, mint and send an token on Calibration using Remix and MetaMask.

Navigate to .

OpenZeppelin
Example using an ERC20 contract
ERC20
ERC20
ERC721
ERC777
ERC1155
Example using an ERC20 contract
ERC-20
MetaMask connected to the Calibration testnet
from the faucet
ERC20
remix.ethereum.org
OpenZeppelin Contracts website
Documentation
GitHub
Documentation
GitHub
Documentation
GitHub
Was this page helpful?