Skip to content

Latest commit

 

History

History
192 lines (138 loc) · 6.04 KB

File metadata and controls

192 lines (138 loc) · 6.04 KB

Mantle Token Launch Script

A Rust CLI with 4 parts for the Mantle network:

  1. Create token – via Printr mainnet API
  2. Swap on Printr – buy/sell on Printr bonding curve
  3. Swap on Fluxion – buy/sell on Fluxion DEX
  4. Unwrap MNT – Unwrap MNT

Uses ethers-rs for on-chain interactions.

Purpose

For developers and traders who want to:

  • Create tokens – Launch memecoins or custom tokens on Mantle via the Printr API (bonding curve)
  • Swap on Printr – Buy tokens with MNT or sell tokens for MNT on Printr’s bonding curve
  • Swap on Fluxion – Buy tokens with MNT or sell tokens for MNT on Fluxion DEX
  • Unwrap MNT – Unwrap MNT

All interactions go through ethers-rs against Mantle’s L2 RPC.

Requirements

  • Rust toolchain
  • Mantle RPC URL and wallet private key (with MNT for gas)
  • Printr API key (for create)

Config

Copy config.sample.toml to config.toml or use env vars with prefix MANTLE_TOKEN_LAUNCH_SCRIPT__.

Required:

  • mantle.rpc_url – Mantle RPC endpoint
  • mantle.chain_id – e.g. 5000 (mainnet)
  • mantle.private_key – Hex private key (with or without 0x)
  • printr.api_base_url – Printr API base URL
  • printr.api_key – Printr API key

For Fluxion swap (Uniswap V3–style):

  • fluxion.router_address – Fluxion router
  • fluxion.wmnt_address – Wrapped MNT address
  • fluxion.pool_fee – Pool fee tier (e.g. 3000 = 0.3%, 500 = 0.05%, 10000 = 1%)

Build & run

cargo build
cargo run -- --help

CLI (3 parts)

Command Description
create Create token via Printr API (sub: payload, launch)
printr Swap on Printr bonding curve (sub: buy, sell, sell-all)
fluxion Swap on Fluxion DEX (sub: buy, sell, sell-all)
deployments Get correct curve address for a Printr token (use before printr buy)
address Print wallet address from config (use for --creator)
unwrap Unwrap all WMNT in wallet to native MNT

1. Create token (Printr API)

Use your wallet address (not a contract) for --creator. Get it from config:

cargo run -- address
# Create token and submit on Mantle
cargo run -- create launch --name "MyToken" --symbol "MTK" --creator $(cargo run -q -- address)

# Or use the address directly
cargo run -- create launch --name "MyToken" --symbol "MTK" --creator 0xYourWalletAddress

# Get unsigned payload (sign elsewhere)
cargo run -- create payload --name "MyToken" --symbol "MTK" --creator $(cargo run -q -- address)
Option Description
--name Token name
--symbol Token symbol
--description Token description (optional)
--creator Creator wallet (0x...)
--chains Chain IDs (default: eip155:5000)

2. Swap on Printr (bonding curve)

Printr buy/sell calls go to the bonding-curve proxy at 0xb77726291b125515d0a7affeea2b04f2ff243172 (ERC-1967, implementation 0x0601d6...). The --token-address identifies which token to trade. Buy uses the spend() function internally.

Get the token address:

# Get Mantle deployment address for a Printr token
cargo run -- deployments YOUR_TOKEN_ID

Use the printed token address in the buy/sell commands:

# Buy token with MNT (amounts are decimal, in wei)
cargo run -- printr buy \
  --token-address 0xTokenAddressFromDeployments \
  --mnt-amount 1000000000000000000 \
  --max-price 5000000000000

# Sell token for MNT (specify amount)
cargo run -- printr sell \
  --token-address 0xTokenAddressFromDeployments \
  --token-amount 1000000000000000000 \
  --min-mnt-out 0

# Sell entire token balance
cargo run -- printr sell-all \
  --token-address 0xTokenAddressFromDeployments

Sell and sell-all automatically approve the Printr proxy before selling.

Option Description
--token-address Token address from deployments command
--mnt-amount MNT to spend in wei, decimal (for buy)
--token-amount Token amount in wei, decimal (for sell)
--max-price Max price per token (slippage cap for buy). Use a reasonable value, e.g. 5000000000000
--min-mnt-out Min MNT received (slippage for sell / sell-all, default: 0)
--printr-contract Override bonding-curve proxy address (default: 0xb777...3172)

3. Swap on Fluxion DEX

Fluxion uses Uniswap V3–style exactInputSingle. Buy and sell approve the router as needed.

# Buy token with MNT
cargo run -- fluxion buy \
  --token 0xTokenAddress \
  --mnt-amount 1000000000000000000 \
  --min-tokens-out 0

# Sell token for MNT (approves router first)
cargo run -- fluxion sell \
  --token 0xTokenAddress \
  --token-amount 1000000000000000000 \
  --min-mnt-out 0

# Sell entire token balance
cargo run -- fluxion sell-all \
  --token 0xTokenAddress \
  --min-mnt-out 0
Option Description
--token Token contract address
--mnt-amount MNT in wei (for buy)
--token-amount Token in wei (for sell)
--min-tokens-out Min tokens received (buy)
--min-mnt-out Min MNT received (sell / sell-all)

4. Unwrap WMNT

Convert all WMNT (Wrapped MNT) in your wallet to native MNT. Uses fluxion.wmnt_address from config.

cargo run -- unwrap

Troubleshooting

  • "Contract call reverted" on Printr buy: Check that --max-price is a reasonable value (not max). Look at recent trades on Mantlescan for the token to find typical maxPrice values. Amounts are parsed as decimal (not hex).
  • Printr bonding curve reverts: Ensure the token is deployed and status: live via cargo run -- deployments TOKEN_ID. The buy calls spend() on proxy 0xb77726291b125515d0a7affeea2b04f2ff243172.
  • Fluxion sell reverts: Ensure you have enough token balance and approval. Set fluxion.pool_fee to match the pool’s fee tier (e.g. 3000 for 0.3%).

Tech stack

Rust, tokio, ethers-rs, reqwest, clap, config, dotenvy, hex

Contact: Telegram