Skip to content

Commit 8669b99

Browse files
committed
suggestions part 2
1 parent 0bdb198 commit 8669b99

File tree

1 file changed

+112
-22
lines changed
  • content/stellar-contracts/tokens/rwa

1 file changed

+112
-22
lines changed

content/stellar-contracts/tokens/rwa/rwa.mdx

Lines changed: 112 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ title: Real World Asset (RWA) Token
66

77
Real World Asset (RWA) tokens are security tokens that represent ownership or rights to real-world assets such as
88
real estate, commodities, securities, or other regulated financial instruments. These tokens must comply with various
9-
regulatory requirements including KYC/AML verification, transfer restrictions, and compliance rules. The RWA module
9+
regulatory requirements including KYC/AML verification, transfer restrictions, and compliance rules. The RWA suite
1010
provides a comprehensive framework based on the T-REX (Token for Regulated Exchanges) standard,
1111
which implements the [ERC-3643](https://docs.erc3643.org/erc-3643) specification.
1212

1313
## Overview
1414

15-
The [RWA](https://github.com/OpenZeppelin/stellar-contracts/tree/main/packages/tokens/src/rwa) module
15+
The [RWA](https://github.com/OpenZeppelin/stellar-contracts/tree/main/packages/tokens/src/rwa) suite
1616
provides a complete implementation of regulated security tokens with built-in compliance,
17-
identity verification, and administrative controls. The module is designed to be flexible and extensible,
17+
identity verification, and administrative controls. The suite is designed to be flexible and extensible,
1818
allowing integration with various identity registry and compliance frameworks.
1919

2020
The RWA token extends the standard fungible token functionality with regulatory features required for
@@ -30,7 +30,7 @@ security tokens, including:
3030

3131
## Architecture
3232

33-
The RWA module follows a modular architecture that separates concerns and allows for flexible integration:
33+
The RWA suite follows a modular architecture that separates concerns and allows for flexible integration:
3434

3535
### Core Components
3636

@@ -84,7 +84,14 @@ pub struct RealEstateToken;
8484

8585
#[contractimpl]
8686
impl RealEstateToken {
87-
pub fn __constructor(e: &Env, admin: Address, manager: Address, initial_supply: i128) {
87+
pub fn __constructor(
88+
e: &Env,
89+
admin: Address,
90+
manager: Address,
91+
compliance: Address,
92+
identity_verifier: Address,
93+
initial_supply: i128,
94+
) {
8895
// Set token metadata
8996
Base::set_metadata(
9097
e,
@@ -93,6 +100,10 @@ impl RealEstateToken {
93100
String::from_str(e, "REST"),
94101
);
95102

103+
// Set compliance and identity verifier contracts
104+
RWA::set_compliance(e, &compliance);
105+
RWA::set_identity_verifier(e, &identity_verifier);
106+
96107
// Set up access control
97108
access_control::set_admin(e, &admin);
98109

@@ -131,17 +142,37 @@ Identity Verification is handled on a separate contract as a module.
131142
All token recipients must have verified identities before receiving tokens. The RWA token integrates
132143
with an identity verifier contract that validates user identities against cryptographic claims.
133144

134-
```rust
135-
// Minting requires identity verification
136-
RWA::mint(e, &verified_investor, amount);
137-
138-
// Transfers automatically verify recipient identity
139-
RWA::transfer(e, &from, &verified_recipient, amount);
145+
Every token operation that involves receiving tokens (mint, transfer, recovery) automatically calls the
146+
identity verifier contract to ensure the recipient has a valid identity with the required claims (KYC, AML, etc.).
140147

141-
// Wallet recovery for lost/old accounts
148+
```rust
149+
// Example: Minting tokens
150+
// Internally calls: identity_verifier.verify_identity(&recipient)
151+
// Then calls: compliance.can_create(&recipient, &amount)
152+
// Finally calls: compliance.created(&recipient, &amount) after minting
153+
RWA::mint(e, &recipient, amount);
154+
155+
// Example: Transferring tokens
156+
// Internally calls: identity_verifier.verify_identity(&from)
157+
// Then calls: identity_verifier.verify_identity(&to)
158+
// Then calls: compliance.can_transfer(&from, &to, &amount)
159+
// Finally calls: compliance.transferred(&from, &to, &amount) after transfer
160+
RWA::transfer(e, &from, &to, amount);
161+
162+
// Example: Wallet recovery for lost/old accounts
163+
// Internally calls: identity_verifier.verify_identity(&new_account)
164+
// Then calls: identity_verifier.recovery_target(&old_account) to verify the new account
165+
// is the authorized recovery target for the old account
166+
// Transfers all tokens and preserves frozen status
142167
RWA::recover_balance(e, &old_account, &new_account, &operator);
143168
```
144169

170+
**Identity Verification Flow:**
171+
1. The RWA token calls `identity_verifier.verify_identity(&address)`
172+
2. The identity verifier checks if the address has a registered identity
173+
3. The identity verifier validates that the identity has all required claims from trusted issuers
174+
4. If verification fails, the entire operation reverts with `IdentityVerificationFailed` error
175+
145176
### Compliance Validation
146177

147178
Compliance Validation is handled on a separate contract as a module.
@@ -207,8 +238,8 @@ The RWA package includes several supporting modules that work together to provid
207238

208239
This is a mandatory module, since RWA token contract expects the compliance checks and hooks to be available.
209240

210-
The compliance module provides a modular framework for implementing custom compliance rules.
211-
It uses a hook-based architecture where compliance modules can be registered for specific events:
241+
Provides a modular framework for implementing custom compliance rules.
242+
[Compliance Contract](https://github.com/OpenZeppelin/stellar-contracts/blob/main/packages/tokens/src/rwa/compliance/mod.rs#L67) uses a hook-based architecture where multiple [compliance modules](https://github.com/OpenZeppelin/stellar-contracts/blob/main/packages/tokens/src/rwa/compliance/mod.rs#L327) can be registered for specific events:
212243

213244
- **Transferred**: Called after tokens are successfully transferred
214245
- **Created**: Called after tokens are successfully minted
@@ -225,28 +256,79 @@ The compliance contract is designed to be shared across multiple RWA tokens, wit
225256
This is a mandatory module, since RWA token contract expects `verify_identity(e: &Env, address: Address)`
226257
function to be available.
227258

228-
The identity verifier module provides the interface for verifying user identities.
259+
The **Identity Verifier Module** provides the interface for verifying user identities.
229260
It can also support possible custom implementation approaches:
230261

231262
- **Claim-based**: Cryptographic claims from trusted issuers (provided default implementation)
232263
- **Merkle Tree**: Efficient verification using merkle proofs
233264
- **Zero-Knowledge**: Privacy-preserving verification with custom ZK circuits
234265
- **Other custom approaches**: Any implementation that satisfies the `verify_identity` interface
235266

236-
The default claim-based implementation integrates with the Claim Topics and Issuers module and
267+
The default claim-based implementation integrates with the **Claim Topics and Issuers Module** and
237268
Identity Registry Storage.
238269

239270
### - Claim Topics and Issuers
240271
[Source Code](https://github.com/OpenZeppelin/stellar-contracts/tree/main/packages/tokens/src/rwa/claim_topics_and_issuers)
241272

242273
This module is an implementation detail. It is provided as the suggested implementation for the **Claim-based** approach.
243274

244-
Manages trusted claim issuers and claim topics (e.g., KYC=1, AML=2, Accredited Investor=3). This module:
275+
Acts as the trust registry that defines which claim topics are required and which issuers are authorized to provide those claims.
276+
277+
Key features/responsibilities of the **Claim Topics and Issuers Module** are:
278+
- **Claim Topic Registry**: Defines which types of claims are required for token participation (e.g., KYC=1, AML=2, Accredited Investor=3)
279+
- **Trusted Issuer Registry**: Maintains a list of authorized claim issuers (e.g., KYC providers, compliance firms)
280+
- **Authorization Mapping**: Maps each trusted issuer to the specific claim topics they are authorized to issue
281+
- Example: Issuer A can issue KYC and AML claims, but not Accreditation claims
282+
- Example: Issuer B can only issue Accreditation claims
283+
- **Multi-Token Support**: Can be shared across multiple RWA tokens, reducing deployment costs
284+
285+
**Configuration Example:**
286+
```rust
287+
// Add claim topics
288+
add_claim_topic(e, 1, operator); // KYC
289+
add_claim_topic(e, 2, operator); // AML
290+
add_claim_topic(e, 3, operator); // Accredited Investor
291+
292+
// Add trusted issuer with authorized topics
293+
add_trusted_issuer(e, issuer_a, vec![1, 2], operator); // Can issue KYC and AML
294+
add_trusted_issuer(e, issuer_b, vec![3], operator); // Can only issue Accreditation
295+
```
296+
297+
#### Understanding Claims
298+
299+
**What is a Claim?**
300+
301+
A claim is a cryptographically signed attestation made by a trusted authority (claim issuer) about a specific aspect
302+
of an identity. Think of it as a digital certificate that proves something about an investor.
303+
304+
**Claim Structure:**
305+
306+
Each claim contains:
307+
- **Topic**: A numeric identifier for what the claim attests to (e.g., KYC=1, AML=2, Accredited Investor=3)
308+
- **Issuer**: The address of the trusted authority that issued the claim
309+
- **Signature**: Cryptographic proof that the issuer created this claim
310+
- **Data**: The actual claim information (can include expiration dates, metadata)
311+
- **Scheme**: The signature algorithm used (Ed25519, Secp256k1, Secp256r1)
312+
313+
**How Claims Work:**
314+
315+
1. **Issuance**: A trusted authority (e.g., KYC provider) verifies an investor's identity off-chain
316+
2. **Signing**: The authority creates a cryptographic signature over the claim data using their private key
317+
3. **Storage**: The claim is stored on-chain in the investor's identity contract
318+
4. **Verification**: When the investor tries to receive tokens, the RWA contract:
319+
- Retrieves the required claims from the identity contract
320+
- Validates the cryptographic signatures using the issuer's public key
321+
- Checks that the claims haven't expired or been revoked
322+
- Ensures the issuer is trusted and authorized for those claim topics
323+
324+
**Example Flow:**
325+
```
326+
Investor → KYC Provider (off-chain verification)
327+
→ Claim Issuer Contract (signs claim with private key)
328+
→ Identity Contract (stores signed claim on-chain)
329+
→ RWA Token (validates claim during transfer/mint)
330+
```
245331

246-
- Maintains a registry of trusted claim issuers
247-
- Defines which claim topics are required for token participation
248-
- Maps issuers to the claim topics they are authorized to issue
249-
- Can be shared across multiple RWA tokens
250332

251333
### - Identity Registry Storage
252334
[Source Code](https://github.com/OpenZeppelin/stellar-contracts/tree/main/packages/tokens/src/rwa/identity_registry_storage)
@@ -265,7 +347,15 @@ Stores identity information for verified investors, including:
265347

266348
This module is an implementation detail. It is provided as the suggested implementation for the **Claim-based** approach.
267349

268-
Manages on-chain identity claims with cryptographic signatures. Claims are issued by trusted authorities and contain:
350+
Manages on-chain identity claims with cryptographic signatures.
351+
352+
This module can be used to extend or be embedded in identity systems.
353+
354+
<Callout type="info">
355+
This contract is under the control of the investors themselves, who are responsible for storing their claims and corresponding signatures. This gives investors ownership of their identity data.
356+
</Callout>
357+
358+
Claims are issued by trusted authorities and contain:
269359

270360
- Claim topic (e.g., KYC, AML)
271361
- Claim data (encrypted or hashed information)

0 commit comments

Comments
 (0)