Prerequisites
Before starting, make sure you have:- An app registered at tren.ch/partner, which gives you a
client_idand an API key. See Registration. - A redirect URI on the app, matching exactly what you will send.
- The
profile:readandtrade:executescopes selected for the app. - A Trench user to connect, with 1-click trading enabled and some SOL in their wallet.
- A Solana RPC endpoint, which you will use to confirm that trades landed.
Endpoints Used
1. Set Up Environment Variables
2. Connect a User
Run the connect flow to obtain an authorization code, then exchange that code for a token pair.cURL
access_token and refresh_token against your own user record.
3. Verify the Token
cURL
tradingEnabled is true, and that scopes includes trade:execute.
Keep walletSolana on hand as well, since you will need it to read the user’s balances and transaction history from your RPC.
4. Place a Buy
All amounts are sent as integer strings in base units, using lamports for SOL and 1e6 units for tokens. See Amount Conventions for details.Response
5. Confirm It Landed
A status ofsubmitted means the network accepted the transaction, not that it succeeded. Confirmation is public on-chain state, so you read it from Solana directly using the signature Trench returned.
Node.js
Node.js
Next Steps
Trade Tokens
Exact-out buys, sells, and volume caps.
Partner Fees
Charge your own fee on every trade.
Governance
Read proposals and vote on behalf of a user.
Security Requirements
Recommended reading before going to production.