The API is designed for dapps to:
connect to the user’s wallet,
construct/sign/push Trac Network transfers.
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).
tracnetwork.requestAccount()
Connects the wallet and returns the connected address.
Params: none
Returns: Promise<string> wallet address
const address = await window.tracnetwork.requestAccount();
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> "livenet" or "testnet"
tracnetwork.switchNetwork(network)
Switches wallet network.
Params:
network: string (expected: "livenet" or "testnet")
Returns: Promise<string> network
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:
Returns: Promise<{ signature: string, publicKey: string, address: string }>
Example response shape:
Notes:
The exact signing semantics (UTF-8 string bytes vs hex-decoding) are wallet-implementation defined.
If you use this to sign a trac-peer prepared tx hash, ensure the wallet signs the same bytes that the peer verifies.
tracnetwork.sendTNK(fromAddress, toAddress, value)
Transfers TNK.
Params:
Returns: Promise<{ txHash: string, success: boolean }>
Example response:
tracnetwork.buildTracTx({ to, amount })
Builds a Trac Network transfer transaction payload (unsigned).
Params:
{ to: string, amount: string | number }
Returns: Promise<object> tx data
Example response shape (fields may vary by wallet version):
tracnetwork.signTracTx(txData)
Signs a Trac Network transfer transaction payload (from buildTracTx).
Params:
txData: object (output of buildTracTx)
Returns: Promise<string> signed payload (described as “payload jwt” in the PDF)
tracnetwork.pushTracTx(payload)
Pushes a signed Trac Network transfer transaction (from signTracTx).
Params:
Returns: Promise<{ txHash: string, success: boolean }>
Example response: