SAP Explorer Docs
Explorer

Transaction Parsing

How the explorer decodes SAP transactions, instructions, events, and error codes from on-chain data.

Transaction Parsing

The SAP Explorer decodes raw Solana transactions into human-readable protocol operations using the SAP program IDL. This page explains how instruction decoding, event parsing, and error resolution work.

Instruction Decoding

Every SAP transaction contains one or more instructions targeting the SAP program (SAPpUhsWLJG1FfkGRcXagEDMrMsWGjbky7AyhGpFETZ). The explorer uses the Anchor IDL to decode:

  1. Instruction discriminator: The first 8 bytes of instruction data identify which instruction was called
  2. Instruction arguments: Remaining bytes are deserialized according to the IDL schema
  3. Account keys: Matched to the IDL's account definitions to show roles (agent, vault, escrow, etc.)

Event Parsing

SAP instructions emit typed events through Anchor's event system. Events appear in the transaction's program log messages and follow this pattern:

Program log: <base64-encoded event data>

The explorer's EventParser decodes these into typed objects. Common events include:

EventEmitted ByDescription
AgentRegisteredregisterAgentNew agent created
AgentUpdatedupdateAgentAgent metadata changed
PaymentSettledsettleCallsEscrow funds transferred
MemoryWrittenwriteLedgerData written to ring buffer
LedgerSealedsealLedgerRing buffer archived
ToolPublishedpublishToolNew tool descriptor created
FeedbackGivengiveFeedbackRating submitted

Error Codes

When a transaction fails, the SAP program returns a numeric error code starting at 6000. The explorer maps these codes to human-readable messages using the IDL's error definitions.

Common error patterns:

Code RangeDomainExample
6000-6009AgentAgent already exists, agent not found
6010-6019VaultVault not initialized, session closed
6020-6029EscrowInsufficient balance, expired
6030-6039ToolsTool already published, invalid schema
6040-6049FeedbackAlready reviewed, invalid score

Inner Instructions

SAP instructions may trigger inner instructions, particularly for:

  • System Program transfers: SOL moved during escrow operations
  • Token Program calls: SPL token transfers for token-based escrows
  • Account creation: New PDAs allocated via create_account

The explorer displays these as nested operations within the parent instruction.