### Install Go SDK package Source: https://docs.near-intents.org/integration/distribution-channels/1click-api/sdk Install the Go SDK module using go get. ```bash go get github.com/defuse-protocol/one-click-sdk-go ``` -------------------------------- ### 200 response example for GET /v0/account/balances Source: https://docs.near-intents.org/api-reference/account/get-user-token-balances Example successful response containing a balances array with tokenId, available, and source fields. ```json { "balances": [ { "tokenId": "nep141:wrap.near", "available": "1000000000000000000000000", "source": "private" } ] } ``` -------------------------------- ### Clone and install the example solver repository Source: https://docs.near-intents.org/integration/market-makers/quickstart Clones the near-intents-amm-solver repository and installs dependencies. Requires Node.js v20.18+ with npm and a NEAR mainnet account. ```bash git clone https://github.com/defuse-protocol/near-intents-amm-solver.git cd near-intents-amm-solver npm install ``` -------------------------------- ### Create environment file from example Source: https://docs.near-intents.org/integration/market-makers/quickstart Copies the example environment file to env/.env.local for local configuration. ```bash cp env/.env.example env/.env.local ``` -------------------------------- ### Install intents-swap-widget package Source: https://docs.near-intents.org/integration/devkit/react-widget Install the standard widget package using npm. ```bash npm install @aurora-is-near/intents-swap-widget ``` -------------------------------- ### Install near-intents skill Source: https://docs.near-intents.org/integration/devkit/skills Run this command to install the near-intents skill from the near/agent-skills repository. After installation, the agent should automatically pick up the skill, or you can explicitly ask it to read the SKILL.md file. ```bash npx skills add near/agent-skills --skill near-intents ``` -------------------------------- ### 200 response example for supported tokens Source: https://docs.near-intents.org/api-reference/oneclick/get-supported-tokens Example JSON response returned by the GET /v0/tokens endpoint. It shows a token entry with fields like assetId, decimals, blockchain, symbol, price, and contractAddress. ```json [ { "assetId": "nep141:wrap.near", "decimals": 24, "blockchain": "near", "symbol": "wNEAR", "price": "2.79", "priceUpdatedAt": "2025-03-28T12:23:00.070Z", "contractAddress": "wrap.near", "coingeckoId": "wrapped-near" } ] ``` -------------------------------- ### Install the Intents SDK Source: https://docs.near-intents.org/integration/devkit/intents-sdk Install the SDK using npm with the --save-exact flag to pin the exact version. ```bash npm install @defuse-protocol/intents-sdk --save-exact ``` -------------------------------- ### Install standalone widget package Source: https://docs.near-intents.org/integration/devkit/react-widget Install the standalone widget package for embedded wallet connection mechanisms. ```bash npm install @aurora-is-near/intents-swap-widget-standalone ``` -------------------------------- ### 200 response example for GET /v0/account/history Source: https://docs.near-intents.org/api-reference/account/get-transaction-history Example JSON response with a transaction item, including fields like status, depositType, recipientType, amounts, and cursors. ```json { "items": [ { "status": "SUCCESS", "depositType": "ORIGIN_CHAIN", "recipientType": "DESTINATION_CHAIN", "createdAt": "2025-01-15T10:30:00.000000Z", "depositAddress": "", "depositMemo": "", "refundType": "ORIGIN_CHAIN", "originAsset": "nep141:arb-0xaf88d065e77c8cc2239327c5edb3a432268e5831.omft.near", "amountInFormatted": "100.50", "amountInUsd": "100.50", "destinationAsset": "nep141:sol-5ce3bf3a31af18be40ba30f721101b4341690186.omft.near", "amountOutFormatted": "100.23", "amountOutUsd": "100.23", "recipient": "", "quoteTransactions": [ { "sender": "", "txHash": "" } ], "refundTo": "", "refundReason": "", "refundedAmountFormatted": "", "refundedAmountUsd": "", "refundFee": "", "refundFeeFormatted": "" } ], "nextCursor": "", "prevCursor": "" } ``` -------------------------------- ### Install TypeScript SDK package Source: https://docs.near-intents.org/integration/distribution-channels/1click-api/sdk Install the TypeScript SDK package using npm. ```bash npm install @defuse-protocol/one-click-sdk-typescript ``` -------------------------------- ### get_status Example Response Source: https://docs.near-intents.org/integration/market-makers/message-bus/rpc Example response from the get_status method, showing the intent status, details, and filled amounts. ```json { "jsonrpc": "2.0", "id": 1, "result": { "intent_hash": "00000000000000000000000000000000", "status": "SETTLED", "status_details": "Settled in block 123456789", "data": { "hash": "8yFNEk7GmRcM3NMJihwCKXt8ZANLpL2koVFWWH1MEEj" }, "filled_amounts": ["300"] } } ``` -------------------------------- ### Request a quote in Go Source: https://docs.near-intents.org/integration/distribution-channels/1click-api/sdk Build a QuoteRequest and call GetQuote to get a quote for a cross-chain swap. The example swaps USDC on Arbitrum for USDC on Solana. The dry flag set to false returns a depositAddress. ```go import "time" // Example: swap USDC on Arbitrum for USDC on Solana quoteRequest := *openapiclient.NewQuoteRequest( false, // dry "EXACT_INPUT", // swapType float32(100), // slippageTolerance (basis points, 100 = 1%) "nep141:arb-0xaf88d065e77c8cc2239327c5edb3a432268e5831.omft.near", // originAsset "ORIGIN_CHAIN", // depositType "nep141:sol-5ce3bf3a31af18be40ba30f721101b4341690186.omft.near", // destinationAsset "1000000", // amount (1 USDC, 6 decimals) "0xYourArbitrumAddress", // refundTo "ORIGIN_CHAIN", // refundType "YourSolanaAddress", // recipient "DESTINATION_CHAIN", // recipientType time.Now().Add(3*time.Minute), // deadline ) quote, _, err := apiClient.OneClickAPI.GetQuote(authCtx).QuoteRequest(quoteRequest).Execute() if err != nil { fmt.Fprintf(os.Stderr, "GetQuote error: %v\n", err) panic(err) } ``` -------------------------------- ### Go request to GET /v0/account/history Source: https://docs.near-intents.org/api-reference/account/get-transaction-history Uses net/http to send a GET request and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://1click.chaindefuser.com/v0/account/history" req, _ := http.NewRequest("GET", url, nil) res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go request to GET /v0/account/balances Source: https://docs.near-intents.org/api-reference/account/get-user-token-balances Uses net/http to send a GET request with an Authorization header. Reads and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://1click.chaindefuser.com/v0/account/balances" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### 200 response example for list orders Source: https://docs.near-intents.org/api-reference/order/list-orders Example JSON response for a successful request, showing order attributes, payouts, and pagination links. ```json { "data": [ { "type": "orders", "id": "", "attributes": { "orderType": "LIMIT", "depositAddress": "0x2527D...a0f10D", "depositMode": "SIMPLE", "depositType": "ORIGIN_CHAIN", "fillStatus": "AWAITING_DEPOSIT", "payoutStatus": "NOT_STARTED", "isPayoutStatusFinal": true, "payouts": { "withdrawal": { "status": "IN_PROGRESS" }, "allWithdrawals": [ { "status": "IN_PROGRESS" } ], "refund": { "status": "IN_PROGRESS" } }, "depositedAmount": "1000000000", "depositedAmountFormatted": "1.0", "baseAsset": "", "quoteAsset": "", "quantity": "", "swapView": { "swapType": "EXACT_INPUT", "originAsset": "", "destinationAsset": "", "amountIn": "", "minAmountOut": "" }, "side": "SELL", "price": "", "appFees": [ { "recipient": "recipient.near", "fee": 100 } ], "recipient": "", "recipientType": "DESTINATION_CHAIN", "refundTo": "", "refundType": "ORIGIN_CHAIN", "estimatedWithdrawFee": "", "estimatedWithdrawFeeFormatted": "", "estimatedRefundFee": "", "estimatedRefundFeeFormatted": "", "confidentiality": "public", "timeInForce": "GTC", "deadline": "2019-08-24T14:15:22Z", "createdAt": "2019-08-24T14:15:22Z", "depositMemo": "123456", "partialFills": [ { "id": "", "amountIn": "", "amountOut": "", "createdAt": "2023-11-07T05:31:56Z", "updatedAt": "2023-11-07T05:31:56Z" } ] }, "links": { "self": "" } } ], "links": { "next": "" }, "meta": { "correlationId": "550e8400-e29b-41d4-a716-446655440000", "timestamp": "2019-08-24T14:15:22Z", "nextCursor": "" } } ``` -------------------------------- ### Go request to GET /v0/status Source: https://docs.near-intents.org/api-reference/oneclick/check-swap-execution-status Uses the net/http package to send a GET request with the X-API-Key header and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://1click.chaindefuser.com/v0/status" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-API-Key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Generate Intent - Example Response Source: https://docs.near-intents.org/integration/distribution-channels/1click-api/quickstart/signed-intent-execution Example response from POST /v0/generate-intent showing the unsigned intent payload and correlationId. ```json { "intent": { "standard": "nep413", "payload": { "recipient": "intents.near", "nonce": "Vij2xgAlKBKzAEiS6N1S/hcQLaHzX2s1fNKhBDblXT4=", "message": "{\"deadline\":\"2026-07-16T12:00:00.000Z\",\"intents\":[{\"intent\":\"token_diff\",\"diff\":{\"nep141:wrap.near\":\"-1000000000000000000000000\",\"nep141:usdt.tether-token.near\":\"1000000\"}}],\"signer_id\":\"user.near\"}" } }, "correlationId": "550e8400-e29b-41d4-a716-446655440000" } ``` -------------------------------- ### Example .env file for solver configuration Source: https://docs.near-intents.org/integration/market-makers/quickstart Environment variables for NEAR account credentials, token pair, network, TEE mode, and margin percentage. MARGIN_PERCENT is the profit percentage taken from the quoted price (0.3 = 0.3% = 30 bps). ```bash # Your NEAR account credentials NEAR_ACCOUNT_ID=your-solver.near NEAR_PRIVATE_KEY=ed25519:your_private_key_here # The token pair you want to market-make AMM_TOKEN1_ID=usdt.tether-token.near AMM_TOKEN2_ID=wrap.near # Network and mode NEAR_NETWORK_ID=mainnet TEE_ENABLED=false # Your solver will take this percentage from the quoted price as profit (0.3 = 0.3% = 30 bps) MARGIN_PERCENT=0.3 ``` -------------------------------- ### Error response for get order Source: https://docs.near-intents.org/api-reference/order/get-an-order Example error response body, showing a validation-failed error. ```json { "errors": [ { "status": "400", "code": "validation-failed", "title": "Validation failed", "detail": "Must be a positive decimal string.", "source": { "pointer": "/data/attributes/price" } } ], "meta": { "correlationId": "550e8400-e29b-41d4-a716-446655440000", "timestamp": "2019-08-24T14:15:22Z" } } ``` -------------------------------- ### Successful response for get order Source: https://docs.near-intents.org/api-reference/order/get-an-order Example 200 response body for a successful order retrieval. ```json { "data": { "type": "orders", "id": "", "attributes": { "orderType": "LIMIT", "depositAddress": "0x2527D...a0f10D", "depositMode": "SIMPLE", "depositType": "ORIGIN_CHAIN", "fillStatus": "AWAITING_DEPOSIT", "payoutStatus": "NOT_STARTED", "isPayoutStatusFinal": true, "payouts": { "withdrawal": { "status": "IN_PROGRESS" }, "allWithdrawals": [ { "status": "IN_PROGRESS" } ], "refund": { "status": "IN_PROGRESS" } }, "depositedAmount": "1000000000", "depositedAmountFormatted": "1.0", "baseAsset": "", "quoteAsset": "", "quantity": "", "swapView": { "swapType": "EXACT_INPUT", "originAsset": "", "destinationAsset": "", "amountIn": "", "minAmountOut": "" }, "side": "SELL", "price": "", "appFees": [ { "recipient": "recipient.near", "fee": 100 } ], "recipient": "", "recipientType": "DESTINATION_CHAIN", "refundTo": "", "refundType": "ORIGIN_CHAIN", "estimatedWithdrawFee": "", "estimatedWithdrawFeeFormatted": "", "estimatedRefundFee": "", "estimatedRefundFeeFormatted": "", "confidentiality": "public", "timeInForce": "GTC", "deadline": "2019-08-24T14:15:22Z", "createdAt": "2019-08-24T14:15:22Z", "depositMemo": "123456", "partialFills": [ { "id": "", "amountIn": "", "amountOut": "", "createdAt": "2023-11-07T05:31:56Z", "updatedAt": "2023-11-07T05:31:56Z" } ] }, "links": { "self": "" } }, "meta": { "correlationId": "550e8400-e29b-41d4-a716-446655440000", "timestamp": "2019-08-24T14:15:22Z" } } ``` -------------------------------- ### Go example for deposit submission Source: https://docs.near-intents.org/api-reference/oneclick/submit-deposit-transaction-hash Uses the net/http package to POST the deposit payload to the endpoint with the X-API-Key header and prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://1click.chaindefuser.com/v0/deposit/submit" payload := strings.NewReader("{\n \"txHash\": \"0x123abc456def789\",\n \"depositAddress\": \"0x2527D02599Ba641c19FEa793cD0F167589a0f10D\",\n \"nearSenderAccount\": \"relay.tg\",\n \"memo\": \"123456\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-API-Key", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Configure Go client Source: https://docs.near-intents.org/integration/distribution-channels/1click-api/sdk Create a Go API client and set the access token context for authenticated requests. ```go import ( "context" "fmt" openapiclient "github.com/defuse-protocol/one-click-sdk-go" ) configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) authCtx := context.WithValue( context.Background(), openapiclient.ContextAccessToken, "YOUR_JWT_TOKEN", ) ``` -------------------------------- ### Error response example for GET /api/v0/transactions (429) Source: https://docs.near-intents.org/api-reference/get-transactions Shows the JSON structure of a 429 error response with status and error details. ```json { "status": 429, "error": { "code": "", "message": "" } } ``` -------------------------------- ### Initialize the Intents SDK Source: https://docs.near-intents.org/integration/devkit/intents-sdk Initialize the SDK with a referral code and an intent signer created from a NEAR key pair. Requires a private key and account ID. ```typescript import { IntentsSDK, createIntentSignerNearKeyPair } from '@defuse-protocol/intents-sdk'; import { KeyPair } from 'near-api-js'; const sdk = new IntentsSDK({ referral: 'your-referral-code', intentSigner: createIntentSignerNearKeyPair({ signer: KeyPair.fromString('your-private-key'), accountId: 'your-account.near', }), }); ``` -------------------------------- ### Error response example for GET /api/v0/transactions (400) Source: https://docs.near-intents.org/api-reference/get-transactions Shows the JSON structure of a 400 error response with status and error details. ```json { "status": 400, "error": { "code": "", "message": "" } } ``` -------------------------------- ### Successful response example for GET /api/v0/transactions Source: https://docs.near-intents.org/api-reference/get-transactions Shows the JSON structure of a successful response, including transaction details such as assets, amounts, fees, and hashes. ```json [ { "originAsset": "nep141:eth-0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.omft.near", "destinationAsset": "nep141:17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1", "depositAddress": "GDJ4JZXZELZD737NVFORH4PSSQDWFDZTKW3AIDKHYQG23ZXBPDGGQBJK", "depositMemo": "12345", "depositAddressAndMemo": "GDJ4JZXZELZD737NVFORH4PSSQDWFDZTKW3AIDKHYQG23ZXBPDGGQBJK_12345", "recipient": "somebody.near", "status": "SUCCESS", "createdAt": "2025-12-31T12:00:00.000Z", "createdAtTimestamp": 1767182400, "intentHashes": "GnGk38hvi92tTWDYMMS8CWYnVT4fixmfBrnqSErCDMTu", "referral": "some-referral", "amountInFormatted": "22.130108", "amountOutFormatted": "22.113697", "appFees": [ { "fee": 50, "recipient": "some.near" }, { "fee": 5, "recipient": "somebody.near" } ], "nearTxHashes": [ "6XqqDwoaopgg39QsEiFGs9HfwP2Vum9tCCyqHDYXWBBH", "EVcgKukwf38XsYcgvkEgiMPWR7qwLfLK5rsVtjgctPBn" ], "originChainTxHashes": [ "0x9bcff372aee89b648c922b850573b22387c31d693079f5e37cd255814e2d615a" ], "destinationChainTxHashes": [ "0x9bcff372aee89b648c922b850573b22387c31d693079f5e37cd255814e2d615a" ], "amountIn": "22130108", "amountInUsd": "22.1272", "amountOut": "22113697", "amountOutUsd": "22.1108", "refundTo": "somebody.near", "senders": [ "0x1234567890abcdef1234567890abcdef12345678" ], "refundFeeFormatted": "0.001", "depositType": "ORIGIN_CHAIN", "recipientType": "DESTINATION_CHAIN", "refundType": "ORIGIN_CHAIN", "refundReason": "AMOUNT_MORE_THAN_BALANCE", "refundFee": "1000" } ] ``` -------------------------------- ### Request a quote in TypeScript Source: https://docs.near-intents.org/integration/distribution-channels/1click-api/sdk Build a QuoteRequest and call getQuote to get a quote for a cross-chain swap. The example swaps USDC on Arbitrum for USDC on Solana. The dry flag set to false returns a depositAddress. ```typescript import { OneClickService, QuoteRequest } from '@defuse-protocol/one-click-sdk-typescript'; // Example: swap USDC on Arbitrum for USDC on Solana const quoteRequest: QuoteRequest = { dry: false, // true = simulate only, no depositAddress returned swapType: QuoteRequest.swapType.EXACT_INPUT, slippageTolerance: 100, // basis points (100 = 1%) originAsset: 'nep141:arb-0xaf88d065e77c8cc2239327c5edb3a432268e5831.omft.near', depositType: QuoteRequest.depositType.ORIGIN_CHAIN, destinationAsset: 'nep141:sol-5ce3bf3a31af18be40ba30f721101b4341690186.omft.near', amount: '1000000', // 1 USDC in smallest units (6 decimals) refundTo: '0xYourArbitrumAddress', refundType: QuoteRequest.refundType.ORIGIN_CHAIN, recipient: 'YourSolanaAddress', recipientType: QuoteRequest.recipientType.DESTINATION_CHAIN, deadline: new Date(Date.now() + 3 * 60 * 1000).toISOString(), }; const quote = await OneClickService.getQuote(quoteRequest); ``` -------------------------------- ### Create an order with Go (net/http) Source: https://docs.near-intents.org/api-reference/order/create-an-order Uses Go's net/http to POST to /v0/orders. Requires an API key in the X-API-Key header. The payload is a JSON string with order details. Prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://1click.chaindefuser.com/v0/orders" payload := strings.NewReader("{\n \"data\": {\n \"type\": \"orders\",\n \"attributes\": {\n \"orderType\": \"LIMIT\",\n \"baseAsset\": \"nep141:arb-0xaf88d065e77c8cc2239327c5edb3a432268e5831.omft.near\",\n \"quoteAsset\": \"nep141:sol-5ce3bf3a31af18be40ba30f721101b4341690186.omft.near\",\n \"quantity\": \"1000000\",\n \"price\": \"100 or 0.5\",\n \"refundTo\": \"0x2527D02599Ba641c19FEa793cD0F167589a0f10D\",\n \"recipient\": \"13QkxhNMrTPxoCkRdYdJ65tFuwXPhL5gLS2Z5Nr6gjRK\",\n \"deadline\": \"2019-08-24T14:15:22Z\",\n \"depositMode\": \"SIMPLE\",\n \"timeInForce\": \"GTC\",\n \"appFees\": [\n {\n \"recipient\": \"recipient.near\",\n \"fee\": 100\n }\n ]\n }\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-API-Key", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Create ANY_INPUT quote request Source: https://docs.near-intents.org/integration/distribution-channels/1click-api/fee-config Example JSON request to create an ANY_INPUT quote. Requires an Authorization: Bearer YOUR_JWT_TOKEN header. Use originAsset "1cs_v1:any" and amount "0" to get a dedicated depositAddress for fee collection. Set quoteWaitingTimeMs to 5000-10000ms for optimal performance. ```json { "dry": false, "swapType": "ANY_INPUT", "slippageTolerance": 0, "originAsset": "1cs_v1:any", "depositType": "INTENTS", "destinationAsset": "nep141:eth-0xdac17f958d2ee523a2206206994597c13d831ec7.omft.near", "amount": "0", "refundTo": "your-wallet.near", "refundType": "INTENTS", "recipient": "0x1ddA60d784483FBB54304c68830d42A706327C6d", "recipientType": "DESTINATION_CHAIN", "deadline": "2025-01-01T00:00:00.000Z", "referral": "YOUR_REFERRAL", "quoteWaitingTimeMs": 10000 } ``` -------------------------------- ### Java Unirest request to get supported tokens Source: https://docs.near-intents.org/api-reference/oneclick/get-supported-tokens Use this Java snippet with Unirest to perform a GET request to the supported tokens endpoint and get the response as a string. ```java HttpResponse response = Unirest.get("https://1click.chaindefuser.com/v0/tokens") .asString(); ``` -------------------------------- ### Build bridge-cli from source Source: https://docs.near-intents.org/integration/bridging/btc-deposit-refund Clone the bridge-sdk-rs repository and build the bridge-cli binary with cargo. The binary is output to ./target/release/bridge-cli. ```bash git clone https://github.com/near-one/bridge-sdk-rs.git cd bridge-sdk-rs cargo build --release # binary at ./target/release/bridge-cli ``` -------------------------------- ### Success response example Source: https://docs.near-intents.org/api-reference/oneclick/submit-a-signed-intent Example of a 200 response with intentHash and correlationId. ```json { "intentHash": "44XpLRAuZKoVGs9T4qbSNv33MDKMePPAibA52geVLWFw", "correlationId": "550e8400-e29b-41d4-a716-446655440000" } ``` -------------------------------- ### Fully populated private_signed_data bundle example Source: https://docs.near-intents.org/integration/market-makers/confidential-example Shows a complete private_signed_data bundle on the wire, shielding public liquidity before the swap. The shield signs a transfer intent on intents.near, swap signs against intents.far with a token_diff and imt_burn, and recover signs an imt_burn with the same nonce as swap. The nonce of swap and recover must match exactly. ```json { "quote_output": { "amount_out": "300" }, "private_signed_data": { "shield": { "standard": "nep413", "payload": { "recipient": "intents.near", "nonce": "Vij2xgAlKBKzAEiS6N1S/hfrNi8/We0ieTmcMBti1YE=", "message": "{\"deadline\":\"2026-07-16T12:05:00.000Z\",\"intents\":[{\"intent\":\"transfer\",\"tokens\":{\"nep141:ft1.near\":\"500\"},\"receiver_id\":\"\",\"memo\":\"\"}],\"signer_id\":\"your-solver.near\"}" }, "public_key": "ed25519:C3jXhkGhEx88Gj7XKtUziJKXEBMRaJ67bWFkxJikVxZ2", "signature": "ed25519:5tk3UyFcAgnd6D4ZAuzEdZqMrneRSiTqe48ptjbjYHwiCy2vTw38uDB3KusW2cEsF3TGcqZXoQmRaeNs2erhPpqu" }, "swap": { "standard": "nep413", "payload": { "recipient": "intents.far", "nonce": "Vij2xgAlKBKzAEiS6N1S/hcQLaHzX2s1fNKhBDblXT4=", "message": "{\"deadline\":\"2026-07-16T12:05:00.000Z\",\"intents\":[{\"intent\":\"token_diff\",\"diff\":{\"nep141:ft2.near\":\"-300\",\"nep141:ft1.near\":\"500\"}},{\"intent\":\"imt_burn\",\"minter_id\":\"\",\"tokens\":{\"nep141:ft1.near\":\"500\"},\"memo\":\"your-solver.near\"}],\"signer_id\":\"your-solver.near\"}" }, "public_key": "ed25519:C3jXhkGhEx88Gj7XKtUziJKXEBMRaJ67bWFkxJikVxZ2", "signature": "ed25519:WQXG37prMyT4f1vp6JSvamsjqDR5fSnDiinSPaCoq9sPcDgFGPRiMWX7csqqudDbzc8i6wrfpemgpVX2wQDmwww" }, "recover": { "standard": "nep413", "payload": { "recipient": "intents.far", "nonce": "Vij2xgAlKBKzAEiS6N1S/hcQLaHzX2s1fNKhBDblXT4=", "message": "{\"deadline\":\"2026-07-16T12:05:00.000Z\",\"intents\":[{\"intent\":\"imt_burn\",\"minter_id\":\"\",\"tokens\":{\"nep141:ft1.near\":\"500\"},\"memo\":\"your-solver.near\"}],\"signer_id\":\"your-solver.near\"}" }, "public_key": "ed25519:C3jXhkGhEx88Gj7XKtUziJKXEBMRaJ67bWFkxJikVxZ2", "signature": "ed25519:2erhPpquWQXG37prMyT4f1vp6JSvamsjqDR5fSnDiinSPaCoq9sPcDgFGPRiMWX7csqqudDbzc8i" }, "solver_id": "your-solver.near" } } ``` -------------------------------- ### Create Order with Go (net/http) Source: https://docs.near-intents.org/api-reference/order/create-an-order Sends a POST request to https://1click.chaindefuser.com/v0/orders using Go's net/http. Requires an X-API-Key header and a JSON body with order details. Prints the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://1click.chaindefuser.com/v0/orders" payload := strings.NewReader("{\n \"data\": {\n \"type\": \"orders\",\n \"attributes\": {\n \"orderType\": \"LIMIT\",\n \"baseAsset\": \"nep141:arb-0xaf88d065e77c8cc2239327c5edb3a432268e5831.omft.near\",\n \"quoteAsset\": \"nep141:sol-5ce3bf3a31af18be40ba30f721101b4341690186.omft.near\",\n \"quantity\": \"1000000\",\n \"price\": \"100 or 0.5\",\n \"refundTo\": \"0x2527D02599Ba641c19FEa793cD0F167589a0f10D\",\n \"recipient\": \"13QkxhNMrTPxoCkRdYdJ65tFuwXPhL5gLS2Z5Nr6gjRK\",\n \"deadline\": \"2019-08-24T14:15:22Z\",\n \"depositMode\": \"SIMPLE\",\n \"timeInForce\": \"GTC\",\n \"appFees\": [\n {\n \"recipient\": \"recipient.near\",\n \"fee\": 100\n }\n ]\n }\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-API-Key", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Install Rust SDK crate Source: https://docs.near-intents.org/integration/distribution-channels/1click-api/sdk Clone the Rust SDK repository and add it as a path dependency in Cargo.toml. ```bash # Clone the repo next to your project git clone https://github.com/defuse-protocol/one-click-sdk-rs.git # Add to your Cargo.toml under [dependencies] # one-click-sdk-rs = { path = "./one-click-sdk-rs" } ``` -------------------------------- ### Error response example Source: https://docs.near-intents.org/api-reference/oneclick/submit-a-signed-intent Example of a 400 error response with a message field. ```json { "message": "error message" } ``` -------------------------------- ### unsubscribe Example Request Source: https://docs.near-intents.org/integration/market-makers/message-bus/websocket Example JSON-RPC request to unsubscribe using a subscription ID. ```json { "jsonrpc": "2.0", "id": 1, "method": "unsubscribe", "params": ["00000000-0000-0000-0000-000000000000"] } ``` -------------------------------- ### Start solver in confidential mode Source: https://docs.near-intents.org/integration/market-makers/confidential-example Run this command to start the solver in confidential mode. It connects to the private relay, subscribes to confidential quote requests, queries balances from the 1Click API, and responds with signed quotes using versioned nonces. ```bash NODE_ENV=local npm start ``` -------------------------------- ### status query parameter example Source: https://docs.near-intents.org/api-reference/account/get-transaction-history Example value for the status filter: an array of statuses. ```json ["PROCESSING", "SUCCESS"] ``` -------------------------------- ### quote method example request Source: https://docs.near-intents.org/integration/market-makers/message-bus/rpc JSON-RPC request to the Message Bus to request price quotes. Provide either exact_amount_in or exact_amount_out, not both. The endpoint waits up to 3000ms for solver responses. ```json { "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 } ] } ``` -------------------------------- ### Go HTTP request to list orders Source: https://docs.near-intents.org/api-reference/order/list-orders Uses net/http to GET /v0/orders with an X-API-Key header and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://1click.chaindefuser.com/v0/orders" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-API-Key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### recipientType query parameter example Source: https://docs.near-intents.org/api-reference/account/get-transaction-history Example value for the recipientType filter: an array of recipient types. ```json ["DESTINATION_CHAIN", "INTENTS"] ``` -------------------------------- ### quote method example response Source: https://docs.near-intents.org/integration/market-makers/message-bus/rpc Example JSON-RPC response from the quote method, containing a list of quote offers with quote_hash, asset identifiers, amounts, and expiration_time. ```json { "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" } ] } ``` -------------------------------- ### depositType query parameter example Source: https://docs.near-intents.org/api-reference/account/get-transaction-history Example value for the depositType filter: an array of deposit types. ```json ["ORIGIN_CHAIN", "INTENTS"] ``` -------------------------------- ### Ruby request to GET /v0/account/history Source: https://docs.near-intents.org/api-reference/account/get-transaction-history Uses net/http to send a GET request and prints the response body. ```ruby require 'uri' require 'net/http' url = URI("https://1click.chaindefuser.com/v0/account/history") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) response = http.request(request) puts response.read_body ``` -------------------------------- ### Create an order with Java (Unirest) Source: https://docs.near-intents.org/api-reference/order/create-an-order Uses Unirest to POST to /v0/orders. Requires an API key in the X-API-Key header. The body is a JSON string with order details. Returns an HttpResponse. ```java HttpResponse response = Unirest.post("https://1click.chaindefuser.com/v0/orders") .header("X-API-Key", "") .header("Content-Type", "application/json") .body("{\n \"data\": {\n \"type\": \"orders\",\n \"attributes\": {\n \"orderType\": \"LIMIT\",\n \"baseAsset\": \"nep141:arb-0xaf88d065e77c8cc2239327c5edb3a432268e5831.omft.near\",\n \"quoteAsset\": \"nep141:sol-5ce3bf3a31af18be40ba30f721101b4341690186.omft.near\",\n \"quantity\": \"1000000\",\n \"price\": \"100 or 0.5\",\n \"refundTo\": \"0x2527D02599Ba641c19FEa793cD0F167589a0f10D\",\n \"recipient\": \"13QkxhNMrTPxoCkRdYdJ65tFuwXPhL5gLS2Z5Nr6gjRK\",\n \"deadline\": \"2019-08-24T14:15:22Z\",\n \"depositMode\": \"SIMPLE\",\n \"timeInForce\": \"GTC\",\n \"appFees\": [\n {\n \"recipient\": \"recipient.near\",\n \"fee\": 100\n }\n ]\n }\n }\n}") .asString(); ``` -------------------------------- ### Python requests example for deposit submission Source: https://docs.near-intents.org/api-reference/oneclick/submit-deposit-transaction-hash Uses the requests library to POST the deposit payload to the endpoint with the X-API-Key header and prints the response. ```python import requests url = "https://1click.chaindefuser.com/v0/deposit/submit" payload = { "txHash": "0x123abc456def789", "depositAddress": "0x2527D02599Ba641c19FEa793cD0F167589a0f10D", "nearSenderAccount": "relay.tg", "memo": "123456" } headers = { "X-API-Key": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.text) ``` -------------------------------- ### Response: 200 OK Source: https://docs.near-intents.org/api-reference/user-auth/refresh-access-token Example successful response containing the new access token and its expiration time in seconds. ```json { "accessToken": "", "expiresIn": 123 } ``` -------------------------------- ### cURL request to GET /v0/account/history Source: https://docs.near-intents.org/api-reference/account/get-transaction-history Sends a GET request to the endpoint using cURL. No authentication is shown. ```bash curl --request GET \ --url https://1click.chaindefuser.com/v0/account/history ``` -------------------------------- ### Configure Rust client Source: https://docs.near-intents.org/integration/distribution-channels/1click-api/sdk Create a Rust Configuration with a bearer access token. The base_path already defaults to https://1click.chaindefuser.com. ```rust use one_click_sdk_rs::apis::configuration::Configuration; // base_path already defaults to https://1click.chaindefuser.com let config = Configuration { bearer_access_token: Some("YOUR_JWT_TOKEN".to_string()), ..Default::default() }; ``` -------------------------------- ### Go request to get an order Source: https://docs.near-intents.org/api-reference/order/get-an-order Uses net/http to GET an order. Requires an API key in the X-API-Key header. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://1click.chaindefuser.com/v0/orders/{orderId}" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-API-Key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Go GET /api/v0/transactions Source: https://docs.near-intents.org/api-reference/get-transactions Uses net/http to send a GET request with a Bearer token and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.example.com/api/v0/transactions" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Python request to GET /v0/account/history Source: https://docs.near-intents.org/api-reference/account/get-transaction-history Uses the requests library to perform a GET request and print the response text. ```python import requests url = "https://1click.chaindefuser.com/v0/account/history" response = requests.get(url) print(response.text) ``` -------------------------------- ### cURL request to GET /api/v0/transactions Source: https://docs.near-intents.org/api-reference/get-transactions Sends a GET request to the transactions endpoint with a Bearer token in the Authorization header. ```bash curl --request GET \ --url https://api.example.com/api/v0/transactions \ --header 'Authorization: Bearer ' ```