A secure blockchain-based smart contract for managing real-world asset ownership records, built on the Stacks blockchain using Clarity language.
AssetLedger provides immutable ownership tracking, secure transfer validation, and comprehensive history logging for real-world assets. Each asset is represented by a unique identifier and maintains a complete audit trail of all ownership changes.
- Asset Registration: Register new assets with unique identifiers and descriptions
- Ownership Transfer: Secure transfer of asset ownership between principals
- History Tracking: Complete audit trail of all ownership changes
- Ownership Verification: Query current owners and asset status
- Access Control: Only asset holders can initiate transfers
(create-property property-id details)Registers a new asset in the system.
property-id: Unique UTF-8 string identifier (36 characters)details: Asset description (up to 256 characters)- Returns: Index of the initial transfer record or error
(change-holder property-id to-holder)Transfers asset ownership to a new holder.
property-id: Unique asset identifierto-holder: Principal address of the new owner- Requires: Caller must be current asset holder
- Returns: Index of the transfer record or error
(get-property-holder property-id)Returns the current owner of an asset.
(get-property-records property-id)Returns complete transfer history for an asset including:
- Total number of ownership changes
- Details of the most recent transfer
(check-property-state property-id)Returns the current status of an asset ("active").
Stores core asset information:
{
holder: principal, // Current owner
details: string, // Asset description
created-at: uint, // Registration block height
state: string // Asset status
}Maintains ownership change history:
{
from-holder: principal, // Previous owner
to-holder: principal, // New owner
timestamp: uint, // Transfer block height
tx-hash: buffer // Transaction hash
}ERR-UNAUTHORIZED (u1): Operation not permittedERR-INVALID-PROPERTY (u2): Asset does not existERR-PROPERTY-EXISTS (u3): Asset already registeredERR-NOT-HOLDER (u4): Caller is not the asset ownerERR-INVALID-OPERATION (u5): Invalid transfer operation
;; Register a new property
(create-property "550e8400-e29b-41d4-a716-446655440000" "Downtown Office Building")
;; Transfer ownership
(change-holder "550e8400-e29b-41d4-a716-446655440000" 'SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7)
;; Query current owner
(get-property-holder "550e8400-e29b-41d4-a716-446655440000")
;; View transfer history
(get-property-records "550e8400-e29b-41d4-a716-446655440000")- Ownership Validation: Only current holders can transfer assets
- Immutable History: All transfers are permanently recorded
- Unique Identifiers: Prevents duplicate asset registration
- Principal-Based Access: Leverages Stacks blockchain security