Skip to content

Transaction Router API#

The Transaction Router is the recommended way to build staking and unstaking transactions. It finds optimal routes and returns ready-to-sign transactions.

Property Value
Base URL https://tx-router.marinade.finance
Documentation tx-router.marinade.finance/docs
Authentication None required
Rate Limit 60 requests/minute

Overview#

The Transaction Router simplifies staking operations by:

  • Finding optimal routes for staking/unstaking
  • Returning ready-to-sign transactions
  • Supporting multiple asset types
  • Handling referral tracking
graph LR
    A[Your App] --> B[Transaction Router]
    B --> C[Returns Transaction]
    C --> D[User Signs]
    D --> E[Submit to Solana]

Route Endpoint#

GET /v1/route

Finds and builds a transaction for staking or unstaking operations.

Required Parameters#

Parameter Type Description
user string User's wallet address
asset_in string Input asset type
amount_in integer Amount in lamports
asset_out string Output asset type

Asset Types#

Asset Description
sol Native SOL
msol Marinade staked SOL (liquid)
mnative Marinade native staked SOL
stake Existing stake account
lst Other liquid staking tokens
validator Direct validator stake

Optional Parameters#

Parameter Type Default Description
tx_version string v0 Transaction version: legacy or v0
priority string/int medium Fee level: low, medium, high, or custom bps
slippage integer - Max slippage in basis points (100 = 1%)
referral_id string - Referral identifier for partner tracking

Example Requests#

Liquid Stake SOL → mSOL#

Bash
curl "https://tx-router.marinade.finance/v1/route?\
user=YOUR_WALLET&\
asset_in=sol&\
amount_in=1000000000&\
asset_out=msol"

Unstake mSOL → SOL#

Bash
curl "https://tx-router.marinade.finance/v1/route?\
user=YOUR_WALLET&\
asset_in=msol&\
amount_in=1000000000&\
asset_out=sol"

Native Stake SOL#

Bash
curl "https://tx-router.marinade.finance/v1/route?\
user=YOUR_WALLET&\
asset_in=sol&\
amount_in=1000000000&\
asset_out=mnative"

Convert Stake Account to mSOL#

Bash
curl "https://tx-router.marinade.finance/v1/route?\
user=YOUR_WALLET&\
asset_in=stake&\
amount_in=STAKE_ACCOUNT_PUBKEY&\
asset_out=msol"

Response Format#

JSON
{
  "id": "route_id",
  "tx": {
    "message": "base64_encoded_transaction",
    "non_user_sigs": [],
    "blockhash": "...",
    "last_valid_block_height": 123456789
  },
  "funding": {
    "fees": 5000,
    "rent": 0
  },
  "amount_out": 950000000
}

Response Fields#

Field Description
id Unique route identifier
tx.message Base64-encoded transaction message
tx.non_user_sigs Additional signatures (if any)
tx.blockhash Recent blockhash used
tx.last_valid_block_height Block height validity window
funding.fees Transaction fees in lamports
funding.rent Rent costs in lamports
amount_out Expected output amount in lamports

Common Routes#

From To Description
sol msol Liquid stake SOL
msol sol Unstake mSOL (instant)
sol mnative Native stake SOL
mnative sol Unstake native (instant)
stake msol Convert stake account to mSOL
stake mnative Move stake to Marinade native

Using with Referrals#

Add your referral ID to earn rewards:

Bash
curl "https://tx-router.marinade.finance/v1/route?\
user=YOUR_WALLET&\
asset_in=sol&\
amount_in=1000000000&\
asset_out=msol&\
referral_id=YOUR_REFERRAL_ID"

See the Referral Program for setup instructions.

Error Handling#

HTTP Code Meaning
200 Success
400 Invalid parameters
404 Route not found
429 Rate limited
500 Server error

Error Response#

JSON
{
  "error": {
    "code": "INVALID_PARAMETER",
    "message": "Description of what went wrong"
  }
}

TypeScript Integration#

TypeScript
// Using fetch
const response = await fetch(
  `https://tx-router.marinade.finance/v1/route?` +
  `user=${wallet.publicKey}&` +
  `asset_in=sol&` +
  `amount_in=${amount}&` +
  `asset_out=msol`
);

const { tx } = await response.json();

// Deserialize and sign
const transaction = VersionedTransaction.deserialize(
  Buffer.from(tx.message, 'base64')
);
transaction.sign([wallet]);

// Submit
const signature = await connection.sendTransaction(transaction);
Resource Link
Interactive Docs tx-router.marinade.finance/docs
TypeScript SDK SDK Guide
Referral Program Referral Docs