FIL.VN — Data Availability & Decentralized Storage
Trang chủ ZRO.VN
⚙️ Kỹ thuật nâng cao · Cluster D1

Filecoin Virtual
Machine (FVM)

FVM biến Filecoin từ "ổ cứng phi tập trung" thành programmable storage layer — nơi smart contract có thể trực tiếp kiểm soát storage deal, tạo dataset marketplace, xây perpetual storage, và kết hợp DeFi với lưu trữ phi tập trung.

FIL.VN Knowledge Base Cập nhật: 2025 Thời gian đọc: ~13 phút Smart Contract · FVM · FEVM
Tóm tắt — FVM trong một đoạn

Trước FVM, Filecoin chỉ có thể lưu file theo deal tĩnh — không có logic tự động. FVM (Filecoin Virtual Machine), ra mắt tháng 3/2023, mang smart contract vào Filecoin. FEVM — implementation đầu tiên — cho phép chạy Solidity contract với đầy đủ EVM compatibility, đồng thời có thêm Filecoin-native precompiles để tương tác trực tiếp với storage market, SP, và network power. Kết quả: perpetual storage, dataset marketplace, storage-backed DeFi — tất cả trở thành hiện thực.

1Tại sao Filecoin cần Virtual Machine?

Trước FVM, Filecoin hoạt động như một static file storage system: bạn tạo deal, SP lưu file, deal hết hạn, file có thể bị xóa. Không có logic tự động, không có composability với DeFi, không có programmable access control.

Điều này giới hạn Filecoin trong những use case đơn giản, trong khi các vấn đề thực tế phức tạp hơn nhiều:

  • Làm sao đảm bảo file tồn tại mãi mãi mà không cần manual renew?
  • Làm sao bán quyền truy cập dataset một cách trustless, không cần middleman?
  • Làm sao dùng FIL collateral trong storage deal như DeFi yield?
  • Làm sao trigger action khi deal expires hoặc SP vi phạm?

FVM giải quyết tất cả bằng cách đưa smart contract vào Filecoin — cho phép lập trình logic trực tiếp trên storage layer.

2Kiến trúc FVM — FEVM và Native Actors

User dApps & Smart Contracts
Perpetual storage, dataset marketplace, storage DeFi, access control
Solidity / WASM
FEVM — Filecoin EVM Runtime
EVM bytecode execution + Filecoin-native precompiles (Storage Market, Miner, Power)
EVM-compatible
Built-in Actors (System Contracts)
Storage Market Actor, Miner Actor, Power Actor, Init Actor — core Filecoin logic
Native Filecoin
Filecoin Network Layer
Storage Providers, Proof of Spacetime, FIL tokenomics, consensus (EC)
L1 Infrastructure

FEVM — EVM trong Filecoin

FEVM là Ethereum Virtual Machine chạy bên trong Filecoin. Developer Ethereum có thể deploy Solidity contract lên Filecoin với gần như không thay đổi gì. Tools quen thuộc đều hoạt động: Hardhat, Foundry, Remix, ethers.js, wagmi.

Chain ID Filecoin: Mainnet = 314 — Calibration testnet = 314159. Khi connect MetaMask hoặc cấu hình RPC, dùng chain ID này để phân biệt với Ethereum mainnet (chain ID 1).

3Filecoin-native Precompiles — Sức mạnh độc đáo của FVM

Điểm khác biệt của FEVM so với Ethereum EVM là các Filecoin-native precompiles — built-in functions cho phép smart contract trực tiếp tương tác với Filecoin network state:

Precompile / ActorChức năngUse case
MarketAPI Tạo storage deal, query deal state, publish deal Perpetual storage, automated deal renewal
MinerAPI Query SP info: power, collateral, fault status SP selection logic, reputation scoring
PowerAPI Query network total power, miner power Governance, weighted voting by storage power
DataCapAPI Quản lý DataCap (Filecoin Plus allocations) Automated Fil+ allocation, verified deal creation
AccountAPI Resolve f0/f1/f2/f4 address types Cross-address type interaction trong contract
SendAPI Gửi FIL sang Filecoin native actors Pay SP từ contract treasury

4Use case quan trọng nhất của FVM

♾️
Perpetual Storage
Contract nhận FIL endowment, tự động renew deal trước khi hết hạn. Một lần deposit → lưu mãi mãi. Tương tự Arweave nhưng trên Filecoin.
Flagship Use Case
🏪
Dataset Marketplace
Mua bán quyền truy cập dataset bằng FIL. Người mua pay → nhận decryption key. Creator nhận revenue tự động mà không cần platform.
DeFi + Storage
🔐
Token-gated Storage
Kết hợp với Lit Protocol: chỉ wallet sở hữu NFT nhất định mới decrypt được file. Access control on-chain, không phụ thuộc server.
Access Control
📊
Storage-backed DeFi
Dùng Filecoin storage collateral như DeFi yield source. SP deposit collateral vào liquidity pool, nhận yield trong khi vẫn prove storage.
DeFi Innovation
🤖
Automated SP Selection
Contract query MinerAPI để chọn SP tự động dựa trên reputation score, location, uptime history — thay vì chọn thủ công.
Smart Routing
🌉
Cross-chain Storage
Smart contract trên Ethereum trigger storage deal trên Filecoin qua CCIP hoặc Axelar bridge — storage cho Ethereum dApps từ Filecoin SP.
Interoperability

5Perpetual Storage Contract — Ví dụ thực tế

♾️ Perpetual Storage Flow trên FVM
User
Deposit FIL vào contract
Contract
Tạo deal với SP, quản lý endowment pool
Deal Active
SP lưu file, PoSt mỗi 24h
Near Expiry
Contract auto-renew bằng pool balance
Lặp lại mãi mãi
// Solidity — Simplified Perpetual Storage Contract trên FVM pragma solidity ^0.8.17; import "@zondax/filecoin-solidity/contracts/v0.8/MarketAPI.sol"; contract PerpetualStorage { address public owner; bytes public dataCid; // CID của file cần lưu uint64 public dealDuration; // Thời hạn mỗi deal (epoch) // User deposit FIL để fund storage mãi mãi receive() external payable {} // Tạo deal mới với SP khi deal cũ gần hết hạn function renewDeal(address storageProvider) external { require(address(this).balance >= minBalance, "Insufficient funds"); // Gọi Filecoin MarketAPI precompile để tạo deal mới MarketTypes.PublishStorageDealsParams memory params; params.deals = _buildDealProposal(dataCid, storageProvider, dealDuration); MarketAPI.publishStorageDeals(params); // → Deal mới được tạo, file tiếp tục được lưu } // Keeper/bot gọi hàm này khi deal gần expire function checkAndRenew() external { (,, int64 slashEpoch) = MarketAPI.getDealActivation(currentDealId); if (slashEpoch > 0 || _nearExpiry()) { renewDeal(preferredSP); } } }

Để hiểu cơ chế Proof of Spacetime mà smart contract có thể query qua MinerAPI, xem bài Proof of Spacetime. FVM cũng là nền tảng cho perpetual AI dataset storage — xem bài AI Training Dataset trên Filecoin.

Ecosystem FVM đang tăng trưởng nhanh: Sau mainnet launch tháng 3/2023, hệ sinh thái FVM đã có hàng chục dApps: Glif (FIL liquid staking), FilForwarder (cross-chain FIL bridge), Moonlanding (storage marketplace), Basin (perpetual storage), và nhiều project khác. Developer có thể bắt đầu với Calibration testnet (faucet miễn phí) trước khi mainnet deploy.

Bài tổng quan tại FIL.VN phân tích đầy đủ vị trí của FVM trong kiến trúc Filecoin và hệ sinh thái storage phi tập trung rộng lớn hơn.

❓ Câu hỏi thường gặp về FVM
FVM (Filecoin Virtual Machine) là gì?
FVM là smart contract platform tích hợp vào Filecoin network, ra mắt tháng 3/2023. Cho phép developer deploy smart contract trực tiếp tương tác với storage deal, SP, và FIL token. FEVM là implementation đầu tiên, chạy Solidity contract với EVM-compatible runtime cộng thêm Filecoin-native precompiles đặc biệt.
FVM khác gì so với Ethereum EVM?
FVM có đầy đủ EVM compatibility (chạy Solidity) nhưng có thêm Filecoin precompiles: MarketAPI để tạo storage deal từ contract, MinerAPI để query SP info, PowerAPI để query network power, DataCapAPI để quản lý Filecoin Plus. Những precompile này không có trên Ethereum — cho phép smart contract kiểm soát storage logic trực tiếp trên Filecoin.
Perpetual storage contract trên FVM hoạt động thế nào?
Contract nhận FIL deposit từ user, quản lý endowment pool, và tự động renew storage deal khi gần hết hạn bằng cách gọi MarketAPI.publishStorageDeals(). Một keeper bot (hoặc Chainlink Automation) trigger renewDeal() khi deal sắp expire. Về lý thuyết, một lần deposit đủ lớn có thể duy trì storage mãi mãi — tương tự Arweave endowment model nhưng trên Filecoin.
Developer Ethereum có thể dùng FVM không?
Có. FEVM cho phép deploy Solidity contract với minimal thay đổi. Hardhat, Foundry, Remix, ethers.js, wagmi đều hoạt động. Chỉ cần thêm Filecoin chain (mainnet: chain ID 314, Calibration testnet: 314159) vào RPC config. Filecoin Solidity library cung cấp precompile interfaces để gọi MarketAPI, MinerAPI và các Actor khác.
FIL và ETH có thể dùng trên FVM không?
FIL là native token của FVM — dùng để pay gas và làm currency. WFIL (Wrapped FIL) là ERC-20 equivalent, dùng trong DeFi protocol chuẩn ERC-20. ETH không native trên FVM — cần bridge qua Axelar hoặc cross-chain messaging protocol nếu muốn dùng ETH trên FVM dApps.
Gas fee trên FVM so với Ethereum thế nào?
Gas fee trên FVM thấp hơn Ethereum mainnet đáng kể do ít congestion hơn. FVM dùng EIP-1559 fee mechanism — base fee + priority fee. Gas được tính bằng attoFIL (10^-18 FIL). Trong giai đoạn 2023–2025, gas fee rất thấp vì hệ sinh thái chưa đông. Khi FVM adoption tăng, gas fee sẽ tăng theo cơ chế fee market.
⚙️

ZRO Research

Phân tích FVM architecture, FEVM implementation và hệ sinh thái smart contract trên Filecoin. Tham khảo: FVM spec, Filecoin Solidity library docs, Protocol Labs engineering blog.

FVM · FEVM Smart Contract Filecoin Dev fil.vn