🛠️
Stacks Documentation
  • Start Here
  • 🧠Concepts
    • Stacks 101
      • What Is Stacks?
      • Bitcoin Connection
      • Proof of Transfer
      • Stacks Among Other Layers
      • Financial Incentive and Security Budget
    • Network Fundamentals
      • Network Basics
      • Mainnet and Testnets
      • Accounts
      • Authentication
      • Bitcoin Name System
      • SIPs
      • Technical Specifications
    • Block Production
      • Mining
      • Signing
      • Bitcoin Finality
      • Bitcoin Reorgs
      • Stacking
    • Transactions
      • How Transactions Work
      • Post Conditions
    • Clarity
      • Overview
      • Decidability
    • sBTC
      • Core Features
      • sBTC Operations
        • Deposit
        • Withdrawal
        • Deposit vs Withdrawal Times
      • Emily API
      • Peg Wallet UTXO
      • Clarity Contracts
        • sBTC Registry
        • sBTC Token
        • sBTC Deposit
        • sBTC Withdrawal
      • Auxiliary Features
        • Transaction Fee Sponsorship
        • Signer Wallet Rotation
      • Walkthroughs
        • Signer Process Walkthrough
        • sBTC Transaction Walkthrough
      • sBTC FAQ
    • Gaia
      • Configuration
      • Deploy Gaia Hub
      • Amazon EC2
      • Linux
      • Mac OS
  • 🛠️Guides & Tutorials
    • Developer Quickstart
    • Clarity Crash Course
    • Build a Borrowing & Lending Protocol
    • Bitcoin Integration
      • Sending Bitcoin with Leather Wallet
      • Verifying a Bitcoin Transaction
      • Parsing a Bitcoin Transaction
    • Create Tokens
      • Creating a NFT
      • Creating a Fungible Token
    • Build a Frontend
      • Post Conditions with Stacks.js
      • Authentication with Stacks.js
      • Sending Transactions with Stacks.js
    • Testing Smart Contracts
      • Fuzz Testing
    • Run a Node
      • Run a Node with Docker
      • Run a Node with Digital Ocean
      • Run a Node with a Hosted Provider
      • Run a Node with Quicknode
      • Run a Bitcoin Node
      • Run a Pruned Bitcoin Node
    • Run a Miner
      • Miner Prerequisites
      • Miner Costs and Fees
      • Mine Testnet Stacks Tokens
      • Mine Mainnet Stacks Tokens
      • Verify Miner
    • Run a Signer
      • Signer Quickstart
      • How to Read Signer Logs
      • How to Monitor a Signer
      • Best practices for running a Signer
      • OpSec Best Practices
    • sBTC
      • How to Run an sBTC Signer
      • Best practices for running an sBTC Signer
      • How to Use the sBTC Bridge
      • Earn sBTC Rewards
    • Stack STX
      • Solo Stack
      • Operate a Pool
      • Stack with a Pool
      • Increase Stacked Position
      • Stop Stacking
    • Oracles
    • Community Tutorials
  • 📚Reference
    • API
    • Clarity Types
    • Clarity Functions
    • Clarity Keywords
    • Stacks Node Configuration
    • Signer Configuration
    • Stacks Tooling
  • 🏗️Example Contracts
    • Audited Starter Contracts
    • Stacking
    • BNS
    • Multi Send
  • 🧡Press & Top Links
    • 🔶2024
      • 🔸January 2024
      • 🔸February 2024
      • 🔸March 2024
      • 🔸April 2024
      • 🔸May 2024
      • 🔸June 2024
      • 🔸July 2024
      • 🔸August 2024
      • 🔸September 2024
      • 🔸October 2024
      • 🔸November 2024
      • 🔸December 2024
    • 🔶2025
      • 🔸January 2025
      • 🔸February 2025
      • 🔸March 2025
      • 🔸April 2025
      • 🔸May 2025
  • 🧡Bitcoin Theses and Reports
    • 🟠Bitcoin Theses
    • 📙Bitcoin Reports
  • Contribute
Powered by GitBook
On this page
  • Overview
  • Constants
  • Fungible Tokens
  • Data Variables
  • Protocol Functions
  • protocol-transfer
  • protocol-lock
  • protocol-unlock
  • protocol-mint
  • protocol-burn
  • protocol-burn-locked
  • protocol-set-name
  • protocol-set-symbol
  • protocol-set-token-uri
  • protocol-mint-many
  • Public Functions (SIP-010 Trait)
  • transfer
  • get-name
  • get-symbol
  • get-decimals
  • get-balance
  • get-balance-available
  • get-balance-locked
  • get-total-supply
  • get-token-uri
  • Private Functions
  • protocol-mint-many-iter
  • Security Considerations
  • Interactions with Other Contracts

Was this helpful?

  1. Concepts
  2. sBTC
  3. Clarity Contracts

sBTC Token

PrevioussBTC RegistryNextsBTC Deposit

Last updated 6 months ago

Was this helpful?

Overview

The (sbtc-token.clar) implements the fungible token functionality for sBTC. It manages both unlocked and locked sBTC tokens and provides functions for minting, burning, transferring, and querying token information. sBTC is a SIP-010 standard fungible token.

Constants

  • ERR_NOT_OWNER (u4): Error when the sender tries to move a token they don't own.

  • ERR_NOT_AUTH (u5): Error when the caller is not an authorized protocol caller.

  • token-decimals (u8): The number of decimal places for the token.

Fungible Tokens

  • sbtc-token: The main sBTC fungible token.

  • sbtc-token-locked: Represents locked sBTC tokens.

Data Variables

  • token-name: The name of the token (default: "sBTC").

  • token-symbol: The symbol of the token (default: "sBTC").

  • token-uri: An optional URI for token metadata.

Protocol Functions

These functions can only be called by authorized protocol contracts:

protocol-transfer

Transfers tokens between principals.

  • Parameters: amount: uint, sender: principal, recipient: principal

  • Returns: (response bool uint)

protocol-lock

Locks a specified amount of tokens for a user.

  • Parameters: amount: uint, owner: principal

  • Returns: (response bool uint)

protocol-unlock

Unlocks a specified amount of tokens for a user.

  • Parameters: amount: uint, owner: principal

  • Returns: (response bool uint)

protocol-mint

Mints new tokens for a recipient.

  • Parameters: amount: uint, recipient: principal

  • Returns: (response bool uint)

protocol-burn

Burns tokens from an owner's balance.

  • Parameters: amount: uint, owner: principal

  • Returns: (response bool uint)

protocol-burn-locked

Burns locked tokens from an owner's balance.

  • Parameters: amount: uint, owner: principal

  • Returns: (response bool uint)

protocol-set-name

Sets a new name for the token.

  • Parameters: new-name: (string-ascii 32)

  • Returns: (response bool uint)

protocol-set-symbol

Sets a new symbol for the token.

  • Parameters: new-symbol: (string-ascii 10)

  • Returns: (response bool uint)

protocol-set-token-uri

Sets a new URI for the token metadata.

  • Parameters: new-uri: (optional (string-utf8 256))

  • Returns: (response bool uint)

protocol-mint-many

Mints tokens for multiple recipients in a single transaction.

  • Parameters: recipients: (list 200 {amount: uint, recipient: principal})

  • Returns: (response (list 200 (response bool uint)) uint)

Public Functions (SIP-010 Trait)

transfer

Transfers tokens between users.

  • Parameters: amount: uint, sender: principal, recipient: principal, memo: (optional (buff 34))

  • Returns: (response bool uint)

get-name

Returns the token name.

  • Returns: (response (string-ascii 32) uint)

get-symbol

Returns the token symbol.

  • Returns: (response (string-ascii 10) uint)

get-decimals

Returns the number of decimal places.

  • Returns: (response uint uint)

get-balance

Returns the total balance (locked + unlocked) for a principal.

  • Parameters: who: principal

  • Returns: (response uint uint)

get-balance-available

Returns the available (unlocked) balance for a principal.

  • Parameters: who: principal

  • Returns: (response uint uint)

get-balance-locked

Returns the locked balance for a principal.

  • Parameters: who: principal

  • Returns: (response uint uint)

get-total-supply

Returns the total supply of tokens (locked + unlocked).

  • Returns: (response uint uint)

get-token-uri

Returns the token metadata URI.

  • Returns: (response (optional (string-utf8 256)) uint)

Private Functions

protocol-mint-many-iter

Helper function for minting tokens to multiple recipients.

  • Parameters: item: {amount: uint, recipient: principal}

  • Returns: (response bool uint)

Security Considerations

  1. Access Control: Protocol functions can only be called by authorized contracts, enforced through the sbtc-registry contract.

  2. Ownership Verification: The transfer function checks that the sender owns the tokens being transferred.

  3. Separate Token Tracking: The contract maintains separate tracking for locked and unlocked tokens, ensuring proper accounting.

Interactions with Other Contracts

  • .sbtc-registry: Used to validate protocol callers for privileged operations.

🧠
sBTC Token contract