Local Trade API
This API allows users to trade SunPump tokens without passing a private key or sensitive information. It works by building transaction instructions for local signing and broadcasting instead.
Endpoint
URL:
/sunpump/localTrade
Method:
POST
Content-Type:
application/json
API Key Header:
api-key: your-api-key-here
Parameters
type
string
Yes
Type of transaction: buy
or sell
.
tokenAddress
string
Yes
Token Contract Address
amount
number/string
Yes
Amount to trade (in TRX for tokens (or %) for sale).
userAddress
string
Yes
Public Tron Address of sender
slippage
number
No
Max allowed price change before the transaction is reverted
Example Buy Request
curl -X POST https://api.dangeracorn.com/sunpump/localTrade \
-H "Content-Type: application/json" \
-H "api-key: your-api-key" \
-d '{
"action": "buy",
"tokenAddress": "token-contract-address",
"amount": 100,
"slippage": 1,
"userAddress": "sender-public-tron-address"
}'
Example Sell Request
curl -X POST https://api.dangeracorn.com/sunpump/localTrade \
-H "Content-Type: application/json" \
-H "api-key: your-api-key" \
-d '{
"action": "sell",
"tokenAddress": "token-contract-address",
"amount": "50%",
"slippage": 2,
"userAddress": "sender-public-tron-address"
}'
Example Response JSON
{
"unsignedTx": {
"raw_data": { /* transaction data */ },
"txID": "b69f27c7bfcf54a464294f1df99aaeff1b53714a12a80460709b20923a24486c"
},
"status": "unsigned",
"code": "200"
}
Error Responses
Invalid Parameters
{
"error": "Invalid parameters",
"message": "You must provide type, tokenAddress, amount, and userAddress",
"code": "400"
}
Max Slippage Reached
{
"error": "Simulation failed",
"message": "Max slippage reached. Transaction reverted.",
"code": "500"
}
Insufficient Funds
{
"error": "Insufficient funds",
"message": "Your account does not have enough funds to perform this transaction.",
"code": "400"
}
Invalid Type
{
"error": "Invalid type",
"message": "Type must be either 'buy' or 'sell'.",
"code": "400"
}
Notes
Rate Limiting: This endpoint is rate-limited according to your plan's API key limits. Ensure that you handle these limits in your application.
Unsigned Transactions: The API returns unsigned transactions that users must sign before broadcasting.
Slippage Tolerance: Ensure the slippage is reasonable to avoid reverted transactions.
Fees: A small fee is applied on each trade. Please refer to Plans to see what fee your plan uses.
Last updated
Was this helpful?