Cerebro Protocol
  • ✍️ Pitch Deck
    • Problem
    • Solution
    • Market Analysis
  • ❔ Overview
    • Technical Framework
    • ZKsync Integration
    • Routing & Delivery
    • Available Chains
    • Supported DEX's
  • ⚑️(new) Sniper
    • πŸ”« LP Sniper Interface
  • ⚑️(new) Trader
    • βœ‹ Setting Up
    • πŸ”΄πŸŸ’ Buy / Sell
    • βš–οΈ Limit Orders
    • ©️ Copy Trade
    • πŸ“£ Channel Snipe
    • πŸ“Š Charts
    • πŸ’³ Wallets
    • πŸ‘€ User Stats
    • πŸ”„ Pending Orders
    • βš™οΈ Settings
  • ⚑️(new) Private Bridge
    • πŸ₯· How to privately send funds
  • ⚑️(new) Multichain Swap
    • πŸͺ™ Swap ANY token - token
  • πŸ€– Bot
    • Interface
    • Manual
    • Safety
  • πŸŒ€ Private Bridge
    • Technical Framework
    • Manual
  • πŸ“Š Terminal
    • App
    • New & Trending Pairs
    • Filters
    • Multichain
    • Live Charting
  • πŸ’²Fees
  • πŸ¦„ Token
  • πŸ“² API
  • πŸ“Socials
Powered by GitBook
On this page

πŸ“² API

Endpoint

POST /createSwap

Description

This endpoint initiates a multi-chain token swap transaction. Users must provide source and destination chain IDs, token details, addresses, and swap parameters.


Request Structure

URL: https://multichain-api-bd341ad6bfc7.herokuapp.com/createSwap

HTTP Method: POST

Headers:

  • Content-Type: application/json

  • Authorization: <API_KEY> An API key for authentication must be provided in the Authorization header.

Request Body (JSON):

Parameter

Type

Required

Description

source_chain

number

Yes

The chain ID of the source blockchain.

source_token

string

Yes

The token identifier on the source chain. For sending native chain tokens (eth, bsc, poly, etc) please use

For sol:

other wise use the token's address.

dest_chain

number

Yes

The chain ID of the destination blockchain.

dest_token

string

Yes

The token identifier on the destination chain. For receving native chain tokens (eth, bsc, poly, etc) please use

For sol:

other wise use the token's address.

dest_address

string

Yes

The recipient wallet address on the destination chain.

src_authority_address

string

Yes

The authority wallet address on the source chain initiating the transaction.

dst_authority_address

string

Yes

The authority wallet address on the destination chain for the transaction.

amount

number

Yes

The amount of tokens to be swapped.

slippage

number

or

string

No

The acceptable slippage percentage. Set to

"auto" or don't include to use automatically adjusted slippage.


Example Request

Request URL: POST https://multichain-api-bd341ad6bfc7.herokuapp.com/createSwap

Headers:

Authorization: <API_KEY> Content-Type: application/json

Request Body:

//This example will swap 0.1 ARB for CRX (eth)

{
    "source_chain": 42161,
    "source_token": "0x0000000000000000000000000000000000000000",
    "dest_chain": 1,
    "dest_token": "0x49218282042072e054afdc90e552e832735f8316",
    "dest_address": "0xDestinationWalletAddress",
    "src_authority_address": "0xSourceAuthorityWallet",
    "dst_authority_address": "0xDestinationAuthorityWallet",
    "amount": 0.1,
    "slippage": "auto"
}

Note: If slippage is not provided, it defaults to "auto".


Example Response

Success Response:

{
  "status": 1,
  "swapTxInfo": {
    "approximateTimeInSeconds": 12,
    "dstChainToken": {
      "address": "0x49218282042072e054afdc90e552e832735f8316",
      "amount": "2776816417315670140859",
      "approximateUsdValue": 307.2314919404435,
      "chainId": 1,
      "decimals": 18,
      "maxTheoreticalAmount": "2785171933115015186418",
      "maxTheoreticalApproximateUsdValue": 308.1559598199032,
      "name": "Cerebro",
      "recommendedAmount": "2776816417315670140859",
      "recommendedApproximateUsdValue": 307.2314919404435,
      "symbol": "CRX"
    },
    "srcChainToken": {
      "address": "0x0000000000000000000000000000000000000000",
      "amount": "102756853086491862",
      "approximateOperatingExpense": "2756853086491862",
      "approximateUsdValue": 343.3777376774561,
      "chainId": 42161,
      "decimals": 18,
      "mutatedWithOperatingExpense": true,
      "name": "Ethereum",
      "originApproximateUsdValue": 334.16529152408964,
      "symbol": "ETH"
    },
    "unsignedTx": {
      "data": "0xb930370100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000001941ec7fef70000000000000000000000000000000000000000000000000000000000000360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000003e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016d10d03e7514d600000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000968811ab583d5f27bb000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000a1a6abcbd4b267b3839956df59308bc597628acd00000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002600000000000000000000000000000000000000000000000000000000000000280000000000000000000000000000000000000000000000000000000000000001449218282042072e054afdc90e552e832735f83160000000000000000000000000000000000000000000000000000000000000000000000000000000000000014a1a6abcbd4b267b3839956df59308bc597628acd0000000000000000000000000000000000000000000000000000000000000000000000000000000000000014a1a6abcbd4b267b3839956df59308bc597628acd0000000000000000000000000000000000000000000000000000000000000000000000000000000000000014555ce236c0220695b68341bc48c68d52210cc35b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000341d3585cd23cd206aa5e6b8344c26eb1588fed0df0000000000000000000000000000000000000000000000000003a6917143bb17000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000420101000000d614ebe057cb0900000000000000000000000000bb275f3d58ab1188960000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "to": "0xeF4fB24aD0916217251F553c0596F8Edc630EB66",
      "value": "103756853086491862"
    }
  }
}

Example Error Response:

{
  "status": 0
  "ErrorCode": "INVALID QUERY PARAMETERS",
  "errorMessage": "dstChainOrderAuthorityAddress has unexpected address representation: expecting EVM-compatible 40 character hexadecimal address representation"
}


Error codes:
403 - incorrect or expired api key
400 - incorrect arguments/request inputs
401 - swap tx creation error

Parameter Details

  1. source_chain / dest_chain: The unique identifier for the blockchain networks. Example IDs: 1 for Ethereum, 56 for Binance Smart Chain.

  2. source_token / dest_token: The tokens to be swapped between the source and destination chains. Provide token symbols or contract identifiers.

  3. dest_address: The wallet address to receive the swapped tokens on the destination chain. Ensure it's valid for the specified chain.

  4. src_authority_address / dst_authority_address: Authority addresses needed to validate the transaction. These are typically associated with the initiating and receiving parties.

  5. amount: The number of tokens to swap. Must be a positive number.

  6. slippage: The maximum allowable price movement during the swap. Use a numerical percentage (e.g., 1 for 1%) or "auto" to use the default slippage.


All available chains and fees:

Chain ID

Blockchain

Fee

42161

Arbitrum

0.001 ETH

43114

Avalanche

0.05 AVAX

56

BSC

0.005 BNB

1

Ethereum

0.001 ETH

137

Polygon

0.5 MATIC

7565164

Solana

0.015 SOL

59144

Linea

0.001 ETH

8453

Base

0.001 ETH

10

Optimism

0.001 ETH

100000002

Gnosis

1 xDAI

100000004

Metis

0.02 METIS

Full Code Examples:

Python:

import requests

url = 'https://multichain-api-bd341ad6bfc7.herokuapp.com/createSwap'

params = {
    "source_chain": 42161,
    "source_token": "0x0000000000000000000000000000000000000000",
    "dest_chain": 1,
    "dest_token": "0x49218282042072e054afdc90e552e832735f8316",
    "dest_address": "0xDestinationWalletAddress",
    "src_authority_address": "0xSourceAuthorityWallet",
    "dst_authority_address": "0xDestinationAuthorityWallet",
    "amount": 0.1,
    "slippage": "auto"
}

headers = {
    'Content-type': 'application/json',
    "Authorization": 'API_KEY'
}

response = requests.post(url, headers=headers, json=params)
print(response.status_code, response.json())

Node.js:

const axios = require('axios');

const url = 'https://multichain-api-bd341ad6bfc7.herokuapp.com/createSwap';

params = {
    "source_chain": 42161,
    "source_token": "0x0000000000000000000000000000000000000000",
    "dest_chain": 1,
    "dest_token": "0x49218282042072e054afdc90e552e832735f8316",
    "dest_address": "0xDestinationWalletAddress",
    "src_authority_address": "0xSourceAuthorityWallet",
    "dst_authority_address": "0xDestinationAuthorityWallet",
    "amount": 0.1,
    "slippage": "auto"
};

const headers = {
    'Content-Type': 'application/json',
    'Authorization': 'API_KEY'
};

axios.post(url, params, { headers })
    .then(response => {
        console.log(response.status);
        console.log(response.data);
    })
    .catch(error => {
        console.error(error.response ? error.response.data : error.message);
    });

cURL:

curl -X POST https://multichain-api-bd341ad6bfc7.herokuapp.com/createSwap \
-H "Content-Type: application/json" \
-H "Authorization: API_KEY" \
-d '{
    "source_chain": 42161,
    "source_token": "0x0000000000000000000000000000000000000000",
    "dest_chain": 1,
    "dest_token": "0x49218282042072e054afdc90e552e832735f8316",
    "dest_address": "0xDestinationWalletAddress",
    "src_authority_address": "0xSourceAuthorityWallet",
    "dst_authority_address": "0xDestinationAuthorityWallet",
    "amount": 0.1,
    "slippage": "auto"
}'
PreviousπŸ¦„ TokenNextπŸ“Socials

Last updated 5 months ago

0x0000000000000000000000000000000000000000
11111111111111111111111111111111
0x0000000000000000000000000000000000000000
11111111111111111111111111111111