Status: Draft
Version: 1.0.0
Author: Jim Toth ([email protected])
This document describes the standard interface for SmartWeave Contracts that represent multitple tokenized assets simultaneously.
While most SmartWeave Contracts represent tokenized assets with a single, uniform balance structure, there are use cases for combining the balances of more than one token - fungible or non-fungible. For example, a developer may want to track a fungible balance alongside a non-fungible one. Other developers may want to track multiple balances of the same class of fungibility without being fungible between themselves.
The multi-token standard is identical to the SWS-2: Smartweave Token
specification with the addition of an optional parameter tokenId
. If
tokenId
is not provided it should be assumed the "default" token is desired.
balanceOf(target: Address, tokenId?: string) => { target: Address, balance: number }
- Returns the current balance of a
target
address for a giventokenId
transfer(target: Address, qty: number, tokenId?: string) => void
- Transfers
qty
oftokenId
tokens totarget
address - SHOULD THROW if the caller does not have enough balance to transfer
name(tokenId?: string) => string | undefined
- Returns the name of the SmartWeave Token for
tokenId
ticker(tokenId?: string) => string | undefined
- Returns the ticker of the SmartWeave Token for
tokenId
decimals(tokenId?: string) => number
- Returns the number of decimal places the token amount should display for
tokenId
- MUST return an integer
defaultToken() => string
- Returns the
tokenId
of the "default" token - MAY be ommitted if the contract state includes a property
defaultToken
of typestring
.