Instant affiliate payouts, settled on Bitcoin. No middlemen. No delays. No trust required.
Architecture Β· Getting Started Β· Smart Contracts Β· Integrations Β· Roadmap Β· Security
The $17B affiliate marketing industry runs on broken payment infrastructure. Amazon Associates controls 40%+ of the market, cuts commissions annually, and holds withdrawals for months. Nearly half of all affiliates quit networks because of payment delays.
Affiliate is a decentralized affiliate network built on Stacks, where every payout is automatic, instant, and settled with Bitcoin finality. Merchants deposit escrow once. Affiliates are paid on every verified sale β no platform in between, no waiting, no trust required.
Stacks is the only smart contract platform that settles directly on Bitcoin. This matters for a payments product:
| Property | Traditional Networks | EVM Chains | Stacks |
|---|---|---|---|
| Settlement Layer | Centralized database | Ethereum | Bitcoin |
| Contract Model | None | Turing-complete (exploit risk) | Clarity (decidable, auditable) |
| Trust Model | Platform trust | Chain trust | Bitcoin finality |
| Payout Asset | Fiat (delayed) | ETH / ERC-20 | sBTC + stablecoins |
| Auditability | None | Partial | Full β before execution |
Clarity's non-Turing-complete design means contract behavior can be fully analyzed before deployment. No reentrancy attacks. No unexpected execution paths. For a product handling merchant escrow at scale, this is not optional.
ββββββββββββββββββββ Sale Event βββββββββββββββββββββββββββ
β E-Commerce β βββββββββββββββββββββΊ β Oracle / Verifier β
β Plugin β β (off-chain service) β
β WooCommerce / β ββββββββββββββ¬βββββββββββββ
β Shopify β β Signed Attestation
ββββββββββββββββββββ βΌ
βββββββββββββββββββββββββββ
ββββββββββββββββββββ Escrow Deposit β Clarity Contracts β
β Merchant β βββββββββββββββββββββΊ β β
β Dashboard β β escrow.clar β
ββββββββββββββββββββ β ββ holds merchant fundsβ
β ββ validates events β
ββββββββββββββββββββ Instant Payout β ββ enforces rules β
β Affiliate β βββββββββββββββββββββ β β
β Wallet β β payout.clar β
ββββββββββββββββββββ β ββ releases commissionsβ
β ββ routes sBTC / USDC β
β β
β affiliate.clar β
β ββ registration β
β ββ referral tracking β
βββββββββββββββββββββββββββ
- Merchant deploys a campaign and deposits USDC or sBTC into the escrow contract
- Affiliate registers, receives a unique referral link, and sets their payout asset preference
- Buyer clicks the affiliate link and completes a purchase on the merchant's store
- Plugin posts the sale event to the oracle service with a signed payload
- Oracle verifies the event and submits a signed attestation to the Clarity contract
- Contract validates the attestation, calculates the commission, and releases the payout instantly to the affiliate's wallet
No human approval. No batch processing. No waiting period.
All contracts are written in Clarity and deployed on the Stacks blockchain.
Manages merchant funds. Merchants deposit USDC or sBTC, set commission rates, and define campaign parameters. The contract enforces minimum escrow thresholds and pauses payouts automatically if the balance falls below the configured floor.
;; Merchant deposits escrow
(define-public (deposit (amount uint) (token <ft-trait>))
...)
;; Campaign configuration
(define-public (set-commission-rate (campaign-id uint) (rate uint))
...)Handles affiliate registration, referral link generation, and on-chain tracking of conversions. Each affiliate is identified by their Stacks wallet address.
;; Register as affiliate
(define-public (register (payout-asset (string-ascii 4)))
...)
;; Record a verified conversion
(define-public (record-conversion (affiliate principal) (sale-id (buff 32)))
...)Releases commissions to affiliate wallets upon receiving a valid oracle attestation. Supports both sBTC and stablecoin payouts based on affiliate preference.
;; Release payout on verified sale
(define-public (release-payout (sale-id (buff 32)) (oracle-sig (buff 65)))
...)Install the plugin on any WooCommerce store. On order completion, the plugin signs and posts the sale event to the oracle service.
# Install via WordPress admin or manually
cp -r plugins/woocommerce/ /wp-content/plugins/affiliate-network/Configuration is handled via the WordPress admin panel. Required fields: merchant wallet address, campaign ID, oracle endpoint.
The Shopify app listens to order webhooks and forwards verified events to the oracle. Available in the Shopify App Store (beta).
The oracle is a lightweight Node.js service that:
- Receives sale events from e-commerce plugins
- Validates event signatures and deduplicates submissions
- Posts signed attestations to the Clarity contract on Stacks
cd oracle
npm install
cp .env.example .env # configure oracle signing key and RPC endpoint
npm startAffiliates choose their preferred payout asset at registration and can update it at any time.
| Asset | Description | Best For |
|---|---|---|
| sBTC | Wrapped Bitcoin on Stacks, 1:1 BTC-backed | Affiliates who want Bitcoin exposure |
| USDC | USD stablecoin bridged to Stacks | Affiliates who want price stability |
Merchants fund escrow in either asset. The contract handles routing based on affiliate preference.
git clone https://github.com/your-org/affiliate.git
cd affiliate
npm install# Start local Stacks devnet (runs Bitcoin + Stacks nodes locally)
clarinet devnet start
# In a separate terminal, start the oracle service
cd oracle && npm run dev
# Start the merchant dashboard
cd frontend/merchant && npm run dev
# Start the affiliate portal
cd frontend/affiliate && npm run dev# Clarity contract tests
clarinet test
# Oracle and plugin unit tests
npm testclarinet deployments apply --devnet # local devnet
clarinet deployments apply --testnet # Stacks testnet
clarinet deployments apply --mainnet # mainnet β requires explicit confirmationaffiliate/
βββ contracts/ # Clarity smart contracts
β βββ escrow.clar # Merchant escrow and campaign management
β βββ affiliate.clar # Affiliate registration and referral tracking
β βββ payout.clar # Commission release logic
βββ tests/ # Contract unit and integration tests
β βββ escrow_test.ts
β βββ affiliate_test.ts
β βββ payout_test.ts
βββ oracle/ # Sale event verification service
β βββ src/
β β βββ verifier.ts # Event signature validation
β β βββ broadcaster.ts # Stacks transaction submission
β β βββ deduplicator.ts # Replay attack prevention
β βββ .env.example
βββ plugins/
β βββ woocommerce/ # WooCommerce plugin (PHP)
β βββ shopify/ # Shopify app (Node.js)
βββ frontend/
β βββ merchant/ # Merchant dashboard (Next.js)
β βββ affiliate/ # Affiliate portal (Next.js)
βββ docs/
βββ architecture.md # Detailed system design
βββ oracle-spec.md # Oracle API and signing spec
βββ integration-guide.md # Merchant integration guide
| Regulation | Implementation |
|---|---|
| FTC | Affiliate disclosure enforced at the link level; non-compliant links are flagged |
| GDPR / CCPA | No personal data stored on-chain; off-chain data minimized and deletable on request |
| AML | Wallet screening via Chainalysis integration at affiliate onboarding |
v1 β Foundation
- Core escrow and payout contracts (Clarity)
- Oracle service (event verification + Stacks broadcaster)
- WooCommerce plugin (beta)
- Merchant dashboard (deposit, campaign management)
- Affiliate portal (referral links, earnings tracking)
v2 β Expansion
- Shopify app
- sBTC payout support
- Multi-tier commission structures (e.g., sub-affiliate splits)
- Dispute resolution mechanism
v3 β Scale
- On-chain affiliate reputation scoring
- SDK for custom platform integrations
- Mobile wallet support
- Cross-chain payout routing
Clarity contracts are decidable β their complete behavior can be statically analyzed before execution. This eliminates entire classes of vulnerabilities common on EVM chains: reentrancy, integer overflow via unexpected paths, and hidden logic branches.
Audit status: Pre-audit. Independent audit scheduled before mainnet deployment.
Responsible disclosure: Email security@your-domain.com with a description of the vulnerability. Do not open a public issue. We respond within 48 hours and follow coordinated disclosure practices.
- Fork the repository
- Create a feature branch:
git checkout -b feat/your-feature - Write tests for any new contract logic
- Open a pull request against
main
Read CONTRIBUTING.md before submitting. All Clarity changes require passing clarinet test with no regressions.