Skip to main content

Submit an encoded swap with signature

POST /api/v1/swap/:encoded

Following the prior API, this API will submit a signed cross-chain swap to Meson.

Path Parameters
  • encoded hex_string_32_bytes required

    The encode of a Meson cross-chain swap, returned by the prior API.

    Examples:

    Example: 0x010000989680d8000000000018740e1f000000138800640554a003c60202ca21

Request Body required
  • 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.

  • signature hex_string required

    The signature should be signed by fromAddress or signer for signingRequest returned by the prior API. Sample codes to generate the signature using ethers.js are given below

    const { Wallet } = require('ethers') // ethers@^6

    // The private key for fromAddress
    const wallet = new Wallet(process.env.PRIVATE_KEY)

    function signData (signingRequest) {
    const sig = wallet.signingKey.sign(signingRequest.hash)
    return sig.serialized
    }

    Meson's smart contract will verify the signature to confirm the cross-chain request is indeed authorized by fromAddress or signer.

    As you can check, the hash in signingRequest is the keccak256 of the message. The UTF8 encoding of the message starts with either \x19Ethereum Signed Message:\n or \x19TRON Signed Message:\n so it is not counterfeit transaction data.

Responses

Successful operation

If your request data is valid and the cross-chain swap is submitted to Meson protocol for processing, you will receive a swapId in response. Please use the next API or go to https://explorer.meson.fi/swap/[swapId] or https://testnet-explorer.meson.fi/swap/[swapId] to check the swap status.

Schema
  • result object
  • swapId hex_string_32_bytes

    The unique id for the swap. Check swap status with the next API or on Meson Explorer (mainnet or testnet).

Loading...