@four-meme/four-meme-ai 1.0.4 → 1.0.6

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.
@@ -1,34 +1,47 @@
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.
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
+ ## AgentIdentifier (BSC)
30
+
31
+ Used to check if a wallet is an **Agent wallet** (holds an Agent NFT). See [agent-creator-and-wallets.md](agent-creator-and-wallets.md).
32
+
33
+ | Chain | Address |
34
+ |-------|---------|
35
+ | BSC | `0x09B44A633de9F9EBF6FB9Bdd5b5629d3DD2cef13` |
36
+
37
+ - **Interface**: `isAgent(address wallet)`, `nftCount()`, `nftAt(uint256 index)`.
38
+
39
+ ---
40
+
41
+ ## Usage
42
+
43
+ 1. Call **TokenManagerHelper3.getTokenInfo(token)** to get `version` and `tokenManager`.
44
+ 2. If `version === 1` → use TokenManager V1 for buy/sell.
45
+ 3. If `version === 2` → use TokenManager2 for buy/sell (and check X Mode / TaxToken / AntiSniperFeeMode if needed).
46
+ 4. Token creation is only via **TokenManager2** on BSC after obtaining `createArg` and `signature` from the four.meme API.
47
+ 5. **Agent Creator**: Token created by agent wallet — on-chain `(template & (1 << 85)) != 0`; off-chain API `data.aiCreator === true`. Agent wallets: call **AgentIdentifier.isAgent(wallet)** on BSC.
@@ -1,63 +1,111 @@
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`.
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).
1
+ # Create Token Scripts (Four.meme)
2
+
3
+ ## One-shot (create-token-instant)
4
+
5
+ **create-token-instant.ts** runs API create + on-chain submit in one command. Same args as create-token-api; on success submits createToken and outputs `txHash`.
6
+
7
+ ```bash
8
+ # Same as create-token-api, all --key=value
9
+ npx tsx .../create-token-instant.ts --image=./logo.png --name=MyToken --short-name=MTK --desc="My desc" --label=AI
10
+ # Or via CLI
11
+ fourmeme create-instant --image=./logo.png --name=MyToken --short-name=MTK --desc="My desc" --label=AI
12
+ ```
13
+
14
+ Optional `--value=wei` overrides the value; otherwise API output `creationFeeWei` is used. Env: `PRIVATE_KEY`, optional `BSC_RPC_URL`.
15
+
16
+ ---
17
+
18
+ ## Step-by-step flow
19
+
20
+ 1. **get-public-config.ts** (optional)
21
+ Fetches `raisedToken` from `https://four.meme/meme-api/v1/public/config`. Use when building the create body manually.
22
+
23
+ 2. **create-token-api.ts**
24
+ - All options as `--key=value`; no positionals.
25
+ - Required: `--image=`, `--name=`, `--short-name=`, `--desc=`, `--label=`.
26
+ - Optional: `--web-url=`, `--twitter-url=`, `--telegram-url=` (only sent when non-empty); `--pre-sale=0` (**presale in ether units**, e.g. `0.001` for 0.001 BNB, not wei); `--fee-plan=false`, `--tax-options=<path>`.
27
+ - Tax token: `--tax-options=tax.json` or `--tax-token` with `--tax-fee-rate=5` etc. (burn+divide+liquidity+recipient=100).
28
+ - Env: `PRIVATE_KEY`; RPC via `BSC_RPC_URL`.
29
+ - Flow: nonce → login → upload image → GET public config → POST create.
30
+ - Output: JSON `{ "createArg", "signature", "creationFeeWei" }`; script hints required value for chain step.
31
+
32
+ 3. **create-token-chain.ts**
33
+ - Env: `PRIVATE_KEY`.
34
+ - Input: `createArg`, `signature` (positional or stdin JSON with `--`).
35
+ - Optional (CLI overrides env): `--value=<wei>` (env `CREATION_FEE_WEI`). RPC via env `BSC_RPC_URL`.
36
+ - Calls `TokenManager2.createToken(createArg, sign)`; excess BNB is refunded by the contract.
37
+
38
+ ## createToken value (CREATION_FEE_WEI) formula
39
+
40
+ **Formula**
41
+
42
+ - **No presale (or quote is ERC20)**
43
+ `value = launch_fee`
44
+ `launch_fee`: read from TokenManager2 `_launchFee()` (wei).
45
+
46
+ - **With presale and quote is BNB**
47
+ `value = launch_fee + presale_wei + trading_fee`
48
+ - `presale_wei`: presale amount in wei (API sends preSale in BNB/ether; script converts to wei for value).
49
+ - `trading_fee`: see below.
50
+
51
+ **How to compute trading_fee**
52
+
53
+ - Contract uses basis-point rate: `trading_fee = presale_wei × fee_rate / 10000` (integer division).
54
+ - `fee_rate` from TokenManager2 `_tradingFeeRate()` (basis points).
55
+ - If the contract enforces a minimum fee per trade, use `max(computed trading_fee, minimum_fee)`.
56
+
57
+ ## Example (piped)
58
+
59
+ ```bash
60
+ export PRIVATE_KEY=your_hex_private_key
61
+ npx tsx skills/four-meme-integration/scripts/create-token-api.ts --image=./logo.png --name=MyToken --short-name=MTK --desc="My desc" --label=AI \
62
+ | npx tsx skills/four-meme-integration/scripts/create-token-chain.ts --
63
+ ```
64
+
65
+ The chain script reads `creationFeeWei` from stdin JSON when present; you can also pass `--value=<wei>` explicitly.
66
+
67
+ ## Example (two steps)
68
+
69
+ ```bash
70
+ export PRIVATE_KEY=your_hex_private_key
71
+ npx tsx skills/four-meme-integration/scripts/create-token-api.ts --image=./logo.png --name=MyToken --short-name=MTK --desc="My desc" --label=AI > create-out.json
72
+ npx tsx skills/four-meme-integration/scripts/create-token-chain.ts "$(jq -r .createArg create-out.json)" "$(jq -r .signature create-out.json)" --value=$(jq -r .creationFeeWei create-out.json)
73
+ ```
74
+
75
+ ## Example (with presale)
76
+
77
+ `--pre-sale` is in **ether units** (e.g. `0.001` = 0.001 BNB; do not pass wei).
78
+
79
+ ```bash
80
+ npx tsx .../create-token-api.ts --image=./logo.png --name=MyToken --short-name=MTK --desc="My desc" --label=AI --pre-sale=0.01
81
+ ```
82
+
83
+ ## Tax token
84
+
85
+ Tax options file must contain `tokenTaxInfo`. Example **tax-options.json**:
86
+
87
+ ```json
88
+ {
89
+ "tokenTaxInfo": {
90
+ "feeRate": 5,
91
+ "burnRate": 20,
92
+ "divideRate": 30,
93
+ "liquidityRate": 40,
94
+ "recipientRate": 10,
95
+ "recipientAddress": "0x1234567890123456789012345678901234567890",
96
+ "minSharing": 100000
97
+ }
98
+ }
99
+ ```
100
+
101
+ `feeRate` must be 1, 3, 5, or 10; burn+divide+liquidity+recipient=100. See [token-tax-info.md](token-tax-info.md).
102
+
103
+ ```bash
104
+ # Option A: --tax-options= path to JSON file
105
+ npx tsx .../create-token-api.ts --image=./logo.png --name=TaxToken --short-name=TAX --desc="Tax token" --label=AI --tax-options=tax-options.json
106
+
107
+ # Option B: --tax-token with rate args
108
+ npx tsx .../create-token-api.ts --image=./logo.png --name=TaxToken --short-name=TAX --desc="Tax token" --label=AI --tax-token --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
109
+ ```
110
+
111
+ Chain and Labels: see [SKILL.md](../SKILL.md) or [api-create-token.md](api-create-token.md).
@@ -1,27 +1,29 @@
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`.
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`.
28
+ - **Token created by Agent Creator**: Off-chain – API `data.aiCreator === true`. On-chain – `(TokenManager2._tokenInfos[token].template & (1 << 85)) != 0`. Does not change trading behavior.
29
+ - **Agent wallets**: Call **AgentIdentifier.isAgent(wallet)** on BSC; see [agent-creator-and-wallets.md](agent-creator-and-wallets.md) and [contract-addresses.md](contract-addresses.md).
@@ -1,75 +1,75 @@
1
- # Event listening (TokenManager2, V2 only)
2
-
3
- Only **TokenManager2 (V2)** is supported. V1 is not supported. Contract address (BSC): `0x5c952063c7fc8610FFDB798152D69F0B9550762b`.
4
-
5
- The agent can react to **token creation, buy/sell, and liquidity add** by listening to the events below (e.g. copy-trading).
6
-
7
- ## Event list
8
-
9
- | Event | Meaning | Main args |
10
- |-----------------|-------------------|---------------------------------------------------------------------------|
11
- | **TokenCreate** | New token created | `creator`, `token`, `requestId`, `name`, `symbol`, `totalSupply`, `launchTime`, `launchFee` |
12
- | **TokenPurchase** | Buy | `token`, `account`, `price`, `amount`, `cost`, `fee`, `offers`, `funds` |
13
- | **TokenSale** | Sell | `token`, `account`, `price`, `amount`, `cost`, `fee`, `offers`, `funds` |
14
- | **LiquidityAdded** | Liquidity added | `base`, `offers`, `quote`, `funds` |
15
-
16
- - **TokenCreate**: With `token` (new token address) and `requestId`, you can call Helper3 `getTokenInfo(token)` or execute buy/sell immediately.
17
- - **TokenPurchase / TokenSale**: Use for copy-trading, stats, etc.; `token` is the token address, `account` is the buyer/seller.
18
- - **LiquidityAdded**: `base` is the token address; the token has been added to the pool and can be traded on the DEX.
19
-
20
- ## How to listen (viem)
21
-
22
- ### Option 1: Poll historical blocks with `getLogs`
23
-
24
- ```typescript
25
- import { createPublicClient, http, parseAbiItem } from 'viem';
26
- import { bsc } from 'viem/chains';
27
-
28
- const TOKEN_MANAGER2 = '0x5c952063c7fc8610FFDB798152D69F0B9550762b';
29
-
30
- const client = createPublicClient({
31
- chain: bsc,
32
- transport: http(process.env.BSC_RPC_URL || 'https://bsc-dataseed.binance.org'),
33
- });
34
-
35
- const logs = await client.getLogs({
36
- address: TOKEN_MANAGER2,
37
- events: [
38
- parseAbiItem('event TokenCreate(address creator, address token, uint256 requestId, string name, string symbol, uint256 totalSupply, uint256 launchTime, uint256 launchFee)'),
39
- parseAbiItem('event TokenPurchase(address token, address account, uint256 price, uint256 amount, uint256 cost, uint256 fee, uint256 offers, uint256 funds)'),
40
- parseAbiItem('event TokenSale(address token, address account, uint256 price, uint256 amount, uint256 cost, uint256 fee, uint256 offers, uint256 funds)'),
41
- parseAbiItem('event LiquidityAdded(address base, uint256 offers, address quote, uint256 funds)'),
42
- ],
43
- fromBlock: fromBlockNumber,
44
- toBlock: toBlockNumber,
45
- });
46
- ```
47
-
48
- ### Option 2: Real-time subscription with `watchContractEvent`
49
-
50
- ```typescript
51
- import { createPublicClient, http, parseAbiItem } from 'viem';
52
- import { bsc } from 'viem/chains';
53
-
54
- const client = createPublicClient({ chain: bsc, transport: http(rpcUrl) });
55
-
56
- const unwatch = client.watchContractEvent({
57
- address: TOKEN_MANAGER2,
58
- events: [
59
- parseAbiItem('event TokenCreate(address creator, address token, uint256 requestId, string name, string symbol, uint256 totalSupply, uint256 launchTime, uint256 launchFee)'),
60
- parseAbiItem('event TokenPurchase(address token, address account, uint256 price, uint256 amount, uint256 cost, uint256 fee, uint256 offers, uint256 funds)'),
61
- parseAbiItem('event TokenSale(address token, address account, uint256 price, uint256 amount, uint256 cost, uint256 fee, uint256 offers, uint256 funds)'),
62
- parseAbiItem('event LiquidityAdded(address base, uint256 offers, address quote, uint256 funds)'),
63
- ],
64
- onLogs: (logs) => {
65
- for (const log of logs) {
66
- console.log(log.eventName, log.args);
67
- }
68
- },
69
- });
70
- // To stop: unwatch()
71
- ```
72
-
73
- ## Script
74
-
75
- Use `fourmeme events <fromBlock> [toBlock]` (script `get-recent-events.ts`) to fetch the four event types in a block range and output JSON. See the events section in [SKILL.md](../SKILL.md).
1
+ # Event listening (TokenManager2, V2 only)
2
+
3
+ Only **TokenManager2 (V2)** is supported. V1 is not supported. Contract address (BSC): `0x5c952063c7fc8610FFDB798152D69F0B9550762b`.
4
+
5
+ The agent can react to **token creation, buy/sell, and liquidity add** by listening to the events below (e.g. copy-trading).
6
+
7
+ ## Event list
8
+
9
+ | Event | Meaning | Main args |
10
+ |-----------------|-------------------|---------------------------------------------------------------------------|
11
+ | **TokenCreate** | New token created | `creator`, `token`, `requestId`, `name`, `symbol`, `totalSupply`, `launchTime`, `launchFee` |
12
+ | **TokenPurchase** | Buy | `token`, `account`, `price`, `amount`, `cost`, `fee`, `offers`, `funds` |
13
+ | **TokenSale** | Sell | `token`, `account`, `price`, `amount`, `cost`, `fee`, `offers`, `funds` |
14
+ | **LiquidityAdded** | Liquidity added | `base`, `offers`, `quote`, `funds` |
15
+
16
+ - **TokenCreate**: With `token` (new token address) and `requestId`, you can call Helper3 `getTokenInfo(token)` or execute buy/sell immediately.
17
+ - **TokenPurchase / TokenSale**: Use for copy-trading, stats, etc.; `token` is the token address, `account` is the buyer/seller.
18
+ - **LiquidityAdded**: `base` is the token address; the token has been added to the pool and can be traded on the DEX.
19
+
20
+ ## How to listen (viem)
21
+
22
+ ### Option 1: Poll historical blocks with `getLogs`
23
+
24
+ ```typescript
25
+ import { createPublicClient, http, parseAbiItem } from 'viem';
26
+ import { bsc } from 'viem/chains';
27
+
28
+ const TOKEN_MANAGER2 = '0x5c952063c7fc8610FFDB798152D69F0B9550762b';
29
+
30
+ const client = createPublicClient({
31
+ chain: bsc,
32
+ transport: http(process.env.BSC_RPC_URL || 'https://bsc-dataseed.binance.org'),
33
+ });
34
+
35
+ const logs = await client.getLogs({
36
+ address: TOKEN_MANAGER2,
37
+ events: [
38
+ parseAbiItem('event TokenCreate(address creator, address token, uint256 requestId, string name, string symbol, uint256 totalSupply, uint256 launchTime, uint256 launchFee)'),
39
+ parseAbiItem('event TokenPurchase(address token, address account, uint256 price, uint256 amount, uint256 cost, uint256 fee, uint256 offers, uint256 funds)'),
40
+ parseAbiItem('event TokenSale(address token, address account, uint256 price, uint256 amount, uint256 cost, uint256 fee, uint256 offers, uint256 funds)'),
41
+ parseAbiItem('event LiquidityAdded(address base, uint256 offers, address quote, uint256 funds)'),
42
+ ],
43
+ fromBlock: fromBlockNumber,
44
+ toBlock: toBlockNumber,
45
+ });
46
+ ```
47
+
48
+ ### Option 2: Real-time subscription with `watchContractEvent`
49
+
50
+ ```typescript
51
+ import { createPublicClient, http, parseAbiItem } from 'viem';
52
+ import { bsc } from 'viem/chains';
53
+
54
+ const client = createPublicClient({ chain: bsc, transport: http(rpcUrl) });
55
+
56
+ const unwatch = client.watchContractEvent({
57
+ address: TOKEN_MANAGER2,
58
+ events: [
59
+ parseAbiItem('event TokenCreate(address creator, address token, uint256 requestId, string name, string symbol, uint256 totalSupply, uint256 launchTime, uint256 launchFee)'),
60
+ parseAbiItem('event TokenPurchase(address token, address account, uint256 price, uint256 amount, uint256 cost, uint256 fee, uint256 offers, uint256 funds)'),
61
+ parseAbiItem('event TokenSale(address token, address account, uint256 price, uint256 amount, uint256 cost, uint256 fee, uint256 offers, uint256 funds)'),
62
+ parseAbiItem('event LiquidityAdded(address base, uint256 offers, address quote, uint256 funds)'),
63
+ ],
64
+ onLogs: (logs) => {
65
+ for (const log of logs) {
66
+ console.log(log.eventName, log.args);
67
+ }
68
+ },
69
+ });
70
+ // To stop: unwatch()
71
+ ```
72
+
73
+ ## Script
74
+
75
+ Use `fourmeme events <fromBlock> [toBlock]` (script `get-recent-events.ts`) to fetch the four event types in a block range and output JSON. See the events section in [SKILL.md](../SKILL.md).
@@ -1,31 +1,31 @@
1
- # Execute Buy / Sell (Four.meme BSC)
2
-
3
- Executes buy/sell (sends on-chain transactions). Requires `PRIVATE_KEY`. Only **TokenManager2 (V2)** tokens are supported.
4
-
5
- ## Buy
6
-
7
- - **By amount**: `buyToken(token, amount, maxFunds)`
8
- CLI: `fourmeme buy <token> amount <amountWei> <maxFundsWei>`
9
- Meaning: Spend at most `maxFundsWei` of quote (BNB or BEP20) to buy `amountWei` tokens.
10
-
11
- - **By funds**: `buyTokenAMAP(token, funds, minAmount)`
12
- CLI: `fourmeme buy <token> funds <fundsWei> <minAmountWei>`
13
- Meaning: Spend `fundsWei` of quote and receive at least `minAmountWei` tokens.
14
-
15
- If quote is BEP20 (not BNB), the script will `approve` TokenManager2 first, then send the buy transaction.
16
-
17
- ## Sell
18
-
19
- - Contract requirement: First `approve(tokenManager, amount)` on TokenManager2, then call `sellToken(token, amount)` or `sellToken(origin, token, amount, minFunds)` for slippage protection.
20
- - The CLI runs approve then sell automatically; no need to do both manually.
21
-
22
- ```bash
23
- fourmeme sell <tokenAddress> <amountWei> [minFundsWei]
24
- ```
25
-
26
- - `minFundsWei` is optional: minimum quote to receive (slippage protection).
27
-
28
- ## Relation to quote commands
29
-
30
- - `quote-buy` / `quote-sell`: Read-only estimates; no transaction is sent.
31
- - `buy` / `sell`: Actually send transactions. Recommended: use `quote-buy` / `quote-sell` first to get estimates, then choose `maxFundsWei`, `minAmountWei`, `minFundsWei` and call `buy` / `sell`.
1
+ # Execute Buy / Sell (Four.meme BSC)
2
+
3
+ Executes buy/sell (sends on-chain transactions). Requires `PRIVATE_KEY`. Only **TokenManager2 (V2)** tokens are supported.
4
+
5
+ ## Buy
6
+
7
+ - **By amount**: `buyToken(token, amount, maxFunds)`
8
+ CLI: `fourmeme buy <token> amount <amountWei> <maxFundsWei>`
9
+ Meaning: Spend at most `maxFundsWei` of quote (BNB or BEP20) to buy `amountWei` tokens.
10
+
11
+ - **By funds**: `buyTokenAMAP(token, funds, minAmount)`
12
+ CLI: `fourmeme buy <token> funds <fundsWei> <minAmountWei>`
13
+ Meaning: Spend `fundsWei` of quote and receive at least `minAmountWei` tokens.
14
+
15
+ If quote is BEP20 (not BNB), the script will `approve` TokenManager2 first, then send the buy transaction.
16
+
17
+ ## Sell
18
+
19
+ - Contract requirement: First `approve(tokenManager, amount)` on TokenManager2, then call `sellToken(token, amount)` or `sellToken(origin, token, amount, minFunds)` for slippage protection.
20
+ - The CLI runs approve then sell automatically; no need to do both manually.
21
+
22
+ ```bash
23
+ fourmeme sell <tokenAddress> <amountWei> [minFundsWei]
24
+ ```
25
+
26
+ - `minFundsWei` is optional: minimum quote to receive (slippage protection).
27
+
28
+ ## Relation to quote commands
29
+
30
+ - `quote-buy` / `quote-sell`: Read-only estimates; no transaction is sent.
31
+ - `buy` / `sell`: Actually send transactions. Recommended: use `quote-buy` / `quote-sell` first to get estimates, then choose `maxFundsWei`, `minAmountWei`, `minFundsWei` and call `buy` / `sell`.
@@ -1,38 +1,38 @@
1
- # Query Tax Token fee/tax info
2
-
3
- Only for **TaxToken** (creatorType 5). The token contract address is the TaxToken contract; call view functions on that address.
4
-
5
- ## On-chain view functions (TaxToken.abi)
6
-
7
- | Function / variable | Description | Unit / meaning |
8
- |---------------------|-------------|----------------|
9
- | **feeRate** | Trading fee rate | Basis points; 10000 = 100%, e.g. 500 = 5% |
10
- | **rateFounder** | Founder allocation share | Percent; 100 = 100%, e.g. 10 = 10% |
11
- | **rateHolder** | Holder dividend share | Same |
12
- | **rateBurn** | Burn share | Same |
13
- | **rateLiquidity** | Liquidity add share | Same; rateFounder + rateHolder + rateBurn + rateLiquidity = 100 |
14
- | **minDispatch** | Cumulative fee threshold to trigger distribution | Token units |
15
- | **minShare** | Min balance to participate in dividends | Token units (ether); below this, no dividend |
16
- | **quote** | Quote token address | 0 = BNB/ETH |
17
- | **founder** | Founder address | Receives founder allocation |
18
-
19
- See also **claimableFee(account)**, **claimedFee(account)**, **userInfo(account)** for claimable/claimed fees and user info in the [official API/Contract docs](https://four-meme.gitbook.io/four.meme/brand/protocol-integration) (e.g. API-Contract-TaxToken).
20
-
21
- ## Script
22
-
23
- ```bash
24
- npx fourmeme tax-info <tokenAddress>
25
- ```
26
-
27
- Or run: `npx tsx .../get-tax-token-info.ts <tokenAddress>`. BSC only.
28
-
29
- Example output (JSON): `feeRateBps`, `feeRatePercent`, `rateFounder`, `rateHolder`, `rateBurn`, `rateLiquidity`, `minDispatch`, `minShare`, `quote`, `founder`.
30
-
31
- ## How to identify a TaxToken
32
-
33
- - **Off-chain**: Call four.meme API `GET /v1/private/token/get?address=<token>`; if response `data` contains `taxInfo`, it is a TaxToken.
34
- - **On-chain**: In TokenManager2, `(template >> 10) & 0x3F === 5` means TaxToken. Or run `get-tax-token-info`; if it succeeds and e.g. `feeRateBps > 0`, treat as TaxToken.
35
-
36
- ## References
37
-
38
- - [Protocol Integration](https://four-meme.gitbook.io/four.meme/brand/protocol-integration) – API documents (API-Contract-TaxToken, etc.) and ABIs (TaxToken.abi)
1
+ # Query Tax Token fee/tax info
2
+
3
+ Only for **TaxToken** (creatorType 5). The token contract address is the TaxToken contract; call view functions on that address.
4
+
5
+ ## On-chain view functions (TaxToken.abi)
6
+
7
+ | Function / variable | Description | Unit / meaning |
8
+ |---------------------|-------------|----------------|
9
+ | **feeRate** | Trading fee rate | Basis points; 10000 = 100%, e.g. 500 = 5% |
10
+ | **rateFounder** | Founder allocation share | Percent; 100 = 100%, e.g. 10 = 10% |
11
+ | **rateHolder** | Holder dividend share | Same |
12
+ | **rateBurn** | Burn share | Same |
13
+ | **rateLiquidity** | Liquidity add share | Same; rateFounder + rateHolder + rateBurn + rateLiquidity = 100 |
14
+ | **minDispatch** | Cumulative fee threshold to trigger distribution | Token units |
15
+ | **minShare** | Min balance to participate in dividends | Token units (ether); below this, no dividend |
16
+ | **quote** | Quote token address | 0 = BNB/ETH |
17
+ | **founder** | Founder address | Receives founder allocation |
18
+
19
+ See also **claimableFee(account)**, **claimedFee(account)**, **userInfo(account)** for claimable/claimed fees and user info in the [official API/Contract docs](https://four-meme.gitbook.io/four.meme/brand/protocol-integration) (e.g. API-Contract-TaxToken).
20
+
21
+ ## Script
22
+
23
+ ```bash
24
+ npx fourmeme tax-info <tokenAddress>
25
+ ```
26
+
27
+ Or run: `npx tsx .../get-tax-token-info.ts <tokenAddress>`. BSC only.
28
+
29
+ Example output (JSON): `feeRateBps`, `feeRatePercent`, `rateFounder`, `rateHolder`, `rateBurn`, `rateLiquidity`, `minDispatch`, `minShare`, `quote`, `founder`.
30
+
31
+ ## How to identify a TaxToken
32
+
33
+ - **Off-chain**: Call four.meme API `GET /v1/private/token/get?address=<token>`; if response `data` contains `taxInfo`, it is a TaxToken.
34
+ - **On-chain**: In TokenManager2, `(template >> 10) & 0x3F === 5` means TaxToken. Or run `get-tax-token-info`; if it succeeds and e.g. `feeRateBps > 0`, treat as TaxToken.
35
+
36
+ ## References
37
+
38
+ - [Protocol Integration](https://four-meme.gitbook.io/four.meme/brand/protocol-integration) – API documents (API-Contract-TaxToken, etc.) and ABIs (TaxToken.abi)