> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sudont.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# RPC Methods

> JSON-RPC method reference for the Sudont sidecar.

Sudont exposes standard JSON-RPC methods plus a small set of diagnostic methods.
Blocked send-path calls return standard JSON-RPC errors with structured Sudont
data under `error.data.sudont`.

<Note>
  Each method below cross-references its Rust implementation in
  `rust/rpc/src/server.rs`. Use the function name as a stable anchor — line
  numbers may drift across revisions.
</Note>

## Solana Demo Methods

### `sendTransaction`

Guard-and-forward a serialized Solana transaction.

**Implementation:** `RpcServerImpl::send_transaction` in `rust/rpc/src/server.rs`.

<CodeGroup>
  ```json Request theme={null}
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "sendTransaction",
    "params": [
      {
        "transaction": "<base64-or-base58-transaction>",
        "encoding": "base64"
      }
    ]
  }
  ```
</CodeGroup>

**Behavior:**

* Decodes the transaction.
* Extracts canonical Solana [intent](/concepts/intent-envelope).
* Simulates with LiteSVM and logs the local protocol surface used for replay.
* Evaluates the Constitution.
* `ALLOW`: records an approval attestation for the signed transaction artifact,
  then either returns a terminal-demo noop signature or broadcasts through
  configured Solana egress and returns the transaction id.
* [`INTERROGATE`](/concepts/verdicts) / [`DENY`](/concepts/verdicts): does not broadcast; returns a structured JSON-RPC error.

### `sudont_executeAgentIntent`

Same guarded send path as `sendTransaction`, with a human-readable agent note
included for logging and demo UX. The note is not trusted for policy approval.
The sidecar still derives canonical intent from the signed transaction bytes and
the simulated state diff.

**Implementation:** `RpcServerImpl::execute_agent_intent` in `rust/rpc/src/server.rs`.

<CodeGroup>
  ```json Request theme={null}
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "sudont_executeAgentIntent",
    "params": [
      {
        "transaction": "<base64-transaction>",
        "encoding": "base64",
        "intent": "Rebalance 0.1 SOL to Treasury Vault A"
      }
    ]
  }
  ```
</CodeGroup>

### `sudont_optimizeSwap`

Off-hot-path planning endpoint used by the terminal demo. The sidecar hydrates
approved route state, samples deterministic size/split candidates, applies the
same Constitution limits used by the hot-path [Judge](/concepts/verdicts), and returns a recommended
swap construction. This endpoint does not broadcast and does not approve the
trade by itself; the agent must still sign the recommended transaction and send
it back through `sendTransaction`.

The sidecar terminal logs route-hydration stats for this endpoint: approved
venues loaded, reserve accounts represented, sample count, policy tail bound,
and the fact that the final signed trade is independently rechecked on the hot
path.

**Implementation:** `RpcServerImpl::optimize_swap` in `rust/rpc/src/server.rs`.

<CodeGroup>
  ```json Request theme={null}
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "sudont_optimizeSwap",
    "params": [
      {
        "intent": "Optimize USDC to mock-SOL execution across approved AMM venues",
        "input_token": "USDC",
        "output_token": "mock-SOL",
        "max_input_usdc": 32,
        "samples": 64
      }
    ]
  }
  ```
</CodeGroup>

Abbreviated result shape:

```json theme={null}
{
  "planner": "terminal-route-split-monte-carlo",
  "samples": 64,
  "policy_max_price_impact_bps": 100,
  "routes": [
    {
      "route_id": "shallow",
      "label": "Shallow AMM: richer quote, fragile depth",
      "pool_usdc": 1000,
      "pool_sol": 10
    },
    {
      "route_id": "deep",
      "label": "Deep AMM: lower edge, stronger fill",
      "pool_usdc": 10400,
      "pool_sol": 100
    }
  ],
  "candidates": [],
  "recommendation": {
    "total_input_usdc": 24,
    "total_input_usdc_base_units": 24000000,
    "shallow_input_usdc": 12,
    "shallow_input_usdc_base_units": 12000000,
    "deep_input_usdc": 12,
    "deep_input_usdc_base_units": 12000000,
    "shallow_split_bps": 5000,
    "deep_split_bps": 5000,
    "expected_edge_bps": 182,
    "tail_impact_bps": 67,
    "rationale": "largest split with positive expected edge, positive downside edge, and policy-safe tail impact"
  }
}
```

### `sol_simulateTransaction`

Simulation-only method for the console log panel. It decodes and runs the
transaction in LiteSVM, but does not evaluate policy and never forwards.

**Implementation:** `RpcServerImpl::simulate_solana_transaction` in `rust/rpc/src/server.rs`.

<CodeGroup>
  ```json Request theme={null}
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "sol_simulateTransaction",
    "params": [
      {
        "transaction": "<base64-transaction>",
        "encoding": "base64"
      }
    ]
  }
  ```
</CodeGroup>

Response result is a `SimOutcome` with fields such as:

```json theme={null}
{
  "success": true,
  "reverted": false,
  "exit_reason": "Executed in LiteSVM (...)",
  "gas_used": 150,
  "raw_logs": ["Program 11111111111111111111111111111111 success"],
  "vm_state_diff": [],
  "state_confidence": "LOW",
  "freshness_source": "DEGRADED"
}
```

### `sudont_diagnoseRawTransaction`

No-broadcast diagnosis method for a base64 Solana transaction. It returns the
decoded intent, simulation outcome, and Judge verdict in the result envelope.

**Implementation:** `RpcServerImpl::diagnose_raw_transaction` in `rust/rpc/src/server.rs`.

<CodeGroup>
  ```json Request theme={null}
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "sudont_diagnoseRawTransaction",
    "params": ["<base64-transaction>"]
  }
  ```
</CodeGroup>

Result shape:

```json theme={null}
{
  "intent": {
    "vm_type": "svm",
    "sol_recipient": "...",
    "sol_program_ids": ["11111111111111111111111111111111"],
    "sol_transfer_lamports": 2500000000
  },
  "outcome": {
    "success": true,
    "raw_logs": []
  },
  "verdict": {
    "Interrogate": {
      "reason_code": "SUDONT_POLICY_DENY",
      "policy_hits": ["sol_max_transfer_lamports"]
    }
  }
}
```

## Health And Policy

### `sudont_getHealth`

Returns node, egress, Solana egress, policy posture, and request counters.

**Implementation:** `RpcServerImpl::get_health` in `rust/rpc/src/server.rs`.

### `sudont_getPolicySnapshot`

Returns the loaded policy snapshot.

**Implementation:** `RpcServerImpl::get_policy_snapshot` in `rust/rpc/src/server.rs`.

### `sudont_getPolicy`

Alias used by the demo console for `sudont_getPolicySnapshot`.

**Implementation:** `RpcServerImpl::get_policy` in `rust/rpc/src/server.rs`.

### `sudont_getCapabilities`

Returns supported methods, [freshness states](/concepts/state-freshness), send mode, and state source.

**Implementation:** `RpcServerImpl::get_capabilities` in `rust/rpc/src/server.rs`.

### `sudont_getAttackReport`

Best-effort local report endpoint for the browser Attack Mode. The sidecar looks
for a generated `attack-report.json` in common local paths, or at the explicit
`SUDONT_ATTACK_REPORT_PATH`, and returns the parsed report when available.

**Implementation:** `RpcServerImpl::get_attack_report` in `rust/rpc/src/server.rs`.

<CodeGroup>
  ```json Request theme={null}
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "sudont_getAttackReport",
    "params": []
  }
  ```
</CodeGroup>

Result shape:

```json theme={null}
{
  "generated_at": "2026-04-21T01:10:59.010525+00:00",
  "git_head": "d495f0f50fcb8fb0492c4072608a5544b337e482",
  "title": "Sudont Live-Fire Attack Mode",
  "summary": {
    "verdicts": "2 blocked / 0 forwarded",
    "execution": "Same signed transactions replayed through guarded sendTransaction",
    "environment": "Deterministic LiteSVM combat environment"
  },
  "scenarios": []
}
```
