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.

  • 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 fromAddress in the request body

  • recipient address

    Same as recipient in the request body

  • initiator address

    A parameter used to call the Meson smart contract. Always an eth address. See usage instructions

  • 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
  • tx object

    Present if the swap originates from an EVM-compatible chain and represents the transaction data required to interact with the Meson smart contract. Note that if the swap involves ERC-20 tokens, you must first call approve on the token contract to grant sufficient allowance to tx.to before submitting this transaction.

  • to address

    Meson contract address

  • value string_of_number

    Amount of the chain's native token (typically ETH) that must be sent with the transaction

  • data hex_string

    ABI-encoded payload including the contract method and parameters

Loading...