Skip to content

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

ItemValue
Packagephantasma-sdk-ts
Current source version0.19.0
RuntimeNode >=22; browser bundles depend on the wallet/link feature being used
Recommended importphantasma-sdk-ts/public

Core Building Blocks

PhantasmaAPI

RPC client for chain reads, fee planning, and transaction broadcast.

Use it for:

  • getAccountInfo, getBlockByHeight, getTransaction
  • fees for the chain’s fee planner
  • sendTransaction to plan, sign and broadcast a Carbon message in one call
  • sendRawTransaction for signed VM transactions
  • sendCarbonTransaction for a Carbon envelope that is already signed
  • invokeRawScript for 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:

  • nexus
  • chain
  • script
  • expiration
  • payload
  • 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.link for 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()
  • PhantasmaLinkStore with connect(), 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:

  • Transaction
  • PhantasmaLink.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) and plan.apply(msg) to set the fee ceilings
  • PhantasmaLink.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:

  • TokenInfoBuilder
  • TokenMetadataBuilder
  • TokenSchemasBuilder
  • SeriesInfoBuilder
  • NftRomBuilder
  • PhantasmaNftRomBuilder

Message builders:

  • NativeTxHelper for transfers, fungible mints and burns
  • CreateTokenTxHelper
  • CreateTokenSeriesTxHelper
  • MintPhantasmaNonFungibleTxHelper

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:

  • Decoder
  • getTokenEventData

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.