Skip to main content

Encode a cross-chain swap

POST /api/v1/swap

Cross-chain swaps on Meson use compact encoding to compress data. This API will accept human-readable parameters in the request body and return an encoded swap.

Request Body required
  • from string (chain:token) required

    The initial chain and token type. See supported chains.

  • to string (chain:token) required

    The target chain and token type. See supported chains.

  • amount string_of_number required

    Amount of tokens to initialize the cross-chain swap.

  • fromAddress address required

    The address on initial chain to initialize the cross-chain swap.

  • fromContract boolean

    The fromAddress parameter can refer to either an externally owned address (EOA) or a smart contract address. This API will check the token balance when the swap originates from an EOA, but this step will be bypassed if initiated from a smart contract. If you intend to send a swap from a smart contract that has not yet been deployed, you should set the fromContract parameter to true.

  • recipient address required

    The address on target chain to receive cross-chain'ed assets.

  • dataToContract hex_string_8_bytes

    A hex string of 8 bytes (e.g. 0x00000000000000000000). If dataToContract is present, the cross-chain'ed fund will be released to a smart contract by calling the method depositWithBeneficiary. Please ensure that the recipient is a smart contract that has implemented this method. Failure to do so may result in the funds becoming stuck. See an example here.

Responses

Successful operation

Schema
  • result object
  • encoded hex_string_32_bytes

    The encoded swap data which will be used in the next API

  • fromAddress address

    Same as in the request body if it is an externally owned address (EOA)

  • fromContract address

    Same as fromAddress in the request body if it is a contract address

  • recipient address

    Same as in the request body

  • fee object

    Fee data of this swap

  • serviceFee string_of_number

    Fee charged by Meson protocol

  • lpFee string_of_number

    Fee charged by liquidity providers on Meson

  • totalFee string_of_number

    Total fee to be charged

  • converted optional

    For some swap routes (i.e. arb:usdc -> merlin:btc) token conversion is allowed.

  • amount string_of_number

    Amount of converted token to receive

  • token string

    Converted token

  • signingRequest object

    Present if fromAddress is an externally owned address (EOA). The hash to be signed before submitting a cross-chain swap through the next API.

  • message hex_string
  • hash hex_string_32_bytes
  • initiator address

    Present if fromAddress is a contract address. See usage instructions.

Loading...