> For the complete documentation index, see [llms.txt](https://docs.veda.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.veda.tech/api/transaction-builder/transaction-builder-examples.md).

# Examples

Runnable examples for the two things you'll do most against the Transaction Builder — discover routes, and build calldata for them.

Runnable examples for the [Transaction Builder](/api/transaction-builder.md). Each section shows the endpoint, a working `curl`, and what to do with the response.

## Prerequisites

* `curl` (required) and `jq` (optional — used to pretty-print responses).
* A Veda-issued API key exported as `VEDA_API_KEY`.
* The `{chain}`, `{vault_address}`, and `{strategist_address}` you're targeting.

Every `curl` below assumes these environment variables:

```bash
export VEDA_API_KEY=veda_user_live_...
BASE=https://api.veda.tech/v1
CHAIN=monad
VAULT=0x1C8a336051D2024E318A229d01F9F6CF96efD316
STRATEGIST=0xAdc33E147ddc92e03A2f9818DbeDEDbAe56829df
```

***

## `/actions` — list available routes

`GET /actions/{chain}/{vault}/{strategist}` returns the full manifest of routes the strategist is permitted to call on the vault. Each key is a **route** (e.g. `steakhouse/deposit`); each value describes the route's `params` and any constraints on them.

```bash
curl -sS \
  -H "Authorization: Bearer $VEDA_API_KEY" \
  "$BASE/tx-builder/api/actions/$CHAIN/$VAULT/$STRATEGIST"
```

**Response** (abridged — one route shown):

```json
{
  "steakhouse/deposit": {
    "name":            "Deposit",
    "protocol":        "SteakhouseMUSD",
    "has_constraints": false,
    "params": [
      { "name": "vault",  "type": "str",   "required": true, "choices": ["SteakhouseMUSD"] },
      { "name": "amount", "type": "float", "required": true }
    ]
  },
  "steakhouse/withdraw": { "…": "same shape" },
  "univ4/swap":          { "…": "…" }
}
```

Use the manifest to see which routes exist for your strategist, what parameters each takes, and whether any parameters are correlated (when `has_constraints` is `true`, call `/constraints/{route}` for the valid combinations).

***

## `/execute` — build a single action

`POST /execute/{chain}/{vault}/{strategist}/{route}` builds calldata for one route. The body carries the `params` for that route (matching the manifest returned by `/actions`) and an optional `simulate_transaction` flag.

```bash
curl -sS -X POST \
  -H "Authorization: Bearer $VEDA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "params": { "vault": "SteakhouseMUSD", "amount": 1.0 },
    "simulate_transaction": false
  }' \
  "$BASE/tx-builder/api/execute/$CHAIN/$VAULT/$STRATEGIST/steakhouse/deposit"
```

***

## Submitting the calldata onchain

The `/execute` response returns:

| Field                     | What it is                                                                 |
| ------------------------- | -------------------------------------------------------------------------- |
| `encoded_tx_data`         | Hex-encoded calldata (`0x…`) — the `data` field of your transaction.       |
| `target`                  | The vault's Manager contract address — the `to` field of your transaction. |
| `description`             | Human-readable description of what the calldata does.                      |
| `simulation_status`       | `true` if Tenderly-simulated cleanly (when `simulate_transaction: true`).  |
| `tenderly_simulation_url` | Link to inspect the sim in Tenderly.                                       |

Submit the transaction as:

```
to    = target
data  = encoded_tx_data
value = 0
```

Under the hood, `encoded_tx_data` is a call to [`ManagerWithMerkleVerification.manageVaultWithMerkleVerification`](https://github.com/Se7en-Seas/boring-vault/blob/main/src/base/Roles/ManagerWithMerkleVerification.sol#L133) on the vault's Manager, so decoding `encoded_tx_data` against that function's ABI shows you the exact `targets` / `targetData` / `values` the Manager will execute. **Verify these match your intent before signing.**

***

## Submitting through an external wallet

`msg.sender` on the onchain transaction must equal `strategist_address` — the Manager reverts otherwise. In practice the strategist is a **Safe**, **Fordefi vault**, or other multisig — not an EOA. You don't broadcast this from a hot wallet; you hand the three fields (`to`, `data`, `value`) to your custody workflow:

* **Safe** — propose a transaction with `to = target`, `data = encoded_tx_data`, `value = 0` (Safe's Transaction Builder app accepts these directly), then execute once threshold is met.
* **Fordefi** — pass the same three fields to your Fordefi policy workflow.
* **Other custody** — anywhere that accepts a raw contract call (to + data + value) can carry this.

See [Transaction Builder → Concepts](/api/transaction-builder.md#concepts) for the exact caller constraint and everything the Manager checks before accepting the call.

***

## Full example — Kraken Advanced USDC on Ink

End-to-end walkthrough against a real vault. Save as `veda-tx-builder-example.sh`, `export VEDA_API_KEY=...`, and run it.

```bash
#!/usr/bin/env bash
#
# Veda Transaction Builder — walkthrough against the Kraken Advanced USDC vault
# on Ink. Lists available routes, then builds one action.
#
# The POST returns `encoded_tx_data` — the calldata to submit as
# to = target, data = encoded_tx_data, value = 0 from the strategist address.

set -euo pipefail

VEDA_API_KEY="${VEDA_API_KEY:-REPLACE_WITH_YOUR_API_KEY}"
BASE="https://api.veda.tech/v1"
CHAIN="ink"
VAULT="0x9761DDF8e79930b334f1Be1BD93aBE3695061CcA"
STRATEGIST="0x49fAEBD1caed2488398E80fBB9D1dfCB8b502bDc"

if [ "$VEDA_API_KEY" = "REPLACE_WITH_YOUR_API_KEY" ]; then
  echo "Set VEDA_API_KEY before running: export VEDA_API_KEY=veda_user_live_..."
  exit 1
fi

pretty() { command -v jq >/dev/null 2>&1 && jq . || cat; }
header() { echo; echo "════ $* ════"; }

# --- 1. List routes available on Ink for this strategist -------------------
header "GET /actions"
curl -sS \
  -H "Authorization: Bearer $VEDA_API_KEY" \
  "$BASE/tx-builder/api/actions/$CHAIN/$VAULT/$STRATEGIST" | pretty

# --- 2. Build one action — bridge 100 USDC Ink → Ethereum via CCTP ---------
header "POST /execute — cctp/deposit (Ink → Ethereum, fast mode)"
curl -sS -X POST \
  -H "Authorization: Bearer $VEDA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "params": {
      "chain":      "ink",
      "dest_chain": "ethereum",
      "token":      "USDC",
      "amount":     100.0,
      "mode":       "fast",
      "max_fee":    1
    },
    "simulate_transaction": false
  }' \
  "$BASE/tx-builder/api/execute/$CHAIN/$VAULT/$STRATEGIST/cctp/deposit" | pretty

echo
echo "Done. Submit encoded_tx_data to target from your Safe."
```

***

## Full example — Balanced Yield USDC on Solana

Solana counterpart. Same three-step story — list actions, build one action, submit — with base58 addresses, a base64 v0 transaction as the return, and native RPC simulation instead of Tenderly. See [Solana Transaction Builder](/api/transaction-builder/transaction-builder-solana.md) for the endpoint-level walkthrough.

```bash
#!/usr/bin/env bash
#
# Veda Transaction Builder — walkthrough against the Balanced Yield USDC vault
# on Solana. Lists available routes, then builds one deposit action.
#
# The POST returns `serialized_transaction_base64` — the base64 v0 tx to
# deserialize, sign with the strategist, and broadcast via Solana RPC.

set -euo pipefail

VEDA_API_KEY="${VEDA_API_KEY:-REPLACE_WITH_YOUR_API_KEY}"
BASE="https://api.veda.tech/v1/tx-builder/api"
VAULT="4dTwdU6t92Fvf3dCQoiztbijX4Ncbu6zHKe9c8rYxmAp"
STRATEGIST="GGPhD3awtUsk4SXuwTcGMsqYbCDu9uNfeBrpe4zGaAom"

if [ "$VEDA_API_KEY" = "REPLACE_WITH_YOUR_API_KEY" ]; then
  echo "Set VEDA_API_KEY before running: export VEDA_API_KEY=veda_user_live_..."
  exit 1
fi

pretty() { command -v jq >/dev/null 2>&1 && jq . || cat; }
header() { echo; echo "════ $* ════"; }

# --- 1. List routes available for this strategist on Solana ----------------
header "GET /actions (solana)"
curl -sS \
  -H "Authorization: Bearer $VEDA_API_KEY" \
  "$BASE/actions/solana/$VAULT/$STRATEGIST" | pretty

# --- 2. Build one action — deposit 0.1 PYUSD via ITB Position Manager ------
header "POST /execute — itb_position_manager/deposit"
curl -sS -X POST \
  -H "Authorization: Bearer $VEDA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "params": {
      "strategy_name": "kraken_earn_pyusd",
      "asset":         "PYUSD",
      "amount":        "0.1"
    },
    "skip_sim": false
  }' \
  "$BASE/execute/solana/$VAULT/$STRATEGIST/itb_position_manager/deposit" | pretty

echo
echo "Done. Deserialize serialized_transaction_base64, sign with the strategist,"
echo "and broadcast via a Solana RPC connection."
```
