@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,150 +1,150 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Four.meme - execute sell on TokenManager2 (BSC only).
4
- * Usage: npx tsx execute-sell.ts <tokenAddress> <amountWei> [minFundsWei]
5
- * Env: PRIVATE_KEY. Sends approve(tokenManager, amount) then sellToken(token, amount).
6
- */
7
-
8
- import { createPublicClient, createWalletClient, http } from 'viem';
9
- import { privateKeyToAccount } from 'viem/accounts';
10
- import { bsc } from 'viem/chains';
11
-
12
- const HELPER_ADDRESS = '0xF251F83e40a78868FcfA3FA4599Dad6494E46034' as const;
13
-
14
- const HELPER_ABI = [
15
- {
16
- name: 'getTokenInfo',
17
- type: 'function',
18
- stateMutability: 'view',
19
- inputs: [{ name: 'token', type: 'address' }],
20
- outputs: [
21
- { name: 'version', type: 'uint256' },
22
- { name: 'tokenManager', type: 'address' },
23
- { name: 'quote', type: 'address' },
24
- { name: 'lastPrice', type: 'uint256' },
25
- { name: 'tradingFeeRate', type: 'uint256' },
26
- { name: 'minTradingFee', type: 'uint256' },
27
- { name: 'launchTime', type: 'uint256' },
28
- { name: 'offers', type: 'uint256' },
29
- { name: 'maxOffers', type: 'uint256' },
30
- { name: 'funds', type: 'uint256' },
31
- { name: 'maxFunds', type: 'uint256' },
32
- { name: 'liquidityAdded', type: 'bool' },
33
- ],
34
- },
35
- ] as const;
36
-
37
- const TM2_ABI_SIMPLE = [
38
- {
39
- name: 'sellToken',
40
- type: 'function',
41
- stateMutability: 'nonpayable',
42
- inputs: [
43
- { name: 'token', type: 'address' },
44
- { name: 'amount', type: 'uint256' },
45
- ],
46
- outputs: [],
47
- },
48
- ] as const;
49
-
50
- const TM2_ABI_WITH_MIN_FUNDS = [
51
- {
52
- name: 'sellToken',
53
- type: 'function',
54
- stateMutability: 'nonpayable',
55
- inputs: [
56
- { name: 'origin', type: 'uint256' },
57
- { name: 'token', type: 'address' },
58
- { name: 'amount', type: 'uint256' },
59
- { name: 'minFunds', type: 'uint256' },
60
- ],
61
- outputs: [],
62
- },
63
- ] as const;
64
-
65
- const ERC20_ABI = [
66
- {
67
- name: 'approve',
68
- type: 'function',
69
- stateMutability: 'nonpayable',
70
- inputs: [
71
- { name: 'spender', type: 'address' },
72
- { name: 'amount', type: 'uint256' },
73
- ],
74
- outputs: [{ type: 'bool' }],
75
- },
76
- ] as const;
77
-
78
- const RPC_URL = process.env.BSC_RPC_URL || 'https://bsc-dataseed.binance.org';
79
-
80
- async function main() {
81
- const pk = process.env.PRIVATE_KEY;
82
- if (!pk) {
83
- console.error('Set PRIVATE_KEY');
84
- process.exit(1);
85
- }
86
- const account = privateKeyToAccount(
87
- (pk.startsWith('0x') ? pk : '0x' + pk) as `0x${string}`
88
- );
89
-
90
- const tokenAddress = process.argv[2] as `0x${string}`;
91
- const amountWei = BigInt(process.argv[3] ?? '0');
92
- const minFundsWei = process.argv[4] ? BigInt(process.argv[4]) : null;
93
-
94
- if (!tokenAddress || amountWei <= 0n) {
95
- console.error('Usage: npx tsx execute-sell.ts <tokenAddress> <amountWei> [minFundsWei]');
96
- process.exit(1);
97
- }
98
-
99
- const publicClient = createPublicClient({
100
- chain: bsc,
101
- transport: http(RPC_URL),
102
- });
103
- const walletClient = createWalletClient({
104
- account,
105
- chain: bsc,
106
- transport: http(RPC_URL),
107
- });
108
-
109
- const [, tokenManager] = await publicClient.readContract({
110
- address: HELPER_ADDRESS,
111
- abi: HELPER_ABI,
112
- functionName: 'getTokenInfo',
113
- args: [tokenAddress],
114
- }).then((r) => [r[0], r[1]] as const);
115
-
116
- const approveHash = await walletClient.writeContract({
117
- address: tokenAddress,
118
- abi: ERC20_ABI,
119
- functionName: 'approve',
120
- args: [tokenManager as `0x${string}`, amountWei],
121
- });
122
- const receipt = await publicClient.waitForTransactionReceipt({ hash: approveHash });
123
- if (receipt.status !== 'success') {
124
- console.error('Approve failed');
125
- process.exit(1);
126
- }
127
-
128
- const tm2 = tokenManager as `0x${string}`;
129
- const hash: `0x${string}` =
130
- minFundsWei !== null
131
- ? await walletClient.writeContract({
132
- address: tm2,
133
- abi: TM2_ABI_WITH_MIN_FUNDS,
134
- functionName: 'sellToken',
135
- args: [0n, tokenAddress, amountWei, minFundsWei],
136
- })
137
- : await walletClient.writeContract({
138
- address: tm2,
139
- abi: TM2_ABI_SIMPLE,
140
- functionName: 'sellToken',
141
- args: [tokenAddress, amountWei],
142
- });
143
-
144
- console.log(JSON.stringify({ txHash: hash }, null, 2));
145
- }
146
-
147
- main().catch((e) => {
148
- console.error(e.message || e);
149
- process.exit(1);
150
- });
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Four.meme - execute sell on TokenManager2 (BSC only).
4
+ * Usage: npx tsx execute-sell.ts <tokenAddress> <amountWei> [minFundsWei]
5
+ * Env: PRIVATE_KEY. Sends approve(tokenManager, amount) then sellToken(token, amount).
6
+ */
7
+
8
+ import { createPublicClient, createWalletClient, http } from 'viem';
9
+ import { privateKeyToAccount } from 'viem/accounts';
10
+ import { bsc } from 'viem/chains';
11
+
12
+ const HELPER_ADDRESS = '0xF251F83e40a78868FcfA3FA4599Dad6494E46034' as const;
13
+
14
+ const HELPER_ABI = [
15
+ {
16
+ name: 'getTokenInfo',
17
+ type: 'function',
18
+ stateMutability: 'view',
19
+ inputs: [{ name: 'token', type: 'address' }],
20
+ outputs: [
21
+ { name: 'version', type: 'uint256' },
22
+ { name: 'tokenManager', type: 'address' },
23
+ { name: 'quote', type: 'address' },
24
+ { name: 'lastPrice', type: 'uint256' },
25
+ { name: 'tradingFeeRate', type: 'uint256' },
26
+ { name: 'minTradingFee', type: 'uint256' },
27
+ { name: 'launchTime', type: 'uint256' },
28
+ { name: 'offers', type: 'uint256' },
29
+ { name: 'maxOffers', type: 'uint256' },
30
+ { name: 'funds', type: 'uint256' },
31
+ { name: 'maxFunds', type: 'uint256' },
32
+ { name: 'liquidityAdded', type: 'bool' },
33
+ ],
34
+ },
35
+ ] as const;
36
+
37
+ const TM2_ABI_SIMPLE = [
38
+ {
39
+ name: 'sellToken',
40
+ type: 'function',
41
+ stateMutability: 'nonpayable',
42
+ inputs: [
43
+ { name: 'token', type: 'address' },
44
+ { name: 'amount', type: 'uint256' },
45
+ ],
46
+ outputs: [],
47
+ },
48
+ ] as const;
49
+
50
+ const TM2_ABI_WITH_MIN_FUNDS = [
51
+ {
52
+ name: 'sellToken',
53
+ type: 'function',
54
+ stateMutability: 'nonpayable',
55
+ inputs: [
56
+ { name: 'origin', type: 'uint256' },
57
+ { name: 'token', type: 'address' },
58
+ { name: 'amount', type: 'uint256' },
59
+ { name: 'minFunds', type: 'uint256' },
60
+ ],
61
+ outputs: [],
62
+ },
63
+ ] as const;
64
+
65
+ const ERC20_ABI = [
66
+ {
67
+ name: 'approve',
68
+ type: 'function',
69
+ stateMutability: 'nonpayable',
70
+ inputs: [
71
+ { name: 'spender', type: 'address' },
72
+ { name: 'amount', type: 'uint256' },
73
+ ],
74
+ outputs: [{ type: 'bool' }],
75
+ },
76
+ ] as const;
77
+
78
+ const RPC_URL = process.env.BSC_RPC_URL || 'https://bsc-dataseed.binance.org';
79
+
80
+ async function main() {
81
+ const pk = process.env.PRIVATE_KEY;
82
+ if (!pk) {
83
+ console.error('Set PRIVATE_KEY');
84
+ process.exit(1);
85
+ }
86
+ const account = privateKeyToAccount(
87
+ (pk.startsWith('0x') ? pk : '0x' + pk) as `0x${string}`
88
+ );
89
+
90
+ const tokenAddress = process.argv[2] as `0x${string}`;
91
+ const amountWei = BigInt(process.argv[3] ?? '0');
92
+ const minFundsWei = process.argv[4] ? BigInt(process.argv[4]) : null;
93
+
94
+ if (!tokenAddress || amountWei <= 0n) {
95
+ console.error('Usage: npx tsx execute-sell.ts <tokenAddress> <amountWei> [minFundsWei]');
96
+ process.exit(1);
97
+ }
98
+
99
+ const publicClient = createPublicClient({
100
+ chain: bsc,
101
+ transport: http(RPC_URL),
102
+ });
103
+ const walletClient = createWalletClient({
104
+ account,
105
+ chain: bsc,
106
+ transport: http(RPC_URL),
107
+ });
108
+
109
+ const [, tokenManager] = await publicClient.readContract({
110
+ address: HELPER_ADDRESS,
111
+ abi: HELPER_ABI,
112
+ functionName: 'getTokenInfo',
113
+ args: [tokenAddress],
114
+ }).then((r) => [r[0], r[1]] as const);
115
+
116
+ const approveHash = await walletClient.writeContract({
117
+ address: tokenAddress,
118
+ abi: ERC20_ABI,
119
+ functionName: 'approve',
120
+ args: [tokenManager as `0x${string}`, amountWei],
121
+ });
122
+ const receipt = await publicClient.waitForTransactionReceipt({ hash: approveHash });
123
+ if (receipt.status !== 'success') {
124
+ console.error('Approve failed');
125
+ process.exit(1);
126
+ }
127
+
128
+ const tm2 = tokenManager as `0x${string}`;
129
+ const hash: `0x${string}` =
130
+ minFundsWei !== null
131
+ ? await walletClient.writeContract({
132
+ address: tm2,
133
+ abi: TM2_ABI_WITH_MIN_FUNDS,
134
+ functionName: 'sellToken',
135
+ args: [0n, tokenAddress, amountWei, minFundsWei],
136
+ })
137
+ : await walletClient.writeContract({
138
+ address: tm2,
139
+ abi: TM2_ABI_SIMPLE,
140
+ functionName: 'sellToken',
141
+ args: [tokenAddress, amountWei],
142
+ });
143
+
144
+ console.log(JSON.stringify({ txHash: hash }, null, 2));
145
+ }
146
+
147
+ main().catch((e) => {
148
+ console.error(e.message || e);
149
+ process.exit(1);
150
+ });
@@ -1,98 +1,98 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Four.meme - send BNB or ERC20 from current wallet to a target address (BSC).
4
- *
5
- * Usage:
6
- * npx tsx send-token.ts <toAddress> <amountWei> [tokenAddress]
7
- * - toAddress: recipient wallet address (0x...)
8
- * - amountWei: amount in wei (for BNB or token decimals)
9
- * - tokenAddress: optional; omit or use "BNB" / "0x0" for native BNB; otherwise ERC20 token contract address
10
- *
11
- * Env: PRIVATE_KEY. Optional: BSC_RPC_URL.
12
- */
13
-
14
- import { createWalletClient, http, parseAbi } from 'viem';
15
- import { privateKeyToAccount } from 'viem/accounts';
16
- import { bsc } from 'viem/chains';
17
-
18
- const ZERO = '0x0000000000000000000000000000000000000000' as const;
19
-
20
- const ERC20_ABI = parseAbi([
21
- 'function transfer(address to, uint256 amount) returns (bool)',
22
- ]);
23
-
24
- function isAddress(s: string): boolean {
25
- return /^0x[0-9a-fA-F]{40}$/.test(s);
26
- }
27
-
28
- async function main() {
29
- const privateKey = process.env.PRIVATE_KEY;
30
- if (!privateKey) {
31
- console.error('Set PRIVATE_KEY');
32
- process.exit(1);
33
- }
34
- const pk = privateKey.startsWith('0x') ? (privateKey as `0x${string}`) : (`0x${privateKey}` as `0x${string}`);
35
- const account = privateKeyToAccount(pk);
36
-
37
- const toAddress = process.argv[2];
38
- const amountWeiRaw = process.argv[3];
39
- const tokenAddress = process.argv[4]; // optional: BNB if omitted or "BNB" or 0x0
40
-
41
- if (!toAddress || !amountWeiRaw) {
42
- console.error('Usage: send-token.ts <toAddress> <amountWei> [tokenAddress]');
43
- console.error(' toAddress: recipient 0x... address');
44
- console.error(' amountWei: amount in wei (for BNB or token smallest unit)');
45
- console.error(' tokenAddress: optional; omit or BNB/0x0 = native BNB; else ERC20 contract address');
46
- process.exit(1);
47
- }
48
- if (!isAddress(toAddress)) {
49
- console.error('Invalid toAddress:', toAddress);
50
- process.exit(1);
51
- }
52
-
53
- const amountWei = BigInt(amountWeiRaw);
54
- if (amountWei <= 0n) {
55
- console.error('amountWei must be positive');
56
- process.exit(1);
57
- }
58
-
59
- const isNative =
60
- !tokenAddress ||
61
- tokenAddress.toUpperCase() === 'BNB' ||
62
- tokenAddress === ZERO ||
63
- tokenAddress.toLowerCase() === '0x0000000000000000000000000000000000000000';
64
-
65
- const rpcUrl = process.env.BSC_RPC_URL || 'https://bsc-dataseed.binance.org';
66
- const client = createWalletClient({
67
- account,
68
- chain: bsc,
69
- transport: http(rpcUrl),
70
- });
71
-
72
- let txHash: `0x${string}`;
73
-
74
- if (isNative) {
75
- txHash = await client.sendTransaction({
76
- to: toAddress as `0x${string}`,
77
- value: amountWei,
78
- });
79
- } else {
80
- if (!isAddress(tokenAddress)) {
81
- console.error('Invalid tokenAddress:', tokenAddress);
82
- process.exit(1);
83
- }
84
- txHash = await client.writeContract({
85
- address: tokenAddress as `0x${string}`,
86
- abi: ERC20_ABI,
87
- functionName: 'transfer',
88
- args: [toAddress as `0x${string}`, amountWei],
89
- });
90
- }
91
-
92
- console.log(JSON.stringify({ txHash, to: toAddress, amountWei: amountWei.toString(), native: isNative }, null, 2));
93
- }
94
-
95
- main().catch((e) => {
96
- console.error(e.message || e);
97
- process.exit(1);
98
- });
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Four.meme - send BNB or ERC20 from current wallet to a target address (BSC).
4
+ *
5
+ * Usage:
6
+ * npx tsx send-token.ts <toAddress> <amountWei> [tokenAddress]
7
+ * - toAddress: recipient wallet address (0x...)
8
+ * - amountWei: amount in wei (for BNB or token decimals)
9
+ * - tokenAddress: optional; omit or use "BNB" / "0x0" for native BNB; otherwise ERC20 token contract address
10
+ *
11
+ * Env: PRIVATE_KEY. Optional: BSC_RPC_URL.
12
+ */
13
+
14
+ import { createWalletClient, http, parseAbi } from 'viem';
15
+ import { privateKeyToAccount } from 'viem/accounts';
16
+ import { bsc } from 'viem/chains';
17
+
18
+ const ZERO = '0x0000000000000000000000000000000000000000' as const;
19
+
20
+ const ERC20_ABI = parseAbi([
21
+ 'function transfer(address to, uint256 amount) returns (bool)',
22
+ ]);
23
+
24
+ function isAddress(s: string): boolean {
25
+ return /^0x[0-9a-fA-F]{40}$/.test(s);
26
+ }
27
+
28
+ async function main() {
29
+ const privateKey = process.env.PRIVATE_KEY;
30
+ if (!privateKey) {
31
+ console.error('Set PRIVATE_KEY');
32
+ process.exit(1);
33
+ }
34
+ const pk = privateKey.startsWith('0x') ? (privateKey as `0x${string}`) : (`0x${privateKey}` as `0x${string}`);
35
+ const account = privateKeyToAccount(pk);
36
+
37
+ const toAddress = process.argv[2];
38
+ const amountWeiRaw = process.argv[3];
39
+ const tokenAddress = process.argv[4]; // optional: BNB if omitted or "BNB" or 0x0
40
+
41
+ if (!toAddress || !amountWeiRaw) {
42
+ console.error('Usage: send-token.ts <toAddress> <amountWei> [tokenAddress]');
43
+ console.error(' toAddress: recipient 0x... address');
44
+ console.error(' amountWei: amount in wei (for BNB or token smallest unit)');
45
+ console.error(' tokenAddress: optional; omit or BNB/0x0 = native BNB; else ERC20 contract address');
46
+ process.exit(1);
47
+ }
48
+ if (!isAddress(toAddress)) {
49
+ console.error('Invalid toAddress:', toAddress);
50
+ process.exit(1);
51
+ }
52
+
53
+ const amountWei = BigInt(amountWeiRaw);
54
+ if (amountWei <= 0n) {
55
+ console.error('amountWei must be positive');
56
+ process.exit(1);
57
+ }
58
+
59
+ const isNative =
60
+ !tokenAddress ||
61
+ tokenAddress.toUpperCase() === 'BNB' ||
62
+ tokenAddress === ZERO ||
63
+ tokenAddress.toLowerCase() === '0x0000000000000000000000000000000000000000';
64
+
65
+ const rpcUrl = process.env.BSC_RPC_URL || 'https://bsc-dataseed.binance.org';
66
+ const client = createWalletClient({
67
+ account,
68
+ chain: bsc,
69
+ transport: http(rpcUrl),
70
+ });
71
+
72
+ let txHash: `0x${string}`;
73
+
74
+ if (isNative) {
75
+ txHash = await client.sendTransaction({
76
+ to: toAddress as `0x${string}`,
77
+ value: amountWei,
78
+ });
79
+ } else {
80
+ if (!isAddress(tokenAddress)) {
81
+ console.error('Invalid tokenAddress:', tokenAddress);
82
+ process.exit(1);
83
+ }
84
+ txHash = await client.writeContract({
85
+ address: tokenAddress as `0x${string}`,
86
+ abi: ERC20_ABI,
87
+ functionName: 'transfer',
88
+ args: [toAddress as `0x${string}`, amountWei],
89
+ });
90
+ }
91
+
92
+ console.log(JSON.stringify({ txHash, to: toAddress, amountWei: amountWei.toString(), native: isNative }, null, 2));
93
+ }
94
+
95
+ main().catch((e) => {
96
+ console.error(e.message || e);
97
+ process.exit(1);
98
+ });