For the complete documentation index, see llms.txt. This page is also available as Markdown.

Portal Program Reference

The Portal is the on-chain program that mints sessions, manages delegation, and enforces TTL + fee constraints. It's the warden — every session lives or dies by Portal's rules.

Program ID (devnet): 74iiMCqFw1afWyp3tdh9pUqfRfCRq7gfdC2YZoNGpovt

Instruction set

Discriminator
Name
Purpose

0

OpenSession

Mint a new session at (owner, grid_id). Creates session PDA + fee_vault.

1

reserved

2

DepositFee

Add lamports to the fee_vault for a session.

3

Delegate

Bind an account to a session.

4

Undelegate

Release an account from a session (callable post-TTL by owner).

OpenSession (discriminator 0)

data: u8(0) | u64 grid_id | u64 ttl_slots | u64 fee_cap

accounts (writable, signer):
  [0] owner          (signer, writable) — pays rent for session + fee_vault
  [1] session_pda    (writable)         — sessionPda(portal, owner, grid_id)
  [2] fee_vault_pda  (writable)         — feeVaultPda(portal, owner)
  [3] system_program

Failure modes:

  • "account already in use" — fee_vault already exists from a prior session for the same owner. Portal does not currently support reusing the fee_vault; use a different owner or wait for CloseSession to release it.

  • "invalid grid_id" — grid_id <= 0 is rejected.

Delegate (discriminator 3)

Used both for PDAs (via the owning program's delegate_to_portal CPI) and for raw keypair-owned accounts (called directly).

For keypair accounts:

For PDAs delegated through their owning program (the delegate_to_portal hook), the program issues this CPI with the appropriate program-derived signer.

Undelegate (discriminator 4)

For PDA accounts the calling program issues the analogous CPI through its program-derived signer.

Account schemas

Session (sessionPda(portal, owner, grid_id))

Field
Type
Notes

discriminator

u8

Always 1

session_owner

Pubkey

Owner keypair that opened the session

grid_id

u64

ttl_slots

u64

fee_cap

u64

Lamports

created_at

u64

Slot when OpenSession landed

nonce

u64

Reserved

bump

u8

Total: 82 bytes.

DelegationRecord (delegationRecordPda(portal, account))

Field
Type
Notes

discriminator

u8

Always 4 for delegation records (5 for deposit receipts)

owner_program

Pubkey

The program that originally owned the account

grid_id

u64

bump

u8

Total: 42 bytes.

FeeVault (feeVaultPda(portal, owner))

Lamports-only account; no decoded fields beyond standard AccountInfo.

PDA derivations

See also

Last updated