Wallet API

The API is designed for dApps to:

  • Connect to the user’s wallet

  • Read identity + balance

  • Sign messages

  • Construct/sign/push Trac Network (TNK) transfers

  • Sign Trac contract transactions (for trac-peer)

This page is based on the reference implementation in tap-wallet-extension (main branch) in this workspace.

Conventions

  • All methods are async and return Promises.

  • Hex strings are lowercase/uppercase tolerant unless stated otherwise.

  • Addresses are bech32m strings with trac1... prefix.

  • Amounts/balances are returned as strings (typically smallest-unit / integer strings).

Methods

tracnetwork.requestAccount()

Connects the wallet and returns the connected address.

  • Params: none

  • Returns: Promise<string> (wallet address)

Example response:

tracnetwork.getAddress()

Returns the currently connected address.

  • Params: none

  • Returns: Promise<string> (wallet address)

tracnetwork.getBalance()

Returns the TNK balance of the connected account.

  • Params: none

  • Returns: Promise<string> (balance)

Example response:

tracnetwork.getNetwork()

Returns the current wallet network.

  • Params: none

  • Returns: Promise<string> (typically "livenet" or "testnet")

tracnetwork.switchNetwork(network)

Switches wallet network.

  • Params:

    • network: string (accepted values include "livenet", "mainnet", "testnet")

  • Returns: Promise<string> (network name, e.g. "testnet")

Example response:

tracnetwork.getPublicKey()

Returns the connected wallet public key (hex).

  • Params: none

  • Returns: Promise<string> (public key hex, 32 bytes / 64 hex chars)

Example response:

tracnetwork.signMessage(message)

Signs an arbitrary message.

  • Params:

    • message: string

  • Returns: Promise<{ signature: string, publicKey: string, address: string }>

Example response shape:

Notes:

  • Signing semantics are wallet-implementation-defined (what bytes are signed).

  • When using this for a protocol that verifies signatures, ensure the verifier uses the same message bytes the wallet signed.

tracnetwork.sendTNK(from, to, amount)

Transfers TNK (high-level helper).

  • Params:

    • from: string

    • to: string

    • amount: string | number

  • Returns: Promise<{ txHash: string, success: boolean }>

Example response:

tracnetwork.buildTracTx({ from?, to, amount })

Builds and signs a Trac Network TNK transfer and returns a broadcastable payload (base64 string).

  • Params:

    • { from?: string, to: string, amount: string | number }

  • Returns: Promise<string> (txPayload, base64)

tracnetwork.pushTracTx(txPayload)

Pushes a signed Trac Network transfer transaction payload (from buildTracTx) to the network.

  • Params:

    • txPayload: string (base64)

  • Returns: Promise<{ txHash: string, success: boolean }>

Example response:

tracnetwork.signTracTx(contractTx)

Signs a contract transaction (used with trac-peer contract RPC flows).

  • Params:

    • contractTx: { prepared_command: object, nonce: string, context: object }

  • Returns: Promise<{ tx: string, signature: string }>

Minimal example (shape):

Return value:

Last updated