API Overview
This page summarizes the main building blocks of the TypeScript SDK and how they fit together in current Carbon, VM, RPC, and wallet workflows.
For method-level details, use the complete reference:
Package
| Item | Value |
|---|---|
| Package | phantasma-sdk-ts |
| Current source version | 0.19.0 |
| Runtime | Node >=22; browser bundles depend on the wallet/link feature being used |
| Recommended import | phantasma-sdk-ts/public |
Core Building Blocks
PhantasmaAPI
RPC client for chain reads, fee planning, and transaction broadcast.
Use it for:
getAccountInfo,getBlockByHeight,getTransactionfeesfor the chain’s fee plannersendTransactionto plan, sign and broadcast a Carbon message in one callsendRawTransactionfor signed VM transactionssendCarbonTransactionfor a Carbon envelope that is already signedinvokeRawScriptfor read-only VM execution
getAccount and getAccounts are deprecated. Their response embeds every NFT
id the address owns, so it grows with the size of the account. Use
getAccountInfo with getAccountFungibleTokens and getAccountNFTs.
ScriptBuilder
Builds VM scripts for invokes and state-changing calls.
Common uses:
allowGas(...)spendGas(...)callContract(...)callInterop(...)
Transaction
Represents a VM transaction object.
Use it when you need to control transaction fields locally before signing, for example:
nexuschainscriptexpirationpayload- pre-mined proof of work
This is the object used with signPrebuiltTransaction(...).
PhantasmaKeys
Local key management and signing helpers.
Common entry points:
PhantasmaKeys.fromWIF(wif)PhantasmaKeys.generate().address
Wallet Layers
The TS SDK exposes four wallet integration layers.
PhantasmaLink5
Use this for new integrations. It is the current protocol generation: a JSON envelope with typed parameters, numeric error codes, capability negotiation and revocable sessions, over the injected, deeplink, loopback and relay transports.
Key capabilities:
PhantasmaLink5.injected(...),.webDeeplink(...),.loopback(...),.relay(...),.relayEcdh(...),.deeplink(...)connect(...),getAccounts(),getChains(),getWalletInfo()signTransaction(...),sendTransaction(...),signMessage(...),invokeScript(...)onEvent(...),disconnect(),forgetSession()
See Phantasma Link v5.
PhantasmaLink
Use this when you want direct wallet control.
Key capabilities:
login(...)signTx(...)signTxSignature(...)signPrebuiltTransaction(...)signCarbonTxAndBroadcast(...)getNexus(...)
EasyConnect
Use this when you want a smaller browser wrapper but still want access to the underlying link.
Key capabilities:
connect(...)signTransaction(...)signCarbonTransaction(...)signPrebuiltTransaction(...)deployContract(...)conn.linkfor lower-level escape hatches
phantasma-link-react
Use this in a React application. It wraps PhantasmaLink5 in a provider, a MobX store and a connect widget.
Key capabilities:
PhantasmaLinkProvider,usePhantasmaLink()PhantasmaLinkStorewithconnect(),disconnect(),setTransport(...),signMessage(...),sendTransaction(...),invokeScript(...)ConnectWidget,PairingModal- transports:
injected,deeplink,relay,loopback verifyV5Signature(...)
See:
Which Signing Path To Use
Wallet-built VM transaction
Use:
PhantasmaLink.signTx(...)- or
EasyConnect.signTransaction(...)
Prebuilt VM transaction
Use:
TransactionPhantasmaLink.signPrebuiltTransaction(...)- or
EasyConnect.signPrebuiltTransaction(...) - then
PhantasmaAPI.sendRawTransaction(...)
This is the correct pattern when your application needs exact control over the final transaction bytes.
Carbon-native transaction, local key
Use:
- Carbon helper builders to create a
TxMsg PhantasmaAPI.sendTransaction(msg, signers)
This plans the fee, runs the token-creation pre-flight, signs with every witness and broadcasts.
Carbon-native transaction, wallet key
Use:
- Carbon helper builders to create a
TxMsg PhantasmaAPI.fees.plan(msg)andplan.apply(msg)to set the fee ceilingsPhantasmaLink.signCarbonTxAndBroadcast(...)- or
EasyConnect.signCarbonTransaction(...)
Carbon Helpers
phantasma-sdk-ts/public exports the RPC client, the Carbon builders and the
fee planner. Use phantasma-sdk-ts/types only for the few helpers that are not
in /public, such as getRandomPhantasmaId.
Schema and payload builders:
TokenInfoBuilderTokenMetadataBuilderTokenSchemasBuilderSeriesInfoBuilderNftRomBuilderPhantasmaNftRomBuilder
Message builders:
NativeTxHelperfor transfers, fungible mints and burnsCreateTokenTxHelperCreateTokenSeriesTxHelperMintPhantasmaNonFungibleTxHelper
These helpers build TxMsg objects or other schema-aware payloads for Carbon
flows. They carry no prices. A message is planned after it is built, and the
plan sets maxGas and maxData.
Decoder And Event Helpers
Use these for result and event parsing:
DecodergetTokenEventData
Schema Conversion Helpers
RPC schema payloads come back as plain objects. Convert them into SDK schema types with:
vmStructSchemaFromRpcResult
This is useful when you fetch token schema information through RPC and want to build series or NFT ROM data locally.