Swap by reply on Farcaster and X
Mention @layerhop with "swap 10 USDC to SOL" in a cast or post and get a link to a prefilled swap. On Farcaster it opens as a Mini App with your Farcaster wallet. The bots never execute swaps.
Write a cast on Farcaster or a post on X that mentions LayerHop's account with a swap request:
@layerhop swap 10 USDC to SOLThe bot replies with a link to a prefilled swap page at app.layerhop.com/swap. You check the live quote, change anything you like, connect your own wallet and sign. The bots never quote on your behalf, hold funds, sign or send anything: the reply is only a link.
What can I write?#
The parser (parseSwapCommand in @layerhop/shared) understands:
| You write | It means |
|---|---|
swap 10 USDC to SOL |
10 USDC (on Base, which the reply says you can change) to SOL on Solana |
swap 100 USDC on Arbitrum to USDT on Polygon |
both chains named |
bridge 0.1 ETH from Arbitrum to Base |
a chain name as the destination coin: ETH on Base |
swap 0.5 SOL to USDC |
SOL names Solana, so USDC arrives on Solana too |
swap 0.1 ETH to USDC on Base |
a chain named only at the end applies to both sides |
buy $10 of SOL, buy SOL with 10 USDC |
buy with USDC |
25 usdc → sol |
no verb needed when the request is complete |
- Amounts:
10,0.5,1,000,2.5k,$10(dollars, only with a stablecoin).max,allorhalfget a question back: the bot never guesses an amount. - Tokens: symbols in any case,
$SOLtickers,usd/dollars(USDC),ether,matic(POL), or a token address with its chain (to 0x4ed4…efed on base; a Solana mint implies Solana). - Chains: slug, name or id, plus
eth/mainnet,arb,op,bnb/bsc,poly/matic,sol,avax. Coins that live on one chain (SOL, BNB, POL, AVAX, …) name their chain; ETH and stablecoins don't. - Ambiguity gets a question, not a guess:
swap 10 USDC to ETHasks which chain ETH should arrive on. A misspelt chain (on bsae) is pointed out. - Chat that merely mentions an amount ("I sent 10 USDC to my friend") and
send … to <address>get no reply.
How does the Farcaster Mini App work?#
Every prefilled swap link on app.layerhop.com/swap carries a Farcaster Mini App embed (fc:miniapp, plus the legacy fc:frame) with an image of the live quote and a Swap on LayerHop button. In a Farcaster client the button opens the page inside the client, and the page connects the client's own wallet (the EIP-1193 provider from the Mini App SDK). You still review and sign the swap. The manifest is at app.layerhop.com/.well-known/farcaster.json.
You can post such links yourself: any deep link to app.layerhop.com/swap?… unfurls the same way on Farcaster, and as an image of the quote on X, Telegram and Discord.
How is the Farcaster bot built?#
Neynar delivers casts that mention the bot to POST /v1/social/farcaster/webhook (cast.created). Each delivery is signed: X-Neynar-Signature is the HMAC-SHA512 (hex) of the raw body with the webhook secret, and unsigned or mis-signed requests get 401. The bot replies through Neynar's cast API with the swap link as an embed, once per cast (a retry is recognised), at most 5 replies per author and hour and FARCASTER_MAX_REPLIES_PER_DAY a day.
How is the X bot built?#
It polls the bot account's mentions (GET /2/users/{id}/mentions, app bearer token) every X_POLL_SECONDS and replies with POST /2/tweets using the account's OAuth 1.0a user tokens. Every mention read and every reply is recorded, so the monthly spend estimate survives restarts. It pauses for the month at X_MONTHLY_BUDGET_USD, posts at most X_MAX_REPLIES_PER_DAY replies and 3 per author a day, and answers each post once. X bills link posts at a much higher rate than plain posts, so keep the daily cap low.
Both bots are off unless their credentials are set; see the deployment guide in the repository (docs/DEPLOY.md) for the variables and the cost notes.
Last updated