Skip to content

Samuel1505/Veritasor-Contracts

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Veritasor Contracts

Soroban smart contracts for the Veritasor revenue attestation protocol on Stellar. Store revenue Merkle roots and metadata on-chain; full data remains off-chain.

Contract: attestation

Stores one attestation per (business address, period). Each attestation is a Merkle root (32 bytes), timestamp, version, and the fee paid. Duplicate (business, period) submissions are rejected.

Dynamic Fee Schedule

The contract supports a tiered, volume-based fee system. Fees are denominated in a configurable Soroban token and collected on each attestation submission.

  • Tier discounts: Businesses are assigned tiers (Standard, Professional, Enterprise, or custom) with configurable discounts in basis points.
  • Volume discounts: Cumulative attestation count triggers bracket-based discounts.
  • Backward compatible: When fees are not configured or disabled, attestations are free.

See docs/attestation-dynamic-fees.md for the full specification, economic rationale, and configuration guide.

Methods

Method Description
initialize(admin) One-time setup. Sets the admin address.
configure_fees(token, collector, base_fee, enabled) Admin: set fee token, collector, base fee, and toggle.
set_tier_discount(tier, discount_bps) Admin: set discount (0–10 000 bps) for a tier level.
set_business_tier(business, tier) Admin: assign a business to a tier.
set_volume_brackets(thresholds, discounts) Admin: set volume discount brackets.
set_fee_enabled(enabled) Admin: toggle fee collection on/off.
submit_attestation(business, period, merkle_root, timestamp, version) Store attestation; collects fee if enabled. Business must authorize.
get_attestation(business, period) Returns Option<(BytesN<32>, u64, u32, i128)> (root, ts, ver, fee_paid).
verify_attestation(business, period, merkle_root) Returns true if attestation exists and root matches.
get_fee_config() Current fee configuration or None.
get_fee_quote(business) Fee the business would pay for its next attestation.
get_business_tier(business) Tier assigned to a business (0 if unset).
get_business_count(business) Cumulative attestation count.
get_admin() Contract admin address.

Prerequisites

Setup

# Install Rust (if needed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Add wasm target for Soroban
rustup target add wasm32-unknown-unknown

# Build the contract
cd contracts/attestation
cargo build --target wasm32-unknown-unknown --release

The .wasm artifact will be in target/wasm32-unknown-unknown/release/veritasor_attestation.wasm.

Tests

cd contracts/attestation
cargo test

27 tests covering core attestation logic, fee calculation arithmetic, tier/volume discounts, combined discounts, fee toggling, access control, input validation, and a full economic simulation.

Project structure

veritasor-contracts/
├── Cargo.toml                  # Workspace root
├── docs/
│   └── attestation-dynamic-fees.md  # Fee schedule specification
└── contracts/
    └── attestation/
        ├── Cargo.toml
        └── src/
            ├── lib.rs               # Contract entry points
            ├── dynamic_fees.rs      # Fee types, storage, calculation
            ├── test.rs              # Core attestation tests
            └── dynamic_fees_test.rs # Fee schedule tests

Deploying (Stellar / Soroban CLI)

With Stellar CLI and a configured network:

stellar contract deploy \
  --network testnet \
  --source <KEY> \
  target/wasm32-unknown-unknown/release/veritasor_attestation.wasm

Merging to remote

This directory is its own git repository. To push to your remote:

git remote add origin <your-contracts-repo-url>
git push -u origin main

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Rust 54.0%
  • Makefile 45.6%
  • DTrace 0.4%