For the complete documentation index, see llms.txt. This page is also available as Markdown.

TypeScript SDK

The MegaTAO TypeScript SDK (@megatao/sdk) provides direct on-chain reads and writes via viem. It is the same SDK used by the MegaTAO frontend.

The TypeScript SDK reads directly from the contract over RPC — no REST API required. For a REST-based approach, use the Python SDK or call the REST API directly.

Installation

npm install @megatao/sdk

Setup

import { MegaTAOClient } from '@megatao/sdk';

const sdk = new MegaTAOClient('prod', {
  rpcUrl: 'https://your-bittensor-rpc-url',
  privateKey: '0xYourPrivateKey',
});

const alpha = sdk.getAlpha();

MegaTAOClient is the top-level client. All trading reads and writes are accessed via sdk.getAlpha(), which returns the AlphaViem contract client.


Writes

Collateral

Positions

Orders


Reads

The TypeScript SDK reads state directly from the contract, enabling lower-latency data not available through the REST API.

Account & positions

Market data

Vault


Leverage format

Leverage is passed in 1e18 format — multiply the multiplier by 10n**18n:


Market addresses

Market
Address
Subnet

CHUTES

0x0000000000000000000000000000000000000040

SN64

LIUM

0x0000000000000000000000000000000000000033

SN51

RIDGES

0x000000000000000000000000000000000000003e

SN62

TARGON

0x0000000000000000000000000000000000000004

SN4

MTSOS

0x000000000000000000000000000000000000FFFE

Index

See Contract Specifications for the full list and contract addresses.

Last updated