Obtain callData

Note

Before the swap, wallet address needs to confirm that FROM currency token approves the contract address. The contract address can be fetched by requesting the endpoint

Method 1: Endpoint usage

POST https://open.crosschainx.io/api/sswap/swap

The fields with * are required, and the fields without * are optional

Request Body

Name
Type
Description

equipmentNo*

String

Equipment number (This field will be used as the unique identifier of the user, and the third parties can obtain it on their own, such as the first 32 characters of fromAddress, or a string of 32 random numbers and letters)

sourceType

String

Device type (H5/IOS/Android The field is optional, if it is requested directly through the API, it can be empty)

sourceFlag*

String

Source channel (Both sides need to agree on a name to represent the channel of the third parties)

fromTokenAddress*

String

Contract address for the token to sell (It can be obtained from the address field in the currency list)

toTokenAddress*

String

Contract address for the token to receive (It can be obtained from the address field in the currency list)

fromAddress*

String

User address

toAddress*

String

receiving Address

fromTokenChain*

String

Network of the token to sell (It can be obtained from the chain field in the currency list, For details of the support chain, please refer to [Basic information])

toTokenChain*

String

Network of the token to received (It can be obtained from the chain field in the currency list, For details of the support chain, please refer to [Basic information])

fromTokenAmount*

String

Amount of token to sell (with precision, which can be obtained through the fromTokenAmount field in the quote endpoint)

amountOutMin*

String

Expected amount received (with precision, which can be obtained through the amountOutMin field in the quote endpoint)

fromCoinCode*

String

Token name for sell token (It can be obtained from the symbol field in the currency list)

toCoinCode*

String

Token name for receive token (It can be obtained from the symbol field in the currency list)

slippage

String

e.g. '0.1' (meaning 10%) Minimum amount received = amountOutMin * (1 - slippage)

Code example

Postman example

Method 2: Directly request the smart contract

To send a swap message, call the contract's swap() or swapEth() function.

Here is an explanation of the swap() and swapEth() interface:

Mainnet currency swap calls the swapEth() method, and token swap calls the swap() method. EVM Contract call instance:

TON Contract call instance:

XRP Contract call instance:

Last updated