Skip to content

TypeScript SDK Carbon API And Wire Format

Most core Carbon value types and builders are exported from phantasma-sdk-ts/public. The full Carbon helper surface is exported from phantasma-sdk-ts/types, including the wire serializers, the fee plan types and helper functions such as getRandomPhantasmaId.

Core Serialization

APIPurpose
CarbonBlob, CarbonBlobLikeInterface and base behavior for Carbon-serializable values.
CarbonBinaryReader, CarbonBinaryWriterCarbon wire-format reader and writer.
readBlob, writeBlobGeneric blob read/write helpers.
Bytes16, Bytes32, Bytes64Fixed-width byte values with toHex() and equals(...).
SmallStringOne-byte-length UTF-8 string value.
IntXCarbon signed integer wrapper.

CarbonBinaryReader rejects negative Carbon array lengths and rejects fixed- width array lengths whose required bytes exceed the remaining input before it allocates result arrays.

Enums, Flags, And Message Types

APIPurpose
TxTypesCarbon transaction type enum.
ModuleIdCarbon module ids.
TokenContractMethodsToken module method ids.
CarbonTokenFlagsToken flags used in TokenInfo.
VmType, VmStructFlagsCarbon metadata schema types and struct flags.
TxMsg, SignedTxMsg, WitnessUnsigned/signed Carbon message and witness structures.
TxMsgCall, TxMsgCallMulti, TxMsgTransfer*, TxMsgMint*, TxMsgBurn*, TxMsgTrade, TxMsgPhantasma, TxMsgPhantasmaRawTyped Carbon payload structures.

Token, Series, Schema, And Metadata Builders

APIPurpose
TokenInfoBuilder, TokenInfoBuild create-token payload data.
SeriesInfoBuilder, SeriesInfoBuild NFT series payload data.
TokenMetadataBuilderBuild required token-level metadata.
TokenSchemasBuilder, TokenSchemas, TokenSchemasJsonStandard and custom schema construction.
TokenSeriesMetadataBuilderBuild series metadata bytes.
NftRomBuilderBuild direct NFT ROM bytes.
PhantasmaNftRomBuilderBuild public deterministic Phantasma NFT ROM bytes.
MetadataField, FieldType, VmDynamicVariable, VmDynamicStruct, VmStructSchemaMetadata field and schema structures.
standardMetadataFields, nftDefaultMetadataFields, seriesDefaultMetadataFields, findMetadataField, pushMetadataFieldMetadata utility helpers.

Standard display metadata fields are name, description, imageURL, infoURL, and royalties. Token-level metadata requires name, icon, url, and description.

Fee Planning

Builders carry no prices. A message is priced after it is built, from the message itself and the chain’s own gas configuration.

APIPurpose
PhantasmaAPI.feesThe FeePlanner of the chain this client talks to.
FeePlanner.plan(msg, options?)Prices one message and returns a FeePlan.
planFees(msg, config, options?)The same calculation against a GasConfig the caller holds. It touches no network.
FeePlan.apply(msg)Returns a copy of the message with maxGas and maxData set.
summarizeFeePlan(plan, decimals?)Renders gasBill, gasOffer and storageCeiling as decimal strings.
NativeFeeKindThe operation kinds the planner prices.
GasConfig, gasConfigFromRpc(result)The chain’s prices, and the conversion from the RPC response.
TxLimitsmaxGas, maxData and expiry, which a builder writes into the message.
DEFAULT_TX_EXPIRY_MS, expiryWithin(windowMs, marginMs?)The default expiry, and the longest one a chain window allows.
parseUnits(value, decimals), formatUnits(atoms, decimals)Conversion between decimal amounts and atoms.
burnedInstances(msg)The instances a burn message destroys.

Lifecycle Builders

BuilderPurpose
CreateTokenTxHelper.buildTxBuilds unsigned create-token TxMsg.
CreateTokenTxHelper.buildTxAndSign / buildTxAndSignHexSigned create-token bytes or hex.
CreateTokenSeriesTxHelper.buildTxBuilds unsigned create-series TxMsg.
CreateTokenSeriesTxHelper.buildTxAndSign / buildTxAndSignHexSigned create-series bytes or hex.
MintPhantasmaNonFungibleTxHelper.buildTxBuilds deterministic Phantasma NFT mint for one item or a token array.
MintPhantasmaNonFungibleTxHelper.buildTxAndSign / buildTxAndSignHexSigned deterministic mint bytes or hex.
NativeTxHelper.transferFungible / transferNonFungibleBuilds a native transfer, in the plain or the gas-payer form.
NativeTxHelper.mintFungible / burnFungible / burnNonFungibleBuilds a native fungible mint, or a burn.

buildTxAndSign and buildTxAndSignHex take a GasConfig and plan the message before signing it. buildTx leaves the message unplanned, which is what PhantasmaAPI.sendTransaction and a wallet-signing flow both expect.

The SDK carries no builder for a direct MintNonFungible. The chain refuses that operation where governance has not allowed caller-supplied ROM ids, and that is the state of the public chains today.

Result Parsers And Address Helpers

APIPurpose
CreateTokenTxHelper.parseResult(resultHex)Parses the Carbon token id as a bigint.
CreateTokenSeriesTxHelper.parseResult(resultHex)Parses Carbon series id.
MintPhantasmaNonFungibleTxHelper.parseResult(resultHex)Parses deterministic mint rows containing Phantasma NFT id and Carbon instance id.
TokenHelper.getNftAddress(carbonTokenId, instanceId)Derives Carbon NFT address bytes.

Parsers expect the transaction result hex from a finalized successful transaction. They do not poll or classify transaction state.