Skip to content

C# Carbon And NFT Types

This page covers Carbon wire blobs, transaction helpers, token/NFT builders, and metadata structures.

Wire Blob Model

Carbon types implement ICarbonBlob:

public interface ICarbonBlob
{
	public void Write(BinaryWriter w);
	public void Read(BinaryReader r);
}

CarbonBlob provides the generic entry points:

APIBehavior
CarbonBlob.New<T>(BinaryReader r)Creates T, calls Read, and returns the populated value.
CarbonBlob.New<T>(Stream s, bool allowTrailingBytes = false)Reads from a stream and, unless allowed, rejects trailing bytes when the stream can seek.
CarbonBlob.New<T>(byte[] bytes, bool allowTrailingBytes = false, long offset = 0)Reads a blob from a byte array, optionally from an offset.
CarbonBlob.Serialize<T>(T carbonBlob)Writes the blob into a byte array.

Use allowTrailingBytes only for callers that intentionally parse a prefix of a larger payload.

ReadLengthFor(...) rejects non-positive element sizes, negative Carbon array lengths, and fixed-width array lengths whose required bytes exceed the remaining seekable stream content.

Fixed And Compact Types

TypeUse
Bytes16, Bytes32, Bytes64Fixed-size byte containers used by addresses, public keys, and signatures.
SmallStringCompact string value used in Carbon wire structures.
IntXInteger helper for Carbon wire integer values.
WitnessSignature witness with public key/address bytes and signature bytes.
GasConfigGas fields serialized into Carbon chain configuration and fee-related payloads.
ChainConfigChain-level configuration blob.

All of these are low-level wire types. Build transactions through helper classes when a helper exists; use the wire types directly when implementing new Carbon message types.

Transaction Message Envelopes

TypePurpose
TxMsgTop-level Carbon message wrapper used by helper builders and SendTransactionAsync.
SignedTxMsgA TxMsg plus one or more Witness entries.
TxMsgCall / TxMsgCall_MultiContract call messages.
TxMsgPhantasma / TxMsgPhantasma_RawPhantasma-specific message wrappers.
TxMsgMintFungible / TxMsgBurnFungible / gas-payer variantsFungible token mint and burn messages.
TxMsgMintNonFungible / TxMsgBurnNonFungible / gas-payer variantsNFT mint and burn messages.
TxMsgTransferFungible / gas-payer variantFungible transfer messages.
TxMsgTransferNonFungible_Single, TxMsgTransferNonFungible_Multi, and gas-payer variantsNFT transfer messages.
TxMsgTradeTrade message payload.
TxMsgSpecialResolutionSpecial-resolution message payload.

Message structs expose Write and Read. The chain validates addresses, token ids, fees, permissions, and contract state after the SDK serializes the message.

Transaction Helpers

HelperMain APIsUse it when
CreateTokenTxHelperBuildTx, BuildTxAndSign, BuildTxAndSignHex, ParseResultCreating a Carbon token and optionally signing/hex-encoding the transaction.
CreateTokenSeriesTxHelperBuildTx, BuildTxAndSign, BuildTxAndSignHex, ParseResultCreating a new series for an NFT token.
MintPhantasmaNonFungibleTxHelperBuildTx, BuildTxAndSign, BuildTxAndSignHex, ParseResultMinting Phantasma-style NFT instances and parsing mint results.
NativeTxHelperTransferFungible, TransferNonFungible, MintFungible, BurnFungible, BurnNonFungibleBuilding a native transfer, mint or burn, which needs no VM script.
TxMsgSignerSignWithKeys, SignAndSerializeWithKeys, SignWithAsync, SignAndSerializeWithAsyncProducing signed Carbon transaction bytes from a TxMsg.

Helper BuildTx methods return unsigned TxMsg values with a zero gas offer. BuildTxAndSign takes a GasConfig, plans the message, signs it and returns the bytes. BuildTxAndSignHex returns a hex string ready for SendCarbonTransactionAsync.

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.

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.

TypeUse
ChainFeePlannerPhantasmaAPI.Fees. It reads the gas configuration, caches it and prices messages.
FeePlanner.Plan(msg, config, options?)The same calculation against a GasConfig the caller holds.
FeePlanMaxGas, MaxData, ExpectedGasBill, Kinds, Exact, EnvelopeBytes, Apply(msg).
FeePlanOptionsThe chain-state facts a caller may state, plus WitnessCount.
FeePlanSummary.Summarize(plan)GasBill, GasOffer and StorageCeiling as decimal strings.
NativeFeeKindThe operation kinds the planner prices.
FeePlanner.BurnedInstances(msg)The NFT instances a message burns, in any shape.
TxLimitsMaxGas, MaxData and Expiry, plus DefaultExpiryMs and ExpiryWithin.
ITxSigner, KeyPairSignerAny witness that can sign, and the in-memory adapter.

Token Builders And Metadata

Builder or typeUse
TokenInfoBuilder.Build(...)Builds the TokenInfo blob for token creation.
SeriesInfoBuilder.Build(...)Builds SeriesInfo for NFT series creation.
TokenSchemasBuilder.PrepareStandardTokenSchemas(sharedMetadata)Creates standard token schema definitions.
TokenSchemasBuilder.ParseTokenSchemasJson, FromJson, Serialize, SerializeHex, BuildAndSerializeConverts schema JSON and schema blobs.
TokenMetadataBuilder.BuildAndSerialize(Dictionary<string, string> fields)Serializes token metadata fields.
TokenSeriesMetadataBuilder.BuildAndSerialize(...)Serializes series metadata.
MetadataHelper.FindMetadataField, GetOptionalBytesField, PushMetadataFieldReads or appends metadata fields in helper code.
IdHelper.GetRandomPhantasmaId()Produces a random Phantasma id value.

Token, series, schema, and metadata builders construct bytes for transaction arguments. They do not guarantee that the submitted token definition satisfies chain-side policy.

NFT ROM And Token Helpers

APIUse
NftRomBuilder.BuildAndSerialize(...)Builds serialized NFT ROM bytes from schema-shaped data.
PhantasmaNftRomBuilder.BuildPublicMintSchema(nftRomSchema)Builds the public mint schema used by Phantasma-style NFT minting.
PhantasmaNftRomBuilder.BuildAndSerialize(...)Builds serialized Phantasma NFT ROM bytes.
TokenHelper.GetNftAddress(tokenId, instanceId)Computes the NFT address bytes from token id and instance id.
TokenHelper.UnpackNftInstanceId(instanceId, out seriesId, out mintNumber)Extracts series id and mint number from an NFT instance id.

Call Arguments

StructUse
NftMintInfoPer-NFT mint metadata inside NFT mint calls.
MintNonFungibleArgsCarbon NFT mint call arguments.
CreateTokenSeriesArgsNFT series creation call arguments.
CreateMintedTokenSeriesArgsSeries creation with initial minted data.
PhantasmaNftMintInfoPer-NFT Phantasma mint data.
MintPhantasmaNonFungibleArgsPhantasma-style NFT mint call arguments.
PhantasmaNftMintResultParsed mint result entry.
MintFungibleArgs, TransferFungibleArgs, BurnFungibleArgsFungible token operation arguments.
TransferNonFungibleArgs, BurnNonFungibleArgsNFT transfer and burn arguments.
UpdateTokenMetadataArgs, UpdateSeriesMetadataArgsMetadata update arguments.

Market call argument structs are available for listing, cancel, buy, and query operations. See Public API Inventory for the complete symbol list.