Prerequisites
- Payward Services API credentials (see the Authentication guide).
- A verified user with at least one account and on-chain quote trading enabled.
- A source wallet registered on the user’s withdrawal-address list as a same-owner address. The address must be approved before you create a quote.
- Enough source-asset balance in the wallet to settle the on-chain quote.
Workflow
1
Create an on-chain quote
Create a wallet-funded xStocks on-chain quote and receive the on-chain payload.
POST /v1/accounts/{account_id}/onchain-quotes2
Submit the on-chain transaction
Call the Payward on-chain proxy contract with the returned payload before
expires_at.executeSwap(...)3
Poll for terminal status
Wait for Payward Services to observe settlement, or subscribe to webhooks.
GET /v1/accounts/{account_id}/onchain-quotes/{quote_id}Quote lifecycle
Specifying the trade
Onchain quotes are restricted to xStock and USDC pairs. Set thewallet block on from: the quote is funded from the user’s wallet, not from the user’s Payward Services account balance.
The only supported
network value is ethereum.
Authentication setup
Authenticated endpoints require an HMAC-SHA512 request signature in theAPI-Sign header and the signing time in the API-Timestamp header. The helpers below compute both. The examples call signed_headers (signedHeaders in JavaScript) with the request’s method, its path including any query string, and the exact body string they send. See the Authentication guide for the full algorithm.
The examples read the API base URL from the PWS_BASE_URL environment variable, and your credentials from PWS_API_KEY and PWS_API_SECRET. Set PWS_BASE_URL to the sandbox or production base URL, listed in Environments.
Step 1: create an on-chain quote
Send aPOST to /v1/accounts/{account_id}/onchain-quotes with from.wallet populated. The create response returns the full quote including execution_details, which carries the proxy contract address and the signed on-chain payload.
Step 2: submit the on-chain transaction
CallexecuteSwap on execution_details.proxy_address. Pass the returned proxy_swap_message before the quote expires.
The proxy call uses this argument shape:
Typescript
Step 3: poll for terminal status
After broadcasting on-chain, pollGET /v1/accounts/{account_id}/onchain-quotes/{quote_id} until status reaches a terminal value (executed, expired, or failed).
Reviewing on-chain quotes
List previously created on-chain quotes withGET /v1/accounts/{account_id}/onchain-quotes. Results are returned newest-first. Use page_token and page_size (defaults to 50, max 200) for pagination: next_page_token is omitted on the final page.
History entries omit
execution_details. The signed on-chain payload is only returned by the create response.Error handling
Best practices
- Register wallets ahead of time. Screening can take time and will block quote creation until the address is approved.
- Store the on-chain quote create response. It is the only response that includes the signed on-chain execution payload.
- Treat
executed,expired, andfailedas terminal. Request a new quote for another attempt. - Submit on-chain well before
expires_at. Gas spikes and confirmation time reduce the usable window. - Capture
Request-Idfrom response headers. It speeds up support investigations.