Skip to main content
This API is designed for market makers/solvers. Distribution channels should use the 1Click Swap API instead.

Frontend JSON-RPC API

Endpoint: POST https://solver-relay-v2.chaindefuser.com/rpc These endpoints are used by frontends to request quotes and publish user intents.

quote

Request price quotes from connected solvers. The Message Bus forwards the request to all solvers, waits up to 3000ms, and returns all available options.
Only one of exact_amount_in or exact_amount_out should be provided, not both.
defuse_asset_identifier_in
string
required
Asset to trade from (e.g., nep141:ft1.near)
defuse_asset_identifier_out
string
required
Asset to trade to (e.g., nep141:ft2.near)
exact_amount_in
string
Amount of input token for exchange
exact_amount_out
string
Amount of output token for exchange
min_deadline_ms
number
default:"60000"
Minimum validity time for offers (in milliseconds). Shorter times may yield better prices.
Array of quote responses from solvers:
  • quote_hash - Quote response hash
  • defuse_asset_identifier_in - Asset to trade from
  • defuse_asset_identifier_out - Asset to trade to
  • amount_in - Input amount (exact if specified, proposed otherwise)
  • amount_out - Output amount (exact if specified, proposed otherwise)
  • expiration_time - Expiration timestamp of the offer
Request
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "quote",
  "params": [
    {
      "defuse_asset_identifier_in": "nep141:ft1.near",
      "defuse_asset_identifier_out": "nep141:ft2.near",
      "exact_amount_in": "1000",
      "min_deadline_ms": 60000
    }
  ]
}
Response
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    {
      "quote_hash": "00000000000000000000000000000000",
      "defuse_asset_identifier_in": "nep141:ft1.near",
      "defuse_asset_identifier_out": "nep141:ft2.near",
      "amount_in": "1000",
      "amount_out": "2000",
      "expiration_time": "2024-10-01T12:10:27Z"
    }
  ]
}

publish_intent

Submit a signed user intent for execution. Supported signature standards: nep413, erc191, raw_ed25519.
quote_hashes
string[]
required
Quote response hashes from solvers
signed_data
object
required
  • standard - "nep413"
  • payload.message - Stringified intent payload
  • payload.nonce - Unique nonce
  • payload.recipient - "intents.near"
  • payload.callbackUrl - Optional, for some wallets
  • signature - Signature of the payload
  • public_key - Signer’s public key
  • status - "OK" or "FAILED"
  • reason - Error reason (if failed)
  • intent_hash - Intent identifier
Request
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "publish_intent",
  "params": [
    {
      "quote_hashes": ["00000000000000000000000000000000"],
      "signed_data": {
        "standard": "nep413",
        "payload": {
          "recipient": "intents.near",
          "nonce": "Vij2xgAlKBKzAEiS6N1S/hfrNi8/We0ieTmcMBti1YE=",
          "message": "{\"deadline\":\"2024-10-14T12:53:40.000Z\",\"intents\":[{\"intent\":\"token_diff\",\"diff\":{\"nep141:ft1.near\":\"300\",\"nep141:ft2.near\":\"-500\"}}],\"signer_id\":\"user.near\"}"
        },
        "public_key": "ed25519:C3jXhkGhEx88Gj7XKtUziJKXEBMRaJ67bWFkxJikVxZ2",
        "signature": "ed25519:5tk3UyFcAgnd6D4ZAuzEdZqMrneRSiTqe48ptjbjYHwiCy2vTw38uDB3KusW2cEsF3TGcqZXoQmRaeNs2erhPpqu"
      }
    }
  ]
}

get_status

Check the status of an intent’s execution.
intent_hash
string
required
Intent identifier
  • intent_hash - Intent identifier
  • status - Execution status (see below)
  • data.hash - NEAR transaction hash (if available)
StatusDescription
PENDINGIntent received, awaiting execution
TX_BROADCASTEDTransaction sent to the Verifier contract
SETTLEDSuccessfully settled on-chain
NOT_FOUND_OR_NOT_VALIDIntent not received, expired, or execution error
Request
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "get_status",
  "params": [
    {
      "intent_hash": "00000000000000000000000000000000"
    }
  ]
}
Response
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "intent_hash": "00000000000000000000000000000000",
    "status": "SETTLED",
    "data": {
      "hash": "8yFNEk7GmRcM3NMJihwCKXt8ZANLpL2koVFWWH1MEEj"
    }
  }
}

Solver WebSocket API

Endpoint: wss://solver-relay-v2.chaindefuser.com/ws Market makers connect via WebSocket to receive and respond to quote requests in real-time.

subscribe

Subscribe to quote requests or quote status events.
params[0]
string
required
Subscription name: "quote" or "quote_status"
Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "subscribe",
  "params": ["quote"]
}
Response
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "00000000-0000-0000-0000-000000000000"
}

Quote request event

After subscribing to "quote", you’ll receive events like this:
Event
{
  "jsonrpc": "2.0",
  "method": "subscribe",
  "params": {
    "subscription": "00000000-0000-0000-0000-000000000000",
    "quote_id": "00000000-0000-0000-0000-000000000000",
    "defuse_asset_identifier_in": "nep141:ft1.near",
    "defuse_asset_identifier_out": "nep141:ft2.near",
    "exact_amount_in": "1000",
    "min_deadline_ms": 60000
  }
}
Only one of exact_amount_in or exact_amount_out will be specified in each request.

quote_response

Respond to a quote request with a signed intent. A unique id is required in the JSON-RPC message.
quote_id
string
required
Quote request identifier from the event
quote_output
object
required
  • amount_out - Proposed amount for exact_amount_in requests
  • amount_in - Proposed amount for exact_amount_out requests
signed_data
object
required
Signed intent data (same format as publish_intent)
other_quote_hashes
string[]
Optional hashes of other quotes needed to fulfill this intent
Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "quote_response",
  "params": [
    {
      "quote_id": "00000000-0000-0000-0000-000000000000",
      "quote_output": {
        "amount_out": "300"
      },
      "signed_data": {
        "standard": "nep413",
        "payload": {
          "recipient": "intents.near",
          "nonce": "Vij2xgAlKBKzAEiS6N1S/hcQLaHzX2s1fNKhBDblXT4=",
          "message": "{\"deadline\":\"2024-10-14T12:53:40.000Z\",\"intents\":[{\"intent\":\"token_diff\",\"diff\":{\"nep141:ft2.near\":\"-300\",\"nep141:ft1.near\":\"500\"}}],\"signer_id\":\"solver.near\"}"
        },
        "public_key": "ed25519:C3jXhkGhEx88Gj7XKtUziJKXEBMRaJ67bWFkxJikVxZ2",
        "signature": "ed25519:WQXG37prMyT4f1vp6JSvamsjqDR5fSnDiinSPaCoq9sPcDgFGPRiMWX7csqqudDbzc8i6wrfpemgpVX2wQDmwww"
      }
    }
  ]
}
Response
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "OK"
}

Quote status event

After subscribing to "quote_status", you’ll receive settlement notifications:
Event
{
  "jsonrpc": "2.0",
  "method": "subscribe",
  "params": {
    "quote_hash": "00000000000000000000000000000000",
    "intent_hash": "00000000000000000000000000000000",
    "tx_hash": "8yFNEk7GmRcM3NMJihwCKXt8ZANLpL2koVFWWH1MEEj"
  }
}

unsubscribe

Unsubscribe from a subscription.
Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "unsubscribe",
  "params": ["00000000-0000-0000-0000-000000000000"]
}
Response
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "OK"
}