Smart Contracts

This page lists the official LiquidMesh Router contracts and explains how to interact with them on each chain.
LiquidMesh keeps one router per chain. For EVM chains, the router address is the same across networks.


Router Addresses

EVM chains share the same router address: 0x3d90f66B534Dd8482b181e24655A9e8265316BE9

Always verify the address from this page before integrating in production.


Integration Overview

There are two ways to obtain the transaction data for interacting with the router:

  1. Quote API (two-step):

    • Get quote and route with GET /v1/{networkId}/quote
    • Build executable callMsg with POST /v1/{networkId}/swap
  2. Flash API (one-step):

    • Get an executable order (with call data) in one request via POST /v1/{networkId}/order

The callMsg includes standard EVM fields such as to, data, value, and from (where applicable). On Solana, the API returns a serialized transaction you can sign and send.


EVM — Executing the Swap

Prerequisites

  • Ensure the user has approved the router to spend the ERC‑20 input token (unless the swap is native token in / out).
  • Respect slippageBps when constructing the swap (already encoded in callMsg by our API).
  • Use the router address for the target chain (same EVM address across chains).

ethers.js (v6) example

import { ethers } from "ethers";

// 1) Obtain callMsg from LiquidMesh API (Quote API or Flash API)
const callMsg = {
  from: "0x...user",
  to: "0x3d90f66B534Dd8482b181e24655A9e8265316BE9",
  data: "0x...",
  value: "0x0"
};

// 2) Send the transaction
const provider = new ethers.JsonRpcProvider(process.env.RPC_URL);
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY!, provider);

const tx = await wallet.sendTransaction({
  to: callMsg.to,
  data: callMsg.data,
  value: callMsg.value,
});
const receipt = await tx.wait();
console.log("Swap tx hash:", receipt?.hash);

web3.py example

from web3 import Web3

w3 = Web3(Web3.HTTPProvider(os.environ["RPC_URL"]))
acct = w3.eth.account.from_key(os.environ["PRIVATE_KEY"])

# callMsg from LiquidMesh API
callMsg = {
    "to": "0x3d90f66B534Dd8482b181e24655A9e8265316BE9",
    "data": "0x...",
    "value": 0
}

tx = {
    "to": callMsg["to"],
    "data": callMsg["data"],
    "value": callMsg["value"],
    "nonce": w3.eth.get_transaction_count(acct.address),
    "gasPrice": w3.eth.gas_price,
    "chainId": w3.eth.chain_id,
}
# optionally set tx["gas"] using API's estimatedGas or w3.eth.estimate_gas

signed = acct.sign_transaction(tx)
tx_hash = w3.eth.send_raw_transaction(signed.rawTransaction)
print("Swap tx hash:", tx_hash.hex())

Token Approval

If the input token is an ERC20 token, the user must approve a sufficient allowance to the designated contract before executing a trade, so that the LiquidMesh Router can transfer the user's assets during settlement.

The approval address can be obtained via:

GET /v1/<networkId>/get-approve-address

Currently, the approval-related addresses are:

  • EVM token approve contract
    0x8157a9d65807521FBB8db8f37EEEcEfDD247E9B1

  • Tron token approve contract
    TNKG4Mji5CjwaEZ8QXk5B4PaDDtax5pxQ5

  • Four.meme token manager
    0x5c952063c7fc8610FFDB798152D69F0B9550762b

In most cases, users should approve tokens to:

0x8157a9d65807521FBB8db8f37EEEcEfDD247E9B1

For the Tron network, the corresponding Tron-format address is:

TNKG4Mji5CjwaEZ8QXk5B4PaDDtax5pxQ5

Special Case: Selling Four.meme Tokens Before Graduation on BSC

When selling Four.meme tokens before graduation (before they migrate to PancakeSwap) on BSC, users must approve tokens to:

0x5c952063c7fc8610FFDB798152D69F0B9550762b

Solana — Executing the Swap

Prerequisites

  • swapTransaction returned by LiquidMesh API is a serialized transaction (base64).
  • You need to deserialize, sign, and send using the user’s wallet.

@solana/web3.js example

import { Connection, VersionedTransaction, sendAndConfirmTransaction } from "@solana/web3.js";

// 1) Parse API response
const swapTxBase64 = "<swapTransaction-from-API>"; // base64-encoded
const raw = Buffer.from(swapTxBase64, "base64");
const tx = VersionedTransaction.deserialize(raw);

// 2) Sign with the user's wallet (pseudocode)
await wallet.signTransaction(tx);

// 3) Send
const conn = new Connection(process.env.SOLANA_RPC!, "confirmed");
const sig = await conn.sendRawTransaction(tx.serialize());
console.log("Swap signature:", sig);

On Solana, ensure the user has sufficient SOL to cover fees and account creation (if any).


Best Practices

  • Always trust but verify: keep the router address in a constant and verify here when deploying.
  • Token approvals: for ERC‑20, prompt the user to approve the exact router address.
  • Native tokens: when swapping native assets (e.g., ETH/BNB), value must be set accordingly in the transaction.
  • Slippage & deadlines: respect slippage and timeouts embedded in the callMsg.
  • Gas & simulation: use estimatedGas as a reference; you may simulate again on your infra.
  • Security: never expose private keys; use secure key management (HSM, Vault, KMS).
  • Monitoring: track confirmations and handle re-orgs where applicable.