Skip to main content
All types are exported from @x84-ai/sdk and match the on-chain Anchor IDL exactly.
import {
  ServiceType,
  PaymentScheme,
  SettlementMode,
  DelegationPermissions,
  DelegationConstraints,
  X84Program,
} from "@x84-ai/sdk";

Enums

ServiceType

Identifies the kind of service an agent exposes. Used as a PDA seed for service and payment requirement accounts.
ServiceType.MCP   // "mcp" — Model Context Protocol
ServiceType.A2A   // "a2a" — Agent-to-Agent
ServiceType.API   // "api" — REST API
ServiceType.Web   // "web" — Web interface

PaymentScheme

Controls how payment amounts are validated during settlement.
VariantDescription
PaymentScheme.ExactPayment must match the required amount exactly
PaymentScheme.UpToPayment can be any amount up to the required maximum

SettlementMode

Determines how payment is verified and executed.
VariantDescriptionRequires
SettlementMode.AtomicOn-chain token transfer via CPIPayer signs the transaction
SettlementMode.AttestationOff-chain payment, facilitator attests on-chainFacilitator signer
SettlementMode.DelegatedSettlement via a delegation account with spending limitsDelegation PDA + facilitator

Interfaces

DelegationPermissions

Seven boolean flags controlling what a delegate can do on behalf of an agent.
interface DelegationPermissions {
  canTransact: boolean;
  canGiveFeedback: boolean;
  canUpdateMetadata: boolean;
  canUpdatePricing: boolean;
  canRegisterServices: boolean;
  canManage: boolean;
  canRedelegate: boolean;
}
FieldPermission granted
canTransactSettle payments on behalf of the agent
canGiveFeedbackSubmit feedback entries for the agent
canUpdateMetadataUpdate agent metadata URI and hash
canUpdatePricingModify payment requirements
canRegisterServicesAdd, update, or remove service endpoints
canManageDeactivate or reactivate the agent
canRedelegateCreate sub-delegations (max depth 2)

DelegationConstraints

Spending and usage limits for a delegation.
interface DelegationConstraints {
  maxSpendPerTx: BN;        // 0 = unlimited
  maxSpendTotal: BN;        // 0 = unlimited
  allowedTokens: PublicKey[]; // empty = all, max 5
  allowedPrograms: PublicKey[]; // empty = all, max 5
  expiresAt: BN;            // unix seconds, 0 = no expiry
  usesRemaining: BN;        // 0 = unlimited
}
FieldDescription
maxSpendPerTxMaximum token amount per transaction. 0 means unlimited.
maxSpendTotalLifetime spending cap. 0 means unlimited.
allowedTokensWhitelist of token mints. Empty array allows all tokens. Maximum 5.
allowedProgramsWhitelist of program IDs. Empty array allows all programs. Maximum 5.
expiresAtUnix timestamp after which the delegation is invalid. 0 means no expiry.
usesRemainingNumber of uses before the delegation is exhausted. 0 means unlimited.

On-chain account structures

ProtocolConfig

Singleton account holding global protocol parameters. Derived from the "config" seed.
FieldTypeDescription
authorityPubkeyAdmin/upgrade authority
collectionPubkeyMetaplex Core collection
registrationFeeu64Fee in lamports (default 0.05 SOL)
settlementFeeBpsu16Basis points (default 300 = 3%)
feeTreasuryPubkeyFee recipient
facilitatorPubkeyAttestation-mode signer
pause_*boolPer-module pause flags

AgentIdentity

One account per agent, derived from ["agent", nftMint].
FieldTypeDescription
nftMintPubkeyAgent ID = NFT mint pubkey
ownerPubkeyCurrent owner (follows NFT)
ownerVersionu64Incremented on transfer, invalidates delegations
activeboolAgent active status
metadataUriStringOff-chain metadata pointer
metadataHash[u8; 32]SHA-256 of metadata
feedbackAuthorityPubkeySeparate key for feedback authorization
delegationCountu64Counter for delegation ID derivation
feedbackScoreu8Aggregated score 0-100
feedbackCountu64Total feedback entries

AgentService

One account per agent per service type, derived from ["service", nftMint, serviceTypeSeed].
FieldTypeDescription
nftMintPubkeyAgent this service belongs to
serviceTypeServiceTypeMCP, A2A, API, or Web
endpointStringService URL
versionStringSemantic version

FeedbackEntry

One account per feedback submission, derived from ["feedback", nftMint, reviewer, nonce].
FieldTypeDescription
nftMintPubkeyAgent being reviewed
reviewerPubkeyFeedback submitter
scoreu8Score 0-100
tag1[u8; 32]Category tag hash
tag2[u8; 32]Category tag hash
detailUriStringOff-chain feedback detail
detailHash[u8; 32]SHA-256 of detail
hasPaymentProofboolWhether feedback has payment proof
paymentAmountu64Amount paid (for weighting)
paymentTokenPubkeyToken used for payment

ValidationRequest

Derived from ["val_request", nftMint, validator, hash[0..8]].
FieldTypeDescription
nftMintPubkeyAgent to validate
validatorPubkeyRequested validator
requestHash[u8; 32]Hash of request details
tag[u8; 32]Validation category
requestUriStringOff-chain request details

ValidationResponse

Derived from ["val_response", nftMint, validator, hash[0..8]].
FieldTypeDescription
nftMintPubkeyAgent validated
validatorPubkeyValidator who responded
requestHash[u8; 32]Matching request hash
scoreu8Validation score 0-100
tag[u8; 32]Validation category
evidenceUriStringOff-chain evidence
evidenceHash[u8; 32]SHA-256 of evidence

Delegation

Derived from ["delegation", delegator, delegate, id].
FieldTypeDescription
delegationIdu64Unique ID
delegatorPubkeyWho created the delegation
delegatePubkeyWho receives the permission
nftMintPubkeyAgent context
ownerVersionu64Checked on use (invalidated on NFT transfer)
can_*bool7 permission flags (see DelegationPermissions)
maxSpendPerTxu64Per-tx limit (0 = unlimited)
maxSpendTotalu64Total limit (0 = unlimited)
spentTotalu64Running total
depthu80 = direct, max 2 for sub-delegations

PaymentRequirement

Derived from ["payment_req", nftMint, serviceTypeSeed].
FieldTypeDescription
nftMintPubkeyAgent this requirement belongs to
serviceTypeServiceTypeService this payment gates
schemePaymentSchemeExact or UpTo
amountu64Required payment amount
tokenMintPubkeyAccepted token
payToPubkeyPayment recipient
descriptionStringHuman-readable description
resourceStringResource path (e.g., /v1/chat)
activeboolWhether the requirement is enforced

Events

The program emits 17 event types. Parse them from transaction logs or full transaction data.

Event parsing

import {
  parseEventsFromLogs,
  parseEventsFromTx,
  findEvent,
  type X84Event,
  type PaymentSettledEvent,
  type AgentRegisteredEvent,
} from "@x84-ai/sdk";

// Parse from transaction signature
const events = await parseEventsFromTx(program, connection, txSignature);
const settled = findEvent(events, "paymentSettled") as PaymentSettledEvent;
FunctionInputDescription
parseEventsFromLogsLog stringsParse events from raw log output
parseEventsFromTxTransaction signatureFetch transaction and parse all events
findEventEvent array + event nameFind the first event of a given type

Event types

EventKey fields
agentRegisterednftMint, owner, metadataUri, feedbackAuthority
metadataUpdatednftMint, oldHash, newHash, newUri, viaDelegation
agentDeactivatednftMint
agentReactivatednftMint
agentClaimednftMint, oldOwner, newOwner, newOwnerVersion
feedbackAuthorityUpdatednftMint, oldAuthority, newAuthority
serviceAddednftMint, serviceType, endpoint
serviceUpdatednftMint, serviceType, newEndpoint
serviceRemovednftMint, serviceType
feedbackGivennftMint, reviewer, score, tag1, tag2
feedbackRevokednftMint, reviewer
validationRequestednftMint, validator, requestHash
validationRespondednftMint, validator, score
delegationCreatednftMint, delegator, delegate, delegationId, depth
delegationRevokednftMint, delegator, delegate, delegationId
paymentRequirementSetnftMint, serviceType, scheme, amount
paymentSettledpaymentId, nftMint, payer, payee, amount, feeAmount