sBTC Token
Last updated
Was this helpful?
Last updated
Was this helpful?
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.
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.
sbtc-token
: The main sBTC fungible token.
sbtc-token-locked
: Represents locked sBTC tokens.
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.
These functions can only be called by authorized protocol contracts:
Transfers tokens between principals.
Parameters: amount: uint
, sender: principal
, recipient: principal
Returns: (response bool uint)
Locks a specified amount of tokens for a user.
Parameters: amount: uint
, owner: principal
Returns: (response bool uint)
Unlocks a specified amount of tokens for a user.
Parameters: amount: uint
, owner: principal
Returns: (response bool uint)
Mints new tokens for a recipient.
Parameters: amount: uint
, recipient: principal
Returns: (response bool uint)
Burns tokens from an owner's balance.
Parameters: amount: uint
, owner: principal
Returns: (response bool uint)
Burns locked tokens from an owner's balance.
Parameters: amount: uint
, owner: principal
Returns: (response bool uint)
Sets a new name for the token.
Parameters: new-name: (string-ascii 32)
Returns: (response bool uint)
Sets a new symbol for the token.
Parameters: new-symbol: (string-ascii 10)
Returns: (response bool uint)
Sets a new URI for the token metadata.
Parameters: new-uri: (optional (string-utf8 256))
Returns: (response bool uint)
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)
Transfers tokens between users.
Parameters: amount: uint
, sender: principal
, recipient: principal
, memo: (optional (buff 34))
Returns: (response bool uint)
Returns the token name.
Returns: (response (string-ascii 32) uint)
Returns the token symbol.
Returns: (response (string-ascii 10) uint)
Returns the number of decimal places.
Returns: (response uint uint)
Returns the total balance (locked + unlocked) for a principal.
Parameters: who: principal
Returns: (response uint uint)
Returns the available (unlocked) balance for a principal.
Parameters: who: principal
Returns: (response uint uint)
Returns the locked balance for a principal.
Parameters: who: principal
Returns: (response uint uint)
Returns the total supply of tokens (locked + unlocked).
Returns: (response uint uint)
Returns the token metadata URI.
Returns: (response (optional (string-utf8 256)) uint)
Helper function for minting tokens to multiple recipients.
Parameters: item: {amount: uint, recipient: principal}
Returns: (response bool uint)
Access Control: Protocol functions can only be called by authorized contracts, enforced through the sbtc-registry
contract.
Ownership Verification: The transfer
function checks that the sender owns the tokens being transferred.
Separate Token Tracking: The contract maintains separate tracking for locked and unlocked tokens, ensuring proper accounting.
.sbtc-registry
: Used to validate protocol callers for privileged operations.