@agglayer/sdk 0.1.0-beta.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 +136 -0
- package/dist/index.d.mts +803 -0
- package/dist/index.d.ts +803 -0
- package/dist/index.js +1863 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1842 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +78 -0
package/README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# AggLayer SDK
|
|
2
|
+
|
|
3
|
+
A TypeScript SDK for interacting with AggLayer.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install agglayer-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { AggLayerSDK } from 'agglayer-sdk';
|
|
15
|
+
|
|
16
|
+
const sdk = new AggLayerSDK();
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Development
|
|
20
|
+
|
|
21
|
+
### Prerequisites
|
|
22
|
+
|
|
23
|
+
- Node.js 18+
|
|
24
|
+
- npm
|
|
25
|
+
|
|
26
|
+
### Setup
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Available Scripts
|
|
33
|
+
|
|
34
|
+
- `npm run build` - Build the library
|
|
35
|
+
- `npm run dev` - Build in watch mode
|
|
36
|
+
- `npm run test` - Run tests
|
|
37
|
+
- `npm run test:coverage` - Run tests with coverage
|
|
38
|
+
- `npm run lint` - Run ESLint
|
|
39
|
+
- `npm run lint:fix` - Fix ESLint issues
|
|
40
|
+
- `npm run format` - Format code with Prettier
|
|
41
|
+
- `npm run typecheck` - Type check with TypeScript
|
|
42
|
+
|
|
43
|
+
### Initialize SDK
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { AggLayerSDK } from 'agglayer-sdk';
|
|
47
|
+
|
|
48
|
+
const sdk = new AggLayerSDK({
|
|
49
|
+
mode: ['native'],
|
|
50
|
+
native: {
|
|
51
|
+
defaultNetwork: 11155111,
|
|
52
|
+
chains: [
|
|
53
|
+
{
|
|
54
|
+
id: 11155111,
|
|
55
|
+
name: 'Ethereum Sepolia',
|
|
56
|
+
rpcUrl: 'https://rpc.sepolia.org',
|
|
57
|
+
nativeCurrency: { name: 'Sepolia Ether', symbol: 'ETH', decimals: 18 },
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
customRpcUrls: {
|
|
61
|
+
1: 'https://your-custom-eth-rpc.com',
|
|
62
|
+
137: 'https://your-custom-polygon-rpc.com',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Read Operation - Get Token Balance
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
// Get Native client
|
|
72
|
+
const native = sdk.getNative();
|
|
73
|
+
|
|
74
|
+
// Create ERC20 instance
|
|
75
|
+
const erc20 = native.erc20(
|
|
76
|
+
'0x1234567890123456789012345678901234567890',
|
|
77
|
+
11155111
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
// Get balance
|
|
81
|
+
const balance = await erc20.getBalance(
|
|
82
|
+
'0xabcdefabcdefabcdefabcdefabcdefabcdefabcd'
|
|
83
|
+
);
|
|
84
|
+
console.log('Balance:', balance); // Returns balance in wei as string
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Write Operation - Build Transfer Transaction
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
// Create ERC20 instance
|
|
91
|
+
const erc20 = native.erc20(
|
|
92
|
+
'0x1234567890123456789012345678901234567890',
|
|
93
|
+
11155111
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
// Build transfer transaction
|
|
97
|
+
const transaction = await erc20.buildTransfer(
|
|
98
|
+
'0xabcdefabcdefabcdefabcdefabcdefabcdefabcd', // recipient
|
|
99
|
+
'1000000000000000000', // amount in wei
|
|
100
|
+
'0x1111111111111111111111111111111111111111' // from address
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
console.log('Transaction:', transaction);
|
|
104
|
+
// Returns: { to, data, gas, maxFeePerGas, maxPriorityFeePerGas, nonce }
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Features
|
|
108
|
+
|
|
109
|
+
- **ERC20 Operations**: Balance, allowance, transfers, approvals
|
|
110
|
+
- **Transaction Building**: Build transactions for MetaMask or other wallets
|
|
111
|
+
- **Multi-Chain Support**: Support for multiple blockchain networks
|
|
112
|
+
- **TypeScript**: Full TypeScript support with type safety
|
|
113
|
+
- **Lightweight**: Minimal dependencies, focused on core functionality
|
|
114
|
+
|
|
115
|
+
### Code Quality
|
|
116
|
+
|
|
117
|
+
This project uses:
|
|
118
|
+
|
|
119
|
+
- **ESLint** for code linting with strict TypeScript rules
|
|
120
|
+
- **Prettier** for code formatting
|
|
121
|
+
- **Vitest** for testing
|
|
122
|
+
- **Husky** for git hooks
|
|
123
|
+
- **TypeScript** with strict configuration
|
|
124
|
+
|
|
125
|
+
### Contributing
|
|
126
|
+
|
|
127
|
+
1. Fork the repository
|
|
128
|
+
2. Create a feature branch
|
|
129
|
+
3. Make your changes
|
|
130
|
+
4. Run tests: `npm run test`
|
|
131
|
+
5. Run linting: `npm run lint`
|
|
132
|
+
6. Submit a pull request
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
ISC
|