First Fully On-Chain DeFi Insurance Protocol on OPNet (Bitcoin L1)
OPNet Insurance Protocol adalah protokol asuransi DeFi pertama yang berjalan sepenuhnya di atas Bitcoin Layer 1 menggunakan infrastruktur OPNet β tanpa bridge, tanpa wrapped token, tanpa backend terpusat. Semua logika kontrak, state, dan tata kelola tersimpan on-chain di Bitcoin L1.
- Gambaran Umum
- Fitur Utama
- Arsitektur Protokol
- Smart Contracts
- Tokenomics
- Keamanan
- Instalasi & Penggunaan
- Wallet Integration
- MCP Integration
- Struktur Proyek
- Halaman Aplikasi
- Formula Premi
- Governance
- Roadmap
- Kontribusi
- Lisensi
OPNet Insurance Protocol memungkinkan pengguna untuk:
- π‘οΈ Membeli polis asuransi terhadap risiko smart contract (hack, rug pull, oracle manipulation, depeg, validator slashing)
- π§ Menyediakan likuiditas ke pool asuransi dan mendapatkan yield dari distribusi premi
- π¬ Mengajukan klaim melalui tiga jalur resolusi: Oracle, verifikasi on-chain, atau voting governance
- βοΈ Berpartisipasi dalam governance menggunakan token SHIELD untuk mempengaruhi parameter protokol
Seluruh aplikasi terdiri dari satu file HTML tunggal (index.html) β tidak ada framework, tidak ada server, tidak ada build tools. Cukup buka di browser.
Teknologi Stack
βββββββββββββββ
Smart Contracts : AssemblyScript β WebAssembly β Bitcoin L1 (OPNet)
Token Standard : OP_20 (OPNet native)
Runtime : @btc-vision/btc-runtime
Frontend : Pure HTML + Vanilla JS + CSS (zero dependencies)
Wallet : OP_WALLET extension (window.opnet / window.unisat)
MCP Reference : https://ai.opnet.org/mcp
| Fitur | Deskripsi |
|---|---|
| π¦ Insurance Pool | Deposit & withdraw modal dengan capital lock 144 blok |
| π Policy NFT | Setiap polis adalah aset on-chain unik yang bisa ditransfer |
| π Claim Resolution | 3 jalur: Oracle / On-chain Verification / Governance Vote |
| βοΈ Governance | Proposal & voting berbasis SHIELD token, quorum 10% |
| π Circuit Breaker | Emergency pause otomatis saat pool insolvent |
| π« Double-Claim Guard | Proteksi klaim ganda per polis secara on-chain |
| π‘οΈ Slashing | Pemilih jahat dan klaim fraudulent dikenakan penalti |
| π Live Dashboard | Real-time pool metrics, health ring, activity log |
| π± Fully Responsive | Mobile (bottom nav), tablet (drawer), desktop (topbar nav) |
| π OP_WALLET Native | Integrasi langsung dengan window.opnet / window.unisat |
ββββββββββββββββββββββββββββββββββββ
β Bitcoin L1 (OPNet) β
ββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββΌββββββββββββββββββββββββββ
β β β
ββββββββΌβββββββ βββββββββΌββββββββ βββββββββΌββββββββ
βInsurancePoolβ β ClaimModule β β Governance β
βββββββββββββββ βββββββββββββββββ βββββββββββββββββ
βdepositCapitalβββββββββββ submitClaim β βcreateProposal β
βwithdrawCapitalβ β oracleVerify β βcastVote β
βbuyPolicy ββββββββββββΊβ castClaimVote β βexecuteProposalβ
βcalcPremium β β finalizeVote β βslashVoter β
βgetPoolHealthβ β processFraud β βtreasuryAlloc β
βprocessClaim ββββββββββββ executePayout β βββββββββ¬ββββββββ
ββββββββ¬βββββββ βββββββββββββββββ β
β β
ββββββββΌβββββββ βββββββββΌββββββββ
β PolicyNFT β β ShieldToken β
βββββββββββββββ βββββββββββββββββ
β mintPolicy β β OP_20 Standardβ
β transferPolicyβ β delegate() β
β getPolicy β β getVotingPowerβ
β setClaimStatusβ β burnFrom() β
βββββββββββββββ βββββββββββββββββ
User membayar premi
β
βΌ
InsurancePool.buyPolicy()
β
βββ 70% βββΊ Liquidity Providers (distribusi proporsional)
βββ 20% βββΊ Treasury (governance-controlled)
βββ 10% βββΊ Claim Validators
Semua kontrak ditulis dalam AssemblyScript dan dikompilasi ke WebAssembly untuk deployment di Bitcoin L1 via OPNet.
Generated using OPNet MCP Smart Contract Reference: https://ai.opnet.org/mcp
| Contract | Address (P2OP) | Fungsi |
|---|---|---|
| InsurancePool | op1shield7pool8capital9defi0insurance1btc2opnet3 |
Core pool, premium, payout |
| PolicyNFT | op1policy4nft5asset6unique7onchain8bitcoin9l1abc |
On-chain policy asset |
| ClaimModule | op1claim10module11dispute12resolution13opnet14btc |
Claim submission & resolution |
| Governance | op1gov15shield16token17voting18treasury19opnet20 |
Proposal & voting system |
| ShieldToken | op1shield21token22op2023standard24governance25btc |
SHIELD governance token (OP_20) |
File utama yang mengelola seluruh likuiditas dan polis.
// Fungsi utama
depositCapital(amount: u256): u256
withdrawCapital(amount: u256): u256
buyPolicy(coverage: u256, riskType: u32, protocol: u32, duration: u32): [u256, u256]
calculatePremium(coverage: u256, riskType: u32, protocol: u32, duration: u32): u256
getPoolHealth(): [totalLiquidity, activeCoverage, reserveAmount, utilization, treasury]
processClaim(policyId: u256, claimant: Address, amount: u256, approved: bool): boolState yang disimpan on-chain:
| Storage Pointer | Variabel | Tipe |
|---|---|---|
0x0001 |
totalLiquidity |
StoredU256 |
0x0002 |
activeCoverage |
StoredU256 |
0x0003 |
reserveAmount |
StoredU256 |
0x0004 |
treasury |
StoredU256 |
0x0005 |
circuitBreaker |
StoredBoolean |
0x0010+ |
lpBalances |
AddressMap<u256> |
0x0011+ |
lockExpiry |
AddressMap<u32> |
Setiap polis adalah aset on-chain unik menggunakan model aset native OPNet.
// Struktur Policy (disimpan per storage pointer)
{
coverageAmount: u256 // jumlah coverage dalam satoshi
riskType: u32 // 0=HACK, 1=RUG, 2=ORACLE, 3=DEPEG, 4=SLASH
insuredProtocol:u32 // 0=DEX, 1=LENDING, 2=BRIDGE, 3=YIELD, 4=NFT, 5=CUSTOM
startBlock: u32 // blok saat polis dibuat
expiryBlock: u32 // blok saat polis kedaluwarsa
premiumPaid: u256 // premi yang dibayarkan
claimStatus: u8 // 0=NONE, 1=PENDING, 2=PAID, 3=DENIED
transferable: bool // apakah polis bisa ditransfer
}Mendukung tiga jalur resolusi klaim:
A) Oracle-Triggered β Otomatis via oracle on-chain
B) On-Chain Condition β Verifikasi langsung dari data Bitcoin L1
C) Governance Vote β SHIELD holders memilih approve/deny
// Parameter governance
VOTING_PERIOD_BLOCKS = 2016 // ~2 minggu
QUORUM_BPS = 1000 // 10% dari total supply
PROPOSER_MIN_SHIELD = 1000 // SHIELD minimum untuk membuat proposal
PROPOSER_BOND = 100 // SHIELD bond (dikembalikan jika quorum tercapai)Token governance berbasis standar OP_20 (analog ERC-20 di Bitcoin L1).
// Supply
Max Supply : 21,000,000 SHIELD
Decimals : 8 (Bitcoin standard)
Symbol : SHIELD
Name : OPNet Insurance Governance TokenSetiap pembayaran premi secara otomatis didistribusikan on-chain di dalam fungsi InsurancePool.buyPolicy():
Premium yang masuk
β
βββ 70% βββΊ Liquidity Providers
β Dibagi proporsional berdasarkan share pool
β
βββ 20% βββΊ Treasury
β Dikelola via governance proposal
β
βββ 10% βββΊ Claim Validators
Validator yang memproses dan memverifikasi klaim
| Tipe Risiko | Multiplier | Deskripsi |
|---|---|---|
HACK |
Γ1.8 | Smart contract exploit |
RUG |
Γ2.5 | Exit scam / rug pull |
ORACLE |
Γ1.4 | Oracle price manipulation |
DEPEG |
Γ1.2 | Stablecoin depegging |
SLASH |
Γ0.9 | Validator slashing event |
| Protocol | Base Rate | Alasan |
|---|---|---|
| DEX / AMM | 0.8% | Risiko sedang, battle-tested |
| Lending | 1.2% | Risiko flash loan, liquidation |
| Bridge | 1.8% | Risiko paling tinggi, riwayat exploit |
| Yield Aggregator | 1.4% | Kompleksitas komposabilitas |
| NFT Marketplace | 1.0% | Risiko moderat |
| Custom Protocol | 1.5% | Default untuk protokol baru |
| Mekanisme | Implementasi | Parameter |
|---|---|---|
| Reentrancy Guard | StoredBoolean flag on-chain |
Setiap fungsi write |
| Capital Lock | lockExpiry per LP address |
144 blok (~1 hari) |
| Circuit Breaker | StoredBoolean circuitBreaker |
Auto-trigger saat pool insolvent |
| Insolvency Protection | Cek saldo sebelum withdrawal | activeCoverage β€ totalLiquidity |
| Max Utilization | Hard cap pada rasio utilisasi | 90% (MAX_UTILIZATION = 9000) |
| Double-Claim Guard | policyId β claimId mapping |
Satu klaim aktif per polis |
| Fraud Detection | Slash otomatis pada double-claim | 10% dari nilai klaim |
| Voter Slashing | burnFrom() via governance |
Governance proposal |
| On-Chain Audit Log | Blockchain.log() setiap transaksi |
Semua fungsi |
User submit klaim
β
βΌ
Double-Claim Check ββββ GAGAL βββΊ Slash 10% (fraud penalty)
β
LULUS
β
βΌ
Tipe Klaim?
ββββββΌβββββ
β β β
βΌ βΌ βΌ
Oracle OnChain Governance
β β β
β β βΌ
β β Voting Period (2016 blok)
β β β
β β βΌ
β β Quorum Check (β₯10%)
β β β
ββββββ΄βββββ
β
βΌ
Approved? ββββ NO βββΊ Status: DENIED
β
YES
β
βΌ
Payout via InsurancePool.processClaim()
β
βΌ
BTC transfer di Bitcoin L1 β
# Clone atau download repo
git clone https://github.com/your-org/opnet-insurance-protocol.git
cd opnet-insurance-protocol
# Buka langsung di browser β tidak perlu server!
open index.html
# Atau jalankan dengan simple HTTP server (opsional)
npx serve .
# atau
python3 -m http.server 8080
β οΈ Catatan: Untuk fitur wallet OP_WALLET berfungsi penuh, buka viahttp://localhostatauhttps://, bukanfile://(karena kebijakan CORS browser).
- Browser modern (Chrome, Firefox, Edge, Brave, Opera)
- OP_WALLET Extension untuk interaksi on-chain penuh
- Koneksi internet (untuk Google Fonts)
# Install OPNet CLI
npm install -g @btc-vision/opnet-cli
# Scaffold project menggunakan OPNet MCP
npx opnet scaffold --template defi-insurance --mcp https://ai.opnet.org/mcp
# Compile kontrak AssemblyScript β WASM
npx opnet compile src/InsurancePool.ts
npx opnet compile src/PolicyNFT.ts
npx opnet compile src/ClaimModule.ts
npx opnet compile src/Governance.ts
npx opnet compile src/ShieldToken.ts
# Deploy ke Bitcoin L1 via OPNet
npx opnet deploy \
--contract dist/InsurancePool.wasm \
--network mainnet \
--wallet ./wallet.json
# Output:
# β
Contract deployed: op1shield7pool8capital9defi0insurance1btc2opnet3OPNet Insurance Protocol mendukung tiga wallet secara native:
Wallet resmi OPNet yang dibuat oleh tim btc-vision, fork dari UniSat Wallet.
// OP_WALLET menginject window.opnet dan window.unisat
const provider = window.opnet || window.unisat;
// Request akses akun β memicu popup OP_WALLET
const accounts = await provider.requestAccounts();
const address = accounts[0]; // bc1p... (Taproot/P2TR)
// Get public key
const publicKey = await provider.getPublicKey();
// Sign pesan
const signature = await provider.signMessage(message, 'bip322-simple');
// Kirim BTC (untuk pembayaran premi)
const txid = await provider.sendBitcoin(contractAddress, premiumSats);
// Listen events
provider.on('accountsChanged', (accounts) => { /* handle */ });
provider.on('networkChanged', (network) => { /* handle */ });Install OP_WALLET:
const provider = window.unisat;
const accounts = await provider.requestAccounts();const provider = window.okxwallet.bitcoin;
const accounts = await provider.requestAccounts();Tidak memerlukan wallet extension β cocok untuk testing UI dan presentasi.
Proyek ini dibuat menggunakan OPNet MCP (Model Context Protocol) Server yang dihosting di https://ai.opnet.org/mcp.
// .cursor/mcp.json atau claude_desktop_config.json
{
"mcpServers": {
"opnet-bob": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://ai.opnet.org/mcp"]
}
}
}MCP Bob menyediakan tool opnet_dev dengan berbagai aksi:
| Aksi | Deskripsi |
|---|---|
scaffold_op20 |
Generate boilerplate token OP_20 |
scaffold_defi |
Generate pola kontrak DeFi |
audit_contract |
Security audit AssemblyScript |
deploy_contract |
Deploy WASM ke Bitcoin L1 |
call_contract |
Read/write state kontrak |
watch_events |
Subscribe ke event kontrak |
import { getContract, JSONRpcProvider } from 'opnet';
import { Address, Wallet } from '@btc-vision/transaction';
import { Network } from '@btc-vision/bitcoin';
const provider = new JSONRpcProvider('https://mainnet.opnet.org', 'mainnet');
const wallet = Wallet.fromWIF('your_wif_key', 'mainnet');
// Connect ke InsurancePool
const pool = getContract(
'op1shield7pool8capital9defi0insurance1btc2opnet3',
OPNET_INSURANCE_POOL_ABI,
provider, 'mainnet',
new Address(wallet.keypair.publicKey)
);
// Read pool health (gratis, tidak perlu gas)
const health = await pool.getPoolHealth();
console.log('TVL:', health.totalLiquidity.toString());
// Beli polis
const tx = await pool.buyPolicy(
BigInt('50000000'), // 0.5 BTC coverage
0, // HACK risk
0, // DEX protocol
8640 // ~60 hari
);
await tx.wait(); // tunggu konfirmasi Bitcoinopnet-insurance-protocol/
β
βββ index.html β Seluruh aplikasi (single file)
β βββ <style> β CSS responsif lengkap
β βββ HTML Sections β 7 halaman sebagai section
β β βββ #page-dashboard β Live metrics & activity
β β βββ #page-buy β Kalkulator premi & beli polis
β β βββ #page-policies β Daftar polis aktif user
β β βββ #page-claim β Form & riwayat klaim
β β βββ #page-liquidity β Deposit/withdraw LP
β β βββ #page-governance β Proposal & voting
β β βββ #page-contracts β Source code viewer
β βββ <script> β Logic JS + contract source embedded
β
βββ README.md β Dokumentasi ini
βββ LICENSE β MIT License
Source code semua kontrak tersedia di halaman Contracts dalam aplikasi:
| Tab | File | Ukuran |
|---|---|---|
| InsurancePool.ts | Core pool contract | ~150 baris |
| PolicyNFT.ts | Policy asset contract | ~120 baris |
| ClaimModule.ts | Claim resolution | ~180 baris |
| Governance.ts | DAO governance | ~170 baris |
| ShieldToken.ts | OP_20 token | ~100 baris |
| MCP Integration | Panduan integrasi | ~120 baris |
Menampilkan metrik protokol secara real-time:
- Total Value Locked (TVL) β total BTC di pool
- Active Coverage β total coverage yang sedang berjalan
- Active Policies β jumlah polis aktif
- LP Annual Yield β estimasi yield tahunan LP
- Pool Utilization β rasio coverage/likuiditas
- Pool Health Ring β visualisasi kesehatan pool
- Treasury Balance β saldo kas protokol
- SHIELD Token Price β harga token governance
- On-Chain Activity β log aktivitas terbaru
- Claim Statistics β statistik klaim (paid/denied/pending)
Form untuk membeli polis asuransi:
- Pilih protokol yang diasuransikan (DEX, Lending, Bridge, dll)
- Pilih tipe risiko (Hack, Rug Pull, Oracle, Depeg, Slash)
- Tentukan jumlah coverage (BTC) dan durasi (blok)
- Kalkulator premi real-time dengan breakdown komponen
- Tampilan kapasitas pool yang tersedia
Menampilkan semua polis aktif yang dimiliki wallet terhubung:
- Coverage amount, tipe risiko, protokol
- Blok mulai dan kedaluwarsa
- Status klaim
- Tombol file claim / transfer polis
Form pengajuan klaim dengan tiga jalur resolusi:
- A) Oracle β verifikasi otomatis via oracle on-chain
- B) On-Chain β verifikasi kondisi langsung dari Bitcoin L1
- C) Governance β voting oleh SHIELD holders
Dilengkapi informasi keamanan (double-claim guard, fraud detection, slashing).
Interface LP:
- Deposit dengan proyeksi yield tahunan
- Withdraw dengan validasi lock period
- Pool statistics (TVL, utilization, solvency score)
- Tokenomics donut chart (70/20/10)
- Tabel posisi LP aktif
Sistem tata kelola on-chain:
- Create Proposal (butuh β₯1,000 SHIELD)
- Vote YES/NO (power = saldo SHIELD)
- Progress bar voting real-time
- Informasi quorum dan periode voting
Source code viewer untuk semua kontrak dengan syntax highlighting.
Formula premi diimplementasikan identik di JavaScript (UI preview) dan AssemblyScript (on-chain):
Premium = Coverage Γ BaseRate Γ RiskFactor Γ (1 + PoolUtilization) Γ DurationMultiplier
DurationMultiplier = durationBlocks / 8640 (baseline = 60 hari)
Contoh Kalkulasi:
Coverage = 0.5 BTC
Protocol = DEX (BaseRate = 0.8%)
Risk = HACK (Factor = 1.8)
Pool Utilization = 42%
Duration = 8,640 blok (60 hari)
Premium = 0.5 Γ 0.008 Γ 1.8 Γ (1 + 0.42) Γ 1.0
= 0.5 Γ 0.008 Γ 1.8 Γ 1.42
= 0.00512 BTC
1. User membuat proposal (butuh β₯1,000 SHIELD + bond 100 SHIELD)
2. Periode voting: 2,016 blok (~2 minggu)
3. Voting dengan bobot = saldo SHIELD
4. Quorum: β₯10% total supply harus berpartisipasi
5. Majority: lebih banyak YES β PASSED, sebaliknya β FAILED
6. Bond dikembalikan jika quorum tercapai
7. Aksi dieksekusi on-chain jika passed
| Tipe | Deskripsi |
|---|---|
PARAM |
Ubah parameter protokol (base rate, lock period, dll) |
CLAIM |
Resolusi dispute klaim yang disengketakan |
TREASURY |
Alokasi dana treasury ke tujuan tertentu |
UPGRADE |
Upgrade logika kontrak |
EMERGENCY |
Aksi darurat (aktifkan/nonaktifkan circuit breaker) |
Pemilih yang terbukti bertindak jahat (melalui proposal governance) dapat dikenakan slash via ShieldToken.burnFrom() β saldo SHIELD mereka dibakar secara permanen.
- Core insurance pool dengan formula premi on-chain
- Policy NFT sebagai aset native OPNet
- Tiga jalur resolusi klaim
- Governance on-chain dengan SHIELD token
- OP_WALLET integration (window.opnet)
- Fully responsive UI (mobile/tablet/desktop)
- Deployment ke OPNet Mainnet (target: Q2 2026)
- Integrasi oracle price feed on-chain
- Audit keamanan oleh auditor tersertifikasi OPNet
- Liquidity mining program untuk LP awal
- Mobile app native (menggunakan OPNet SDK)
- Multi-chain coverage (Bitcoin + L2)
- Reinsurance module untuk coverage besar
Kontribusi sangat disambut! Silakan:
- Fork repository ini
- Buat branch fitur:
git checkout -b feature/nama-fitur - Commit perubahan:
git commit -m 'feat: deskripsi fitur' - Push ke branch:
git push origin feature/nama-fitur - Buka Pull Request
- Semua kontrak baru harus mengikuti pola OPNet MCP (
https://ai.opnet.org/mcp) - Gunakan
StoredU256,AddressMap, dan tipe nativebtc-runtimeuntuk state storage - Setiap fungsi write wajib menggunakan
ReentrancyGuard - Tambahkan event
NetEventuntuk setiap perubahan state penting - UI tetap dalam satu file HTML tanpa dependencies eksternal
| Resource | Link |
|---|---|
| OPNet Documentation | https://docs.opnet.org |
| btc-runtime SDK | https://github.com/btc-vision/btc-runtime |
| OP_WALLET Extension | https://github.com/btc-vision/opwallet |
| OPNet MCP Server | https://ai.opnet.org/mcp |
| OPNet npm Package | https://www.npmjs.com/package/opnet |
| Chrome Web Store | https://chromewebstore.google.com/detail/opwallet/pmbjpcmaaladnfpacpmhmnfmpklgbdjb |
Proyek ini dilisensikan di bawah MIT License β lihat file LICENSE untuk detail lengkap.
⬑ OPNet Insurance Protocol
First Fully On-Chain Insurance Protocol on OPNet (Bitcoin L1)
Generated using OPNet MCP Smart Contract Reference
No admin keys. No backend. No bridges. 100% on-chain. βΏ