PoffertSwapDocs
Open app

For developers

RPC proxy

How the app talks to Solana through PoffertSwap's own endpoint, which calls it allows, its limits and how it fails over.

On this page

The web app never talks to a Solana RPC provider directly. It sends every request to PoffertSwap's own endpoint, which forwards it to the best available provider.

Devnet endpoint POST https://api-devnet.poffertswap.fun/rpc
Protocol Standard Solana JSON-RPC 2.0. A single request, or a batch (an array) of requests.

Why it exists#

  • No keys in the browser. Provider keys stay on the server and are never shown to users.
  • Reliability. Free provider plans get rate limited. The proxy spreads requests across several providers and moves on to another one when a provider slows down or fails.
  • Safety. It only allows the calls the app needs and refuses the expensive ones that could be used to overload the providers.

Allowed methods#

Only these calls are accepted. Anything else is answered with the JSON-RPC error -32601 (method not found).

Method Used for
getAccountInfo, getMultipleAccounts Reading accounts such as curves, pools and the configuration.
getBalance, getTokenAccountBalance, getTokenAccountsByOwner Balances.
getLatestBlockhash, isBlockhashValid Building and tracking transactions.
simulateTransaction Testing a transaction before it is signed.
sendTransaction Sending a signed transaction.
getSignatureStatuses Following a transaction until it is confirmed.
getFeeForMessage, getMinimumBalanceForRentExemption Fee and rent estimates.
getSlot The current slot.
getRecentPrioritizationFees, getPriorityFeeEstimate Priority-fee hints (when a provider supports them).

Refused on purpose: getProgramAccounts, getSignaturesForAddress, getTransaction, getBlock and its relatives, and getTokenLargestAccounts. They are heavy, and the data they return is available from the REST API, which reads them once on the server and caches the answer.

Limits#

Limit Value
Requests per client 30 per 10 seconds
sendTransaction per client 5 per 10 seconds
Calls in one batch 10
Request size 100,000 bytes

A client that goes over a limit gets HTTP 429. Browsers may only call the endpoint from an allowed origin (HTTP 403 otherwise). Scripts that send no Origin header are allowed.

How requests are routed#

  • Reads go to a healthy provider chosen at random in proportion to a weight, preferring providers that still have room in their own rate limit.
  • If a provider fails (a rate limit, a server error or no answer within 8 seconds), the proxy tries a different provider, up to 3 attempts in total.
  • A provider that misbehaves is put on a break. It rests for 30 seconds after a failure, and the break doubles on each further failure, up to 10 minutes. It returns to normal after a success.
  • sendTransaction is broadcast to up to three providers at once with maxRetries forced to 0, and the first success wins. The client re-sends until the transaction lands or its blockhash expires, so no provider needs to retry on its own.
  • Provider addresses are never revealed. /api/health lists the providers by name with their health, but never their URLs or keys.

Example#

bash
curl -s https://api-devnet.poffertswap.fun/rpc \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"getSlot"}'
json
{ "jsonrpc": "2.0", "id": 1, "result": 525796984 }

A batch is an array of requests, up to 10, answered in an array:

bash
curl -s https://api-devnet.poffertswap.fun/rpc \
  -H 'content-type: application/json' \
  -d '[{"jsonrpc":"2.0","id":1,"method":"getSlot"},{"jsonrpc":"2.0","id":2,"method":"getLatestBlockhash"}]'

Good to know#

  • Use it for what the app uses it for. If you build a bot that needs heavy history, use your own RPC provider.
  • Reading a lot? Use the REST API and the live feed instead of polling accounts.
  • isBlockhashValid is allowed, getBlockHeight is not. To know whether a transaction can still land, ask whether its blockhash is still valid.
  • Simulate before you send. simulateTransaction tells you the program's own error code. See the error list.