@four-meme/four-meme-ai 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CLAUDE.md +91 -0
  2. package/README.md +79 -0
  3. package/bin/fourmeme.cjs +124 -0
  4. package/openclaw.plugin.json +11 -0
  5. package/package.json +55 -0
  6. package/plugin.ts +7 -0
  7. package/skills/four-meme-integration/SKILL.md +432 -0
  8. package/skills/four-meme-integration/references/api-create-token.md +55 -0
  9. package/skills/four-meme-integration/references/contract-addresses.md +34 -0
  10. package/skills/four-meme-integration/references/create-token-scripts.md +63 -0
  11. package/skills/four-meme-integration/references/errors.md +27 -0
  12. package/skills/four-meme-integration/references/event-listening.md +75 -0
  13. package/skills/four-meme-integration/references/execute-trade.md +31 -0
  14. package/skills/four-meme-integration/references/tax-token-query.md +38 -0
  15. package/skills/four-meme-integration/references/token-query-api.md +40 -0
  16. package/skills/four-meme-integration/references/token-tax-info.md +77 -0
  17. package/skills/four-meme-integration/scripts/8004-balance.ts +52 -0
  18. package/skills/four-meme-integration/scripts/8004-register.ts +108 -0
  19. package/skills/four-meme-integration/scripts/create-token-api.ts +251 -0
  20. package/skills/four-meme-integration/scripts/create-token-chain.ts +85 -0
  21. package/skills/four-meme-integration/scripts/execute-buy.ts +198 -0
  22. package/skills/four-meme-integration/scripts/execute-sell.ts +150 -0
  23. package/skills/four-meme-integration/scripts/get-public-config.ts +25 -0
  24. package/skills/four-meme-integration/scripts/get-recent-events.ts +76 -0
  25. package/skills/four-meme-integration/scripts/get-tax-token-info.ts +69 -0
  26. package/skills/four-meme-integration/scripts/get-token-info.ts +94 -0
  27. package/skills/four-meme-integration/scripts/quote-buy.ts +85 -0
  28. package/skills/four-meme-integration/scripts/quote-sell.ts +66 -0
  29. package/skills/four-meme-integration/scripts/send-token.ts +98 -0
  30. package/skills/four-meme-integration/scripts/token-get.ts +31 -0
  31. package/skills/four-meme-integration/scripts/token-list.ts +52 -0
  32. package/skills/four-meme-integration/scripts/token-rankings.ts +54 -0
  33. package/skills/four-meme-integration/scripts/verify-events.ts +47 -0
  34. package/tsconfig.json +15 -0
@@ -0,0 +1,432 @@
1
+ ---
2
+ name: four-meme-ai
3
+ description: |
4
+ CLI tool to create and trade meme tokens on four.meme (BSC only). Returns structured JSON for config, token info, quotes, events, and TaxToken tax info.
5
+
6
+ **AGENT MUST**: On first response to any user request related to fourmeme or this skill, **you must first** present to the user, **in this order: User Agreement, then Security Notice** (User Agreement = plugin nature and limitation of liability). **Present them in the user’s language**: use the 繁體中文 block if the user writes in Traditional Chinese, otherwise use the English block (see the bilingual section below). State clearly that by choosing to continue, the user agrees to the User Agreement. Until the user explicitly agrees or confirms to continue, you **must not** run any private-key or on-chain write operations (e.g. create-api, create-chain, buy, sell, send, 8004-register). Read-only commands (e.g. config, token-info, quote-buy, 8004-balance) may run while or after presenting the notice.
7
+
8
+ USE FOR:
9
+ - Creating meme tokens (API + chain) on BSC, including tax-type tokens
10
+ - Getting buy/sell quotes and token info via TokenManagerHelper3 (BSC only)
11
+ - Listening to TokenCreate, TokenPurchase, TokenSale, LiquidityAdded (TokenManager2, BSC)
12
+ - Querying TaxToken fee/tax config on-chain (BSC only)
13
+ - **Discover → detail → quote → execute**: use token-rankings / token-list / events to find tokens → token-get / token-info for details → quote-buy / quote-sell to estimate → buy / sell to execute (see "Agent workflow: buy/sell from rankings or events" below).
14
+
15
+ BSC only (Arbitrum/Base not supported). Requires npm install. Create/chain need PRIVATE_KEY. TokenManager V1 not supported.
16
+ **OpenClaw**: PRIVATE_KEY and BSC_RPC_URL are declared in metadata and injected by OpenClaw only when this skill is enabled (only this skill can access them). Configure in `~/.openclaw/openclaw.json` under `skills.entries["four-meme-ai"].env` or `apiKey`.
17
+ allowed-tools:
18
+ - Bash(fourmeme *)
19
+ - Bash(npx fourmeme *)
20
+ license: MIT
21
+ metadata:
22
+ {"author":"Four.meme AI Skill","version":"1.0.0","openclaw":{"requires":{"env":["PRIVATE_KEY"]},"primaryEnv":"PRIVATE_KEY"}}
23
+ ---
24
+
25
+ ## [Agent must follow] User agreement and security notice on first use
26
+
27
+ When responding to any user request about fourmeme or this skill, **you must first** present the content below in this order: **User Agreement, then Security Notice**, and state clearly that by choosing to continue, the user agrees to the User Agreement.
28
+ Until the user has explicitly agreed or confirmed to continue, **do not** run `create-api`, `create-chain`, `buy`, `sell`, `send`, or `8004-register` (any operation that uses the private key or writes to the chain). Read-only commands (e.g. `config`, `token-info`, `quote-buy`, `8004-balance`) may be run while or after presenting the notice.
29
+
30
+ **Language selection**: Present the User Agreement and Security Notice **in the user’s language**. If the user is writing in **Traditional Chinese (繁體中文)**, use the **繁體中文** block below; otherwise use the **English** block.
31
+
32
+ ---
33
+
34
+ ### User Agreement & Security Notice (繁體中文)
35
+
36
+ **用戶協議**
37
+
38
+ **前情提示**:使用本插件及本 skill 所涉功能(包括但不限於代幣創建、買賣、轉帳、8004 註冊等)前,請您閱讀以下協議。**若您選擇繼續使用本插件及本 skill 功能,即表示您已閱讀、理解並同意本協議。**
39
+
40
+ **本插件性質與責任限制**:本插件僅提供純本地的命令列互動能力(私鑰透過環境變數或本地設定使用),**不會收集、上傳或儲存您的私鑰**。因任何原因(包括但不限於插件被竄改、環境遭入侵、誤操作、第三方插件等)導致的私鑰洩露或資產損失,**本插件及提供方不承擔責任**。
41
+
42
+ **安全警示**
43
+
44
+ 使用本插件進行代幣創建、買賣、轉帳等操作時,請務必注意:
45
+
46
+ - **保護私鑰**:切勿在聊天對話中輸入、貼上或洩露私鑰;不要將私鑰分享給任何人或任何第三方。
47
+ - **交易錢包僅存小額資金**:用於執行操作的錢包(即提供 PRIVATE_KEY 的錢包)建議只存放少量資金,以降低因洩露或誤操作導致的損失。
48
+ - **及時轉出資金**:完成交易後,請及時將交易錢包中的資產轉移到您自己控制的、更安全的錢包或冷錢包中。
49
+ - **謹慎安裝 Agent/插件**:下載或安裝任何 Agent、瀏覽器插件或第三方工具時,請確認來源可信,避免惡意插件竊取私鑰或助記詞。
50
+
51
+ ---
52
+
53
+ ### User Agreement & Security Notice (English)
54
+
55
+ **User Agreement**
56
+
57
+ **Notice**: Before using this plugin and this skill (including but not limited to token creation, buy/sell, transfers, 8004 registration), please read the following. **By choosing to continue using this plugin and this skill, you have read, understood, and agreed to this agreement.**
58
+
59
+ **Plugin nature and limitation of liability**: This plugin provides local-only CLI interaction (private key is used via environment or local config). It **does not collect, upload, or store your private key**. The plugin and its providers **are not liable** for private key disclosure or asset loss due to any cause (including but not limited to tampered plugin, compromised environment, user error, or third-party plugins).
60
+
61
+ **Security Notice**
62
+
63
+ When using this plugin for token creation, trading, or transfers, please:
64
+
65
+ - **Protect your private key**: Do not type, paste, or expose your private key in chat; do not share it with anyone or any third party.
66
+ - **Keep only small amounts in the trading wallet**: The wallet used for operations (the one whose PRIVATE_KEY you provide) should hold only a small amount of funds to limit loss from disclosure or mistakes.
67
+ - **Move funds out promptly**: After trading, move assets from the trading wallet to a wallet or cold storage you control.
68
+ - **Install agents/plugins carefully**: When installing any agent, browser extension, or third-party tool, verify the source to avoid malware that could steal your private key or seed phrase.
69
+
70
+ ---
71
+
72
+ ## fourmeme capability overview
73
+
74
+ After you agree to the above and confirm to continue, this skill can help you with the following (all via the `fourmeme` CLI on BSC):
75
+
76
+ | Category | Capability | Description |
77
+ |----------|-------------|-------------|
78
+ | **Create** | Create token | Upload image + name/symbol/description/label; optional tax-token params; API returns signature then on-chain create. |
79
+ | **Query** | Public config | Get raisedToken and other public config (no auth). |
80
+ | **Query** | Token info (on-chain) | By address: version, tokenManager, price, offers (Helper3). |
81
+ | **Query** | Token list / detail / rankings | REST: filtered paginated list, single-token detail and trading info, hot/24h volume/newest/graduated rankings. |
82
+ | **Trading** | Buy/sell quotes | Estimate cost or proceeds for buy or sell (no transaction sent). |
83
+ | **Trading** | Execute buy | Buy a given token by amount or by quote spent (requires PRIVATE_KEY). |
84
+ | **Trading** | Execute sell | Sell a given token amount; optional minimum quote received (requires PRIVATE_KEY). |
85
+ | **Other** | Event listening | Fetch TokenCreate, TokenPurchase, TokenSale, LiquidityAdded on-chain. |
86
+ | **Other** | Tax token fees | Query on-chain fee and burn/dividend/liquidity config for a token. |
87
+ | **Other** | Send | Send BNB or ERC20 to a given address (requires PRIVATE_KEY). |
88
+ | **Other** | EIP-8004 | Register 8004 identity NFT; query balance by address. |
89
+
90
+ See the **CLI (fourmeme)** table and sections below for commands and arguments.
91
+
92
+ ---
93
+
94
+ # fourmeme CLI
95
+
96
+ BSC only; all commands output JSON. Run `fourmeme --help` for usage.
97
+
98
+ This skill provides: token creation (API + chain), buy/sell quotes and execution, token info/list/rankings, event listening, Tax token fee queries, send, and EIP-8004 identity NFT register and balance. Contract addresses and version notes: [references/contract-addresses.md](references/contract-addresses.md). **TokenManager V1 is not supported in this skill.**
99
+
100
+ ## Create token flow
101
+
102
+ ### 1. Ask user for required information (must be done first)
103
+
104
+ Before calling `create-api`, the Agent **must** ask the user for and confirm:
105
+
106
+ | Info | Required | Description |
107
+ |------|----------|-------------|
108
+ | **Image path** (imagePath) | Yes | Local logo path; jpeg/png/gif/bmp/webp |
109
+ | **Token name** (name) | Yes | Full token name |
110
+ | **Token symbol** (shortName) | Yes | e.g. MTK, DOGE |
111
+ | **Description** (desc) | Yes | Token description text |
112
+ | **Label** (label) | Yes | One of: Meme \| AI \| Defi \| Games \| Infra \| De-Sci \| Social \| Depin \| Charity \| Others |
113
+ | **Tax token?** | No | If yes, then ask for tokenTaxInfo (feeRate, four rates, recipientAddress, minSharing); see "Create token (full flow)" below |
114
+
115
+ Optional: WEB_URL, TWITTER_URL, TELEGRAM_URL, PRE_SALE, FEE_PLAN (AntiSniperFeeMode), etc.; may be provided by user or left at defaults.
116
+
117
+ ### 2. Technical flow (done by create-api / create-chain)
118
+
119
+ After collecting the above, execute in this order (handled by scripts or CLI):
120
+
121
+ 1. **Get nonce** — `POST /private/user/nonce/generate` with body accountAddress, verifyType, networkCode (BSC).
122
+ 2. **Login** — Sign `You are sign in Meme {nonce}` with wallet; `POST /private/user/login/dex` to get access_token.
123
+ 3. **Upload image** — `POST /private/token/upload` with access_token in header and image as body; get imgUrl.
124
+ 4. **Create (API)** — GET `/public/config` for raisedToken (do not modify); `POST /private/token/create` with name, shortName, desc, imgUrl, label, raisedToken, etc.; get createArg, signature.
125
+ 5. **Create (chain)** — Call `TokenManager2.createToken(createArg, sign)` on BSC to complete on-chain creation.
126
+
127
+ Commands: first `fourmeme create-api <imagePath> <name> <shortName> <desc> <label> [taxOptions.json]`, then `fourmeme create-chain <createArgHex> <signatureHex>`. Full API and parameters: [references/api-create-token.md](references/api-create-token.md); script flow and examples: [references/create-token-scripts.md](references/create-token-scripts.md); Tax token params: [references/token-tax-info.md](references/token-tax-info.md).
128
+
129
+ ## Agent workflow: buy/sell from rankings or events
130
+
131
+ This skill supports a flow to discover tokens, get details, quote, and execute. The following is an example workflow, not a trading recommendation: discover → detail → quote → execute.
132
+
133
+ 1. **Discover** (one or more of):
134
+ - **Rankings**: `fourmeme token-rankings <orderBy>` (orderBy = Hot, TradingDesc, Time, ProgressDesc, Graduated); use token addresses from the response.
135
+ - **List**: `fourmeme token-list [--orderBy=] [--labels=] ...` to filter and get addresses.
136
+ - **On-chain events**: `fourmeme events <fromBlock> [toBlock]`; parse token addresses from TokenCreate/TokenPurchase, etc., for “newly created” or “recent trades” strategies.
137
+ 2. **Get details**: For each candidate, call `fourmeme token-get <address>` (REST detail and trading info) or `fourmeme token-info <address>` (on-chain version, tokenManager, price, offers) to filter or display.
138
+ 3. **Quote**: `fourmeme quote-buy <token> <amountWei> [fundsWei]` / `fourmeme quote-sell <token> <amountWei>` for estimated cost or proceeds.
139
+ 4. **Execute**: `fourmeme buy ...` / `fourmeme sell ...` (requires PRIVATE_KEY). **Before executing, the Agent must confirm user intent** (e.g. user said “buy 0.05 BNB each for top 5 by 24h volume” or “auto-buy 0.01 BNB for new tokens”) and obtain explicit confirmation before first automated execution to avoid unauthorized use of funds.
140
+
141
+ When the user asks to “buy/sell based on rankings or activity”, the Agent should clarify: which ranking (hot, 24h volume, newest, graduated, etc.), amount per token, and whether to quote only or also execute; then run the appropriate commands.
142
+
143
+ ## Trading (Buy / Sell)
144
+
145
+ - **Version** – Use TokenManagerHelper3 `getTokenInfo(token)`. If `version === 1` use V1 TokenManager; if `version === 2` use TokenManager2 (and check for X Mode / TaxToken / AntiSniperFeeMode if needed).
146
+ - **Quote (pre-calc)** – TokenManagerHelper3:
147
+ - Buy: `tryBuy(token, amount, funds)` – use `amount > 0` for “buy X tokens”, or `funds > 0` for “spend X quote”.
148
+ - Sell: `trySell(token, amount)`.
149
+ - **Execute** – Use the `tokenManager` address from `getTokenInfo` and call the corresponding contract:
150
+ - V1: `purchaseToken` / `purchaseTokenAMAP`, `saleToken`.
151
+ - V2: `buyToken` / `buyTokenAMAP`, `sellToken`. For sell, user must `ERC20.approve(tokenManager, amount)` first.
152
+ - X Mode tokens: use TokenManager2 `buyToken(bytes args, uint256 time, bytes signature)` with encoded `BuyTokenParams`.
153
+
154
+ ## CLI (fourmeme)
155
+
156
+ Run `npx fourmeme --help` for usage. From project root after `npm install`, use **`npx fourmeme <command> [args]`** (local install does not add `fourmeme` to PATH; use `npm link` for global `fourmeme`).
157
+
158
+ ### OpenClaw config (PRIVATE_KEY / BSC_RPC_URL)
159
+
160
+ This skill declares `requires.env: ["PRIVATE_KEY"]` and `primaryEnv: "PRIVATE_KEY"` in metadata; OpenClaw injects them when an agent runs with **only this skill** enabled (other skills cannot access them).
161
+
162
+ - **apiKey**: Corresponds to `primaryEnv: "PRIVATE_KEY"`; you can enter the private key in the four-meme-ai skill’s `apiKey` field in the Skill management page.
163
+ - **env**: Injected into the agent process for this skill; BSC_RPC_URL can be set in the global env management page.
164
+
165
+ | Need | Command | When |
166
+ |------|---------|------|
167
+ | Public config | `fourmeme config` | Get raisedToken / config (no auth) |
168
+ | Token info (on-chain) | `fourmeme token-info <tokenAddress>` | Version, tokenManager, price, offers (BSC Helper3) |
169
+ | Token list (REST) | `fourmeme token-list [--orderBy=] [--pageIndex=] [--pageSize=] [--tokenName=] [--symbol=] [--labels=] [--listedPancake=]` | Filtered, paginated token list |
170
+ | Token detail (REST) | `fourmeme token-get <tokenAddress>` | Token detail and trading info (get/v2) |
171
+ | Token rankings (REST) | `fourmeme token-rankings <orderBy> [--barType=HOUR24]` | Time / ProgressDesc / TradingDesc / Hot / Graduated; barType for TradingDesc |
172
+ | Buy quote | `fourmeme quote-buy <token> <amountWei> [fundsWei]` | Estimate only; no transaction |
173
+ | Sell quote | `fourmeme quote-sell <token> <amountWei>` | Estimate only; no transaction |
174
+ | **Execute buy** | `fourmeme buy <token> amount <amountWei> <maxFundsWei>` | Buy fixed amount (needs PRIVATE_KEY) |
175
+ | **Execute buy** | `fourmeme buy <token> funds <fundsWei> <minAmountWei>` | Spend fixed quote (e.g. BNB) (needs PRIVATE_KEY) |
176
+ | **Execute sell** | `fourmeme sell <token> <amountWei> [minFundsWei]` | Sell (needs PRIVATE_KEY) |
177
+ | **Send** | `fourmeme send <toAddress> <amountWei> [tokenAddress]` | Send BNB or ERC20 to address (needs PRIVATE_KEY) |
178
+ | **EIP-8004 register** | `fourmeme 8004-register <name> [imageUrl] [description]` | Register 8004 identity NFT (needs PRIVATE_KEY) |
179
+ | **EIP-8004 query** | `fourmeme 8004-balance <ownerAddress>` | Query 8004 NFT balance (read-only) |
180
+ | Events | `fourmeme events <fromBlock> [toBlock]` | TokenCreate / Purchase / Sale / LiquidityAdded |
181
+ | Tax token info | `fourmeme tax-info <tokenAddress>` | Fee/tax config for TaxToken |
182
+ | Read-only check | `fourmeme verify` | Run config + events (last 50 blocks) |
183
+
184
+ Chain: **BSC only** (Arbitrum/Base not supported).
185
+
186
+ ### Create token (full flow)
187
+
188
+ **Agent interaction: ask about tax token and parameters before creating**
189
+
190
+ When the user asks to create a token, the Agent must ask in this order:
191
+
192
+ 1. **Tax token or not?**
193
+ Ask: “Do you want to create a tax (Tax) token? If not, it will be a normal token.”
194
+ - If **no**: use `fourmeme create-api <imagePath> <name> <shortName> <desc> <label>` (no sixth argument, no TAX_* env vars).
195
+ - If **yes**: continue to step 2.
196
+
197
+ 2. **Tax parameters** (only when user chose tax token)
198
+ Ask for (and explain constraints; see “tokenTaxInfo parameters” table below):
199
+ - **feeRate**: Fee rate (%). **Only 1, 3, 5, or 10.**
200
+ - **burnRate**, **divideRate**, **liquidityRate**, **recipientRate**: Four percentages; **sum must be 100**.
201
+ - If **recipientRate > 0**: ask **recipientAddress**.
202
+ - **minSharing**: Minimum token balance to participate in dividends (in ether units, e.g. 100000, 1000000).
203
+
204
+ Then either:
205
+ - **Option A**: Write `{ "tokenTaxInfo": { ... } }` to a JSON file and call `fourmeme create-api ... <path/to/tax.json>`.
206
+ - **Option B**: Set env vars TAX_TOKEN=1, TAX_FEE_RATE, TAX_BURN_RATE, TAX_DIVIDE_RATE, TAX_LIQUIDITY_RATE, TAX_RECIPIENT_RATE, TAX_RECIPIENT_ADDRESS (optional), TAX_MIN_SHARING, then run `fourmeme create-api <imagePath> <name> <shortName> <desc> <label>` (no sixth argument).
207
+
208
+ **Step 1 – Config (optional)**
209
+ ```bash
210
+ fourmeme config
211
+ ```
212
+
213
+ **Step 2 – Create token (API)**
214
+ Requires `PRIVATE_KEY` or `FOURMEME_PRIVATE_KEY`. Outputs `createArg` and `signature` (hex).
215
+
216
+ | Position | Argument | Description |
217
+ |----------|----------|-------------|
218
+ | 1 | `imagePath` | Local image path (jpeg/png/gif/bmp/webp) |
219
+ | 2 | `name` | Token full name |
220
+ | 3 | `shortName` | Token symbol (e.g. MTK) |
221
+ | 4 | `desc` | Description text |
222
+ | 5 | `label` | Category label (see list below) |
223
+ | 6 | `[taxOptions.json]` | Optional; path to JSON containing `tokenTaxInfo` for tax token |
224
+
225
+ **Label** (exactly one): `Meme` \| `AI` \| `Defi` \| `Games` \| `Infra` \| `De-Sci` \| `Social` \| `Depin` \| `Charity` \| `Others`.
226
+
227
+ **Optional env vars** (defaults if omitted): `WEB_URL`, `TWITTER_URL`, `TELEGRAM_URL`; `PRE_SALE` (default `"0"`); `FEE_PLAN` (`"true"` = AntiSniperFeeMode, default `"false"`).
228
+
229
+ ```bash
230
+ fourmeme create-api <imagePath> <name> <shortName> <desc> <label> [taxOptions.json]
231
+ # Example: fourmeme create-api ./logo.png MyToken MTK "Description" AI
232
+ # Tax: fourmeme create-api ./logo.png TaxToken TAX "Tax token" Meme tax.json
233
+ ```
234
+
235
+ **Tax token**
236
+ - **Option 1**: Last argument = path to JSON file with `{ "tokenTaxInfo": { ... } }`; fields see “tokenTaxInfo parameters” below.
237
+ - **Option 2**: Env vars: `TAX_TOKEN=1`, `TAX_FEE_RATE` (1|3|5|10), `TAX_BURN_RATE` / `TAX_DIVIDE_RATE` / `TAX_LIQUIDITY_RATE` / `TAX_RECIPIENT_RATE` (sum = 100), `TAX_RECIPIENT_ADDRESS`, `TAX_MIN_SHARING` (e.g. 100000). See [references/token-tax-info.md](references/token-tax-info.md).
238
+
239
+ **tokenTaxInfo parameters** (required for tax token, via JSON or env):
240
+
241
+ | Field | Type | Description | Constraint |
242
+ |-------|------|-------------|------------|
243
+ | `feeRate` | number | Trading fee rate (%) | **Only** `1`, `3`, `5`, `10` |
244
+ | `burnRate` | number | Burn share (%) | Sum with next three = 100 |
245
+ | `divideRate` | number | Dividend share (%) | Same |
246
+ | `liquidityRate` | number | Liquidity share (%) | Same |
247
+ | `recipientRate` | number | Recipient share (%) | 0 if unused |
248
+ | `recipientAddress` | string | Recipient address | `""` if unused |
249
+ | `minSharing` | number | Min balance for dividend (ether units) | d×10ⁿ, n≥5, 1≤d≤9; e.g. 100000, 1000000 |
250
+
251
+ Example (5% fee, 20% burn, 30% dividend, 40% liquidity, 10% recipient):
252
+
253
+ ```json
254
+ {
255
+ "tokenTaxInfo": {
256
+ "feeRate": 5,
257
+ "burnRate": 20,
258
+ "divideRate": 30,
259
+ "liquidityRate": 40,
260
+ "recipientRate": 10,
261
+ "recipientAddress": "0x1234567890123456789012345678901234567890",
262
+ "minSharing": 100000
263
+ }
264
+ }
265
+ ```
266
+
267
+ **Step 3 – Create token (chain)**
268
+ ```bash
269
+ fourmeme create-chain <createArgHex> <signatureHex>
270
+ # Or pipe: fourmeme create-api ... | fourmeme create-chain --
271
+ ```
272
+
273
+ #### Full automated create flow
274
+
275
+ To **create and submit on-chain in one go**, the Agent should:
276
+
277
+ 1. **Run create-api** to get signature data (same as Step 2 above; JSON with `createArg` and `signature`):
278
+ ```bash
279
+ fourmeme create-api <imagePath> <name> <shortName> <desc> <label> [taxOptions.json]
280
+ ```
281
+ Parse stdout JSON for `createArg` and `signature` (already hex strings).
282
+
283
+ 2. **Run create-chain** with those two values:
284
+ ```bash
285
+ fourmeme create-chain <createArgHex> <signatureHex>
286
+ ```
287
+ This calls `TokenManager2.createToken(createArg, sign)` on BSC and outputs tx result / token address.
288
+
289
+ 3. **Optional**: If the user said “create and go on-chain for me”, the Agent can run the two steps in sequence after collecting tax params, then summarize: success, `tokenAddress` / `requestId`, and main params (name, shortName, label, tax config).
290
+
291
+ ### token-info
292
+
293
+ ```bash
294
+ fourmeme token-info <tokenAddress>
295
+ ```
296
+ On-chain query (Helper3); returns version, tokenManager, price, offers, etc.
297
+
298
+ ### token-list / token-get / token-rankings (REST)
299
+
300
+ Four.meme REST API; use `Accept: application/json`; no login or cookie.
301
+
302
+ **Token list (filter / paginate)**
303
+ ```bash
304
+ fourmeme token-list [--orderBy=Hot] [--pageIndex=1] [--pageSize=30] [--tokenName=] [--symbol=] [--labels=] [--listedPancake=false]
305
+ ```
306
+
307
+ **Token detail and trading info**
308
+ ```bash
309
+ fourmeme token-get <tokenAddress>
310
+ ```
311
+ API: GET `/private/token/get/v2?address=...`
312
+
313
+ **Rankings**
314
+ ```bash
315
+ fourmeme token-rankings <orderBy> [--barType=HOUR24]
316
+ ```
317
+ orderBy: `Time` (newest) | `ProgressDesc` | `TradingDesc` (24h volume; barType HOUR24) | `Hot` | `Graduated`. Output JSON.
318
+
319
+ ### quote-buy / quote-sell (estimate only; no transaction)
320
+
321
+ ```bash
322
+ fourmeme quote-buy <tokenAddress> <amountWei> [fundsWei]
323
+ fourmeme quote-sell <tokenAddress> <amountWei>
324
+ ```
325
+ - amountWei: token amount (use 0 when buying by quote amount); fundsWei: quote to spend (omit or 0 when buying by token amount).
326
+
327
+ ### buy / sell (execute; requires PRIVATE_KEY)
328
+
329
+ **Buy** (one of):
330
+ - By amount: `fourmeme buy <token> amount <amountWei> <maxFundsWei>` (spend at most maxFundsWei to buy amountWei tokens).
331
+ - By funds: `fourmeme buy <token> funds <fundsWei> <minAmountWei>` (spend fundsWei quote, receive at least minAmountWei tokens).
332
+
333
+ **Sell**: Script performs approve then sell.
334
+ ```bash
335
+ fourmeme sell <tokenAddress> <amountWei> [minFundsWei]
336
+ ```
337
+ - minFundsWei optional (slippage: minimum quote received). V2 tokens only.
338
+
339
+ ### send (send BNB or ERC20 to an address)
340
+
341
+ Send **native BNB** or **ERC20** from the current wallet (PRIVATE_KEY) to a given address (BSC).
342
+
343
+ ```bash
344
+ fourmeme send <toAddress> <amountWei> [tokenAddress]
345
+ ```
346
+
347
+ | Argument | Description |
348
+ |----------|-------------|
349
+ | `toAddress` | Recipient address (0x...) |
350
+ | `amountWei` | Amount in wei (BNB or token smallest unit) |
351
+ | `tokenAddress` | Optional. Omit or use `BNB` / `0x0` for native BNB; otherwise ERC20 contract address |
352
+
353
+ - Env: `PRIVATE_KEY` or `FOURMEME_PRIVATE_KEY`. Optional: `BSC_RPC_URL`.
354
+ - Output: JSON with `txHash`, `to`, `amountWei`, `native` (whether BNB).
355
+
356
+ Examples:
357
+ ```bash
358
+ # Send 0.1 BNB (1e17 wei)
359
+ fourmeme send 0x1234...abcd 100000000000000000
360
+
361
+ # Send 1000 units of an ERC20 (18 decimals)
362
+ fourmeme send 0x1234...abcd 1000000000000000000000 0xTokenContractAddress
363
+ ```
364
+
365
+ ### EIP-8004 identity NFT (register and query)
366
+
367
+ EIP-8004 identity NFT: **register** (mint) and **query balance**. Default contract: `0x8004A169FB4a3325136EB29fA0ceB6D2e539a432` (BSC). Override with env `8004_NFT_ADDRESS` or `EIP8004_NFT_ADDRESS`.
368
+
369
+ **Register**: Requires `PRIVATE_KEY`. User provides name (required), image URL (optional), description (optional). CLI builds EIP-8004 payload (type, name, description, image, active, supportedTrust), encodes as `data:application/json;base64,<base64>` for `agentURI`, and calls `register(string agentURI)`.
370
+
371
+ ```bash
372
+ fourmeme 8004-register <name> [imageUrl] [description]
373
+ ```
374
+
375
+ | Argument | Description |
376
+ |----------|-------------|
377
+ | `name` | Required. Identity name |
378
+ | `imageUrl` | Optional. Avatar/image URL (must be publicly reachable) |
379
+ | `description` | Optional. Description |
380
+
381
+ - Output JSON: `txHash`, `agentId` (from event), `agentURI`.
382
+
383
+ **Query**: Read-only; number of 8004 NFTs held by an address.
384
+
385
+ ```bash
386
+ fourmeme 8004-balance <ownerAddress>
387
+ ```
388
+
389
+ - Output JSON: `owner`, `balance`.
390
+
391
+ Examples:
392
+ ```bash
393
+ fourmeme 8004-register "myagent" "https://example.com/logo.png" "My agent description"
394
+ fourmeme 8004-balance 0x1234567890123456789012345678901234567890
395
+ ```
396
+
397
+ ### events (TokenManager2 V2 only)
398
+
399
+ Fetch TokenCreate, TokenPurchase, TokenSale, LiquidityAdded on BSC.
400
+
401
+ ```bash
402
+ fourmeme events <fromBlock> [toBlock]
403
+ ```
404
+ Omit toBlock for latest. Real-time subscription: [references/event-listening.md](references/event-listening.md).
405
+
406
+ ### tax-info (TaxToken fee/tax)
407
+
408
+ Only for TaxToken (creatorType 5).
409
+
410
+ ```bash
411
+ fourmeme tax-info <tokenAddress>
412
+ ```
413
+ See [references/tax-token-query.md](references/tax-token-query.md).
414
+
415
+ ## API and config reference
416
+
417
+ - **Token detail (REST)**: `GET /private/token/get?address=<token>`, `GET /private/token/getById?id=<requestId>` (requestId from TokenCreate event). List/rankings: [references/token-query-api.md](references/token-query-api.md).
418
+ - **raisedToken**: `GET https://four.meme/meme-api/v1/public/config` for current raisedToken; use as-is in create body; do not modify its fields.
419
+
420
+ ## References
421
+
422
+ | Document | Description |
423
+ |----------|-------------|
424
+ | [contract-addresses.md](references/contract-addresses.md) | TokenManager / TokenManager2 / Helper3 addresses (BSC) |
425
+ | [api-create-token.md](references/api-create-token.md) | Create token API (nonce / login / upload / create) |
426
+ | [create-token-scripts.md](references/create-token-scripts.md) | Create token script flow and examples |
427
+ | [token-tax-info.md](references/token-tax-info.md) | Tax token tokenTaxInfo parameters and constraints |
428
+ | [token-query-api.md](references/token-query-api.md) | Token list / detail / rankings REST API |
429
+ | [errors.md](references/errors.md) | buy/sell error codes; X Mode / TaxToken / AntiSniperFeeMode |
430
+ | [execute-trade.md](references/execute-trade.md) | Execute buy/sell CLI and contract usage |
431
+ | [event-listening.md](references/event-listening.md) | TokenManager2 event listening (V2) |
432
+ | [tax-token-query.md](references/tax-token-query.md) | TaxToken on-chain fee/tax query (tax-info) |
@@ -0,0 +1,55 @@
1
+ # Four.meme API – Create Token
2
+
3
+ Base URL: `https://four.meme/meme-api/v1`
4
+
5
+ ## Endpoints (in order)
6
+
7
+ | Step | Method | Path | Description |
8
+ |------|--------|------|-------------|
9
+ | 1 | POST | `/private/user/nonce/generate` | Get nonce |
10
+ | 2 | POST | `/private/user/login/dex` | Login → access_token |
11
+ | 3 | POST | `/private/token/upload` | Upload image → imgUrl |
12
+ | 4 | POST | `/private/token/create` | Create → createArg, signature |
13
+
14
+ ## 1. Nonce
15
+
16
+ - **URL**: `https://four.meme/meme-api/v1/private/user/nonce/generate`
17
+ - **Body**: `{ "accountAddress": "<wallet>", "verifyType": "LOGIN", "networkCode": "BSC" }`
18
+ - **Response**: `{ "code": "0", "data": "<nonce>" }`
19
+
20
+ ## 2. Login
21
+
22
+ - **URL**: `https://four.meme/meme-api/v1/private/user/login/dex`
23
+ - **Body**: Include `verifyInfo.signature` = sign(`You are sign in Meme {nonce}`) with wallet, `verifyInfo.address`, `verifyInfo.networkCode` ("BSC"), `verifyInfo.verifyType` ("LOGIN"), plus region, langType, walletName, etc.
24
+ - **Response**: `{ "code": "0", "data": "<access_token>" }`
25
+
26
+ ## 3. Upload image
27
+
28
+ - **URL**: `https://four.meme/meme-api/v1/private/token/upload`
29
+ - **Headers**: `meme-web-access: <access_token>`, `Content-Type: multipart/form-data`
30
+ - **Body**: `file` = image (jpeg/png/gif/bmp/webp)
31
+ - **Response**: `{ "code": "0", "data": "<imgUrl>" }`
32
+
33
+ ## 4. Create token
34
+
35
+ - **URL**: `https://four.meme/meme-api/v1/private/token/create`
36
+ - **Headers**: `meme-web-access: <access_token>`, `Content-Type: application/json`
37
+ - **Body**: **Required**: **raisedAmount** (raise amount; use 24 or raisedToken.totalBAmount from public config), **raisedToken** (from `GET /public/config`; do not modify). Customizable: name, shortName, desc, imgUrl, launchTime, label, lpTradingFee (0.0025), webUrl, twitterUrl, telegramUrl, preSale, onlyMPC, feePlan, tokenTaxInfo (optional).
38
+ - **Response**: `{ "code": "0", "data": { "createArg": "...", "signature": "..." } }`
39
+
40
+ Then call **TokenManager2.createToken(createArg, sign)** on BSC with these values (as bytes).
41
+
42
+ ## Labels
43
+
44
+ Meme, AI, Defi, Games, Infra, De-Sci, Social, Depin, Charity, Others.
45
+
46
+ ## tokenTaxInfo (optional; Tax-type token)
47
+
48
+ Omit to create a normal token; include to create a tax-type token.
49
+
50
+ - **feeRate**: Trading fee; must be **1, 3, 5, or 10** (1%/3%/5%/10%).
51
+ - **burnRate**, **divideRate**, **liquidityRate**, **recipientRate**: All percentages; **sum of the four must be 100**.
52
+ - **recipientAddress**: Address that receives the recipient share; use `""` when not used, and **recipientRate = 0**.
53
+ - **minSharing**: Min balance to participate in dividends (ether units); must satisfy **minSharing = d×10ⁿ**, n≥5, 1≤d≤9, e.g. 100000, 1000000.
54
+
55
+ Full field description and examples: [token-tax-info.md](token-tax-info.md).
@@ -0,0 +1,34 @@
1
+ # Four.meme Contract Addresses (BSC only)
2
+
3
+ This skill supports **BSC only** (chainId 56). Arbitrum and Base are not supported.
4
+
5
+ ## TokenManager (V1)
6
+
7
+ Used for tokens created **before** September 5, 2024. Only trading (no create).
8
+
9
+ | Chain | Address |
10
+ |-------|---------|
11
+ | BSC | `0xEC4549caDcE5DA21Df6E6422d448034B5233bFbC` |
12
+
13
+ ## TokenManager2 (V2)
14
+
15
+ Used for tokens created **after** September 5, 2024. Create and trade.
16
+
17
+ | Chain | Address |
18
+ |-------|---------|
19
+ | BSC | `0x5c952063c7fc8610FFDB798152D69F0B9550762b` |
20
+
21
+ ## TokenManagerHelper3 (V3)
22
+
23
+ Use for **getTokenInfo**, **tryBuy**, **trySell**. Supports both V1 and V2 tokens.
24
+
25
+ | Chain | Address |
26
+ |-------|---------|
27
+ | BSC | `0xF251F83e40a78868FcfA3FA4599Dad6494E46034` |
28
+
29
+ ## Usage
30
+
31
+ 1. Call **TokenManagerHelper3.getTokenInfo(token)** to get `version` and `tokenManager`.
32
+ 2. If `version === 1` → use TokenManager V1 for buy/sell.
33
+ 3. If `version === 2` → use TokenManager2 for buy/sell (and check X Mode / TaxToken / AntiSniperFeeMode if needed).
34
+ 4. Token creation is only via **TokenManager2** on BSC after obtaining `createArg` and `signature` from the four.meme API.
@@ -0,0 +1,63 @@
1
+ # Create Token Scripts (Four.meme)
2
+
3
+ ## One-shot flow
4
+
5
+ 1. **get-public-config.ts** (optional)
6
+ Fetches `raisedToken` from `https://four.meme/meme-api/v1/public/config`. Use when building the create body manually.
7
+
8
+ 2. **create-token-api.ts**
9
+ - Env: `PRIVATE_KEY` or `FOURMEME_PRIVATE_KEY`.
10
+ - Args: `imagePath`, `name`, `shortName`, `desc`, `label`.
11
+ - Optional env: `WEB_URL`, `TWITTER_URL`, `TELEGRAM_URL`, `PRE_SALE` (default `"0"`), `FEE_PLAN` (default `"false"`).
12
+ - Performs: nonce → login (signs `You are sign in Meme {nonce}`) → upload image → GET public config → POST create.
13
+ - Output: JSON `{ "createArg": "0x...", "signature": "0x..." }`.
14
+
15
+ 3. **create-token-chain.ts**
16
+ - Env: same key for wallet; optional `BSC_RPC_URL`, `CREATION_FEE_WEI` (set if you need to attach extra BNB; default 0).
17
+ - Input: `createArg` and `signature` (hex) as args or JSON on stdin (`--`).
18
+ - Calls `TokenManager2.createToken(createArg, sign)` on BSC.
19
+
20
+ ## Example (piped)
21
+
22
+ ```bash
23
+ export PRIVATE_KEY=your_hex_private_key
24
+ npx tsx skills/four-meme-integration/scripts/create-token-api.ts ./logo.png MyToken MTK "My desc" AI \
25
+ | npx tsx skills/four-meme-integration/scripts/create-token-chain.ts --
26
+ ```
27
+
28
+ ## Example (two steps)
29
+
30
+ ```bash
31
+ export PRIVATE_KEY=your_hex_private_key
32
+ npx tsx skills/four-meme-integration/scripts/create-token-api.ts ./logo.png MyToken MTK "My desc" AI > create-out.json
33
+ npx tsx skills/four-meme-integration/scripts/create-token-chain.ts "$(jq -r .createArg create-out.json)" "$(jq -r .signature create-out.json)"
34
+ ```
35
+
36
+ ## Tax token
37
+
38
+ Pass a JSON file path as the last argument; the file must contain `tokenTaxInfo`. Example:
39
+
40
+ **tax-options.json**:
41
+ ```json
42
+ {
43
+ "tokenTaxInfo": {
44
+ "feeRate": 5,
45
+ "burnRate": 20,
46
+ "divideRate": 30,
47
+ "liquidityRate": 40,
48
+ "recipientRate": 10,
49
+ "recipientAddress": "0x1234567890123456789012345678901234567890",
50
+ "minSharing": 100000
51
+ }
52
+ }
53
+ ```
54
+
55
+ Requirements: `feeRate` must be 1, 3, 5, or 10; `burnRate + divideRate + liquidityRate + recipientRate = 100`. See [token-tax-info.md](token-tax-info.md).
56
+
57
+ ```bash
58
+ npx tsx .../create-token-api.ts ./logo.png TaxToken TAX "Tax token" AI tax-options.json
59
+ ```
60
+
61
+ You can also use env vars: `TAX_TOKEN=1`, `TAX_FEE_RATE=5`, `TAX_BURN_RATE=20`, `TAX_DIVIDE_RATE=30`, `TAX_LIQUIDITY_RATE=40`, `TAX_RECIPIENT_RATE=10`, `TAX_RECIPIENT_ADDRESS=0x...`, `TAX_MIN_SHARING=100000`.
62
+
63
+ Chain and Labels: see [SKILL.md](../SKILL.md) or [api-create-token.md](api-create-token.md).
@@ -0,0 +1,27 @@
1
+ # Four.meme Error Codes
2
+
3
+ ## buyToken
4
+
5
+ | Code | Meaning |
6
+ |-----------|---------|
7
+ | GW (GWEI) | Amount precision not aligned to GWEI |
8
+ | ZA | Zero Address – `to` must not be address(0) |
9
+ | TO | Invalid to – `to` must not be PancakePair address |
10
+ | Slippage | Spent amount &gt; maxFunds |
11
+ | More BNB | Insufficient BNB in msg.value |
12
+ | A | X Mode token bought with wrong method – use X Mode buy |
13
+
14
+ ## sellToken
15
+
16
+ | Code | Meaning |
17
+ |----------|---------|
18
+ | GW (GWEI)| Amount precision not aligned to GWEI |
19
+ | FR (FeeRate) | Fee rate &gt; 5% |
20
+ | SO (Small Order) | Order amount too small |
21
+ | Slippage | Received amount &lt; minFunds |
22
+
23
+ ## Identification
24
+
25
+ - **X Mode (exclusive)**: Off-chain – API token info `version === "V8"`. On-chain – `TokenManager2._tokenInfos[token].template & 0x10000 > 0`.
26
+ - **TaxToken**: Off-chain – API response has `taxInfo`. On-chain – `(template >> 10) & 0x3F === 5`.
27
+ - **AntiSniperFeeMode**: Off-chain – API `feePlan === true`. On-chain – `TokenManager2._tokenInfoEx1s[token].feeSetting > 0`.