Skip to content

Commit 2bcdc4d

Browse files
avralclaude
andcommitted
add CPU Payer API documentation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 992d48e commit 2bcdc4d

1 file changed

Lines changed: 159 additions & 0 deletions

File tree

source/index.html.md

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,29 @@ id | string | token-id
159159
system_price | number | token price in chain system token
160160
usd_price | number | token price in USD
161161

162+
## Token Logo
163+
```shell
164+
curl https://wax.alcor.exchange/api/v2/tokens/wax-eosio.token/logo
165+
```
166+
167+
Get token logo image (PNG) by token id.
168+
169+
### HTTP Request
170+
171+
`GET https://alcor.exchange/api/v2/tokens/<token_id>/logo`
172+
173+
### URL Parameters
174+
Name | Type | Description
175+
---------- | --------------------------- | -----------
176+
token_id | string | Token identifier (symbol-contract)
177+
178+
### Response
179+
Returns PNG image file if logo exists, or 404 error if not found.
180+
181+
<aside class="notice">
182+
Logo URL can be constructed from token id: /api/v2/tokens/{token_id}/logo
183+
</aside>
184+
162185
# Global Data
163186

164187
## Stats
@@ -1677,3 +1700,139 @@ Call action **cancelsell** or **cancelbuy** with parameters:
16771700
* **executor** - order owner account name
16781701
* **market_id** - id of the order related market
16791702
* **order_id** - order id.
1703+
1704+
# CPU Payer (WAX only)
1705+
1706+
Alcor provides a free CPU payer service for WAX blockchain that covers transaction CPU costs for users interacting with Alcor contracts. This uses the `ONLY_BILL_FIRST_AUTHORIZER` mechanism.
1707+
1708+
<aside class="notice">
1709+
This service is only available on WAX blockchain.
1710+
</aside>
1711+
1712+
## How it works
1713+
1714+
1. Client checks `/status` endpoint to see if service is available
1715+
2. If available, client builds transaction with `liquid.alcor::noop` as first action
1716+
3. Client signs the transaction (only their actions, noop has payer's auth)
1717+
4. Client sends serialized transaction to `/cosign` endpoint
1718+
5. Worker validates and cosigns for `liquid.alcor@bw`
1719+
6. Client combines signatures and pushes to blockchain
1720+
7. CPU cost is billed to `liquid.alcor` (first authorizer)
1721+
1722+
## Status
1723+
1724+
```shell
1725+
curl -X POST https://wax.alcor.exchange/api/v2/cpu/status \
1726+
-H "Content-Type: application/json"
1727+
```
1728+
1729+
> The above command returns JSON structured like this:
1730+
1731+
```json
1732+
{
1733+
"available": true,
1734+
"signing": true,
1735+
"throttled": false,
1736+
"cpu": {
1737+
"used": 100000,
1738+
"max": 400000,
1739+
"percent": 25.0
1740+
},
1741+
"lastCheck": 1705123456789
1742+
}
1743+
```
1744+
1745+
Check if CPU payer service is available and signing.
1746+
1747+
### HTTP Request
1748+
1749+
`POST https://wax.alcor.exchange/api/v2/cpu/status`
1750+
1751+
### Response
1752+
1753+
Name | Type | Description
1754+
--- | --- | ---
1755+
available | boolean | Whether the service is available
1756+
signing | boolean | Whether the service is currently signing transactions
1757+
throttled | boolean | Whether rate limiting is in effect
1758+
cpu | object | Current CPU usage info
1759+
cpu.used | number | Current CPU usage in microseconds
1760+
cpu.max | number | Maximum CPU available in microseconds
1761+
cpu.percent | number | CPU usage percentage
1762+
lastCheck | number | Timestamp of last CPU status check
1763+
1764+
## Cosign
1765+
1766+
```shell
1767+
curl -X POST https://wax.alcor.exchange/api/v2/cpu/cosign \
1768+
-H "Content-Type: application/json" \
1769+
-d '{"serializedTransaction": "..."}'
1770+
```
1771+
1772+
> The above command returns JSON structured like this:
1773+
1774+
```json
1775+
{
1776+
"signature": "SIG_K1_..."
1777+
}
1778+
```
1779+
1780+
Cosign a pre-built transaction. The transaction must have `liquid.alcor::noop` as the first action with `liquid.alcor@bw` authorization.
1781+
1782+
### HTTP Request
1783+
1784+
`POST https://wax.alcor.exchange/api/v2/cpu/cosign`
1785+
1786+
### Request Body
1787+
1788+
Name | Type | Description | Required
1789+
--- | --- | --- | ---
1790+
serializedTransaction | string | Hex-encoded serialized transaction | true
1791+
1792+
### Response
1793+
1794+
Name | Type | Description
1795+
--- | --- | ---
1796+
signature | string | The payer's signature (SIG_K1_...)
1797+
1798+
### Errors
1799+
1800+
```json
1801+
{
1802+
"error": "Rate limit exceeded"
1803+
}
1804+
```
1805+
1806+
Error | Description
1807+
--- | ---
1808+
Rate limit exceeded | Too many requests from this IP or account
1809+
Invalid transaction | Transaction format is invalid
1810+
First action must be noop | Transaction doesn't start with liquid.alcor::noop
1811+
Unauthorized contract | Transaction contains actions to non-whitelisted contracts
1812+
Service unavailable | CPU payer is currently disabled or overloaded
1813+
1814+
## Rate Limits
1815+
1816+
| Limit | Default | Description |
1817+
|-------|---------|-------------|
1818+
| Per IP (hourly) | 500 | Requests per IP per hour |
1819+
| Per Account (hourly) | 300 | Requests per WAX account per hour |
1820+
| Per IP (daily) | 5000 | Requests per IP per day |
1821+
| Per Account (daily) | 2000 | Requests per WAX account per day |
1822+
| Global (hourly) | 10000 | Total requests per hour |
1823+
| Global (daily) | 80000 | Total requests per day |
1824+
1825+
<aside class="warning">
1826+
When CPU usage exceeds 95%, all hourly limits are reduced by 50%.
1827+
</aside>
1828+
1829+
## Allowed Contracts
1830+
1831+
Transactions can only contain actions to whitelisted Alcor contracts:
1832+
1833+
* `alcordexmain` - Spot DEX
1834+
* `swap.alcor` - AMM Swap
1835+
* `otc.alcor` - OTC trading
1836+
* `alcorotcswap` - OTC swap
1837+
1838+
Plus `eosio.token::transfer` actions are always allowed.

0 commit comments

Comments
 (0)