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 requiredExamples:
The encode of a Meson cross-chain swap, returned by the prior API.
- Mainnet
- Testnet
Example:
0x010000989680d8000000000018740e1f000000138800640554a003c60202ca21
Example:
0x010000989680d80000000000cb13cba8000000000000644325ec02ca2236a721
- application/json
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 byfromAddress
orsigner
forsigningRequest
returned by the prior API. Sample codes to generate the signature usingethers.js
are given belowconst { 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
orsigner
.As you can check, the
hash
insigningRequest
is thekeccak256
of themessage
. The UTF8 encoding of themessage
starts with either\x19Ethereum Signed Message:\n
or\x19TRON Signed Message:\n
so it is not counterfeit transaction data.
- 200
- 400
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.
- application/json
- Schema
- Example (from schema)
- For Mainnet
- For Testnet
{
"result": {
"swapId": "string"
}
}
{
"result": {
"swapId": "0x03ae219df61c9a564f9a68a9b8b48539060e869ff8ef9dc457d21e0a924f48be"
}
}
{
"result": {
"swapId": "0xf1a9f12fe479e80f3e8003a347303ff39652766b34f5aa454cf5aedd8f3c2021"
}
}
Error
- application/json
- Schema
- Example (from schema)
Schema
error object
code int32message stringdata object
code string
{
"error": {
"code": -1,
"message": "[error_message]",
"data": {
"code": "[error_code]"
}
}
}