Skip to main content

RPC Drop-In

Details​

Provided as a migration solution, BaaS provides an RPC endpoint which is compatible with the native broker.

This allows integrators to simply re-use existing code written against the native broker with BaaS, just by changing the broker address.

This call overwrites the broker commission with your configured settings if the passed in commission is lower, to avoid users from tampering.

Refund parameters are required, as on the native broker: the 8th param of broker_request_swap_deposit_address is an object with retry_duration, refund_address and min_price, and broker_request_swap_parameter_encoding carries them in extra_parameters (refund_parameters, or min_output_amount and retry_duration for Bitcoin). A call without them is answered with a 400 and never reaches the broker.

Assets that are disabled or cannot be swapped in the requested direction, such as relay-chain DOT (dot.dot), are refused with a 400 (for example Source Asset not enabled to swap from.) and never reach the broker. DOT is dot.hub.

API Endpoint​

  • /rpc/{apiKey} - Make a broker_request_swap_deposit_address RPC call.

Chainflip SDK Example​

tip

Want to test first? Change the API base URL to https://perseverance.chainflip-broker.io. The Testing environment swaps testnet assets with no real value.

Swap the API key in the examples for your own production API key. Testing requires a separate testnet API key.

When using the Chainflip SDK you can provide a custom broker url to use your BaaS account:

import { SwapSDK } from '@chainflip/sdk/swap';

const options = {
network: 'mainnet', // Mainnet
broker: {
url: 'https://chainflip-broker.io/rpc/87517a91d5f34dbabfc1e410946a3a3c',
},
};

const swapSDK = new SwapSDK(options);

To test against the Testing environment instead, set network: 'perseverance' and point the broker URL at https://perseverance.chainflip-broker.io/rpc/YOUR_TESTNET_API_KEY — the Chainflip SDK requires both values to change together.

Swapkit Example​

When using the Swapkit SDK you can provide a custom broker url to use your BaaS account:

import { createSwapKit } from "@swapkit/sdk";

const skClient = createSwapKit({
config: {
ethplorerApiKey: "freekey",
chainflipBrokerConfig: {
useChainflipSDKBroker: true,
chainflipBrokerUrl: "https://chainflip-broker.io/rpc/87517a91d5f34dbabfc1e410946a3a3c",
}
},
});

// Request quotes, connect wallets, ...

await skClient.swap(...);