Skip to content
30 changes: 14 additions & 16 deletions Clarinet.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
[project]
name = "AssetBridge"
description = ""
name = 'AssetBridge'
description = ''
authors = []
telemetry = true
cache_dir = "./.cache"

# [contracts.counter]
# path = "contracts/counter.clar"

cache_dir = './.cache'
requirements = []
[contracts.asset-tokenization]
path = 'contracts/asset-tokenization.clar'
clarity_version = 3
epoch = 3.1
[repl.analysis]
passes = ["check_checker"]
check_checker = { trusted_sender = false, trusted_caller = false, callee_filter = false }
passes = ['check_checker']

# Check-checker settings:
# trusted_sender: if true, inputs are trusted after tx_sender has been checked.
# trusted_caller: if true, inputs are trusted after contract-caller has been checked.
# callee_filter: if true, untrusted data may be passed into a private function without a
# warning, if it gets checked inside. This check will also propagate up to the
# caller.
# More informations: https://www.hiro.so/blog/new-safety-checks-in-clarinet
[repl.analysis.check_checker]
strict = false
trusted_sender = false
trusted_caller = false
callee_filter = false
173 changes: 173 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
# AssetBridge: Advanced Real-World Asset Tokenization Protocol

![Platform: Stacks](https://img.shields.io/badge/Platform-Stacks-5546FF)
![Bitcoin: L2](https://img.shields.io/badge/Bitcoin-L2-orange)

AssetBridge is a sophisticated smart contract protocol built on Stacks that enables the tokenization of real-world assets with secure fractional ownership capabilities. Leveraging Bitcoin's security through Stacks' PoX consensus, it provides a robust framework for creating, managing, and trading tokenized assets while maintaining regulatory compliance.

## Key Features

### Asset Tokenization

- **Asset Creation**: Create digital representations of real-world assets with configurable supply and metadata
- **Fractional Ownership**: Enable multiple investors to own shares of high-value assets
- **Metadata Management**: Store and manage comprehensive asset information using IPFS/Arweave URIs
- **Supply Configuration**: Flexible total supply and fractional share settings

### Security & Compliance

- **Bitcoin-Anchored Security**: Utilizes Stacks' PoX consensus for Bitcoin-level security
- **Built-in Compliance**: Automated KYC/AML checks for all transfers
- **Granular Access Control**: Administrative controls for compliance management
- **Event Logging**: Comprehensive transaction and state change tracking

### Ownership Management

- **Secure Transfers**: Atomic ownership transfers with Bitcoin finality
- **Share Management**: Efficient tracking of fractional ownership
- **Compliance Verification**: Pre-transfer compliance checks
- **NFT Integration**: Non-fungible tokens representing primary ownership

## Technical Architecture

### Core Components

1. **Asset Registry**

- Tracks asset details and ownership
- Stores metadata URIs and configuration
- Manages transferability settings

2. **Compliance System**

- Maintains user compliance status
- Tracks approval history
- Enforces transfer restrictions

3. **Share Management**

- Handles fractional ownership accounting
- Manages share transfers
- Tracks individual balances

4. **Event System**
- Logs all contract interactions
- Maintains audit trail
- Enables external monitoring

## Smart Contract Interface

### Public Functions

#### Asset Management

```clarity
(create-asset
(total-supply uint)
(fractional-shares uint)
(metadata-uri (string-utf8 256))
)
```

Creates a new tokenized asset with specified supply and share configuration.

#### Ownership Transfer

```clarity
(transfer-fractional-ownership
(asset-id uint)
(to-principal principal)
(amount uint)
)
```

Transfers fractional ownership shares between parties.

#### Compliance Management

```clarity
(set-compliance-status
(asset-id uint)
(user principal)
(is-approved bool)
)
```

Updates compliance status for users.

### Read-Only Functions

```clarity
(get-asset-details (asset-id uint))
(get-owner-shares (asset-id uint) (owner principal))
(get-compliance-details (asset-id uint) (user principal))
(get-event (event-id uint))
```

## Error Handling

The contract defines several error constants for proper error handling:

- `ERR-UNAUTHORIZED` (u1): Access control violation
- `ERR-INSUFFICIENT-FUNDS` (u2): Insufficient balance for operation
- `ERR-INVALID-ASSET` (u3): Invalid asset ID or reference
- `ERR-TRANSFER-FAILED` (u4): Transfer operation failure
- `ERR-COMPLIANCE-CHECK-FAILED` (u5): Failed compliance verification
- `ERR-INVALID-INPUT` (u6): Invalid input parameters
- `ERR-INSUFFICIENT-SHARES` (u7): Insufficient shares for transfer
- `ERR-EVENT-LOGGING` (u8): Event logging failure

## Security Considerations

1. **Access Control**

- Contract owner privileges
- Compliance officer roles
- Transfer restrictions

2. **Data Validation**

- Input parameter validation
- Asset existence checks
- Share balance verification

3. **Compliance Enforcement**
- Automated compliance checks
- Transfer restrictions
- Administrative controls

## Usage Examples

### Creating a New Asset

```clarity
;; Create a new asset with 1000 total shares
(contract-call? .asset-bridge create-asset
u1000 ;; total-supply
u10 ;; fractional-shares (minimum transfer amount)
"ipfs://QmXgZAUWd8Ua9vQMPLetPQb6DrwzYhUPJoYJewdYgQwYk2" ;; metadata-uri
)
```

### Transferring Shares

```clarity
;; Transfer 100 shares to another user
(contract-call? .asset-bridge transfer-fractional-ownership
u1 ;; asset-id
'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM ;; to-principal
u100 ;; amount
)
```

## Development Setup

1. Install Clarinet for local development
2. Clone the repository

## Contributing

1. Fork the repository
2. Create a feature branch
3. Commit changes
4. Submit a pull request
Loading