Core Solana data model
The core data model gives the SDK one shared language for Solana identities, account state, binary values, program identifiers, and JSON-RPC data. Higher-level APIs use these types to move data between on-chain bytes, RPC responses, program instructions, and signed transactions without changing the meaning of keys or account roles.
System role
The core layer connects three forms of data: fixed Solana values such as public keys and signatures, account state held by the chain, and wire data returned by RPC. It also provides shared program identifiers and the registry that connects a program address to the decoder that can explain that program's instruction data.
The main relationships are:
flowchart LR
RPC[RPC or WebSocket data] --> JSON[Shared JSON rules]
JSON --> Account[Account state]
JSON --> Data[Encoded account or return data]
Data --> Bytes[Decoded bytes]
Bytes --> Program[Program-specific state or instruction]
Key[Public keys] --> Account
Key --> Roles[Account roles]
Roles --> Program
IDs[Program identifiers] --> Program
Program --> Registry[Program decoder registry]
Public-key parsing and address encoding have a focused guide in Core keys and encoding. Instruction account layout and message construction are covered in Core instruction and message.
Identity values
Public keys
home/…/keys.go defines PublicKey as the SDK's fixed 32-byte identity value. The type is used for wallets, programs, accounts, lookup tables, and other Solana addresses. Its text and JSON forms use base58, while its byte form is used when a message or account codec needs the raw address.
The type accepts both on-curve and off-curve addresses. This matters because program-derived addresses are valid public keys even though they are not signing keys. The same value can therefore identify a signer, a program, or an address derived from program seeds. The core layer also derives seeded and program-derived addresses, then returns the bump value when a program-derived address needs one.
References: keys.go• L166-241 keys.go• L282-328 keys.go• L632-729
Program identifiers
home/…/program_ids.go provides the shared public keys for Solana's built-in programs and common token, memo, metadata, and lookup-table programs. These constants give account models, instruction builders, address derivation, and decoder lookup one stable value for each program across the SDK.
Program identifiers are data values rather than program behavior. A higher-level API uses the relevant identifier to select an owner, target a program, derive a related address, or find a registered decoder.
References: program_ids.go• L17-48 program_ids.go• L50-88 keys.go• L586-613
Signatures and hashes
Signature represents a 64-byte signed result. Hash shares the public-key-sized byte shape but names a value used as a digest or block reference. Both types provide base58 text and JSON forms so RPC data and local values use the same visible representation.
A private key stays separate from these public values. It can derive a public key and create a signature, while signature verification only needs the public key, message, and signature. This separation lets transaction and RPC layers handle identities without exposing private-key material.
References: nativetypes.go• L34-105 nativetypes.go• L108-194 keys.go• L37-151
Account state
On-chain account state
home/…/account.go defines Account as the plain state stored for a Solana account. It combines the account's lamports, program-owned data bytes, owner, executable status, and rent epoch. This form is used when code needs the binary account state itself, such as decoding program fixtures or mirroring validator-side data.
The root Account and rpc.Account describe the same Solana concept at different boundaries. The root type is a binary-state model. The RPC type is a response model that also carries the requested data encoding and RPC-only fields such as storage space. Their JSON shapes are not interchangeable.
References: account.go• L193-233 account.go• L301-329 rpc/types.go• L330-377
Account roles
AccountMeta describes how an instruction uses an account rather than describing the account's stored state. Each entry identifies a public key and marks whether the account must sign and whether the instruction may write it. Higher-level instruction builders collect these roles before transaction message construction.
The account list is ordered. Its order and role flags become part of the instruction and message meaning, so a public key alone is not enough to describe an instruction account.
References: account.go• L57-94 account.go• L107-155 account.go• L137-154
Encoded data boundaries
Account data encodings
Data is the common value for bytes that cross an RPC boundary. It pairs content with an EncodingType, allowing the SDK to decode base58, base64, or base64 plus zstd data back into bytes. JSON-parsed data is a separate object form used when an RPC node has a program parser for the data.
rpc.DataBytesOrJSON keeps these two wire forms together until the caller asks for the needed view. GetBinary returns decoded bytes for binary encodings. GetRawJSON returns the original JSON object for parsed data. This boundary lets callers pass binary account data to a program decoder or pass parsed transaction data to the model layer.
References: nativetypes.go• L196-255 nativetypes.go• L259-330 nativetypes.go• L372-396 rpc/types.go• L379-457
JSON foundation
home/…/json.go provides the package-wide JSON entry point used by core types and RPC models. Custom values such as public keys, signatures, hashes, encoded bytes, and account data use this shared path so their JSON behavior stays aligned across HTTP and WebSocket responses.
The JSON layer preserves the distinction between a string value, an encoded byte value, and a structured parsed value. A caller should select the matching accessor instead of treating all RPC data fields as one JSON shape.
References: json.go• L15-38 keys.go• L221-241 nativetypes.go• L168-237 rpc/types.go• L404-457
Native values and time
Time and duration values
The SDK uses named native types when a number has a protocol meaning that plain integers do not show. UnixTimeSeconds and UnixTimeMilliseconds convert RPC timestamps to time.Time, while DurationSeconds and DurationMilliseconds convert measured intervals to time.Duration.
These types keep unit conversion at the data boundary. Higher-level code can then work with Go time values without guessing whether an integer means seconds or milliseconds.
References: types.go• L24-64 rpc/types.go• L80-94 rpc/types.go• L307-327
Encoded byte values
Base58 and Base64 name byte slices whose JSON form is an encoded string. They are used where Solana APIs carry raw bytes inside JSON, such as instruction data, account data, and transaction payloads. Data adds the encoding label and supports the compressed base64 variant used for larger account data.
These types keep transport encoding separate from the bytes that program code must decode. Once the boundary is crossed, program-specific code can work with bytes and choose its own binary format.
References: nativetypes.go• L196-242 nativetypes.go• L244-255 rpc/types.go• L286-300
Instruction decoder registry
Program decoder lookup
The instruction decoder registry maps a program PublicKey to a function that turns that program's account list and instruction bytes into a higher-level value. It is the shared discovery point used when a caller knows the program address but does not want to select a program package by hand.
Program packages register their decoder when they are imported. A decoder receives the accounts for one instruction, not the full message account list. The caller must resolve indexed message accounts before lookup so the decoder sees the account roles that belong to that instruction.
Registration is safe to repeat for the same function. A different decoder for an existing program is rejected because silent replacement could make the same instruction bytes produce different meanings.
References: registry.go• L27-45 registry.go• L64-117 README.md• L311-381
Message and transaction model
Message versions and account resolution
Message is the shared description of a transaction's recent block reference, ordered account keys, account-role header, and compiled instructions. Legacy and v0 messages use the established account and lookup forms. V1 adds inline transaction configuration and does not support address-table lookups.
V0 messages can keep some account keys in address tables. The message stores table identifiers and indexes until the caller supplies the table contents or the loaded writable and read-only accounts. Resolution then exposes one ordered account view for account-role queries and instruction decoding.
The message supports three matching JSON and binary forms:
- Legacy messages have no version marker and no lookup or inline-config fields.
- V0 messages use address-table lookup descriptors and a version marker.
- V1 messages use the inline
TransactionConfigfields and a version marker. Their config selects priority fee, compute units, loaded account data size, or heap size values.
This diagram shows how a message turns static keys and optional lookup data into the account view used by instructions.
flowchart LR
Static[Static account keys] --> Message[Message]
Lookups[V0 lookup descriptors] --> Resolve[Lookup resolution]
Tables[Address table contents or loaded accounts] --> Resolve
Resolve --> All[Ordered account view]
Static --> All
Header[Signer and writable header] --> All
All --> Compiled[Compiled instruction account indices]
Config[V1 inline transaction config] --> Message
References: message.go• L98-151 message.go• L161-312 message.go• L546-657 message.go• L823-879 message_v1.go• L46-83 message_v1.go• L217-420
Transaction assembly and signatures
Transaction combines a message with signatures that correspond by position to the message's required signer keys. NewTransaction turns high-level instructions into this form by choosing the fee payer, merging repeated account keys, preserving the strongest account role, adding program IDs, and replacing account objects with message indexes.
The resulting order is a contract. The fee payer is first, required signers occupy the leading key range, and writable and read-only groups determine the message header. Signing uses the encoded message bytes, while verification uses the matching public key and signature position.
Version choice changes the transaction boundary. V0 can move eligible non-signer accounts into address-table lookups. V1 carries its compute budget in the message and rejects lookup tables and Compute Budget instructions.
References: transaction.go• L34-44 transaction.go• L137-183 transaction.go• L289-315 transaction.go• L363-611 transaction.go• L616-725 transaction.go• L877-901
Message and transaction validation
Sanitize checks that a message or transaction is structurally safe before it is treated as valid. It checks header ranges, account and program indexes, signer counts, lookup structure, and version-specific rules. Transaction validation also requires the signature count to match the message header.
V1 has two kinds of limits. Wire limits come from one-byte address and instruction counts and cannot be raised. Policy limits describe the active cluster rules and can be supplied through V1Limits; Sanitize uses the default policy, while SanitizeWithV1Limits lets a caller match a cluster feature gate. A raised policy does not remove checks for duplicate addresses, heap size, indexes, or unsupported lookups.
NewTransaction applies the selected V1 limits early when it builds a V1 transaction. The limits are not stored in the transaction, so later validation must use the same custom limits when the target cluster uses a non-default policy.
References: sanitize.go• L21-90 sanitize.go• L127-219 sanitize.go• L237-268 message_v1.go• L46-70 message_v1.go• L217-285 transaction.go• L200-223 transaction.go• L593-607
Higher-level API boundaries
The shared model is the contract between RPC clients, program clients, and transaction code. RPC models provide context and wire shape. Core values normalize keys and bytes. Program code interprets decoded state or instruction data. Message and transaction code uses public keys, account roles, compiled indexes, and signatures to represent an executable transaction.
When a transaction or instruction flow needs more than these shared values, follow the child pages for the next layer: Core keys and encoding explains address text and derived-address rules, and Core instruction and message explains how account roles become compiled instructions and messages.
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to
PublicKey,Signature, orHashtext and JSON forms affect RPC models, transaction messages, registry keys, and stored JSON data at the same time. - Changes to shared program identifiers affect instruction targets, account ownership checks, derived addresses, and program decoder lookup.
- Changes to the account fields or binary codec require review of program state decoders and any data that mirrors Solana's account binary layout.
- Changes to
EncodingTypeorDataBytesOrJSONmust preserve the mapping between RPC encoding options, decoded bytes, and JSON-parsed objects. - Changes to
AccountMetarole handling must be checked against message account ordering and every program instruction builder that supplies account metas. - Changes to decoder registration rules must be checked against program packages that register in
initand callers that rely on central instruction lookup. - Changes to message version fields or JSON markers must preserve legacy, v0, and v1 detection across RPC JSON and binary transaction decoding.
- Changes to address-table resolution must preserve the order and writable/read-only split consumed by compiled instruction indexes.
- Changes to V1 policy limits must be checked against both transaction construction and later sanitization with the target cluster's limits.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A public-key byte slice is not exactly 32 bytes | Construction from bytes panics, or base58 parsing returns an error | Validate external input before calling the fixed-size byte constructor; use the error-returning base58 parser for untrusted text |
| Seed count or seed length exceeds Solana's address rules, or all bump values produce on-curve results | Seeded address creation returns an error and no usable derived address | Keep seed inputs within the protocol limits and handle derivation errors before building account or instruction data |
| RPC account data is JSON-parsed but the caller requests binary bytes | GetBinary has no decoded content for that response | Request a binary encoding or read the parsed object with GetRawJSON |
| A decoder is not registered for the instruction's program ID | Central lookup returns ErrInstructionDecoderNotFound | Import the program package or register a decoder for the program |
| Two different decoders claim the same program ID | Registration fails, or MustRegisterInstructionDecoder panics during package setup | Keep one authoritative decoder per program ID |
| The binary account model is used as if it were the RPC account model | JSON fields or data envelopes do not match the expected RPC shape | Use Account for binary state and rpc.Account for RPC responses |
| A v0 message with lookups is queried before its tables or loaded accounts are supplied | Account-role and instruction-account queries return ErrAddressTablesNotSet | Fetch the table contents or call ResolveLookupsWith with the exact writable and read-only account lists |
| A V1 message contains lookup tables or exceeds its wire or active policy limit | Construction, sanitization, or encoding rejects the message | Use V1 inline config without lookup tables and validate with the cluster-matching V1Limits |
| A transaction has a signature count different from the message's required signer count | Sanitization or signature verification rejects the transaction | Keep one signature slot for each required signer and verify after signing |
TransactionFromBytes receives trailing bytes after a V1 transaction | The whole-slice decode rejects the input, even though streaming decode is lenient | Remove trailing data for whole-slice inputs or use TransactionFromDecoder for a stream |
Key files
| File | Why to read it |
|---|---|
| keys.go | Defines public and private key values and the shared address behavior used across the SDK. |
| program_ids.go | Defines the shared program addresses used as owners, instruction targets, and registry keys. |
| account.go | Defines on-chain account state and the account roles passed into instructions. |
| nativetypes.go | Defines signatures, hashes, encoded byte values, and account data encoding rules. |
| rpc/types.go | Shows how RPC account, transaction, and parsed-data responses use the core model. |
| json.go | Defines the common JSON boundary for core and RPC values. |
| registry.go | Defines program-ID-based instruction decoder discovery and registration rules. |
| types.go | Defines named time and duration values used by RPC-facing models. |
| message.go | Defines the shared message shape, version selection, lookup resolution, and account-role queries. |
| message_v1.go | Defines the V1 message config, wire shape, and encoding limits. |
| transaction.go | Defines transaction assembly, signature placement, serialization, and verification. |
| sanitize.go | Defines structural validation for messages and transactions, including V1 policy limits. |