n8n-nodes-avalanche 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.
- package/LICENSE +46 -0
- package/README.md +407 -0
- package/dist/credentials/AvalancheRpc.credentials.d.ts +11 -0
- package/dist/credentials/AvalancheRpc.credentials.d.ts.map +1 -0
- package/dist/credentials/AvalancheRpc.credentials.js +172 -0
- package/dist/credentials/AvalancheRpc.credentials.js.map +1 -0
- package/dist/credentials/AvalancheSubnet.credentials.d.ts +10 -0
- package/dist/credentials/AvalancheSubnet.credentials.d.ts.map +1 -0
- package/dist/credentials/AvalancheSubnet.credentials.js +76 -0
- package/dist/credentials/AvalancheSubnet.credentials.js.map +1 -0
- package/dist/credentials/Snowtrace.credentials.d.ts +10 -0
- package/dist/credentials/Snowtrace.credentials.d.ts.map +1 -0
- package/dist/credentials/Snowtrace.credentials.js +56 -0
- package/dist/credentials/Snowtrace.credentials.js.map +1 -0
- package/dist/nodes/Avalanche/Avalanche.node.d.ts +6 -0
- package/dist/nodes/Avalanche/Avalanche.node.d.ts.map +1 -0
- package/dist/nodes/Avalanche/Avalanche.node.js +1320 -0
- package/dist/nodes/Avalanche/Avalanche.node.js.map +1 -0
- package/dist/nodes/Avalanche/AvalancheTrigger.node.d.ts +6 -0
- package/dist/nodes/Avalanche/AvalancheTrigger.node.d.ts.map +1 -0
- package/dist/nodes/Avalanche/AvalancheTrigger.node.js +384 -0
- package/dist/nodes/Avalanche/AvalancheTrigger.node.js.map +1 -0
- package/dist/nodes/Avalanche/avalanche.svg +4 -0
- package/package.json +84 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
License text copyright (c) 2017 MariaDB Corporation Ab.
|
|
4
|
+
|
|
5
|
+
Licensor:
|
|
6
|
+
Velocity BPA, LLC
|
|
7
|
+
https://velobpa.com
|
|
8
|
+
|
|
9
|
+
Licensed Work:
|
|
10
|
+
This repository and all source code, documentation, and associated artifacts
|
|
11
|
+
contained herein, including all n8n community nodes published by Velocity BPA.
|
|
12
|
+
|
|
13
|
+
Additional Use Grant:
|
|
14
|
+
You may use, modify, and run the Licensed Work free of charge for:
|
|
15
|
+
- Personal use
|
|
16
|
+
- Educational use
|
|
17
|
+
- Research use
|
|
18
|
+
- Internal business use, provided such use does not involve resale,
|
|
19
|
+
redistribution, or offering the Licensed Work as part of a commercial
|
|
20
|
+
product or service.
|
|
21
|
+
|
|
22
|
+
Commercial Use Restriction:
|
|
23
|
+
Commercial Use of the Licensed Work is prohibited without a valid
|
|
24
|
+
Commercial License issued by the Licensor.
|
|
25
|
+
|
|
26
|
+
Commercial Use includes, but is not limited to:
|
|
27
|
+
- Use of the Licensed Work within any Software-as-a-Service (SaaS),
|
|
28
|
+
Platform-as-a-Service (PaaS), or hosted application that is sold,
|
|
29
|
+
licensed, or monetized in any form
|
|
30
|
+
- Offering the Licensed Work as part of a managed services engagement
|
|
31
|
+
- Bundling or redistributing the Licensed Work with a paid product
|
|
32
|
+
- Reselling, sublicensing, or white-labeling the Licensed Work
|
|
33
|
+
- Embedding the Licensed Work into any commercial automation platform,
|
|
34
|
+
integration product, or solution offering
|
|
35
|
+
|
|
36
|
+
Change Date:
|
|
37
|
+
January 1, 2030
|
|
38
|
+
|
|
39
|
+
Change License:
|
|
40
|
+
Apache License, Version 2.0
|
|
41
|
+
|
|
42
|
+
For commercial licensing inquiries:
|
|
43
|
+
licensing@velobpa.com
|
|
44
|
+
|
|
45
|
+
Business Source License 1.1 full text:
|
|
46
|
+
https://mariadb.com/bsl11/
|
package/README.md
ADDED
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
# n8n-nodes-avalanche
|
|
2
|
+
|
|
3
|
+
> **[Velocity BPA Licensing Notice]**
|
|
4
|
+
>
|
|
5
|
+
> This n8n node is licensed under the Business Source License 1.1 (BSL 1.1).
|
|
6
|
+
>
|
|
7
|
+
> Use of this node by for-profit organizations in production environments requires a commercial license from Velocity BPA.
|
|
8
|
+
>
|
|
9
|
+
> For licensing information, visit https://velobpa.com/licensing or contact licensing@velobpa.com.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
A comprehensive n8n community node for Avalanche blockchain providing 12 resources and 40+ operations for C-Chain, X-Chain, P-Chain, DeFi, staking, and cross-chain operations. Includes polling triggers for blockchain monitoring.
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+

|
|
17
|
+

|
|
18
|
+

|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
### C-Chain (EVM) Operations
|
|
23
|
+
- **Account**: Get balances, transaction counts, transaction history
|
|
24
|
+
- **Transactions**: Send AVAX, get transaction details, wait for confirmations
|
|
25
|
+
- **Tokens (ERC-20)**: Get balances, transfer, approve, check allowances
|
|
26
|
+
- **NFTs (ERC-721/1155)**: Get balances, owners, metadata, transfer NFTs
|
|
27
|
+
- **Smart Contracts**: Read/write contract functions, get ABIs
|
|
28
|
+
- **DeFi**: WAVAX wrap/unwrap, token price queries
|
|
29
|
+
|
|
30
|
+
### X-Chain Operations
|
|
31
|
+
- Asset balances and transfers
|
|
32
|
+
- UTXO management
|
|
33
|
+
- Asset information queries
|
|
34
|
+
|
|
35
|
+
### P-Chain Operations
|
|
36
|
+
- **Validators**: Get current/pending validators
|
|
37
|
+
- **Staking**: Get staking parameters and info
|
|
38
|
+
- **Subnets**: Query subnet information
|
|
39
|
+
|
|
40
|
+
### Cross-Chain
|
|
41
|
+
- Atomic UTXOs for cross-chain transfers
|
|
42
|
+
- Multi-chain balance queries
|
|
43
|
+
|
|
44
|
+
### Network & Utility
|
|
45
|
+
- Network information (ID, name, node version)
|
|
46
|
+
- Gas price and fee data
|
|
47
|
+
- Block information
|
|
48
|
+
- AVAX price from Snowtrace
|
|
49
|
+
- Unit conversion utilities
|
|
50
|
+
- Address validation
|
|
51
|
+
|
|
52
|
+
### Triggers (Polling)
|
|
53
|
+
- New block detection
|
|
54
|
+
- Address activity monitoring
|
|
55
|
+
- Token transfer monitoring
|
|
56
|
+
- Contract event listening
|
|
57
|
+
- Balance change alerts
|
|
58
|
+
- Gas price alerts
|
|
59
|
+
- Whale transfer alerts
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
### Community Nodes (Recommended)
|
|
64
|
+
|
|
65
|
+
1. Open n8n
|
|
66
|
+
2. Go to **Settings** > **Community Nodes**
|
|
67
|
+
3. Click **Install a community node**
|
|
68
|
+
4. Enter `n8n-nodes-avalanche`
|
|
69
|
+
5. Click **Install**
|
|
70
|
+
|
|
71
|
+
### Manual Installation
|
|
72
|
+
|
|
73
|
+
1. Clone or download this repository:
|
|
74
|
+
```bash
|
|
75
|
+
git clone https://github.com/Velocity-BPA/n8n-nodes-avalanche.git
|
|
76
|
+
cd n8n-nodes-avalanche
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
2. Install dependencies and build:
|
|
80
|
+
```bash
|
|
81
|
+
npm install
|
|
82
|
+
npm run build
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
3. Link to n8n:
|
|
86
|
+
```bash
|
|
87
|
+
mkdir -p ~/.n8n/custom
|
|
88
|
+
ln -s $(pwd) ~/.n8n/custom/n8n-nodes-avalanche
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
4. Restart n8n
|
|
92
|
+
|
|
93
|
+
### Development Installation
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Extract the zip file
|
|
97
|
+
unzip n8n-nodes-avalanche.zip
|
|
98
|
+
cd n8n-nodes-avalanche
|
|
99
|
+
|
|
100
|
+
# Install dependencies
|
|
101
|
+
npm install
|
|
102
|
+
|
|
103
|
+
# Build the project
|
|
104
|
+
npm run build
|
|
105
|
+
|
|
106
|
+
# Create symlink to n8n custom nodes directory
|
|
107
|
+
mkdir -p ~/.n8n/custom
|
|
108
|
+
ln -s $(pwd) ~/.n8n/custom/n8n-nodes-avalanche
|
|
109
|
+
|
|
110
|
+
# Restart n8n
|
|
111
|
+
n8n start
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Credentials Setup
|
|
115
|
+
|
|
116
|
+
### Avalanche RPC
|
|
117
|
+
|
|
118
|
+
| Field | Description |
|
|
119
|
+
|-------|-------------|
|
|
120
|
+
| Network | Mainnet, Fuji Testnet, or Custom |
|
|
121
|
+
| RPC Provider | Public (free), Infura, Alchemy, QuickNode, or Custom URL |
|
|
122
|
+
| Private Key | Optional - for signing transactions (hex format) |
|
|
123
|
+
|
|
124
|
+
### Snowtrace API
|
|
125
|
+
|
|
126
|
+
| Field | Description |
|
|
127
|
+
|-------|-------------|
|
|
128
|
+
| API Key | Get from [Snowtrace](https://snowtrace.io/apis) |
|
|
129
|
+
| Network | Mainnet or Fuji |
|
|
130
|
+
|
|
131
|
+
### Avalanche Subnet
|
|
132
|
+
|
|
133
|
+
| Field | Description |
|
|
134
|
+
|-------|-------------|
|
|
135
|
+
| Subnet RPC URL | Your subnet's RPC endpoint |
|
|
136
|
+
| Subnet ID | The subnet identifier |
|
|
137
|
+
| Blockchain ID | The blockchain identifier |
|
|
138
|
+
| Chain ID | The EVM chain ID |
|
|
139
|
+
|
|
140
|
+
## Resources & Operations
|
|
141
|
+
|
|
142
|
+
### Account
|
|
143
|
+
| Operation | Description |
|
|
144
|
+
|-----------|-------------|
|
|
145
|
+
| Get Balance | Get AVAX balance of an address |
|
|
146
|
+
| Get Transaction Count | Get nonce/transaction count |
|
|
147
|
+
| Get Transaction History | Get transaction history from Snowtrace |
|
|
148
|
+
|
|
149
|
+
### Block
|
|
150
|
+
| Operation | Description |
|
|
151
|
+
|-----------|-------------|
|
|
152
|
+
| Get Block | Get block by number or hash |
|
|
153
|
+
| Get Latest Block | Get the latest block |
|
|
154
|
+
| Get Block Number | Get current block number |
|
|
155
|
+
|
|
156
|
+
### Token (ERC-20)
|
|
157
|
+
| Operation | Description |
|
|
158
|
+
|-----------|-------------|
|
|
159
|
+
| Get Token Balance | Get ERC-20 token balance |
|
|
160
|
+
| Get Token Info | Get token name, symbol, decimals |
|
|
161
|
+
| Transfer Token | Transfer ERC-20 tokens |
|
|
162
|
+
| Get Allowance | Get token spending allowance |
|
|
163
|
+
| Approve Token | Approve token spending |
|
|
164
|
+
|
|
165
|
+
### NFT (ERC-721)
|
|
166
|
+
| Operation | Description |
|
|
167
|
+
|-----------|-------------|
|
|
168
|
+
| Get NFT Balance | Get NFT balance for an address |
|
|
169
|
+
| Get NFT Owner | Get owner of an NFT |
|
|
170
|
+
| Get NFT Metadata | Get NFT metadata |
|
|
171
|
+
| Get NFT Token URI | Get NFT token URI |
|
|
172
|
+
|
|
173
|
+
### Transaction
|
|
174
|
+
| Operation | Description |
|
|
175
|
+
|-----------|-------------|
|
|
176
|
+
| Send AVAX | Send AVAX to an address |
|
|
177
|
+
| Get Transaction | Get transaction details |
|
|
178
|
+
| Get Transaction Receipt | Get transaction receipt |
|
|
179
|
+
| Wait for Transaction | Wait for confirmation |
|
|
180
|
+
|
|
181
|
+
### Contract
|
|
182
|
+
| Operation | Description |
|
|
183
|
+
|-----------|-------------|
|
|
184
|
+
| Read Contract | Call a read-only function |
|
|
185
|
+
| Write Contract | Execute a contract function |
|
|
186
|
+
| Get ABI | Get contract ABI from Snowtrace |
|
|
187
|
+
|
|
188
|
+
### DeFi
|
|
189
|
+
| Operation | Description |
|
|
190
|
+
|-----------|-------------|
|
|
191
|
+
| Get Token Price | Get token price from DEX |
|
|
192
|
+
| Get Swap Quote | Get quote for token swap |
|
|
193
|
+
| Wrap AVAX | Wrap AVAX to WAVAX |
|
|
194
|
+
| Unwrap WAVAX | Unwrap WAVAX to AVAX |
|
|
195
|
+
|
|
196
|
+
### P-Chain
|
|
197
|
+
| Operation | Description |
|
|
198
|
+
|-----------|-------------|
|
|
199
|
+
| Get Validators | Get current validators |
|
|
200
|
+
| Get Pending Validators | Get pending validators |
|
|
201
|
+
| Get Staking Info | Get staking parameters |
|
|
202
|
+
| Get Subnets | Get all subnets |
|
|
203
|
+
|
|
204
|
+
### X-Chain
|
|
205
|
+
| Operation | Description |
|
|
206
|
+
|-----------|-------------|
|
|
207
|
+
| Get Balance | Get X-Chain balance |
|
|
208
|
+
| Get Asset Info | Get asset information |
|
|
209
|
+
| Get UTXOs | Get UTXOs for an address |
|
|
210
|
+
|
|
211
|
+
### Network
|
|
212
|
+
| Operation | Description |
|
|
213
|
+
|-----------|-------------|
|
|
214
|
+
| Get Network Info | Get network information |
|
|
215
|
+
| Get Gas Price | Get current gas price |
|
|
216
|
+
| Get Chain ID | Get chain ID |
|
|
217
|
+
| Get AVAX Price | Get AVAX price in USD |
|
|
218
|
+
|
|
219
|
+
### Utility
|
|
220
|
+
| Operation | Description |
|
|
221
|
+
|-----------|-------------|
|
|
222
|
+
| Convert Units | Convert between AVAX units |
|
|
223
|
+
| Validate Address | Validate Avalanche address |
|
|
224
|
+
| Encode Function | Encode function call data |
|
|
225
|
+
| Decode Function | Decode function return data |
|
|
226
|
+
|
|
227
|
+
## Trigger Node
|
|
228
|
+
|
|
229
|
+
The Avalanche Trigger node monitors blockchain events using polling.
|
|
230
|
+
|
|
231
|
+
### Event Types
|
|
232
|
+
|
|
233
|
+
| Event | Description |
|
|
234
|
+
|-------|-------------|
|
|
235
|
+
| New Block | Trigger on new blocks |
|
|
236
|
+
| Address Activity | Monitor address for transactions |
|
|
237
|
+
| Token Transfer | Monitor ERC-20 transfers |
|
|
238
|
+
| Contract Event | Listen for contract events |
|
|
239
|
+
| Balance Change | Monitor balance changes |
|
|
240
|
+
| Gas Price Alert | Alert on gas price changes |
|
|
241
|
+
| Whale Alert | Large transfer monitoring |
|
|
242
|
+
|
|
243
|
+
## Usage Examples
|
|
244
|
+
|
|
245
|
+
### Get Account Balance
|
|
246
|
+
|
|
247
|
+
```javascript
|
|
248
|
+
// Using Avalanche node
|
|
249
|
+
// Resource: Account
|
|
250
|
+
// Operation: Get Balance
|
|
251
|
+
// Address: 0x742d35Cc6634C0532925a3b844Bc9e7595f9Eb3d
|
|
252
|
+
|
|
253
|
+
// Returns:
|
|
254
|
+
{
|
|
255
|
+
"address": "0x742d35Cc6634C0532925a3b844Bc9e7595f9Eb3d",
|
|
256
|
+
"balanceWei": "1500000000000000000",
|
|
257
|
+
"balanceAvax": "1.5"
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Send AVAX
|
|
262
|
+
|
|
263
|
+
```javascript
|
|
264
|
+
// Using Avalanche node
|
|
265
|
+
// Resource: Transaction
|
|
266
|
+
// Operation: Send AVAX
|
|
267
|
+
// To Address: 0x...
|
|
268
|
+
// Amount: 1.0
|
|
269
|
+
|
|
270
|
+
// Returns:
|
|
271
|
+
{
|
|
272
|
+
"hash": "0x...",
|
|
273
|
+
"from": "0x...",
|
|
274
|
+
"to": "0x...",
|
|
275
|
+
"value": "1.0"
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Monitor Whale Transfers
|
|
280
|
+
|
|
281
|
+
```javascript
|
|
282
|
+
// Using Avalanche Trigger node
|
|
283
|
+
// Event: Whale Alert
|
|
284
|
+
// Threshold: 10000 AVAX
|
|
285
|
+
|
|
286
|
+
// Triggers when transfers >= 10000 AVAX detected
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Avalanche Concepts
|
|
290
|
+
|
|
291
|
+
### Three-Chain Architecture
|
|
292
|
+
|
|
293
|
+
Avalanche uses three built-in blockchains:
|
|
294
|
+
|
|
295
|
+
- **C-Chain**: Contract Chain - EVM-compatible for smart contracts
|
|
296
|
+
- **X-Chain**: Exchange Chain - for creating and trading assets
|
|
297
|
+
- **P-Chain**: Platform Chain - for validators and subnets
|
|
298
|
+
|
|
299
|
+
### Native Token
|
|
300
|
+
|
|
301
|
+
AVAX is the native token used for:
|
|
302
|
+
- Transaction fees
|
|
303
|
+
- Staking
|
|
304
|
+
- Subnet creation
|
|
305
|
+
- Cross-chain transfers
|
|
306
|
+
|
|
307
|
+
### Subnets
|
|
308
|
+
|
|
309
|
+
Subnets are independent networks that can have their own:
|
|
310
|
+
- Validators
|
|
311
|
+
- Virtual machines
|
|
312
|
+
- Token economics
|
|
313
|
+
- Governance rules
|
|
314
|
+
|
|
315
|
+
## Networks
|
|
316
|
+
|
|
317
|
+
| Network | Chain ID | RPC Endpoint |
|
|
318
|
+
|---------|----------|--------------|
|
|
319
|
+
| Mainnet C-Chain | 43114 | https://api.avax.network/ext/bc/C/rpc |
|
|
320
|
+
| Fuji C-Chain | 43113 | https://api.avax-test.network/ext/bc/C/rpc |
|
|
321
|
+
|
|
322
|
+
## Error Handling
|
|
323
|
+
|
|
324
|
+
The node includes comprehensive error handling:
|
|
325
|
+
|
|
326
|
+
- Network connection errors
|
|
327
|
+
- Invalid address errors
|
|
328
|
+
- Insufficient balance errors
|
|
329
|
+
- Contract execution errors
|
|
330
|
+
- Rate limiting errors
|
|
331
|
+
|
|
332
|
+
Enable **Continue on Fail** to handle errors gracefully in workflows.
|
|
333
|
+
|
|
334
|
+
## Security Best Practices
|
|
335
|
+
|
|
336
|
+
1. **Never share private keys** - Use secure credential storage
|
|
337
|
+
2. **Use testnet first** - Test workflows on Fuji before mainnet
|
|
338
|
+
3. **Validate addresses** - Use the Validate Address operation
|
|
339
|
+
4. **Set gas limits** - Prevent unexpected transaction costs
|
|
340
|
+
5. **Monitor balances** - Use triggers to track wallet activity
|
|
341
|
+
|
|
342
|
+
## Development
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
# Install dependencies
|
|
346
|
+
npm install
|
|
347
|
+
|
|
348
|
+
# Build
|
|
349
|
+
npm run build
|
|
350
|
+
|
|
351
|
+
# Watch mode
|
|
352
|
+
npm run dev
|
|
353
|
+
|
|
354
|
+
# Run tests
|
|
355
|
+
npm test
|
|
356
|
+
|
|
357
|
+
# Run tests with coverage
|
|
358
|
+
npm run test:coverage
|
|
359
|
+
|
|
360
|
+
# Lint
|
|
361
|
+
npm run lint
|
|
362
|
+
|
|
363
|
+
# Fix linting issues
|
|
364
|
+
npm run lint:fix
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
## Author
|
|
368
|
+
|
|
369
|
+
**Velocity BPA**
|
|
370
|
+
- Website: [velobpa.com](https://velobpa.com)
|
|
371
|
+
- GitHub: [Velocity-BPA](https://github.com/Velocity-BPA)
|
|
372
|
+
|
|
373
|
+
## Licensing
|
|
374
|
+
|
|
375
|
+
This n8n community node is licensed under the **Business Source License 1.1**.
|
|
376
|
+
|
|
377
|
+
### Free Use
|
|
378
|
+
Permitted for personal, educational, research, and internal business use.
|
|
379
|
+
|
|
380
|
+
### Commercial Use
|
|
381
|
+
Use of this node within any SaaS, PaaS, hosted platform, managed service,
|
|
382
|
+
or paid automation offering requires a commercial license.
|
|
383
|
+
|
|
384
|
+
For licensing inquiries:
|
|
385
|
+
**licensing@velobpa.com**
|
|
386
|
+
|
|
387
|
+
See [LICENSE](LICENSE), [COMMERCIAL_LICENSE.md](COMMERCIAL_LICENSE.md), and [LICENSING_FAQ.md](LICENSING_FAQ.md) for details.
|
|
388
|
+
|
|
389
|
+
## Contributing
|
|
390
|
+
|
|
391
|
+
Contributions are welcome! Please ensure:
|
|
392
|
+
|
|
393
|
+
1. Code follows the existing style
|
|
394
|
+
2. Tests are included for new features
|
|
395
|
+
3. Documentation is updated
|
|
396
|
+
4. Licensing headers are included in new files
|
|
397
|
+
|
|
398
|
+
## Support
|
|
399
|
+
|
|
400
|
+
For issues and feature requests, please use the [GitHub Issues](https://github.com/Velocity-BPA/n8n-nodes-avalanche/issues) page.
|
|
401
|
+
|
|
402
|
+
## Acknowledgments
|
|
403
|
+
|
|
404
|
+
- [Avalanche](https://www.avax.network/) - Blockchain platform
|
|
405
|
+
- [n8n](https://n8n.io/) - Workflow automation platform
|
|
406
|
+
- [ethers.js](https://ethers.org/) - Ethereum library
|
|
407
|
+
- [Snowtrace](https://snowtrace.io/) - Block explorer API
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IAuthenticateGeneric, ICredentialDataDecryptedObject, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class AvalancheRpc implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
documentationUrl: string;
|
|
6
|
+
properties: INodeProperties[];
|
|
7
|
+
authenticate: IAuthenticateGeneric;
|
|
8
|
+
test: ICredentialTestRequest;
|
|
9
|
+
}
|
|
10
|
+
export declare function getRpcUrl(credentials: ICredentialDataDecryptedObject): string;
|
|
11
|
+
//# sourceMappingURL=AvalancheRpc.credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AvalancheRpc.credentials.d.ts","sourceRoot":"","sources":["../../credentials/AvalancheRpc.credentials.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,oBAAoB,EACpB,8BAA8B,EAC9B,sBAAsB,EACtB,eAAe,EACf,eAAe,EAChB,MAAM,cAAc,CAAC;AAEtB,qBAAa,YAAa,YAAW,eAAe;IAClD,IAAI,SAAkB;IACtB,WAAW,SAAmB;IAC9B,gBAAgB,SAAqD;IACrE,UAAU,EAAE,eAAe,EAAE,CAmG3B;IAEF,YAAY,EAAE,oBAAoB,CAGhC;IAEF,IAAI,EAAE,sBAAsB,CAe1B;CACH;AAED,wBAAgB,SAAS,CAAC,WAAW,EAAE,8BAA8B,GAAG,MAAM,CAmC7E"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) Velocity BPA, LLC
|
|
4
|
+
* Licensed under the Business Source License 1.1
|
|
5
|
+
* Commercial use requires a separate commercial license.
|
|
6
|
+
* See LICENSE file for details.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AvalancheRpc = void 0;
|
|
10
|
+
exports.getRpcUrl = getRpcUrl;
|
|
11
|
+
class AvalancheRpc {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.name = 'avalancheRpc';
|
|
14
|
+
this.displayName = 'Avalanche RPC';
|
|
15
|
+
this.documentationUrl = 'https://docs.avax.network/apis/avalanchego/apis';
|
|
16
|
+
this.properties = [
|
|
17
|
+
{
|
|
18
|
+
displayName: 'Network',
|
|
19
|
+
name: 'network',
|
|
20
|
+
type: 'options',
|
|
21
|
+
options: [
|
|
22
|
+
{ name: 'Mainnet', value: 'mainnet' },
|
|
23
|
+
{ name: 'Fuji Testnet', value: 'fuji' },
|
|
24
|
+
{ name: 'Custom', value: 'custom' },
|
|
25
|
+
],
|
|
26
|
+
default: 'mainnet',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
displayName: 'RPC Provider',
|
|
30
|
+
name: 'rpcProvider',
|
|
31
|
+
type: 'options',
|
|
32
|
+
options: [
|
|
33
|
+
{ name: 'Public (Free)', value: 'public' },
|
|
34
|
+
{ name: 'Infura', value: 'infura' },
|
|
35
|
+
{ name: 'Alchemy', value: 'alchemy' },
|
|
36
|
+
{ name: 'QuickNode', value: 'quicknode' },
|
|
37
|
+
{ name: 'Custom URL', value: 'custom' },
|
|
38
|
+
],
|
|
39
|
+
default: 'public',
|
|
40
|
+
displayOptions: {
|
|
41
|
+
show: {
|
|
42
|
+
network: ['mainnet', 'fuji'],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
displayName: 'Infura Project ID',
|
|
48
|
+
name: 'infuraProjectId',
|
|
49
|
+
type: 'string',
|
|
50
|
+
typeOptions: { password: true },
|
|
51
|
+
default: '',
|
|
52
|
+
displayOptions: {
|
|
53
|
+
show: {
|
|
54
|
+
rpcProvider: ['infura'],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
displayName: 'Alchemy API Key',
|
|
60
|
+
name: 'alchemyApiKey',
|
|
61
|
+
type: 'string',
|
|
62
|
+
typeOptions: { password: true },
|
|
63
|
+
default: '',
|
|
64
|
+
displayOptions: {
|
|
65
|
+
show: {
|
|
66
|
+
rpcProvider: ['alchemy'],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
displayName: 'QuickNode Endpoint URL',
|
|
72
|
+
name: 'quicknodeUrl',
|
|
73
|
+
type: 'string',
|
|
74
|
+
typeOptions: { password: true },
|
|
75
|
+
default: '',
|
|
76
|
+
placeholder: 'https://your-endpoint.quiknode.pro/your-key/',
|
|
77
|
+
displayOptions: {
|
|
78
|
+
show: {
|
|
79
|
+
rpcProvider: ['quicknode'],
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
displayName: 'Custom RPC URL',
|
|
85
|
+
name: 'customRpcUrl',
|
|
86
|
+
type: 'string',
|
|
87
|
+
default: '',
|
|
88
|
+
placeholder: 'https://your-rpc-endpoint.com',
|
|
89
|
+
displayOptions: {
|
|
90
|
+
show: {
|
|
91
|
+
rpcProvider: ['custom'],
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
displayName: 'Custom RPC URL',
|
|
97
|
+
name: 'customNetworkUrl',
|
|
98
|
+
type: 'string',
|
|
99
|
+
default: '',
|
|
100
|
+
placeholder: 'https://your-rpc-endpoint.com',
|
|
101
|
+
displayOptions: {
|
|
102
|
+
show: {
|
|
103
|
+
network: ['custom'],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
displayName: 'Private Key (Optional)',
|
|
109
|
+
name: 'privateKey',
|
|
110
|
+
type: 'string',
|
|
111
|
+
typeOptions: { password: true },
|
|
112
|
+
default: '',
|
|
113
|
+
description: 'Private key for signing transactions (hex format without 0x prefix)',
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
this.authenticate = {
|
|
117
|
+
type: 'generic',
|
|
118
|
+
properties: {},
|
|
119
|
+
};
|
|
120
|
+
this.test = {
|
|
121
|
+
request: {
|
|
122
|
+
baseURL: '={{$self.getRpcUrl()}}',
|
|
123
|
+
url: '',
|
|
124
|
+
method: 'POST',
|
|
125
|
+
body: JSON.stringify({
|
|
126
|
+
jsonrpc: '2.0',
|
|
127
|
+
id: 1,
|
|
128
|
+
method: 'eth_chainId',
|
|
129
|
+
params: [],
|
|
130
|
+
}),
|
|
131
|
+
headers: {
|
|
132
|
+
'Content-Type': 'application/json',
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.AvalancheRpc = AvalancheRpc;
|
|
139
|
+
function getRpcUrl(credentials) {
|
|
140
|
+
const network = credentials.network;
|
|
141
|
+
const rpcProvider = credentials.rpcProvider;
|
|
142
|
+
if (network === 'custom') {
|
|
143
|
+
return credentials.customNetworkUrl;
|
|
144
|
+
}
|
|
145
|
+
const isMainnet = network === 'mainnet';
|
|
146
|
+
const baseMainnet = 'https://api.avax.network';
|
|
147
|
+
const baseFuji = 'https://api.avax-test.network';
|
|
148
|
+
const baseUrl = isMainnet ? baseMainnet : baseFuji;
|
|
149
|
+
switch (rpcProvider) {
|
|
150
|
+
case 'public':
|
|
151
|
+
return `${baseUrl}/ext/bc/C/rpc`;
|
|
152
|
+
case 'infura': {
|
|
153
|
+
const infuraId = credentials.infuraProjectId;
|
|
154
|
+
return isMainnet
|
|
155
|
+
? `https://avalanche-mainnet.infura.io/v3/${infuraId}`
|
|
156
|
+
: `https://avalanche-fuji.infura.io/v3/${infuraId}`;
|
|
157
|
+
}
|
|
158
|
+
case 'alchemy': {
|
|
159
|
+
const alchemyKey = credentials.alchemyApiKey;
|
|
160
|
+
return isMainnet
|
|
161
|
+
? `https://avax-mainnet.g.alchemy.com/v2/${alchemyKey}`
|
|
162
|
+
: `https://avax-fuji.g.alchemy.com/v2/${alchemyKey}`;
|
|
163
|
+
}
|
|
164
|
+
case 'quicknode':
|
|
165
|
+
return credentials.quicknodeUrl;
|
|
166
|
+
case 'custom':
|
|
167
|
+
return credentials.customRpcUrl;
|
|
168
|
+
default:
|
|
169
|
+
return `${baseUrl}/ext/bc/C/rpc`;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=AvalancheRpc.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AvalancheRpc.credentials.js","sourceRoot":"","sources":["../../credentials/AvalancheRpc.credentials.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA0IH,8BAmCC;AAnKD,MAAa,YAAY;IAAzB;QACE,SAAI,GAAG,cAAc,CAAC;QACtB,gBAAW,GAAG,eAAe,CAAC;QAC9B,qBAAgB,GAAG,iDAAiD,CAAC;QACrE,eAAU,GAAsB;YAC9B;gBACE,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE;oBACP,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;oBACrC,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE;oBACvC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;iBACpC;gBACD,OAAO,EAAE,SAAS;aACnB;YACD;gBACE,WAAW,EAAE,cAAc;gBAC3B,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE;oBACP,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,QAAQ,EAAE;oBAC1C,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;oBACnC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;oBACrC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE;oBACzC,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE;iBAC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AAC;IAEnD,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,QAAQ;YACX,OAAO,GAAG,OAAO,eAAe,CAAC;QACnC,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,QAAQ,GAAG,WAAW,CAAC,eAAyB,CAAC;YACvD,OAAO,SAAS;gBACd,CAAC,CAAC,0CAA0C,QAAQ,EAAE;gBACtD,CAAC,CAAC,uCAAuC,QAAQ,EAAE,CAAC;QACxD,CAAC;QACD,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,MAAM,UAAU,GAAG,WAAW,CAAC,aAAuB,CAAC;YACvD,OAAO,SAAS;gBACd,CAAC,CAAC,yCAAyC,UAAU,EAAE;gBACvD,CAAC,CAAC,sCAAsC,UAAU,EAAE,CAAC;QACzD,CAAC;QACD,KAAK,WAAW;YACd,OAAO,WAAW,CAAC,YAAsB,CAAC;QAC5C,KAAK,QAAQ;YACX,OAAO,WAAW,CAAC,YAAsB,CAAC;QAC5C;YACE,OAAO,GAAG,OAAO,eAAe,CAAC;IACrC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class AvalancheSubnet implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
documentationUrl: string;
|
|
6
|
+
properties: INodeProperties[];
|
|
7
|
+
authenticate: IAuthenticateGeneric;
|
|
8
|
+
test: ICredentialTestRequest;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=AvalancheSubnet.credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AvalancheSubnet.credentials.d.ts","sourceRoot":"","sources":["../../credentials/AvalancheSubnet.credentials.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,eAAe,EAChB,MAAM,cAAc,CAAC;AAEtB,qBAAa,eAAgB,YAAW,eAAe;IACrD,IAAI,SAAqB;IACzB,WAAW,SAAsB;IACjC,gBAAgB,SAAuC;IACvD,UAAU,EAAE,eAAe,EAAE,CAqC3B;IAEF,YAAY,EAAE,oBAAoB,CAGhC;IAEF,IAAI,EAAE,sBAAsB,CAe1B;CACH"}
|