Skip to main content

⚡ Smart Contracts — Open Source Architecture

Trustless by Design. All reward logic, referral trees, and halving schedules are enforced on-chain via auditable Rust programs. Source code: GitHub


Overview

Matsuri deploys three Anchor (Rust) programs on Solana, each handling a distinct pillar of the ecosystem:

graph TB
subgraph "On-Chain Programs (Solana)"
P1["📣 matsuri-referral\nEn-Mining Protocol"]
P2["⛩️ matsuri-worship\nWorship Routing Engine"]
P3["📊 matsuri-distribution\nHalving Distribution"]
end
subgraph "Off-Chain (Django + Next.js)"
BE["🖥️ Backend Oracle\nIdentity + GPS Verification\nCranker TX Submission"]
FE["📱 Frontend\nWallet + Dashboard\nSacred Site Map"]
end
FE -->|"Wallet Sign"| P1 & P2 & P3
BE -->|"Cranker TXs"| P1 & P2 & P3
P1 & P2 & P3 -->|"CPI"| MTC["💎 MTC (SPL Token)"]

1. 📣 En-Mining (縁マイニング) Protocol

Purpose: A hybrid growth engine that rewards both breadth (referral reach) and depth (economic impact). Not just affiliates — a full mining protocol where real-world economic activity generates on-chain value.

Scoring Formula

S_final = S_raw × M_toku × B_title

where:
S_raw = 0.30 × referrals + 0.70 × (volume / 10^9)
M_toku = f(staked_mtc) ∈ [1.0×, 10.0×]
B_title = 1.0 + min(seasons_ranked × 0.05, 0.50)
ComponentWeightPurpose
Breadth (referral count)30%Network reach — how many people you bring
Depth (settlement volume)70%Economic impact — real purchases, not just signups
Toku Multiplier×1–10Lock MTC to boost mining power
Title Boost+5%/seasonPermanent reward for consistent top performers

Toku (徳) Staking Tiers

Staked MTCMultiplierTier
01.0×
1,000+1.5×Bronze
10,000+3.0×Silver
100,000+5.0×Gold
1,000,000+10.0×Diamond

En no Banzuke (季節ランキング)

Each season (epoch), top performers are ranked. Benefits:

  • Top 10% earn Evangelist title (permanent SBT flag)
  • Each season ranked grants +5% mining boost (cumulative, cap: 50%)

Anti-Sybil Defence (3 Layers)

LayerMechanismWhere
Identity GateX/Twitter OAuth + SMSOff-chain (Django)
On-chain GateOnly is_verified = true profiles earnSmart Contract
Depth Weighting70% of score = real payments → bots earn nothingScoring Engine

2. ⛩️ Worship Routing Engine (巡礼分散エンジン)

Purpose: The world's first ReFi protocol that solves over-tourism using token economics. Visit sacred sites → earn MTC. But here's the twist: less-visited sites pay exponentially more.

The Insight

This is "reverse Uber surge pricing" — crowded sites get penalized, frontier sites get boosted. Tourists route themselves to less-visited locations because it's more profitable.

6-Layer Reward Formula

R_final = R_pioneer × M_dynamic × M_regional × M_streak × M_omikuji

where:
R_pioneer = daily_pool / visit_order (harmonic 1/n decay)
M_dynamic = admin-controlled ∈ [0.1×, 50×]
M_regional = tier_table[tier] ∈ {1×, 2×, 5×, 10×}
M_streak = 1.0 + min(days × 0.02, 0.50)
M_omikuji = fortune_lottery ∈ {1.0, 1.2, 1.5, 3.0}

Layer 1: Pioneer Bonus (先行者利益)

Harmonic decay — the math that routes tourists:

Visit OrderReward vs 1stReal Example (1000 MTC pool)
1st100%1,000 MTC
5th20%200 MTC
10th10%100 MTC
100th1%10 MTC

First visitor = 100× more reward than 100th visitor. This creates a powerful incentive to visit at off-peak times.

Layer 2: Dynamic Multiplier (混雑分散)

Controlled in real-time by admins via the GCF Admin panel:

ScenarioMultiplierEffect
Over-touristed (Asakusa peak)0.1×90% reward penalty
Normal1.0×Standard
Under-visited10×10× reward boost
Frontier campaign50×Maximum incentive

Layer 3: Regional Tier

TierLabelMultiplierExamples
0🏙️ Major浅草寺, 清水寺, 伏見稲荷
1🌆 Medium地方一宮, 県庁所在地の大社
2🏞️ Rural田舎の歴史ある古社
3⛰️ Hidden10×山奥の霊場, 離島の御嶽

Layer 4: Streak Bonus

+2% per consecutive day, capped at +50%. Rewards regular visitors.

Layer 5: 🎲 Omikuji Protocol

ResultProbabilityMultiplier
🏆 大吉5%3.0×
15%1.5×
🌸 小吉30%1.2×
🍃 末吉35%1.0×
💀 15%1.0×

Layer 6: Sponsored Beacons (B2B/B2G)

Municipalities, railway companies, and tourism boards can deposit MTC to create time-limited high-reward zones at specific sites.

graph LR
MUN["🏛️ Municipality\nDeposits 100K MTC"] --> BEACON["📡 Beacon\n+500 MTC/visit\n30 days"]
BEACON --> SITE["⛩️ Rural Shrine\n×50 multiplier"]
SITE --> TOURIST["👤 Tourist\nVisits shrine"]
TOURIST --> REWARD["💎 High MTC reward\n→ Stays longer\n→ Spends locally"]

B2B Revenue Model: Sponsors pay MTC to route tourists. MTC buying pressure → token value. Win-win-win.


3. 📊 Halving Distribution

Purpose: The 550M MTC mining pool distributed over decades via a 2-year halving cycle — faster than Bitcoin's 4-year cycle.

Halving Schedule

Total Pool: 550,000,000 MTC

Epoch 0 (2027–2029): 275,000,000 MTC (50%)
Epoch 1 (2029–2031): 137,500,000 MTC (25%)
Epoch 2 (2031–2033): 68,750,000 MTC (12.5%)
Epoch 3 (2033–2035): 34,375,000 MTC (6.25%)
... ...
∑ → 550,000,000 MTC (asymptotic total)

Individual Reward Formula

your_reward = epoch_budget × (your_score / total_score)

All arithmetic uses 128-bit intermediate computation — mathematically impossible to overflow.

Performance Score Sources

ActivityScore Weight
Guide sessions conductedHigh
Event ticket salesHigh
Referral network activityMedium
Worship mining visitsMedium
Media engagementLow
Permissionless Epoch Advancement

The advance_epoch instruction can be called by anyone — no admin needed. The system clock determines when epochs transition, ensuring trustless operation even if the team disappears.


Math Modules (Open Source Core)

Both programs separate all scoring/reward math into pure, auditable math.rs modules with:

  • Zero side effects — no I/O, no allocations, no external calls
  • Documented formulas — LaTeX-style notation in rustdoc
  • Overflow analysis — u128 intermediate values with proven bounds
  • Comprehensive tests — edge cases, boundary conditions, ratio verification
// Example: Pioneer Bonus (from worship/math.rs)
#[inline]
pub fn pioneer_reward(daily_pool: u64, visit_order: u32) -> u64 {
if visit_order == 0 { return 0; }
(daily_pool as u128 / visit_order as u128) as u64
}

4. 🎴 AR Mining — WebAR おみくじマイニング

Purpose: スマホのブラウザだけで現実空間にARおみくじを出現させ、MTCをマイニングする体験。アプリDL不要。神道の精神性と最先端技術が融合した世界初のWebAR×ブロックチェーンインフラ。

アーキテクチャ

sequenceDiagram
participant U as ユーザー (Phone)
participant AR as WebAR (Three.js)
participant VP as VisionProof
participant API as Django API
participant SC as Solana

U->>AR: カメラ起動 + GPS許可
AR->>API: セッション開始 (GPS)
API-->>AR: session_token + site_info
AR->>AR: 3Dおみくじボックス表示
U->>AR: タップ
AR->>VP: motion + light 収集開始
AR->>API: draw_omikuji (session_token)
Note over AR: 演出アニメ 2.5秒再生
API->>API: validate (5層) → draw() → NFT判定
API-->>AR: result + reward + nft
AR->>U: 🏆大吉 +50 MTC
API->>SC: Cranker TX (非同期)

Optimistic UI(待ち時間ゼロ)

ステップ時間処理
タップ → 演出開始0msフロントで即座にアニメ再生
API draw_omikuji~50msDjango で抽選 + NFT判定
演出完了2500ms結果確定済み → 表示
Solana TX~400msバックグラウンドで送信

おみくじ確率設定 (GCF Admin)

Basis Points (10000 = 100%) で0.01%刻みの精密制御。

等級デフォルト報酬倍率NFT
🏆 大吉5.00% (500bp)×3.0
✨ 吉15.00% (1500bp)×1.5任意
🌸 小吉30.00% (3000bp)×1.2
🍃 末吉35.00% (3500bp)×1.0
💀 凶15.00% (1500bp)×1.0

ZK-Proof of Vision(5層検証)

GPS偽装・リプレイ攻撃を多層で排除。プライバシー保護のため画像データは送信しない。

Layer検証内容配点
Temporalセッション時間 5-120秒/20
Motionジャイロ分散 0.005-0.5 (手持ち自然度)/20
Light環境光×時間帯整合性/20
HMACproof_hash 署名検証/20
Fingerprintデバイス一意性/20
合計PASS 閾値60/100

報酬計算式

Reward = Base(10 MTC) × SiteMultiplier × OmikujiMult × TierMult

TierMult = { メジャー: 1.0, 中規模: 2.0, 地方: 5.0, 秘境: 10.0 }

Security Model (Open Source)

These contracts are fully open source. Security relies on mathematical guarantees, not obscurity.

PrincipleImplementation
PDA-Only VaultsToken vaults are controlled by Program Derived Addresses — no human key can drain them
Checked ArithmeticEvery computation uses checked_* operations — overflow is impossible
Authority SeparationAdmin (multisig) ≠ Cranker (limited ops) ≠ User (self-custody)
Emergency PauseAdmin can pause all programs instantly; cannot steal funds
Immutable TokenomicsHalving factor, total pool, and epoch duration are set once and cannot be changed
Pure Math ModulesScoring/reward logic separated into auditable, testable math libraries
Vision Proof5-layer anti-spoofing without transmitting camera data (privacy-preserving)

◀ Back to RoadmapView Source Code