Local Transaction API
The Local Transaction API provides maximum security and control. We build the transaction for you, but you sign and broadcast it using your own wallet and RPC endpoint.
Overview
Base URL: https://api.turnpike.dev
Flow:
Request a transaction from Turnpike
Receive base64-encoded unsigned transaction
Sign the transaction with your wallet
Broadcast to Solana using your RPC endpoint
Why Use Local Transactions?
Full Control: You sign and send transactions yourself
Custom RPC: Use your own Solana RPC infrastructure
Maximum Security: Private keys never leave your system
Transaction Transparency: Inspect transactions before signing
Institutional Grade: Meets compliance requirements
Endpoints
Build Buy Transaction
Build an unsigned transaction for buying tokens.
Endpoint: POST /transaction/buy
Request Body:
publicKey
string
Yes
Your Solana wallet public key
mint
string
Yes
Token mint address to purchase
amount
number
Yes
Amount of SOL to spend
slippage
number
No
Maximum slippage percentage (default: 10)
priorityFee
number
No
Priority fee in SOL (default: auto)
Example Request:
Success Response (200):
Build Sell Transaction
Build an unsigned transaction for selling tokens.
Endpoint: POST /transaction/sell
Request Body:
publicKey
string
Yes
Your Solana wallet public key
mint
string
Yes
Token mint address to sell
amount
number
Yes
Amount of tokens to sell
slippage
number
No
Maximum slippage percentage
priorityFee
number
No
Priority fee in SOL
Example Request:
Success Response (200):
Signing and Sending
After receiving the unsigned transaction, you need to sign and broadcast it.
JavaScript/TypeScript Example
Using with Wallet Adapter (Browser)
Python Example
Rust Example
Transaction Expiration
Transactions have a limited validity period:
lastValidBlockHeight: Block height after which transaction is invalid
expiresAt: Unix timestamp when transaction expires (typically 60 seconds)
Always send transactions promptly after building them.
Best Practices
Verify Transaction Contents: Inspect the transaction before signing
Use Trusted RPC: Use your own RPC or a trusted provider
Handle Expiration: Build and send transactions quickly
Confirm Transactions: Always wait for confirmation
Store Private Keys Securely: Never expose private keys
Test Thoroughly: Test with small amounts first
Security Considerations
Inspect Before Signing
Simulate Before Sending
Error Handling
Same error codes as Lightning API apply. See Error Handling.
Next Steps
View WebSocket API for real-time data
Check Examples for complete integration code
Learn about Error Handling
Last updated