Skip to main content

Development

User Flow

The process involves two main participants: the user, who initiates the swap, and the resolver, who executes it.

The swap process starts with a quote request.

Quote Request

The user specifies the currency pair they would like to swap and the amount. The client sends these parameters to the Changelly DeFi Quote API. The API returns a quote, a time-limited execution estimate that includes all pricing information.

Intent Creation

After receiving a quote, the client creates an intent, a structured representation of the user's swap intention, by specifying the user's addresses and the quote identifier the user agreed to. This represents the user's intention to execute the swap under the quoted conditions.

Signing an Intent

After intent creation, the API provides all the necessary information for the user to sign the swap. The user signs the intent off-chain, cryptographically approving the swap parameters defined in the intent and authorizing resolvers to execute it according to the quoted conditions.

Execution

Once the user has signed an intent, the system notifies the winning resolver to start swap execution by depositing the maker's assets into an escrow contract on the source chain and then transferring the corresponding assets to the user. During execution, the user can query the Changelly DeFi Intent API to retrieve the swap status.

Authorization

Affiliates must include their assigned X-Api-Key value in the request header when making calls to the API. All requests are authenticated by validating this header, and any request sent without a valid X-Api-Key will be rejected. Make sure the header is added to every request to ensure proper authorization and access to protected endpoints.

Authentication Method

Send your API key in the X-Api-Key HTTP header:

X-Api-Key: <your_api_key>

Errors

The API returns errors in a consistent JSON format. Each error includes a numeric code, a short message, and the related entity.

Error Response Format:

application/json
{
"code": 1,
"message": "Internal server error",
"entity": "Intent"
}

Error Codes:

CodeMessageDescription / Notes
2Unexpected swap statusSwap is in an invalid state for the requested operation
3Serde errorFailed to serialize or deserialize data
4Messaging errorIssue with internal messaging or event system
6Base58 errorBase58 encoding/decoding failed
7Not foundRequested resource does not exist
8Hex errorHex encoding/decoding failed
10Approval errorError during approval process
11Permit2 errorFailed to generate or validate Permit2 signature
12Intent status errorInvalid or unavailable intent status
13Missing contextRequired request context missing
14Malformed headerInvalid HTTP headers
15Serde server errorServer failed to serialize/deserialize
16Token errorInvalid token or token mismatch
17Resolver address errorResolver address invalid or missing
19Fulfillment request hash creation errorFailed to create fulfillment request hash
20Fulfillment request hash signing errorFailed to sign fulfillment request hash
22Incorrect swap typeSwap type does not match expected
23Optimized swap unsupportedAttempted optimized swap not supported
24Provider errorExternal provider failed
25Balance errorInsufficient balance
26Address validation failedUser or contract address invalid
27Slippage validation failedProvided slippage value invalid
28Signature validation failedUser or system signature invalid
31Resolver public key errorResolver public key invalid or missing
32Required public key missingPublic key required but not provided
33BTC transaction builder errorFailed to build BTC transaction
35Forbidden network pairSwap between this source/dest network not allowed