repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
Mirrored from https://github.com/ProjectOpenSea/opensea-skill
stars
latest
clone command
git clone gitlawb://did:key:z6MkqRzA...RfoM/ProjectOpenSea-...git clone gitlawb://did:key:z6MkqRzA.../ProjectOpenSea-...fef93001Release v2.14.011h ago| #1 | # Token Swaps via OpenSea MCP |
| #2 | |
| #3 | OpenSea MCP provides token swap functionality through integrated DEX aggregation. This allows swapping ERC20 tokens and native currencies across supported chains. |
| #4 | |
| #5 | ## Overview |
| #6 | |
| #7 | The `get_token_swap_quote` tool returns: |
| #8 | 1. **Quote details** - Expected output, fees, price impact |
| #9 | 2. **Transaction calldata** - Ready to submit onchain |
| #10 | |
| #11 | ## Supported Chains |
| #12 | |
| #13 | - Ethereum (`ethereum`) |
| #14 | - Base (`base`) |
| #15 | - Polygon (`matic`) |
| #16 | - Arbitrum (`arbitrum`) |
| #17 | - Optimism (`optimism`) |
| #18 | |
| #19 | ## Getting a Swap Quote |
| #20 | |
| #21 | ### Via mcporter CLI |
| #22 | |
| #23 | ```bash |
| #24 | mcporter call opensea.get_token_swap_quote --args '{ |
| #25 | "fromContractAddress": "0x0000000000000000000000000000000000000000", |
| #26 | "fromChain": "base", |
| #27 | "toContractAddress": "0xb695559b26bb2c9703ef1935c37aeae9526bab07", |
| #28 | "toChain": "base", |
| #29 | "fromQuantity": "0.02", |
| #30 | "address": "0xYourWalletAddress" |
| #31 | }' |
| #32 | ``` |
| #33 | |
| #34 | ### Parameters |
| #35 | |
| #36 | | Parameter | Required | Description | |
| #37 | |-----------|----------|-------------| |
| #38 | | `fromContractAddress` | Yes | Token to swap FROM. Use `0x0000...0000` for native ETH | |
| #39 | | `toContractAddress` | Yes | Token to swap TO | |
| #40 | | `fromChain` | Yes | Source chain identifier | |
| #41 | | `toChain` | Yes | Destination chain identifier | |
| #42 | | `fromQuantity` | Yes | Amount in human units (e.g., "0.02" for 0.02 ETH) | |
| #43 | | `address` | Yes | Your wallet address | |
| #44 | | `recipient` | No | Recipient address (defaults to sender) | |
| #45 | | `slippageTolerance` | No | Slippage as decimal (e.g., 0.005 for 0.5%) | |
| #46 | |
| #47 | ### Response Structure |
| #48 | |
| #49 | ```json |
| #50 | { |
| #51 | "swapQuote": { |
| #52 | "swapRoutes": [{ |
| #53 | "toAsset": { "symbol": "MOLT", "usdPrice": "0.00045" }, |
| #54 | "fromAsset": { "symbol": "ETH", "usdPrice": "2370" }, |
| #55 | "costs": [ |
| #56 | { "costType": "GAS", "cost": { "usd": 0.01 } }, |
| #57 | { "costType": "MARKETPLACE", "cost": { "usd": 0.40 } } |
| #58 | ], |
| #59 | "swapImpact": { "percent": "3.5" } |
| #60 | }], |
| #61 | "totalPrice": { "usd": 47.40 } |
| #62 | }, |
| #63 | "swap": { |
| #64 | "actions": [{ |
| #65 | "transactionSubmissionData": { |
| #66 | "to": "0xSwapRouterContract", |
| #67 | "data": "0x...", |
| #68 | "value": "20000000000000000", |
| #69 | "chain": { "networkId": 8453, "identifier": "base" } |
| #70 | } |
| #71 | }] |
| #72 | } |
| #73 | } |
| #74 | ``` |
| #75 | |
| #76 | ## Executing the Swap |
| #77 | |
| #78 | ### Using the CLI (recommended) |
| #79 | |
| #80 | The `opensea swaps execute` command quotes and executes in one step, signing via a Privy-managed wallet: |
| #81 | |
| #82 | ```bash |
| #83 | opensea swaps execute \ |
| #84 | --from-chain base \ |
| #85 | --from-address 0x0000000000000000000000000000000000000000 \ |
| #86 | --to-chain base \ |
| #87 | --to-address 0xb695559b26bb2c9703ef1935c37aeae9526bab07 \ |
| #88 | --quantity 0.02 |
| #89 | ``` |
| #90 | |
| #91 | Requires `PRIVY_APP_ID`, `PRIVY_APP_SECRET`, and `PRIVY_WALLET_ID` environment variables. |
| #92 | See the [`opensea-wallet`](../../opensea-wallet/SKILL.md) skill for Privy configuration. |
| #93 | |
| #94 | ### Using the SDK (TypeScript) |
| #95 | |
| #96 | ```typescript |
| #97 | import { OpenSeaCLI, PrivyAdapter } from '@opensea/cli'; |
| #98 | |
| #99 | const sdk = new OpenSeaCLI({ apiKey: process.env.OPENSEA_API_KEY }); |
| #100 | const wallet = PrivyAdapter.fromEnv(); |
| #101 | |
| #102 | const results = await sdk.swaps.execute({ |
| #103 | fromChain: 'base', |
| #104 | fromAddress: '0x0000000000000000000000000000000000000000', |
| #105 | toChain: 'base', |
| #106 | toAddress: '0xb695559b26bb2c9703ef1935c37aeae9526bab07', |
| #107 | quantity: '0.02', |
| #108 | }, wallet); |
| #109 | |
| #110 | for (const tx of results) { |
| #111 | console.log(`TX: ${tx.hash}`); |
| #112 | } |
| #113 | ``` |
| #114 | |
| #115 | ### Using the swap script |
| #116 | |
| #117 | ```bash |
| #118 | ./scripts/opensea-swap.sh <to_token_address> <amount> [chain] [from_token] |
| #119 | |
| #120 | # Example: Swap 0.02 ETH to MOLT on Base |
| #121 | ./scripts/opensea-swap.sh 0xb695559b26bb2c9703ef1935c37aeae9526bab07 0.02 base |
| #122 | ``` |
| #123 | |
| #124 | ## Finding Tokens |
| #125 | |
| #126 | ### Search by name |
| #127 | ```bash |
| #128 | mcporter call opensea.search_tokens --args '{"query": "MOLT", "chain": "base", "limit": 5}' |
| #129 | ``` |
| #130 | |
| #131 | ### Get trending tokens |
| #132 | ```bash |
| #133 | mcporter call opensea.get_trending_tokens --args '{"chains": ["base"], "limit": 10}' |
| #134 | ``` |
| #135 | |
| #136 | ### Get top tokens by volume |
| #137 | ```bash |
| #138 | mcporter call opensea.get_top_tokens --args '{"chains": ["base"], "limit": 10}' |
| #139 | ``` |
| #140 | |
| #141 | ## Checking Balances |
| #142 | |
| #143 | ```bash |
| #144 | mcporter call opensea.get_token_balances --args '{ |
| #145 | "address": "0xYourWallet", |
| #146 | "chains": ["base", "ethereum"] |
| #147 | }' |
| #148 | ``` |
| #149 | |
| #150 | ## Common Token Addresses (Base) |
| #151 | |
| #152 | | Token | Address | |
| #153 | |-------|---------| |
| #154 | | WETH | `0x4200000000000000000000000000000000000006` | |
| #155 | | USDC | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` | |
| #156 | | MOLT | `0xb695559b26bb2c9703ef1935c37aeae9526bab07` | |
| #157 | | CLAWD | `0x9f86db9fc6f7c9408e8fda3ff8ce4e78ac7a6b07` | |
| #158 | | 4CLAW | `0x3b94a3fa7f33930cf9fdc5f36cb251533c947b07` | |
| #159 | |
| #160 | ## Tips |
| #161 | |
| #162 | 1. **Use native ETH address** (`0x0000...0000`) when swapping from ETH |
| #163 | 2. **Check slippage** - High impact swaps may fail; consider smaller amounts |
| #164 | 3. **Quote expiration** - Execute quickly after getting quote; prices change |
| #165 | 4. **Gas estimation** - The returned value includes all costs |
| #166 | 5. **Cross-chain swaps** - Same-chain swaps are faster and cheaper |
| #167 |