XSC-0001: Fungible Token
XSC-0001 is the core fungible-token interface used across the Xian stack.
Required Surface
The standard token surface is:
python
@export
def change_metadata(key: str, value: Any):
...
@export
def transfer(amount: float, to: str):
...
@export
def approve(amount: float, to: str):
...
@export
def transfer_from(amount: float, to: str, main_account: str):
...
@export
def balance_of(address: str) -> float:
...Expected Semantics
transfermoves balance fromctx.callertotoapprovesets an allowance fortotransfer_fromspends frommain_accountusing the caller's allowancebalance_ofreturns the current balance for an address
The current canonical implementation stores allowances in a dedicated approvals hash using a two-dimensional key:
python
approvals[owner, spender] = amountExpected Events
The canonical token contract emits:
TransferApprove
Typical indexed fields are sender and recipient/spender so that CometBFT and dashboard subscribers can query them efficiently.
Recommended State Layout
python
balances = Hash(default_value=0)
approvals = Hash(default_value=0)
metadata = Hash()
operator = Variable()The current canonical implementation stores metadata edit authority in the separate operator variable instead of metadata["operator"].
Common metadata keys in the canonical token are:
token_nametoken_symboltoken_logo_urltoken_logo_svgtoken_websitetotal_supply
Wallets should prefer token_logo_url when it is present and non-empty. If the URL field is empty, they should fall back to token_logo_svg and render the on-chain SVG directly.
Compatibility Notes
- validate
amount > 0for transfers - approvals may be
0and should overwrite prior allowance - emit events on successful transfer/approval paths
- keep function names and argument names stable so tooling can introspect them