Skip to main content
POST
/
2
/
swap
/
send
Send Swap Transaction
curl --request POST \
  --url https://demo-api.mobula.io/api/2/swap/send \
  --header 'Content-Type: application/json' \
  --data '{
  "chainId": "<string>",
  "signedTransaction": "<string>"
}'
{
  "data": {
    "success": true,
    "transactionHash": "<string>",
    "requestId": "<string>"
  },
  "error": "<string>"
}

Overview

The Swap Send endpoint allows you to broadcast a signed transaction to the blockchain network. This endpoint should be used after obtaining a quote from the Swap Quoting endpoint and signing the transaction with your wallet.
Private Beta Access OnlyThis endpoint is not yet available to the general public. Please contact the Mobula team to request access.

Request Body

The request body must be a JSON object with the following fields:
  • chainId (required) — The blockchain identifier (e.g., evm:1, solana, ethereum)
  • signedTransaction (required) — Base64 encoded signed transaction

Usage Examples

Send Solana Swap

curl -X POST "https://api.mobula.io/api/2/swap/send" \
  -H "Content-Type: application/json" \
  -d '{
    "chainId": "solana",
    "signedTransaction": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDMzMzMzMzMzMzMzMzMzMzMzMzMzMz..."
  }'

Send EVM Swap

curl -X POST "https://api.mobula.io/api/2/swap/send" \
  -H "Content-Type: application/json" \
  -d '{
    "chainId": "ethereum",
    "signedTransaction": "AiUISA3b2F0ZWQgdHJhbnNhY3Rpb24gaGVyZQ=="
  }'

Send with Specific Chain ID

curl -X POST "https://api.mobula.io/api/2/swap/send" \
  -H "Content-Type: application/json" \
  -d '{
    "chainId": "evm:56",
    "signedTransaction": "AjhkZmhqa2RmaGpzZGZoanNkZmhqc2RmaGpzZGZoag=="
  }'

Response Format

{
  "data": {
    "success": true,
    "transactionHash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "requestId": "123e4567-e89b-12d3-a456-426614174000"
  }
}

Response Fields

Data Object

  • success (boolean) — Indicates if the transaction was successfully broadcast
  • transactionHash (string, optional) — Transaction hash/signature on the blockchain
  • requestId (string) — Unique identifier for the request

Error Field

  • error (string, optional) — Error message if the transaction failed to broadcast

Example Responses

Successful Transaction

{
  "data": {
    "success": true,
    "transactionHash": "0x8e3b5c4d7f9a2e1b6c8d4a9f7e3b5c2d1a8f6e4c3b9d7e5a2f1c8b6d4e9a7f3",
    "requestId": "550e8400-e29b-41d4-a716-446655440000"
  }
}

Successful Solana Transaction

{
  "data": {
    "success": true,
    "transactionHash": "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW",
    "requestId": "660e8400-e29b-41d4-a716-446655440001"
  }
}

Failed Transaction

{
  "data": {
    "success": false,
    "requestId": "770e8400-e29b-41d4-a716-446655440002"
  },
  "error": "Transaction simulation failed: insufficient funds"
}

Invalid Signature

{
  "data": {
    "success": false,
    "requestId": "880e8400-e29b-41d4-a716-446655440003"
  },
  "error": "Invalid transaction signature"
}

Transaction Flow

  1. Get Quote: Call the Swap Quoting endpoint to get a serialized transaction
  2. Sign Transaction: Use your wallet to sign the transaction
    • For Solana: Use @solana/web3.js or similar
    • For EVM: Use ethers.js, web3.js, or similar
  3. Encode to Base64: Convert the signed transaction to base64
  4. Broadcast: Send the encoded transaction using this endpoint
  5. Track: Use the returned transaction hash to track on blockchain explorers

Important Notes

  • Transaction Validity: Transactions may expire if not sent within a certain timeframe
  • Gas/Priority Fees: The transaction includes estimated fees from the quoting phase
  • Slippage: If market conditions change significantly, the transaction may fail
  • Idempotency: Sending the same transaction multiple times may result in errors
  • Transaction Hash: Use this to track the transaction on blockchain explorers

Error Handling

Common error scenarios:
  • Insufficient Funds: Wallet doesn’t have enough balance to cover the swap + fees
  • Slippage Exceeded: Market moved beyond acceptable slippage tolerance
  • Invalid Signature: Transaction was not properly signed
  • Expired Transaction: Transaction validity period has passed
  • Network Congestion: Blockchain network is experiencing high load

Next Steps

After broadcasting:
  1. Monitor the transaction using the returned hash
  2. Wait for blockchain confirmation
  3. Verify the swap completed successfully on a blockchain explorer

Use Cases

  • Automated Trading: Execute swaps programmatically
  • Multi-Wallet Management: Broadcast transactions from multiple wallets
  • Trading Bots: Implement automated trading strategies
  • DeFi Integration: Complete swap flows in your application

Body

application/json
chainId
string
required

The blockchain identifier (e.g., evm:1, solana, ethereum)

signedTransaction
string
required

Base64 encoded signed transaction

Response

200 - application/json

Transaction broadcast response

data
object
required
error
string | null

Error message if the transaction failed to broadcast