moltspay 0.1.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.
package/README.md ADDED
@@ -0,0 +1,212 @@
1
+ # MoltsPay
2
+
3
+ Blockchain payment infrastructure for AI Agents on Moltbook.
4
+
5
+ ## Features
6
+
7
+ - ๐ŸŽซ **Invoice Generation** - Create standardized payment requests
8
+ - โœ… **Payment Verification** - Verify on-chain USDC transfers
9
+ - ๐Ÿ’ณ **Custody Wallet** - Manage USDC transfers
10
+ - ๐Ÿ”’ **Secure Wallet** - Limits, whitelist, and audit logging
11
+ - ๐Ÿ“ **EIP-2612 Permit** - Gasless user payments
12
+ - โ›“๏ธ **Multi-chain** - Base, Polygon, Ethereum (mainnet & testnet)
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install moltspay@latest
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ```typescript
23
+ import { PaymentAgent, SecureWallet } from 'moltspay';
24
+
25
+ // Initialize payment agent
26
+ const agent = new PaymentAgent({
27
+ chain: 'base',
28
+ walletAddress: '0x...',
29
+ });
30
+
31
+ // Generate invoice
32
+ const invoice = agent.createInvoice({
33
+ orderId: 'order_123',
34
+ amount: 2.0,
35
+ service: 'video_generation',
36
+ });
37
+
38
+ // Verify payment
39
+ const result = await agent.verifyPayment(txHash);
40
+ if (result.verified) {
41
+ console.log('Payment confirmed!');
42
+ }
43
+ ```
44
+
45
+ ## Usage with AI Agents
46
+
47
+ Payment Agent is designed to be called by AI Agents (like Clawdbot) to handle payment logic:
48
+
49
+ ```
50
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
51
+ โ”‚ Bot (Clawdbot) โ”‚
52
+ โ”‚ โ€ข Business logic โ”‚
53
+ โ”‚ โ€ข User interaction โ”‚
54
+ โ”‚ โ€ข Service delivery โ”‚
55
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
56
+ โ†“ calls
57
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
58
+ โ”‚ Payment Agent (this package) โ”‚
59
+ โ”‚ โ€ข Invoice generation โ”‚
60
+ โ”‚ โ€ข Payment verification โ”‚
61
+ โ”‚ โ€ข Wallet management โ”‚
62
+ โ”‚ โ€ข Security controls โ”‚
63
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
64
+ โ†“
65
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
66
+ โ”‚ Blockchain โ”‚
67
+ โ”‚ (Base / Polygon / Ethereum) โ”‚
68
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
69
+ ```
70
+
71
+ ## API Reference
72
+
73
+ ### PaymentAgent
74
+
75
+ ```typescript
76
+ const agent = new PaymentAgent({
77
+ chain: 'base', // Chain name
78
+ walletAddress: '0x...', // Recipient address
79
+ rpcUrl: '...', // Optional custom RPC
80
+ });
81
+
82
+ // Create invoice
83
+ const invoice = agent.createInvoice({
84
+ orderId: 'order_123',
85
+ amount: 2.0,
86
+ service: 'video_generation',
87
+ expiresMinutes: 30,
88
+ });
89
+
90
+ // Verify payment
91
+ const result = await agent.verifyPayment(txHash, {
92
+ expectedAmount: 2.0,
93
+ tolerance: 0.01, // 1% tolerance
94
+ });
95
+
96
+ // Get balance
97
+ const balance = await agent.getBalance();
98
+ ```
99
+
100
+ ### Wallet
101
+
102
+ ```typescript
103
+ const wallet = new Wallet({
104
+ chain: 'base',
105
+ privateKey: '0x...',
106
+ });
107
+
108
+ // Get balance
109
+ const balance = await wallet.getBalance();
110
+
111
+ // Transfer USDC
112
+ const result = await wallet.transfer('0x...', 10.0);
113
+ ```
114
+
115
+ ### SecureWallet
116
+
117
+ ```typescript
118
+ const wallet = new SecureWallet({
119
+ chain: 'base',
120
+ limits: {
121
+ singleMax: 100, // Max $100 per transfer
122
+ dailyMax: 1000, // Max $1000 per day
123
+ },
124
+ whitelist: ['0x...'],
125
+ });
126
+
127
+ // Transfer with security checks
128
+ const result = await wallet.transfer({
129
+ to: '0x...',
130
+ amount: 50,
131
+ reason: 'Service payment',
132
+ });
133
+
134
+ // Approve pending transfer (when limit exceeded)
135
+ await wallet.approve(requestId, 'admin');
136
+
137
+ // Add to whitelist
138
+ await wallet.addToWhitelist('0x...', 'admin');
139
+ ```
140
+
141
+ ### PermitPayment (EIP-2612)
142
+
143
+ ```typescript
144
+ const permit = new PermitPayment({
145
+ chain: 'base',
146
+ privateKey: '0x...', // Service provider's key
147
+ });
148
+
149
+ // Create permit request for user to sign
150
+ const request = await permit.createPermitRequest(
151
+ userAddress,
152
+ amount,
153
+ orderId
154
+ );
155
+
156
+ // After user signs, execute permit + transfer
157
+ const result = await permit.executePermitAndTransfer(
158
+ userAddress,
159
+ amount,
160
+ { v, r, s, deadline }
161
+ );
162
+ ```
163
+
164
+ ## CLI
165
+
166
+ ```bash
167
+ # Install globally
168
+ npm install -g moltspay
169
+
170
+ # Get balance
171
+ moltspay balance --chain base
172
+
173
+ # Generate invoice
174
+ moltspay invoice --order order_123 --amount 2.0 --service video
175
+
176
+ # Verify payment
177
+ moltspay verify --tx 0x... --amount 2.0
178
+
179
+ # Transfer USDC
180
+ moltspay transfer --to 0x... --amount 10 --secure
181
+
182
+ # List supported chains
183
+ moltspay chains
184
+ ```
185
+
186
+ ## Environment Variables
187
+
188
+ ```bash
189
+ PAYMENT_AGENT_WALLET=0x... # Wallet address
190
+ PAYMENT_AGENT_PRIVATE_KEY=0x... # Private key (for transfers)
191
+ ```
192
+
193
+ ## Supported Chains
194
+
195
+ | Chain | Chain ID | Type | Status |
196
+ |-------|----------|------|--------|
197
+ | base | 8453 | Mainnet | โœ… |
198
+ | polygon | 137 | Mainnet | โœ… |
199
+ | ethereum | 1 | Mainnet | โœ… |
200
+ | base_sepolia | 84532 | Testnet | โœ… |
201
+ | sepolia | 11155111 | Testnet | โœ… |
202
+
203
+ ## Security
204
+
205
+ - **Limits**: Single and daily transfer limits
206
+ - **Whitelist**: Only transfer to approved addresses
207
+ - **Audit Log**: Immutable, hash-chained logs
208
+ - **Pending Approval**: Large transfers require manual approval
209
+
210
+ ## License
211
+
212
+ MIT
@@ -0,0 +1,25 @@
1
+ import { C as ChainName, a as ChainConfig } from '../index-CZzgdtin.mjs';
2
+
3
+ /**
4
+ * ๅŒบๅ—้“พ้…็ฝฎ
5
+ */
6
+
7
+ declare const CHAINS: Record<ChainName, ChainConfig>;
8
+ /**
9
+ * ่Žทๅ–้“พ้…็ฝฎ
10
+ */
11
+ declare function getChain(name: ChainName): ChainConfig;
12
+ /**
13
+ * ๅˆ—ๅ‡บๆ‰€ๆœ‰ๆ”ฏๆŒ็š„้“พ
14
+ */
15
+ declare function listChains(): ChainName[];
16
+ /**
17
+ * ๆ นๆฎ chainId ่Žทๅ–้“พ้…็ฝฎ
18
+ */
19
+ declare function getChainById(chainId: number): ChainConfig | undefined;
20
+ /**
21
+ * ERC20 ABI๏ผˆๆœ€ๅฐๅŒ–๏ผŒไป…ๅŒ…ๅซ้œ€่ฆ็š„ๆ–นๆณ•๏ผ‰
22
+ */
23
+ declare const ERC20_ABI: string[];
24
+
25
+ export { CHAINS, ChainConfig, ChainName, ERC20_ABI, getChain, getChainById, listChains };
@@ -0,0 +1,25 @@
1
+ import { C as ChainName, a as ChainConfig } from '../index-CZzgdtin.js';
2
+
3
+ /**
4
+ * ๅŒบๅ—้“พ้…็ฝฎ
5
+ */
6
+
7
+ declare const CHAINS: Record<ChainName, ChainConfig>;
8
+ /**
9
+ * ่Žทๅ–้“พ้…็ฝฎ
10
+ */
11
+ declare function getChain(name: ChainName): ChainConfig;
12
+ /**
13
+ * ๅˆ—ๅ‡บๆ‰€ๆœ‰ๆ”ฏๆŒ็š„้“พ
14
+ */
15
+ declare function listChains(): ChainName[];
16
+ /**
17
+ * ๆ นๆฎ chainId ่Žทๅ–้“พ้…็ฝฎ
18
+ */
19
+ declare function getChainById(chainId: number): ChainConfig | undefined;
20
+ /**
21
+ * ERC20 ABI๏ผˆๆœ€ๅฐๅŒ–๏ผŒไป…ๅŒ…ๅซ้œ€่ฆ็š„ๆ–นๆณ•๏ผ‰
22
+ */
23
+ declare const ERC20_ABI: string[];
24
+
25
+ export { CHAINS, ChainConfig, ChainName, ERC20_ABI, getChain, getChainById, listChains };
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/chains/index.ts
21
+ var chains_exports = {};
22
+ __export(chains_exports, {
23
+ CHAINS: () => CHAINS,
24
+ ERC20_ABI: () => ERC20_ABI,
25
+ getChain: () => getChain,
26
+ getChainById: () => getChainById,
27
+ listChains: () => listChains
28
+ });
29
+ module.exports = __toCommonJS(chains_exports);
30
+ var CHAINS = {
31
+ // ============ ไธป็ฝ‘ ============
32
+ base: {
33
+ name: "Base",
34
+ chainId: 8453,
35
+ rpc: "https://mainnet.base.org",
36
+ usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
37
+ explorer: "https://basescan.org/address/",
38
+ explorerTx: "https://basescan.org/tx/",
39
+ avgBlockTime: 2
40
+ },
41
+ polygon: {
42
+ name: "Polygon",
43
+ chainId: 137,
44
+ rpc: "https://polygon-rpc.com",
45
+ usdc: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
46
+ explorer: "https://polygonscan.com/address/",
47
+ explorerTx: "https://polygonscan.com/tx/",
48
+ avgBlockTime: 2
49
+ },
50
+ ethereum: {
51
+ name: "Ethereum",
52
+ chainId: 1,
53
+ rpc: "https://eth.llamarpc.com",
54
+ usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
55
+ explorer: "https://etherscan.io/address/",
56
+ explorerTx: "https://etherscan.io/tx/",
57
+ avgBlockTime: 12
58
+ },
59
+ // ============ ๆต‹่ฏ•็ฝ‘ ============
60
+ base_sepolia: {
61
+ name: "Base Sepolia",
62
+ chainId: 84532,
63
+ rpc: "https://sepolia.base.org",
64
+ usdc: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
65
+ explorer: "https://sepolia.basescan.org/address/",
66
+ explorerTx: "https://sepolia.basescan.org/tx/",
67
+ avgBlockTime: 2
68
+ },
69
+ sepolia: {
70
+ name: "Sepolia",
71
+ chainId: 11155111,
72
+ rpc: "https://rpc.sepolia.org",
73
+ usdc: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
74
+ explorer: "https://sepolia.etherscan.io/address/",
75
+ explorerTx: "https://sepolia.etherscan.io/tx/",
76
+ avgBlockTime: 12
77
+ }
78
+ };
79
+ function getChain(name) {
80
+ const config = CHAINS[name];
81
+ if (!config) {
82
+ throw new Error(`Unsupported chain: ${name}. Supported: ${Object.keys(CHAINS).join(", ")}`);
83
+ }
84
+ return config;
85
+ }
86
+ function listChains() {
87
+ return Object.keys(CHAINS);
88
+ }
89
+ function getChainById(chainId) {
90
+ return Object.values(CHAINS).find((c) => c.chainId === chainId);
91
+ }
92
+ var ERC20_ABI = [
93
+ "function balanceOf(address owner) view returns (uint256)",
94
+ "function transfer(address to, uint256 amount) returns (bool)",
95
+ "function approve(address spender, uint256 amount) returns (bool)",
96
+ "function allowance(address owner, address spender) view returns (uint256)",
97
+ "function decimals() view returns (uint8)",
98
+ "function symbol() view returns (string)",
99
+ "function name() view returns (string)",
100
+ "function nonces(address owner) view returns (uint256)",
101
+ "function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)",
102
+ "event Transfer(address indexed from, address indexed to, uint256 value)",
103
+ "event Approval(address indexed owner, address indexed spender, uint256 value)"
104
+ ];
105
+ // Annotate the CommonJS export names for ESM import in node:
106
+ 0 && (module.exports = {
107
+ CHAINS,
108
+ ERC20_ABI,
109
+ getChain,
110
+ getChainById,
111
+ listChains
112
+ });
113
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/chains/index.ts"],"sourcesContent":["/**\n * ๅŒบๅ—้“พ้…็ฝฎ\n */\n\nimport type { ChainConfig, ChainName } from '../types/index.js';\n\nexport const CHAINS: Record<ChainName, ChainConfig> = {\n // ============ ไธป็ฝ‘ ============\n base: {\n name: 'Base',\n chainId: 8453,\n rpc: 'https://mainnet.base.org',\n usdc: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',\n explorer: 'https://basescan.org/address/',\n explorerTx: 'https://basescan.org/tx/',\n avgBlockTime: 2,\n },\n polygon: {\n name: 'Polygon',\n chainId: 137,\n rpc: 'https://polygon-rpc.com',\n usdc: '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359',\n explorer: 'https://polygonscan.com/address/',\n explorerTx: 'https://polygonscan.com/tx/',\n avgBlockTime: 2,\n },\n ethereum: {\n name: 'Ethereum',\n chainId: 1,\n rpc: 'https://eth.llamarpc.com',\n usdc: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',\n explorer: 'https://etherscan.io/address/',\n explorerTx: 'https://etherscan.io/tx/',\n avgBlockTime: 12,\n },\n\n // ============ ๆต‹่ฏ•็ฝ‘ ============\n base_sepolia: {\n name: 'Base Sepolia',\n chainId: 84532,\n rpc: 'https://sepolia.base.org',\n usdc: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',\n explorer: 'https://sepolia.basescan.org/address/',\n explorerTx: 'https://sepolia.basescan.org/tx/',\n avgBlockTime: 2,\n },\n sepolia: {\n name: 'Sepolia',\n chainId: 11155111,\n rpc: 'https://rpc.sepolia.org',\n usdc: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',\n explorer: 'https://sepolia.etherscan.io/address/',\n explorerTx: 'https://sepolia.etherscan.io/tx/',\n avgBlockTime: 12,\n },\n};\n\n/**\n * ่Žทๅ–้“พ้…็ฝฎ\n */\nexport function getChain(name: ChainName): ChainConfig {\n const config = CHAINS[name];\n if (!config) {\n throw new Error(`Unsupported chain: ${name}. Supported: ${Object.keys(CHAINS).join(', ')}`);\n }\n return config;\n}\n\n/**\n * ๅˆ—ๅ‡บๆ‰€ๆœ‰ๆ”ฏๆŒ็š„้“พ\n */\nexport function listChains(): ChainName[] {\n return Object.keys(CHAINS) as ChainName[];\n}\n\n/**\n * ๆ นๆฎ chainId ่Žทๅ–้“พ้…็ฝฎ\n */\nexport function getChainById(chainId: number): ChainConfig | undefined {\n return Object.values(CHAINS).find(c => c.chainId === chainId);\n}\n\n/**\n * ERC20 ABI๏ผˆๆœ€ๅฐๅŒ–๏ผŒไป…ๅŒ…ๅซ้œ€่ฆ็š„ๆ–นๆณ•๏ผ‰\n */\nexport const ERC20_ABI = [\n 'function balanceOf(address owner) view returns (uint256)',\n 'function transfer(address to, uint256 amount) returns (bool)',\n 'function approve(address spender, uint256 amount) returns (bool)',\n 'function allowance(address owner, address spender) view returns (uint256)',\n 'function decimals() view returns (uint8)',\n 'function symbol() view returns (string)',\n 'function name() view returns (string)',\n 'function nonces(address owner) view returns (uint256)',\n 'function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)',\n 'event Transfer(address indexed from, address indexed to, uint256 value)',\n 'event Approval(address indexed owner, address indexed spender, uint256 value)',\n];\n\nexport type { ChainConfig, ChainName };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,IAAM,SAAyC;AAAA;AAAA,EAEpD,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,SAAS;AAAA,IACT,KAAK;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB;AAAA,EACA,SAAS;AAAA,IACP,MAAM;AAAA,IACN,SAAS;AAAA,IACT,KAAK;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB;AAAA,EACA,UAAU;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,KAAK;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB;AAAA;AAAA,EAGA,cAAc;AAAA,IACZ,MAAM;AAAA,IACN,SAAS;AAAA,IACT,KAAK;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB;AAAA,EACA,SAAS;AAAA,IACP,MAAM;AAAA,IACN,SAAS;AAAA,IACT,KAAK;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB;AACF;AAKO,SAAS,SAAS,MAA8B;AACrD,QAAM,SAAS,OAAO,IAAI;AAC1B,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,sBAAsB,IAAI,gBAAgB,OAAO,KAAK,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE;AAAA,EAC5F;AACA,SAAO;AACT;AAKO,SAAS,aAA0B;AACxC,SAAO,OAAO,KAAK,MAAM;AAC3B;AAKO,SAAS,aAAa,SAA0C;AACrE,SAAO,OAAO,OAAO,MAAM,EAAE,KAAK,OAAK,EAAE,YAAY,OAAO;AAC9D;AAKO,IAAM,YAAY;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
@@ -0,0 +1,84 @@
1
+ // src/chains/index.ts
2
+ var CHAINS = {
3
+ // ============ ไธป็ฝ‘ ============
4
+ base: {
5
+ name: "Base",
6
+ chainId: 8453,
7
+ rpc: "https://mainnet.base.org",
8
+ usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
9
+ explorer: "https://basescan.org/address/",
10
+ explorerTx: "https://basescan.org/tx/",
11
+ avgBlockTime: 2
12
+ },
13
+ polygon: {
14
+ name: "Polygon",
15
+ chainId: 137,
16
+ rpc: "https://polygon-rpc.com",
17
+ usdc: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
18
+ explorer: "https://polygonscan.com/address/",
19
+ explorerTx: "https://polygonscan.com/tx/",
20
+ avgBlockTime: 2
21
+ },
22
+ ethereum: {
23
+ name: "Ethereum",
24
+ chainId: 1,
25
+ rpc: "https://eth.llamarpc.com",
26
+ usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
27
+ explorer: "https://etherscan.io/address/",
28
+ explorerTx: "https://etherscan.io/tx/",
29
+ avgBlockTime: 12
30
+ },
31
+ // ============ ๆต‹่ฏ•็ฝ‘ ============
32
+ base_sepolia: {
33
+ name: "Base Sepolia",
34
+ chainId: 84532,
35
+ rpc: "https://sepolia.base.org",
36
+ usdc: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
37
+ explorer: "https://sepolia.basescan.org/address/",
38
+ explorerTx: "https://sepolia.basescan.org/tx/",
39
+ avgBlockTime: 2
40
+ },
41
+ sepolia: {
42
+ name: "Sepolia",
43
+ chainId: 11155111,
44
+ rpc: "https://rpc.sepolia.org",
45
+ usdc: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
46
+ explorer: "https://sepolia.etherscan.io/address/",
47
+ explorerTx: "https://sepolia.etherscan.io/tx/",
48
+ avgBlockTime: 12
49
+ }
50
+ };
51
+ function getChain(name) {
52
+ const config = CHAINS[name];
53
+ if (!config) {
54
+ throw new Error(`Unsupported chain: ${name}. Supported: ${Object.keys(CHAINS).join(", ")}`);
55
+ }
56
+ return config;
57
+ }
58
+ function listChains() {
59
+ return Object.keys(CHAINS);
60
+ }
61
+ function getChainById(chainId) {
62
+ return Object.values(CHAINS).find((c) => c.chainId === chainId);
63
+ }
64
+ var ERC20_ABI = [
65
+ "function balanceOf(address owner) view returns (uint256)",
66
+ "function transfer(address to, uint256 amount) returns (bool)",
67
+ "function approve(address spender, uint256 amount) returns (bool)",
68
+ "function allowance(address owner, address spender) view returns (uint256)",
69
+ "function decimals() view returns (uint8)",
70
+ "function symbol() view returns (string)",
71
+ "function name() view returns (string)",
72
+ "function nonces(address owner) view returns (uint256)",
73
+ "function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)",
74
+ "event Transfer(address indexed from, address indexed to, uint256 value)",
75
+ "event Approval(address indexed owner, address indexed spender, uint256 value)"
76
+ ];
77
+ export {
78
+ CHAINS,
79
+ ERC20_ABI,
80
+ getChain,
81
+ getChainById,
82
+ listChains
83
+ };
84
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/chains/index.ts"],"sourcesContent":["/**\n * ๅŒบๅ—้“พ้…็ฝฎ\n */\n\nimport type { ChainConfig, ChainName } from '../types/index.js';\n\nexport const CHAINS: Record<ChainName, ChainConfig> = {\n // ============ ไธป็ฝ‘ ============\n base: {\n name: 'Base',\n chainId: 8453,\n rpc: 'https://mainnet.base.org',\n usdc: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',\n explorer: 'https://basescan.org/address/',\n explorerTx: 'https://basescan.org/tx/',\n avgBlockTime: 2,\n },\n polygon: {\n name: 'Polygon',\n chainId: 137,\n rpc: 'https://polygon-rpc.com',\n usdc: '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359',\n explorer: 'https://polygonscan.com/address/',\n explorerTx: 'https://polygonscan.com/tx/',\n avgBlockTime: 2,\n },\n ethereum: {\n name: 'Ethereum',\n chainId: 1,\n rpc: 'https://eth.llamarpc.com',\n usdc: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',\n explorer: 'https://etherscan.io/address/',\n explorerTx: 'https://etherscan.io/tx/',\n avgBlockTime: 12,\n },\n\n // ============ ๆต‹่ฏ•็ฝ‘ ============\n base_sepolia: {\n name: 'Base Sepolia',\n chainId: 84532,\n rpc: 'https://sepolia.base.org',\n usdc: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',\n explorer: 'https://sepolia.basescan.org/address/',\n explorerTx: 'https://sepolia.basescan.org/tx/',\n avgBlockTime: 2,\n },\n sepolia: {\n name: 'Sepolia',\n chainId: 11155111,\n rpc: 'https://rpc.sepolia.org',\n usdc: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',\n explorer: 'https://sepolia.etherscan.io/address/',\n explorerTx: 'https://sepolia.etherscan.io/tx/',\n avgBlockTime: 12,\n },\n};\n\n/**\n * ่Žทๅ–้“พ้…็ฝฎ\n */\nexport function getChain(name: ChainName): ChainConfig {\n const config = CHAINS[name];\n if (!config) {\n throw new Error(`Unsupported chain: ${name}. Supported: ${Object.keys(CHAINS).join(', ')}`);\n }\n return config;\n}\n\n/**\n * ๅˆ—ๅ‡บๆ‰€ๆœ‰ๆ”ฏๆŒ็š„้“พ\n */\nexport function listChains(): ChainName[] {\n return Object.keys(CHAINS) as ChainName[];\n}\n\n/**\n * ๆ นๆฎ chainId ่Žทๅ–้“พ้…็ฝฎ\n */\nexport function getChainById(chainId: number): ChainConfig | undefined {\n return Object.values(CHAINS).find(c => c.chainId === chainId);\n}\n\n/**\n * ERC20 ABI๏ผˆๆœ€ๅฐๅŒ–๏ผŒไป…ๅŒ…ๅซ้œ€่ฆ็š„ๆ–นๆณ•๏ผ‰\n */\nexport const ERC20_ABI = [\n 'function balanceOf(address owner) view returns (uint256)',\n 'function transfer(address to, uint256 amount) returns (bool)',\n 'function approve(address spender, uint256 amount) returns (bool)',\n 'function allowance(address owner, address spender) view returns (uint256)',\n 'function decimals() view returns (uint8)',\n 'function symbol() view returns (string)',\n 'function name() view returns (string)',\n 'function nonces(address owner) view returns (uint256)',\n 'function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)',\n 'event Transfer(address indexed from, address indexed to, uint256 value)',\n 'event Approval(address indexed owner, address indexed spender, uint256 value)',\n];\n\nexport type { ChainConfig, ChainName };\n"],"mappings":";AAMO,IAAM,SAAyC;AAAA;AAAA,EAEpD,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,SAAS;AAAA,IACT,KAAK;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB;AAAA,EACA,SAAS;AAAA,IACP,MAAM;AAAA,IACN,SAAS;AAAA,IACT,KAAK;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB;AAAA,EACA,UAAU;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,KAAK;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB;AAAA;AAAA,EAGA,cAAc;AAAA,IACZ,MAAM;AAAA,IACN,SAAS;AAAA,IACT,KAAK;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB;AAAA,EACA,SAAS;AAAA,IACP,MAAM;AAAA,IACN,SAAS;AAAA,IACT,KAAK;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB;AACF;AAKO,SAAS,SAAS,MAA8B;AACrD,QAAM,SAAS,OAAO,IAAI;AAC1B,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,sBAAsB,IAAI,gBAAgB,OAAO,KAAK,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE;AAAA,EAC5F;AACA,SAAO;AACT;AAKO,SAAS,aAA0B;AACxC,SAAO,OAAO,KAAK,MAAM;AAC3B;AAKO,SAAS,aAAa,SAA0C;AACrE,SAAO,OAAO,OAAO,MAAM,EAAE,KAAK,OAAK,EAAE,YAAY,OAAO;AAC9D;AAKO,IAAM,YAAY;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
package/dist/cli.d.mts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node