Tóm tắt — Đây là bài thực hành
Bài này là hướng dẫn thực tế tạo Filecoin storage deal từ A-Z. Quy trình: chuẩn bị data → đóng gói thành CAR → chọn SP → tạo deal → chờ PoRep sealing → verify on-chain → monitor WindowPoSt định kỳ. Cũng bao gồm best practice: số SP tối thiểu, cách chọn deal duration, và khi nào nên dùng managed service (Lighthouse, web3.storage) thay vì deal trực tiếp.
1Storage Deal là gì — Hiểu trước khi làm
Storage deal là hợp đồng on-chain giữa hai bên:
- Client: Người/tổ chức muốn lưu data, trả FIL
- Storage Provider (SP): Operator có hardware lưu data, nhận FIL + block reward
SP cam kết lưu data trong thời gian deal duration và phải cung cấp cryptographic proof liên tục:
- PoRep (Proof of Replication): Proof rằng SP đã sealing data vào sector — xảy ra một lần khi deal bắt đầu
- WindowPoSt (Window Proof of Spacetime): Proof định kỳ mỗi 24h rằng SP vẫn đang lưu data — liên tục suốt deal duration
Nếu SP mất data hoặc không submit WindowPoSt, collateral FIL bị slash. Đây là economic guarantee — không phải trust vào lời hứa của SP.
Deal trực tiếp vs Managed service: Bài này hướng dẫn deal trực tiếp — phù hợp khi cần control tối đa, production-grade archive, hoặc verified deal (Fil+). Nếu chỉ cần lưu nhanh <100 GB, Lighthouse hoặc web3.storage đơn giản hơn nhiều và tự động deal với Filecoin.
2Quy trình từ A đến Z — 7 bước
1
Chuẩn bị data và tạo CID
Organize files vào folder. Tạo dataset_card.json mô tả nội dung. Install ipfs-car hoặc kubo (IPFS CLI).
# Cài ipfs-car CLI
npm install -g @web3-storage/car
# Tính CID của folder (chưa upload)
ipfs add -r --only-hash ./my-dataset/
# Output: QmXxx... my-dataset — đây là root CID
2
Đóng gói thành CAR file
Filecoin deal yêu cầu data được đóng gói thành CAR (Content Addressed aRchive) format. CAR file có PieceCID (CommP) — identifier on-chain cho deal.
# Pack folder thành CAR file
ipfs-car pack ./my-dataset/ --output dataset.car
# Output: Root CID + CAR file path
# Tính PieceCID (CommP) — cần khi tạo deal
boostd commp dataset.car
# Output:
CID (payload): bafybeig...
Piece CID: baga6ea4seaq...
Padded piece size: 32 GiB
- Lưu Piece CID và Padded piece size — cần khi tạo deal
- CAR file tối đa 32 GiB per deal (giới hạn sector size). Dataset lớn hơn cần split thành nhiều CAR
3
Chọn Storage Provider (SP) phù hợp
Đây là bước quan trọng nhất. Tiêu chí chọn SP:
- Reputation: Check trên Filscan.io và Filfox.info — xem uptime history, số deal active
- Ask price: Một số SP nhận verified deal (Fil+) miễn phí. Unverified deal thường ~0.0000000005 FIL/GiB/epoch
- Location: SP gần bạn địa lý → retrieval nhanh hơn
- Min/Max piece size: Kiểm tra SP có accept size của CAR file không
- Replication: Deal với ít nhất 3 SP khác nhau, khác geography
# Query SP info qua Lotus CLI
lotus client query-ask --peerid [SP_PEER_ID]
# Output: giá, min/max size, verified price
# Tìm SP qua Filecoin.io API
curl https://api.filrep.io/api/v1/providers?limit=20&sortBy=score
4
Upload CAR file đến SP và tạo deal
Dùng Boost — tool deal-making chuẩn của Filecoin. SP phải chạy Boost server để nhận deal.
# Tạo deal với Boost CLI
boost deal \
--provider=f01234 \ # SP address
--http-url=https://your-server/dataset.car \ # URL SP download CAR
--commp=baga6ea4seaq... \ # Piece CID từ bước 2
--piece-size=34359738368 \ # Padded piece size (bytes)
--car-size=32000000000 \ # Actual CAR file size
--payload-cid=bafybeig... \ # Root CID từ bước 1
--storage-price=0 \ # 0 nếu verified deal Fil+
--verified-deal=true \ # Nếu có DataCap
--duration=518400 # 180 ngày (tối thiểu)
# Output nếu thành công:
sent deal proposal
deal uuid: 550e8400-e29b-41d4-a716-446655440000
5
Chờ PoRep Sealing — 24–48 giờ
Sau khi SP nhận deal proposal và data, quá trình PoRep sealing bắt đầu. Đây là 4 giai đoạn tốn thời gian nhất:
- PC1 (PreCommit1): SHA-256 hashing — CPU intensive, ~3–6 giờ/32 GiB sector
- PC2 (PreCommit2): Poseidon hashing — GPU nếu có, ~30–60 phút
- C1 (Commit1): Generate zk-SNARK proof — ~30 phút
- C2 (Commit2): Finalize proof và submit on-chain — ~20 phút + block confirm
Sau khi C2 success, deal chuyển sang trạng thái Active và được ghi on-chain.
6
Verify Deal On-Chain
Sau khi sealing hoàn tất, verify deal đang active:
# Xem tất cả deal của client hiện tại
lotus client list-deals --verbose
# Lấy thông tin deal theo deal ID
lotus state market-deal [DEAL_ID]
# Output có: State, StartEpoch, EndEpoch, PieceCID, Provider
# Verify deal trên Filscan explorer
# https://filscan.io/deal/[DEAL_ID]
# Kiểm tra State = Active, Provider = đúng SP
7
Monitor WindowPoSt — Giám sát dài hạn
Sau khi deal active, SP phải submit WindowPoSt mỗi 24h (~2880 epoch). Nếu SP miss WindowPoSt, họ bị penalize. Nếu miss nhiều lần liên tiếp, sector bị fault và deal bị terminated.
# Check SP miner info — xem fault sectors
lotus state miner-info [SP_ADDRESS]
# FaultyPower phải = 0
# Script monitor đơn giản (chạy daily)
lotus state market-deal [DEAL_ID] | grep -E "State|EndEpoch"
# State: StorageDealActive → deal đang tốt
# State: StorageDealExpired → cần renew
- Set calendar reminder renew deal trước khi EndEpoch khoảng 30 ngày
- Hoặc dùng FVM Perpetual Storage contract để tự động renew
3Deal States — Hiểu các trạng thái
Pending
Deal proposal đã gửi, chờ SP accept và sealing
Active ✅
PoRep thành công, deal on-chain, SP đang lưu data
Unverified
Deal không có DataCap — giá cao hơn verified
Verified ⭐
Deal có DataCap từ Fil+ — 10× QAP, thường miễn phí
Expired
Deal hết hạn. SP không bắt buộc giữ data nữa
Slashed ⚠️
SP mất data. Collateral bị slash, deal terminate sớm
4Best Practices cho Production
| Tiêu chí | Minimum | Recommended (Production) |
| Số SP per dataset | 1 | 3–5 SP |
| SP diversity | Cùng location OK | Ít nhất 2 continent khác nhau |
| Deal duration | 180 ngày (tối thiểu) | 540 ngày + renewal plan |
| Deal type | Unverified deal | Verified deal (Fil+) nếu dataset qualify |
| Verify sau sealing | Check deal ID | Check deal ID + download test từ IPFS |
| Monitor | Không cần | Weekly check WindowPoSt health |
| Renewal | Manual khi nhớ | FVM perpetual contract hoặc calendar 30 ngày trước |
Khi nào dùng Lighthouse / web3.storage thay vì deal trực tiếp? Nếu dataset <100 GB, không cần custom deal duration, và không cần Fil+ verified deal — managed service như Lighthouse hoặc web3.storage đơn giản hơn 10 lần. Chúng tự động tạo Filecoin deal, pin trên IPFS, và handle renewal. Deal trực tiếp phù hợp cho: dataset >100 GB, cần control SP cụ thể, cần verified deal, hoặc archive infrastructure nghiêm túc.
Để hiểu chi tiết cơ chế PoRep + WindowPoSt, xem bài Proof of Spacetime. Để hiểu cách FVM cho phép perpetual storage contract, xem Filecoin Virtual Machine (FVM). Bài tổng quan tại FIL.VN phân tích đầy đủ hệ sinh thái Filecoin.
❓ Câu hỏi thường gặp về Storage Deal
Filecoin storage deal là gì?
Storage deal là hợp đồng phi tập trung giữa client và Storage Provider (SP). Client trả FIL, SP cam kết lưu data trong khoảng thời gian nhất định và cung cấp cryptographic proof (PoRep + WindowPoSt) rằng data đang được lưu. Deal được ghi on-chain và SP bị slash FIL nếu mất data — không phải trust vào lời hứa, mà là economic guarantee.
CAR file là gì và tại sao cần đóng gói trước khi deal?
CAR (Content Addressed aRchive) là format chuẩn của IPFS/Filecoin để đóng gói content. Data phải được pack thành CAR trước khi tạo deal vì Filecoin cần PieceCID (CommP) để ghi vào on-chain deal. CAR file cũng đảm bảo Merkle DAG structure nguyên vẹn, cho phép verify từng phần mà không cần download toàn bộ.
Chọn Storage Provider nào để deal?
Tiêu chí chọn SP: (1) Reputation score trên Filscan.io hoặc Filfox.info; (2) Ask price — một số SP nhận verified deal miễn phí; (3) Location — SP gần bạn có retrieval nhanh hơn; (4) Min/Max piece size phù hợp với CAR của bạn; (5) Replication — deal với 3+ SP khác nhau, khác geography để redundancy. Công cụ: Filscan.io, Filfox.info để research SP.
Deal bao lâu? Hết hạn thì sao?
Deal duration tối thiểu ~180 ngày, tối đa ~540 ngày. Sau khi deal hết hạn, SP không bắt buộc lưu data nữa — có thể xóa. Để lưu lâu hơn: tạo deal mới trước khi hết hạn (manual hoặc script), dùng FVM Perpetual Storage contract tự động renew, hoặc dùng Lighthouse với auto-renewal. Best practice: set calendar reminder 30 ngày trước EndEpoch.
Verified deal (Filecoin Plus) là gì?
Filecoin Plus (Fil+) là chương trình verified storage. Notary cấp DataCap cho client sau khi verify dataset là public good (dataset khoa học, open source, archive). Verified deal nhận 10× Quality Adjusted Power — SP được thưởng nhiều hơn khi lưu verified data. Kết quả: SP sẵn sàng nhận verified deal với giá thấp hơn hoặc miễn phí — rất có lợi cho large dataset.
Làm thế nào verify deal đang active trên chain?
Có nhiều cách: (1) Filscan.io hoặc Filfox.info — search deal ID để xem status, duration, SP info; (2) Lotus CLI — lệnh 'lotus client list-deals' để xem tất cả deal active; (3) lotus state market-deal [DEAL_ID] để query on-chain state trực tiếp. Verify định kỳ là best practice — đặc biệt check FaultyPower của SP (phải = 0) để đảm bảo WindowPoSt đang được submit.
📦
Hướng dẫn thực hành Filecoin storage deal, CAR file packaging, và best practice cho production archive. Tham khảo: Filecoin docs, Boost documentation, Protocol Labs guides.
Storage Deal
Boost · Lotus CLI
Developer Guide
fil.vn