Skip to content

AssetLedger is a blockchain-based smart contract designed to create an immutable, transparent record-keeping system for real-world asset ownership. Built on the Stacks blockchain using Clarity, it serves as a digital registry that tracks asset ownership and maintains a complete audit trail of all transfers.

Notifications You must be signed in to change notification settings

blessing-samuel/Asset-Ledger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

AssetLedger Smart Contract

A secure blockchain-based smart contract for managing real-world asset ownership records, built on the Stacks blockchain using Clarity language.

Overview

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.

Features

  • 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

Contract Functions

Public Functions

create-property

(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

(change-holder property-id to-holder)

Transfers asset ownership to a new holder.

  • property-id: Unique asset identifier
  • to-holder: Principal address of the new owner
  • Requires: Caller must be current asset holder
  • Returns: Index of the transfer record or error

Read-Only Functions

get-property-holder

(get-property-holder property-id)

Returns the current owner of an asset.

get-property-records

(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

(check-property-state property-id)

Returns the current status of an asset ("active").

Data Structure

Properties Map

Stores core asset information:

{
  holder: principal,           // Current owner
  details: string,            // Asset description
  created-at: uint,          // Registration block height
  state: string              // Asset status
}

Transfer Records Map

Maintains ownership change history:

{
  from-holder: principal,     // Previous owner
  to-holder: principal,       // New owner
  timestamp: uint,           // Transfer block height
  tx-hash: buffer           // Transaction hash
}

Error Codes

  • ERR-UNAUTHORIZED (u1): Operation not permitted
  • ERR-INVALID-PROPERTY (u2): Asset does not exist
  • ERR-PROPERTY-EXISTS (u3): Asset already registered
  • ERR-NOT-HOLDER (u4): Caller is not the asset owner
  • ERR-INVALID-OPERATION (u5): Invalid transfer operation

Usage Example

;; 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")

Security Features

  • 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

About

AssetLedger is a blockchain-based smart contract designed to create an immutable, transparent record-keeping system for real-world asset ownership. Built on the Stacks blockchain using Clarity, it serves as a digital registry that tracks asset ownership and maintains a complete audit trail of all transfers.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published