@1llet.xyz/erc4337-gasless-sdk 0.4.46 → 0.4.48
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 +71 -7
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ERC-4337 Gasless SDK ⛽️
|
|
2
2
|
|
|
3
|
-
A lightweight, typed SDK to integrate Account Abstraction (ERC-4337) and Cross-Chain transfers into your dApp. It handles Smart Account creation, gasless transactions, and orchestrates cross-chain bridges.
|
|
3
|
+
A lightweight, typed SDK to integrate Account Abstraction (ERC-4337) and Cross-Chain transfers into your dApp. It handles Smart Account creation, gasless transactions, and orchestrates cross-chain bridges strategies including CCTP and Near Intents.
|
|
4
4
|
|
|
5
5
|
## 📦 Installation
|
|
6
6
|
|
|
@@ -61,7 +61,7 @@ await aa.sendTransaction({
|
|
|
61
61
|
|
|
62
62
|
## 🌉 Cross-Chain Transfer Manager
|
|
63
63
|
|
|
64
|
-
The `TransferManager` orchestrates transfers between chains, choosing the best strategy (CCTP
|
|
64
|
+
The `TransferManager` orchestrates transfers between chains, choosing the best strategy (**CCTP**, **Near Intents**) or signaling a **Direct Transfer** if on the same chain.
|
|
65
65
|
|
|
66
66
|
```typescript
|
|
67
67
|
import { TransferManager, BridgeContext } from "@1llet.xyz/erc4337-gasless-sdk";
|
|
@@ -76,7 +76,14 @@ const context: BridgeContext = {
|
|
|
76
76
|
amount: "10.5", // Human readable string
|
|
77
77
|
recipient: "0xRecipient...",
|
|
78
78
|
senderAddress: "0xSender...",
|
|
79
|
-
|
|
79
|
+
|
|
80
|
+
// Optional: Provide depositTxHash if you already made the deposit
|
|
81
|
+
depositTxHash: "0x...",
|
|
82
|
+
|
|
83
|
+
// Optional: For Stellar source
|
|
84
|
+
paymentPayload: {
|
|
85
|
+
signedXDR: "AAAA..."
|
|
86
|
+
}
|
|
80
87
|
};
|
|
81
88
|
|
|
82
89
|
const result = await transferManager.execute(context);
|
|
@@ -86,22 +93,79 @@ if (result.success) {
|
|
|
86
93
|
// Signal to Client: Execute direct transfer on same chain!
|
|
87
94
|
console.log("Execute local transfer:", result.data);
|
|
88
95
|
} else {
|
|
89
|
-
// Cross-chain initiated
|
|
90
|
-
console.log("Bridge Tx:", result.
|
|
96
|
+
// Cross-chain initiated (or Deposit Address returned for Near)
|
|
97
|
+
console.log("Bridge Tx / Deposit Address:", result.data);
|
|
91
98
|
}
|
|
92
99
|
} else {
|
|
93
100
|
console.error("Error:", result.errorReason);
|
|
94
101
|
}
|
|
95
102
|
```
|
|
96
103
|
|
|
104
|
+
### Simulation (Quote)
|
|
105
|
+
|
|
106
|
+
You can simulate a simulation to estimate fees and received amount before executing.
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
import { getNearSimulation } from "@1llet.xyz/erc4337-gasless-sdk";
|
|
110
|
+
|
|
111
|
+
const simulation = await getNearSimulation(
|
|
112
|
+
"Base",
|
|
113
|
+
"Gnosis",
|
|
114
|
+
"10",
|
|
115
|
+
"USDC", // Source
|
|
116
|
+
"EURe" // Destination
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
if (simulation.success) {
|
|
120
|
+
console.log(`Fee: ${simulation.protocolFee}`);
|
|
121
|
+
console.log(`Est. Received: ${simulation.estimatedReceived}`);
|
|
122
|
+
} else {
|
|
123
|
+
console.error(simulation.error);
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 🌟 Stellar Service
|
|
130
|
+
|
|
131
|
+
The SDK includes a dedicated `StellarService` to handle non-EVM interactions, useful for bridging from Stellar to EVM.
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
import { StellarService } from "@1llet.xyz/erc4337-gasless-sdk";
|
|
135
|
+
|
|
136
|
+
const stellar = new StellarService();
|
|
137
|
+
|
|
138
|
+
// 1. Get Balance
|
|
139
|
+
const balance = await stellar.getBalance("G...", "USDC");
|
|
140
|
+
|
|
141
|
+
// 2. Build Transfer XDR (for bridging)
|
|
142
|
+
const xdr = await stellar.buildTransferXdr(
|
|
143
|
+
"S_SENDER_PRIVATE_KEY",
|
|
144
|
+
"G_RECIPIENT_ADDRESS",
|
|
145
|
+
"10", // Amount
|
|
146
|
+
"USDC",
|
|
147
|
+
"MEMO_IF_NEEDED"
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
// 3. Submit Transaction
|
|
151
|
+
const hash = await stellar.submitXdr(xdr);
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
97
156
|
## 🛠️ Supported Chains
|
|
98
157
|
|
|
99
158
|
The SDK exports pre-configured objects:
|
|
100
159
|
|
|
101
|
-
- `BASE_MAINNET`
|
|
102
|
-
- `BASE_SEPOLIA`
|
|
160
|
+
- `BASE_MAINNET`, `BASE_SEPOLIA`
|
|
103
161
|
- `OPTIMISM_MAINNET`
|
|
162
|
+
- `ARBITRUM_MAINNET`
|
|
104
163
|
- `GNOSIS_MAINNET`
|
|
164
|
+
- `POLYGON_MAINNET`
|
|
165
|
+
- `AVALANCHE_MAINNET`
|
|
166
|
+
- `STELLAR_MAINNET`
|
|
167
|
+
- `UNICHAIN_SEPOLIA`
|
|
168
|
+
- `WORLD_CHAIN_MAINNET`
|
|
105
169
|
|
|
106
170
|
```typescript
|
|
107
171
|
import { GNOSIS_MAINNET } from "@1llet.xyz/erc4337-gasless-sdk";
|
package/dist/index.d.mts
CHANGED
|
@@ -464,7 +464,7 @@ declare function getNearSimulation(sourceChain: ChainKey, destChain: ChainKey, a
|
|
|
464
464
|
amountSent: number;
|
|
465
465
|
protocolFee: number;
|
|
466
466
|
netAmountBridged: number;
|
|
467
|
-
estimatedReceived:
|
|
467
|
+
estimatedReceived: string;
|
|
468
468
|
minAmount: number;
|
|
469
469
|
error?: undefined;
|
|
470
470
|
} | {
|
package/dist/index.d.ts
CHANGED
|
@@ -464,7 +464,7 @@ declare function getNearSimulation(sourceChain: ChainKey, destChain: ChainKey, a
|
|
|
464
464
|
amountSent: number;
|
|
465
465
|
protocolFee: number;
|
|
466
466
|
netAmountBridged: number;
|
|
467
|
-
estimatedReceived:
|
|
467
|
+
estimatedReceived: string;
|
|
468
468
|
minAmount: number;
|
|
469
469
|
error?: undefined;
|
|
470
470
|
} | {
|
package/dist/index.js
CHANGED
|
@@ -2403,14 +2403,13 @@ async function getNearSimulation(sourceChain, destChain, amount, destToken, sour
|
|
|
2403
2403
|
sender,
|
|
2404
2404
|
{ dry: true }
|
|
2405
2405
|
);
|
|
2406
|
-
console.log(">>> [Bridge Quote] API Response:", JSON.stringify(quoteResult.quote, null, 2));
|
|
2407
2406
|
return {
|
|
2408
2407
|
success: true,
|
|
2409
2408
|
amountSent: amountNum,
|
|
2410
2409
|
protocolFee: usedFee,
|
|
2411
2410
|
netAmountBridged: parseFloat(netAmountBridged),
|
|
2412
2411
|
// @ts-ignore - access safe property
|
|
2413
|
-
estimatedReceived: quoteResult.quote?.quote?.
|
|
2412
|
+
estimatedReceived: quoteResult.quote?.quote?.amountOutFormatted || "0",
|
|
2414
2413
|
minAmount: MIN_AMOUNT
|
|
2415
2414
|
};
|
|
2416
2415
|
} catch (error) {
|