Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This is a **Bitcoin Cash (BCH) Knowledge Base** focused on **CashScript smart co
- CashTokens (native fungible and non-fungible tokens)
- SDK usage for contract deployment and interaction
- Security best practices and vulnerability patterns
- Real-world production patterns (including ParityUSD, a 26-contract stablecoin system)
- Real-world production patterns (including ParyonUSD, a 26-contract stablecoin system)
- Community FAQs extracted from BCH developer Telegram groups

## Critical Domain Knowledge
Expand Down
2 changes: 1 addition & 1 deletion Knowledge-Base-V2/CORE_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ require((flags & 0x01) == 0x01);

### Array Bounds
```cashscript
// Guard optional output access with if-statement (from ParityUSD)
// Guard optional output access with if-statement (from ParyonUSD)
if (tx.outputs.length > 8) {
bytes tokenCategoryOutput8 = tx.outputs[8].tokenCategory;
if (tokenCategoryOutput8 != 0x) {
Expand Down
2 changes: 1 addition & 1 deletion Knowledge-Base-V2/FAQ_DISTILLED.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ Check `tx.inputs[i].tokenCategory.length > 32` to verify it's an NFT.
### Reference implementations
**Q**: Where can I find advanced open-source contracts?

**A**: ParityUSD open-sourced 26 contracts forming one of the most advanced BCH applications. See parityusd.com/blog/open-source-contracts
**A**: ParyonUSD open-sourced 26 contracts forming one of the most advanced BCH applications. See paryonusd.com/blog/open-source-contracts

---

Expand Down
2 changes: 1 addition & 1 deletion concepts/cashscript-mental-model.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CashScript Mental Model for Production Systems

A comprehensive framework for designing safe, production-ready CashScript contract systems. Derived from analysis of ParityUSD's 26-contract stablecoin system.
A comprehensive framework for designing safe, production-ready CashScript contract systems. Derived from analysis of ParyonUSD's 26-contract stablecoin system.

---

Expand Down
2 changes: 1 addition & 1 deletion concepts/multi-contract-architecture.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Multi-Contract Architecture in CashScript

This document covers production-grade patterns for building complex systems with multiple interacting CashScript contracts. These patterns are derived from analysis of ParityUSD, a 26-contract production stablecoin system.
This document covers production-grade patterns for building complex systems with multiple interacting CashScript contracts. These patterns are derived from analysis of ParyonUSD, a 26-contract production stablecoin system.

---

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# ParityUSD Deep Analysis Report
# ParyonUSD Deep Analysis Report
## CashScript Multi-Contract Patterns & Lessons Learned

---

## 1. SYSTEM ARCHITECTURE OVERVIEW

ParityUSD is a production-grade stablecoin system with **26 CashScript contracts** organized into 4 domains:
ParyonUSD is a production-grade stablecoin system with **26 CashScript contracts** organized into 4 domains:

```
ParityUSD System (26 contracts)
ParyonUSD System (26 contracts)
├── Loan Module (10 contracts)
│ ├── Loan.cash (main state holder)
│ ├── LoanSidecar.cash (token holder)
Expand Down Expand Up @@ -238,7 +238,7 @@ require(tx.inputs[4].tokenCategory == redeemerTokenId + 0x02);
**Solution**: Send to OP_RETURN output.

```cashscript
// From LiquidateLoan.cash - burning ParityUSD during liquidation
// From LiquidateLoan.cash - burning ParyonUSD during liquidation
require(tx.outputs[5].lockingBytecode == 0x6a); // OP_RETURN
require(tx.outputs[5].tokenCategory == parityTokenId);
require(tx.outputs[5].tokenAmount == burnAmount);
Expand Down Expand Up @@ -323,7 +323,7 @@ require(currentPeriod > storedPeriod);
**Pattern**: All operations have minimum thresholds.

```cashscript
// 100.00 ParityUSD minimum everywhere
// 100.00 ParyonUSD minimum everywhere
require(borrowAmount >= 100_00);
require(redemptionAmount >= 100_00);
require(depositAmount >= 100_00);
Expand Down Expand Up @@ -413,7 +413,7 @@ Every contract must explicitly check that outputs match expected:

## 5. ANTI-PLACEHOLDER LESSONS

### Why ParityUSD Has No Placeholders
### Why ParyonUSD Has No Placeholders

1. **Every contract has REAL logic**: The simplest contract (LoanSidecar) still has meaningful validation - checking transaction hash and index relationships.

Expand All @@ -423,7 +423,7 @@ Every contract must explicitly check that outputs match expected:

### The Minimum Viable Contract

The smallest real contract in ParityUSD (LoanTokenSidecar.cash):
The smallest real contract in ParyonUSD (LoanTokenSidecar.cash):
```cashscript
contract LoanTokenSidecar() {
function attach() {
Expand Down Expand Up @@ -504,7 +504,7 @@ For converting EVM to CashScript:

## 8. KEY TAKEAWAYS FOR PREVENTING PLACEHOLDER VIOLATIONS

The ParityUSD analysis reveals **why placeholders are architecturally impossible in well-designed CashScript**:
The ParyonUSD analysis reveals **why placeholders are architecturally impossible in well-designed CashScript**:

1. **Every contract PROVES something** - The sidecar proves it was created with the main contract. The function contract proves it has authority to execute that operation. If a contract proves nothing, it has no reason to exist.

Expand All @@ -519,4 +519,4 @@ The ParityUSD analysis reveals **why placeholders are architecturally impossible
3. Enforce minimum require() statements per contract
4. Validate that every contract has meaningful logic connecting inputs to outputs

The ParityUSD patterns give us concrete examples of what "real" multi-contract systems look like - every contract has purpose, every function has validation, and every interaction is explicitly constrained.
The ParyonUSD patterns give us concrete examples of what "real" multi-contract systems look like - every contract has purpose, every function has validation, and every interaction is explicitly constrained.
8 changes: 4 additions & 4 deletions examples/real-world/production-patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ contract StreamingPayment(

### 7. Price Feed Oracle

Based on ParityUSD's PriceContract — single oracle signs price data, contract validates
Based on ParyonUSD's PriceContract — single oracle signs price data, contract validates
heartbeat or deviation threshold before accepting updates.

```cashscript
Expand Down Expand Up @@ -750,9 +750,9 @@ describe('Production Contract Tests', () => {

These real-world patterns demonstrate how CashScript can be used to build sophisticated applications on Bitcoin Cash, from DeFi protocols to NFT marketplaces and governance systems. Each pattern includes security considerations, error handling, and practical implementation details suitable for production use.

## ParityUSD-Derived Production Patterns
## ParyonUSD-Derived Production Patterns

The following patterns are derived from analysis of ParityUSD, a production stablecoin system with 26 contracts. See `parityusd-analysis.md` for the full analysis.
The following patterns are derived from analysis of ParyonUSD, a production stablecoin system with 26 contracts. See `paryonusd-analysis.md` for the full analysis.

### 14. Sidecar Contract Template

Expand Down Expand Up @@ -1108,4 +1108,4 @@ contract OriginEnforcer(bytes32 factoryCategory) {
}
```

These ParityUSD-derived patterns represent battle-tested approaches used in production DeFi systems. Each pattern emphasizes explicit validation, output limiting, and clear constraint specification.
These ParyonUSD-derived patterns represent battle-tested approaches used in production DeFi systems. Each pattern emphasizes explicit validation, output limiting, and clear constraint specification.
4 changes: 2 additions & 2 deletions faq/telegram/cashscript_faq_2025.json
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
},
{
"q": "Are CashScript contracts deployed like Ethereum smart contracts?",
"a": "Think of BCH contracts as elaborate spending conditions rather than deployments. Some contracts have unique 'deployments' authenticated by a tokenId (like Moria, ParityUSD), while others are just spending scripts like multisig or vaults that share the same spending conditions and get a stable address. You can also put functions themselves on token commitments (if they fit in 128 bytes), giving you local transferrable functions."
"a": "Think of BCH contracts as elaborate spending conditions rather than deployments. Some contracts have unique 'deployments' authenticated by a tokenId (like Moria, ParyonUSD), while others are just spending scripts like multisig or vaults that share the same spending conditions and get a stable address. You can also put functions themselves on token commitments (if they fit in 128 bytes), giving you local transferrable functions."
},
{
"q": "Do CashScript contracts have an address and balance?",
Expand Down Expand Up @@ -489,7 +489,7 @@
},
{
"q": "Where can I find advanced open-source CashScript contract examples?",
"a": "ParityUSD has open-sourced their smart contract source code - 26 contracts forming one of the most advanced applications built on BCH script. See parityusd.com/blog/open-source-contracts for the full code and documentation."
"a": "ParyonUSD has open-sourced their smart contract source code - 26 contracts forming one of the most advanced applications built on BCH script. See paryonusd.com/blog/open-source-contracts for the full code and documentation."
},
{
"q": "What interesting BCH project ideas would the CashScript team like to see built?",
Expand Down