@mhbdev/ai-sdk-ton-tools
v0.2.0
Published
TON blockchain tools for Vercel AI SDK.
Maintainers
Readme
AI SDK TON Tools
TON blockchain tools for the Vercel AI SDK, powered by TonAPI + STON.fi SDKs.
Installation
pnpm add @mhbdev/ai-sdk-ton-toolsPrerequisites
- TonAPI key from https://tonconsole.com
Set your API key:
TONAPI_API_KEY=your_api_key_hereOptional STON.fi settings (required for STON.fi DEX tools):
TON_RPC_ENDPOINT=https://ton-rpc.example.com/jsonRPC
TON_RPC_API_KEY=your_ton_rpc_key
STONFI_OMNISTON_API_URL=wss://omni-ws.ston.fiUsage
import { generateText, stepCountIs } from "ai";
import { createTonTools } from "@mhbdev/ai-sdk-ton-tools";
const tonTools = createTonTools({
apiKey: process.env.TONAPI_API_KEY,
network: "mainnet",
});
const { text } = await generateText({
model: "openai/gpt-5.1-codex",
prompt: "Get the latest events for EQB5... and summarize them.",
tools: tonTools,
stopWhen: stepCountIs(3),
});
console.log(text);Tool List
Accounts
tonGetAccount,tonGetAccountsBulk,tonGetAccountPublicKeytonGetAccountEvents,tonGetAccountEvent,tonGetAccountTracestonGetAccountTransactions,tonGetAccountDifftonGetAccountJettons,tonGetAccountJettonBalancetonGetAccountJettonsHistory,tonGetAccountJettonHistorytonGetAccountNfts,tonGetAccountNftHistorytonGetAccountDomains,tonGetAccountDnsExpiringtonGetAccountSubscriptions,tonGetAccountMultisigstonGetAccountExtraCurrencyHistory,tonSearchAccountstonReindexAccount
Jettons
tonGetJettons,tonGetJettonInfo,tonGetJettonInfosBulktonGetJettonHolders,tonGetJettonsEvent,tonGetJettonTransferPayload
NFTs
tonGetNftCollections,tonGetNftCollection,tonGetNftCollectionItemstonGetNftItemsBulk,tonGetNftCollectionItemsBulk,tonGetNftItemtonGetNftHistoryById
Inscriptions (Experimental)
tonGetAccountInscriptions,tonGetAccountInscriptionsHistorytonGetAccountInscriptionsHistoryByTicker,tonGetInscriptionOpTemplate
DNS
tonResolveDns,tonGetDnsInfo,tonGetDnsBids,tonGetDnsAuctions
Rates
tonGetRates,tonGetChartRates,tonGetMarketsRates
Wallet & TonConnect
tonGetTonConnectPayload,tonGetAccountInfoByStateInittonGetAccountSeqno,tonGetWalletsByPublicKey,tonTonConnectProof
Staking
tonGetStakingPools,tonGetStakingPoolInfo,tonGetStakingPoolHistorytonGetAccountNominatorPools
Storage
tonGetStorageProviders
Traces & Events
tonGetTrace,tonGetEvent
Emulation & Decoding (Local + TonAPI)
tonDecodeMessageBoc,tonDecodeTransactionBoctonDecodeStateInitBoc,tonComputeAddressFromStateInittonDecodeMessageApi,tonEmulateMessageToEventtonEmulateMessageToTrace,tonEmulateMessageToWallettonEmulateMessageToAccountEvent
Blockchain
tonGetReducedBlockchainBlockstonGetMasterchainHead,tonGetMasterchainShards,tonGetMasterchainBlockstonGetMasterchainTransactions,tonGetBlock,tonGetBlockTransactionstonGetTransaction,tonGetTransactionByMessageHashtonGetValidators,tonGetBlockchainStatustonGetBlockchainConfig,tonGetBlockchainConfigFromBlocktonGetRawBlockchainConfig,tonGetRawBlockchainConfigFromBlocktonGetBlockchainRawAccount,tonInspectBlockchainAccount,tonExecGetMethod
Extra Currency
tonGetExtraCurrencyInfo
Multisig
tonGetMultisigAccountInfo
Utilities
tonAddressParse,tonAddressParseApitonGetTonApiStatus,tonGetTonApiOpenapiJson
Write, Signing & Wallet Generation
tonBuildCellBoc,tonSliceRunOperations,tonParseCellTreetonGenerateWalletMnemonic,tonMnemonicToWalletKeystonSignData,tonVerifySignedDatatonSafeSignCellBoc,tonSafeVerifyCellBocSignaturetonBuildExternalMessageBoc,tonSendBlockchainMessagetonSendBlockchainMessageBatch,tonBuildAndSendExternalMessage
STON.fi DEX (v2_2, unsigned/read capability tools)
tonStonfiDexGetRouterDatatonStonfiDexResolveAddressestonStonfiDexGetPoolDatatonStonfiDexGetLpAccountDatatonStonfiDexGetVaultDatatonStonfiDexBuildRouterBodytonStonfiDexBuildRouterTxtonStonfiDexBuildPoolBodytonStonfiDexBuildPoolTxtonStonfiDexBuildLpAccountBodytonStonfiDexBuildLpAccountTxtonStonfiDexBuildVaultBodytonStonfiDexBuildVaultTxtonStonfiDexBuildPtonBodytonStonfiDexBuildPtonTx
STON.fi Omniston (bounded snapshots + unsigned builders)
tonStonfiOmnistonRequestQuotestonStonfiOmnistonBuildTransfertonStonfiOmnistonBuildWithdrawaltonStonfiOmnistonTrackTradetonStonfiOmnistonEscrowList
Options
type TonToolsOptions = {
apiKey?: string;
baseUrl?: string;
network?: "mainnet" | "testnet";
stonfiRpcEndpoint?: string;
stonfiRpcApiKey?: string;
stonfiOmnistonApiUrl?: string;
};apiKeydefaults toprocess.env.TONAPI_API_KEYnetworkcontrols the default base URL (mainnetortestnet)baseUrloverridesnetworkif providedstonfiRpcEndpointdefaults toprocess.env.TON_RPC_ENDPOINTand is required by STON.fi DEX toolsstonfiRpcApiKeydefaults toprocess.env.TON_RPC_API_KEYstonfiOmnistonApiUrldefaults toprocess.env.STONFI_OMNISTON_API_URLand falls back towss://omni-ws.ston.fi
STON.fi Write Behavior
STON.fi tools intentionally expose read operations plus unsigned body/transaction preparation only.
send* contract methods are not exposed; signing/sending stays under your app or wallet flow.
License
MIT
