Integrate NEAR on an existing SwapKit integration
NEAR is a new swap provider for SwapKit that enables cross-chain swaps through NEAR Intents. If you already have a SwapKit integration, adding NEAR support requires minimal changes to your existing implementation.
Integration Overview
NEAR follows the standard SwapKit quoting flow documented in the Quote Implementation Flow. Your existing integration will automatically include NEAR quotes when the traded assets are supported.
Provider Identification
Responses that include NEAR as a provider will show "NEAR"
in the providers
field of a /quote
response:
{
"providers": ["NEAR"],
// ... other quote fields
}
Provider Selection
NEAR will be included in quote responses when:
The
providers
field is omitted from your/quote
request (default behavior includes all available providers)The
providers
field explicitly includes"NEAR"
in the array
Example request to specifically include NEAR:
curl -X POST "<https://api.swapkit.dev/quote>" \\
-H "Content-Type: application/json" \\
-H "x-api-key: YOUR_VARIABLE_HERE" \\
-d '{
"sellAsset": "BTC.BTC",
"buyAsset": "ETH.ETH",
"sellAmount": "0.1",
"sourceAddress": "357a3So9CbsNfBBgFYACGvxxS6tMaDoa1P",
"destinationAddress": "0x0a4c79cE84202b03e95B7a692E5D728d83C44c76",
"providers": ["NEAR"]
}'
Supported Chains
NEAR currently supports the following blockchain networks:
Currently Available
Arbitrum
Avalanche
Base
Binance Smart Chain
Bitcoin
Dogecoin
Ethereum
Ripple
Solana
TRON
Coming Soon
NEAR
ZCash
Polygon
Optimism
Future Support
TON
Sui
Aptos
Cardano
Kaspa
Stellar
Key Difference: Transaction Architecture
The primary difference between NEAR and other SwapKit providers is the transaction structure when includeTx: true
is used:
NEAR transactions are transfers to exchange vaults rather than direct smart contract interactions. When you receive a transaction object in the quote response, it represents a transfer to a specific vault designated for settlement with the market maker.
EIP-7702 Support
NEAR supports Type 4 transactions, introduced with EIP-7702, enabling advanced transaction capabilities on supported networks.
Network Confirmations
When sending funds to the NEAR exchange vault, 2 network confirmations are required before the swap begins processing. This confirmation requirement is accurately reflected in the estimatedTime
field of quote responses:
{
"estimatedTime": {
"inbound": 1200, // Includes 2 block confirmation wait time
"swap": 12,
"outbound": 400,
"total": 1612
}
}
Implementation Requirements
No additional implementation is required beyond your existing SwapKit integration. NEAR:
Follows the same quote request/response structure
Uses the same error handling patterns
Supports the same
includeTx
flow for transaction buildingReturns standard SwapKit response formats
Example Integration
If you're already integrated with SwapKit, NEAR quotes will automatically appear when available. Here's a typical flow, also explained in our recommended quote implementation flow:
Initial Quote (existing code, no changes needed):
curl -X POST "<https://api.swapkit.dev/quote>" \\
-H "Content-Type: application/json" \\
-H "x-api-key: YOUR_VARIABLE_HERE" \\
-d '{
"sellAsset": "BTC.BTC",
"buyAsset": "ETH.ETH",
"sellAmount": "0.1"
}'
You can also filter providers if you are already limitting them, but adding NEAR to the list.
Provider Selection (existing code, no changes needed):
Select the best option for the quote requested. Present it to the user for them to accept.
Transaction Building:
Request a new quote using "includeTx": true
and adding a filter by provider.
curl -X POST "<https://api.swapkit.dev/quote>" \\
-H "Content-Type: application/json" \\
-H "x-api-key: YOUR_VARIABLE_HERE" \\
-d '{
"sellAsset": "BTC.BTC",
"buyAsset": "ETH.ETH",
"sellAmount": "0.1",
"sourceAddress": "357a3So9CbsNfBBgFYACGvxxS6tMaDoa1P",
"destinationAddress": "0x0a4c79cE84202b03e95B7a692E5D728d83C44c76",
"providers": ["NEAR"],
"includeTx": true
}'
Sign and broadcast the returned transaction (existing wallet integration, no changes needed)
The only difference you'll notice is that NEAR transactions transfer funds to exchange vaults rather than interacting directly with contracts, but this is handled transparently by the SwapKit API.
Last updated