@paulstinchcombe/gasless-nft-tx 0.7.2 → 0.8.1
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 +228 -672
- package/dist/SmartContractWallet/ContractDeployer.d.ts +32 -0
- package/dist/SmartContractWallet/ContractDeployer.d.ts.map +1 -0
- package/dist/SmartContractWallet/ContractDeployer.js +29 -0
- package/dist/SmartContractWallet/ContractDeployer.js.map +1 -0
- package/dist/index.d.ts +13 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -77
- package/dist/index.js.map +1 -1
- package/dist/kami-sponsored-deployment.d.ts +103 -0
- package/dist/kami-sponsored-deployment.d.ts.map +1 -0
- package/dist/kami-sponsored-deployment.js +376 -0
- package/dist/kami-sponsored-deployment.js.map +1 -0
- package/dist/kami-sponsored-operations.d.ts +169 -0
- package/dist/kami-sponsored-operations.d.ts.map +1 -0
- package/dist/kami-sponsored-operations.js +458 -0
- package/dist/kami-sponsored-operations.js.map +1 -0
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -1,779 +1,335 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Sponsored KAMI NFT Transactions Library
|
|
2
2
|
|
|
3
|
-
A comprehensive TypeScript library for
|
|
4
|
-
|
|
5
|
-
> **📚 For the complete consolidated guide, see [docs/CONSOLIDATED_GUIDE.md](docs/CONSOLIDATED_GUIDE.md)**
|
|
3
|
+
A comprehensive TypeScript library for **truly sponsored** KAMI NFT operations where users pay **ZERO gas fees** for all transactions.
|
|
6
4
|
|
|
7
5
|
## 🎯 What This Library Does
|
|
8
6
|
|
|
9
|
-
- ✅ **Truly
|
|
7
|
+
- ✅ **Truly Sponsored Operations** - Users pay ZERO gas fees for ALL operations
|
|
8
|
+
- ✅ **Complete NFT Management** - Deploy, mint, rent, sell, and manage NFTs
|
|
10
9
|
- ✅ **Three NFT Standards** - Support for KAMI721C (ERC721), KAMI721AC (ERC721A), and KAMI1155C (ERC1155)
|
|
11
|
-
- ✅ **
|
|
12
|
-
- ✅ **
|
|
13
|
-
- ✅ **Library Linking** - Automatic handling of Solidity library dependencies
|
|
10
|
+
- ✅ **Platform-Sponsored** - Platform pays all gas costs
|
|
11
|
+
- ✅ **User Ownership** - All contracts owned by user's EOA
|
|
14
12
|
- ✅ **Type-Safe** - Full TypeScript support with comprehensive type definitions
|
|
15
13
|
|
|
16
|
-
##
|
|
17
|
-
|
|
18
|
-
- [Quick Start](#quick-start)
|
|
19
|
-
- [Complete Setup Guide](#complete-setup-guide)
|
|
20
|
-
- [Step 1: Environment Setup](#step-1-environment-setup)
|
|
21
|
-
- [Step 2: Deploy SimpleAccount](#step-2-deploy-simpleaccount)
|
|
22
|
-
- [Step 3: Deploy ContractDeployer](#step-3-deploy-contractdeployer)
|
|
23
|
-
- [Step 4: Deploy KAMI Libraries](#step-4-deploy-kami-libraries)
|
|
24
|
-
- [Step 5: Deploy Your NFT Contract](#step-5-deploy-your-nft-contract)
|
|
25
|
-
- [Contract Types](#contract-types)
|
|
26
|
-
- [API Reference](#api-reference)
|
|
27
|
-
- [Gas Costs](#gas-costs)
|
|
28
|
-
- [Examples](#examples)
|
|
29
|
-
- [Gasless Paid Minting](#gasless-paid-minting)
|
|
30
|
-
- [SimpleAccount Strategy](#simpleaccount-strategy)
|
|
31
|
-
- [Next.js Deployment](#nextjs-deployment)
|
|
32
|
-
- [Troubleshooting](#troubleshooting)
|
|
33
|
-
|
|
34
|
-
## Quick Start
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
# Install
|
|
38
|
-
npm install your-package-name
|
|
39
|
-
|
|
40
|
-
# Set environment variables
|
|
41
|
-
export PRIVATE_KEY="0x..."
|
|
42
|
-
export SIMPLE_ACCOUNT_ADDRESS="0x..."
|
|
43
|
-
|
|
44
|
-
# Deploy infrastructure (one-time setup)
|
|
45
|
-
npx tsx examples/gasless-deployment-complete.ts
|
|
46
|
-
export CONTRACT_DEPLOYER_ADDRESS="0x..."
|
|
47
|
-
|
|
48
|
-
# Deploy libraries (one-time setup)
|
|
49
|
-
npx tsx examples/deploy-shared-libraries-example.ts
|
|
50
|
-
|
|
51
|
-
# Deploy your NFT contract (gasless!)
|
|
52
|
-
npx tsx examples/true-gasless-deployment.ts
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Complete Setup Guide
|
|
56
|
-
|
|
57
|
-
### Prerequisites
|
|
58
|
-
|
|
59
|
-
- Node.js 18+ and npm/pnpm
|
|
60
|
-
- An Ethereum wallet with private key
|
|
61
|
-
- ~0.05 ETH on Base Sepolia testnet for initial setup
|
|
62
|
-
|
|
63
|
-
### Step 1: Environment Setup
|
|
64
|
-
|
|
65
|
-
Create a `.env` file in your project:
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
# Your EOA private key (for signing transactions)
|
|
69
|
-
PRIVATE_KEY="0x1234567890abcdef..."
|
|
70
|
-
|
|
71
|
-
# RPC endpoint (Base Sepolia testnet)
|
|
72
|
-
RPC_URL="https://sepolia.base.org"
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Step 2: Deploy SimpleAccount
|
|
76
|
-
|
|
77
|
-
SimpleAccount is an EIP-4337 smart contract wallet that will pay for all gas.
|
|
78
|
-
|
|
79
|
-
#### Option A: Using the Library
|
|
80
|
-
|
|
81
|
-
```typescript
|
|
82
|
-
import { createSimpleAccount, deploySimpleAccountFactory } from 'your-package-name';
|
|
83
|
-
import { privateKeyToAccount } from 'viem/accounts';
|
|
84
|
-
|
|
85
|
-
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
|
|
86
|
-
|
|
87
|
-
// 1. Deploy SimpleAccountFactory (if not already deployed)
|
|
88
|
-
const factory = await deploySimpleAccountFactory({
|
|
89
|
-
rpcUrl: 'https://sepolia.base.org',
|
|
90
|
-
deployerPrivateKey: process.env.PRIVATE_KEY as `0x${string}`,
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
console.log('Factory:', factory.factoryAddress);
|
|
14
|
+
## 🏗️ Architecture
|
|
94
15
|
|
|
95
|
-
// 2. Create SimpleAccount for your EOA
|
|
96
|
-
const simpleAccount = await createSimpleAccount({
|
|
97
|
-
rpcUrl: 'https://sepolia.base.org',
|
|
98
|
-
factoryAddress: factory.factoryAddress,
|
|
99
|
-
owner: account.address,
|
|
100
|
-
deployerPrivateKey: process.env.PRIVATE_KEY as `0x${string}`,
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
console.log('SimpleAccount:', simpleAccount.accountAddress);
|
|
104
16
|
```
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
```bash
|
|
111
|
-
export SIMPLE_ACCOUNT_ADDRESS="0xYourSimpleAccountAddress"
|
|
17
|
+
┌─────────────────┐ Signs Message ┌──────────────────┐ Pays All Gas ┌────────────────────┐
|
|
18
|
+
│ User's EOA ├───────────────────>│ Platform ├───────────────────>│ KAMI Contract │
|
|
19
|
+
│ (NO ETH) │ │ SimpleAccount │ │ (executes) │
|
|
20
|
+
└─────────────────┘ └──────────────────┘ └────────────────────┘
|
|
112
21
|
```
|
|
113
22
|
|
|
114
|
-
|
|
23
|
+
## 🚀 Quick Start
|
|
115
24
|
|
|
116
|
-
|
|
25
|
+
### 1. Installation
|
|
117
26
|
|
|
118
27
|
```bash
|
|
119
|
-
|
|
120
|
-
cast send $SIMPLE_ACCOUNT_ADDRESS \
|
|
121
|
-
--value 0.05ether \
|
|
122
|
-
--private-key $PRIVATE_KEY \
|
|
123
|
-
--rpc-url https://sepolia.base.org
|
|
28
|
+
npm install @paulstinchcombe/gasless-nft-tx
|
|
124
29
|
```
|
|
125
30
|
|
|
126
|
-
|
|
31
|
+
### 2. Deploy Infrastructure (One-Time Setup)
|
|
127
32
|
|
|
128
33
|
```bash
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
### Step 3: Deploy ContractDeployer
|
|
133
|
-
|
|
134
|
-
ContractDeployer is a helper contract that enables gasless deployments via SimpleAccount.
|
|
135
|
-
|
|
136
|
-
**Why needed?** SimpleAccount's `execute()` function can't deploy contracts directly. ContractDeployer acts as a helper that SimpleAccount calls, which then deploys your contracts using the CREATE opcode.
|
|
137
|
-
|
|
138
|
-
```bash
|
|
139
|
-
npx tsx examples/gasless-deployment-complete.ts
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
**Expected Output:**
|
|
143
|
-
|
|
144
|
-
```
|
|
145
|
-
✅ Configuration validated
|
|
146
|
-
💰 SimpleAccount balance: 0.050000 ETH
|
|
147
|
-
|
|
148
|
-
🔧 Deploying ContractDeployer helper contract...
|
|
149
|
-
⚠️ NOTE: This deployment requires gas from your EOA (not gasless)
|
|
150
|
-
ContractDeployer is a one-time deployment that enables all future gasless deployments
|
|
151
|
-
|
|
152
|
-
Transaction: 0xabc123...
|
|
153
|
-
✅ ContractDeployer deployed at: 0xDEF456...
|
|
154
|
-
💾 Save this address for future use!
|
|
155
|
-
📝 This was a one-time cost. All future KAMI deployments will be gasless!
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
**Cost:** ~0.001 ETH from your EOA (one-time only)
|
|
159
|
-
|
|
160
|
-
**Update `.env`:**
|
|
161
|
-
|
|
162
|
-
```bash
|
|
163
|
-
CONTRACT_DEPLOYER_ADDRESS="0x..."
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
### Step 4: Deploy KAMI Libraries
|
|
167
|
-
|
|
168
|
-
KAMI contracts use five shared libraries. Deploy them once and reuse for all NFT contracts.
|
|
169
|
-
|
|
170
|
-
```bash
|
|
171
|
-
npx tsx examples/deploy-shared-libraries-example.ts
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
**Expected Output:**
|
|
175
|
-
|
|
176
|
-
```
|
|
177
|
-
📚 Deploying all KAMI libraries via SimpleAccount (gasless)...
|
|
178
|
-
🚀 Deploying KamiNFTCore...
|
|
179
|
-
Transaction: 0x...
|
|
180
|
-
✅ Contract deployed at: 0x...
|
|
181
|
-
|
|
182
|
-
[... repeats for all 5 libraries ...]
|
|
183
|
-
|
|
184
|
-
✅ All libraries deployed successfully!
|
|
185
|
-
💾 SAVE THESE ADDRESSES - Reuse them for all future NFT deployments:
|
|
186
|
-
{
|
|
187
|
-
"kamiNFTCore": "0x...",
|
|
188
|
-
"kamiPlatform": "0x...",
|
|
189
|
-
"kamiRoyalty": "0x...",
|
|
190
|
-
"kamiRental": "0x...",
|
|
191
|
-
"kamiTransfer": "0x..."
|
|
192
|
-
}
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
**Cost:** ~0.008 ETH from SimpleAccount (one-time, reusable)
|
|
196
|
-
|
|
197
|
-
**Update `.env`:**
|
|
198
|
-
|
|
199
|
-
```bash
|
|
200
|
-
KAMI_NFT_CORE="0x..."
|
|
201
|
-
KAMI_PLATFORM="0x..."
|
|
202
|
-
KAMI_ROYALTY="0x..."
|
|
203
|
-
KAMI_RENTAL="0x..."
|
|
204
|
-
KAMI_TRANSFER="0x..."
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
### Step 5: Deploy Your NFT Contract
|
|
208
|
-
|
|
209
|
-
Now deploy any KAMI NFT contract completely gaslessly!
|
|
210
|
-
|
|
211
|
-
#### Deploy KAMI721C (Standard ERC721)
|
|
212
|
-
|
|
213
|
-
```bash
|
|
214
|
-
npx tsx examples/true-gasless-deployment.ts
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
#### Deploy KAMI721AC (ERC721A with Batch Minting)
|
|
218
|
-
|
|
219
|
-
```bash
|
|
220
|
-
npx tsx examples/deploy-kami721ac-gasless.ts
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
#### Deploy KAMI1155C (ERC1155 Multi-Token)
|
|
224
|
-
|
|
225
|
-
```bash
|
|
226
|
-
npx tsx examples/deploy-kami1155c-gasless.ts
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
**Expected Output:**
|
|
230
|
-
|
|
231
|
-
```
|
|
232
|
-
🚀 Deploying KAMI721C gaslessly with library linking...
|
|
233
|
-
Name: My NFT Collection (MNFT)
|
|
234
|
-
Mint Price: 0.001 ETH
|
|
235
|
-
|
|
236
|
-
📚 Linking libraries to KAMI721C bytecode...
|
|
237
|
-
✅ Bytecode linked, length: 45678 bytes
|
|
238
|
-
|
|
239
|
-
🚀 Deploying contract gaslessly via ContractDeployer...
|
|
240
|
-
📤 Sending deployment transaction via SimpleAccount...
|
|
241
|
-
Transaction: 0x...
|
|
242
|
-
✅ Contract deployed at: 0x...
|
|
243
|
-
|
|
244
|
-
🎉 KAMI721C deployed successfully (gasless)!
|
|
245
|
-
📍 Address: 0x...
|
|
246
|
-
👤 Owner: 0x... (SimpleAccount)
|
|
247
|
-
🔗 Explorer: https://sepolia.basescan.org/address/0x...
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
**Cost:** ~0.015 ETH from SimpleAccount (per deployment)
|
|
251
|
-
|
|
252
|
-
**Save the contract address:**
|
|
34
|
+
# Set your platform private key
|
|
35
|
+
export PRIVATE_KEY="0x..."
|
|
253
36
|
|
|
254
|
-
|
|
255
|
-
|
|
37
|
+
# Deploy all infrastructure needed for sponsored transactions
|
|
38
|
+
npx tsx setup-sponsored-infrastructure.ts
|
|
256
39
|
```
|
|
257
40
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
### KAMI721C - Standard ERC721 with Creator Features
|
|
261
|
-
|
|
262
|
-
**Use for:**
|
|
263
|
-
|
|
264
|
-
- Standard NFT collections
|
|
265
|
-
- Art projects
|
|
266
|
-
- Collectibles
|
|
267
|
-
- Small to medium collections (< 1,000 NFTs)
|
|
268
|
-
|
|
269
|
-
**Features:**
|
|
41
|
+
This will deploy:
|
|
270
42
|
|
|
271
|
-
-
|
|
272
|
-
-
|
|
273
|
-
-
|
|
274
|
-
-
|
|
275
|
-
- ✅ Maximum compatibility
|
|
43
|
+
- SimpleAccountFactory
|
|
44
|
+
- Platform SimpleAccount (funded with ETH)
|
|
45
|
+
- ContractDeployer helper
|
|
46
|
+
- KAMI Libraries
|
|
276
47
|
|
|
277
|
-
|
|
48
|
+
### 3. Platform Setup
|
|
278
49
|
|
|
279
50
|
```typescript
|
|
280
|
-
import {
|
|
281
|
-
import { parseEther, Address } from 'viem';
|
|
51
|
+
import { KamiSponsoredOperations, KamiSponsoredDeployment } from '@paulstinchcombe/gasless-nft-tx';
|
|
282
52
|
|
|
283
|
-
|
|
53
|
+
// Platform configuration
|
|
54
|
+
const config = {
|
|
284
55
|
rpcUrl: 'https://sepolia.base.org',
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
contractDeployerAddress: process.env.CONTRACT_DEPLOYER_ADDRESS
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
kamiPlatform: process.env.KAMI_PLATFORM as Address,
|
|
291
|
-
kamiRoyalty: process.env.KAMI_ROYALTY as Address,
|
|
292
|
-
kamiRental: process.env.KAMI_RENTAL as Address,
|
|
293
|
-
kamiTransfer: process.env.KAMI_TRANSFER as Address,
|
|
294
|
-
},
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
const params: KAMI721CParams = {
|
|
298
|
-
paymentToken: '0x0000000000000000000000000000000000000000', // Native ETH
|
|
299
|
-
name: 'My NFT Collection',
|
|
300
|
-
symbol: 'MNFT',
|
|
301
|
-
baseTokenURI: 'ipfs://QmYourBaseURI/',
|
|
302
|
-
platformAddress: process.env.SIMPLE_ACCOUNT_ADDRESS as Address,
|
|
303
|
-
platformCommissionPercentage: 250, // 2.5%
|
|
304
|
-
adminAddress: process.env.SIMPLE_ACCOUNT_ADDRESS as Address, // Admin address
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
const result = await deployer.deployKAMI721C(params);
|
|
308
|
-
console.log('Deployed at:', result.contractAddress);
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
### KAMI721AC - ERC721A with Batch Minting
|
|
312
|
-
|
|
313
|
-
**Use for:**
|
|
314
|
-
|
|
315
|
-
- Large NFT collections (1k-10k+ NFTs)
|
|
316
|
-
- Projects with batch minting needs
|
|
317
|
-
- Gas-efficient launches
|
|
318
|
-
- Generative art projects
|
|
319
|
-
|
|
320
|
-
**Features:**
|
|
321
|
-
|
|
322
|
-
- ✅ ERC721A (batch minting optimization)
|
|
323
|
-
- ✅ Much cheaper batch mints (~90% gas savings)
|
|
324
|
-
- ✅ All Creator features (royalties, rentals)
|
|
325
|
-
- ✅ Perfect for large drops
|
|
326
|
-
|
|
327
|
-
**Deployment:**
|
|
328
|
-
|
|
329
|
-
```typescript
|
|
330
|
-
const params: KAMI721ACParams = {
|
|
331
|
-
paymentToken: '0x0000000000000000000000000000000000000000',
|
|
332
|
-
name: 'Creator Collection',
|
|
333
|
-
symbol: 'CNFT',
|
|
334
|
-
baseTokenURI: 'ipfs://QmYourBaseURI/',
|
|
335
|
-
platformAddress: process.env.SIMPLE_ACCOUNT_ADDRESS as Address,
|
|
336
|
-
platformCommissionPercentage: 250,
|
|
337
|
-
adminAddress: process.env.SIMPLE_ACCOUNT_ADDRESS as Address,
|
|
56
|
+
platformPrivateKey: process.env.PLATFORM_PRIVATE_KEY, // Platform's key (has ETH)
|
|
57
|
+
platformSimpleAccountAddress: process.env.PLATFORM_SIMPLE_ACCOUNT_ADDRESS, // Platform's SA (has ETH)
|
|
58
|
+
contractDeployerAddress: process.env.CONTRACT_DEPLOYER_ADDRESS,
|
|
59
|
+
platformAddress: process.env.PLATFORM_ADDRESS,
|
|
60
|
+
paymentToken: process.env.PAYMENT_TOKEN,
|
|
338
61
|
};
|
|
339
62
|
|
|
340
|
-
|
|
63
|
+
// Create handlers
|
|
64
|
+
const sponsoredDeployment = new KamiSponsoredDeployment(config);
|
|
65
|
+
const sponsoredOps = new KamiSponsoredOperations(config);
|
|
341
66
|
```
|
|
342
67
|
|
|
343
|
-
|
|
344
|
-
Mint 10 NFTs for nearly the same gas cost as minting 1!
|
|
345
|
-
|
|
346
|
-
### KAMI1155C - ERC1155 Multi-Token
|
|
347
|
-
|
|
348
|
-
**Use for:**
|
|
349
|
-
|
|
350
|
-
- Gaming projects (items, currencies, characters)
|
|
351
|
-
- Multi-edition artworks
|
|
352
|
-
- Mixed fungible/non-fungible tokens
|
|
353
|
-
- Membership tiers
|
|
354
|
-
|
|
355
|
-
**Features:**
|
|
356
|
-
|
|
357
|
-
- ✅ ERC1155 multi-token standard
|
|
358
|
-
- ✅ Multiple token IDs in one contract
|
|
359
|
-
- ✅ Fungible and non-fungible support
|
|
360
|
-
- ✅ Very gas efficient
|
|
361
|
-
- ✅ All Creator features
|
|
362
|
-
|
|
363
|
-
**Deployment:**
|
|
68
|
+
### 4. Deploy Contract (Sponsored)
|
|
364
69
|
|
|
365
70
|
```typescript
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
71
|
+
// User signs message for deployment (no ETH needed)
|
|
72
|
+
const userSignature = createUserSignatureData(
|
|
73
|
+
userAddress,
|
|
74
|
+
"Paul's NFT Collection",
|
|
75
|
+
'PNC',
|
|
76
|
+
'https://api.example.com/metadata/',
|
|
77
|
+
parseEther('0.001'),
|
|
78
|
+
250, // 2.5% platform commission
|
|
79
|
+
userSignature
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
// Platform deploys contract with sponsored gas
|
|
83
|
+
const result = await sponsoredDeployment.deployKAMI721C({
|
|
84
|
+
contractName: "Paul's NFT Collection",
|
|
85
|
+
contractSymbol: 'PNC',
|
|
86
|
+
baseTokenURI: 'https://api.example.com/metadata/',
|
|
87
|
+
initialMintPrice: parseEther('0.001'),
|
|
370
88
|
platformCommissionPercentage: 250,
|
|
371
|
-
|
|
372
|
-
};
|
|
89
|
+
userSignature,
|
|
90
|
+
});
|
|
373
91
|
|
|
374
|
-
|
|
92
|
+
console.log('Contract deployed:', result.contractAddress);
|
|
93
|
+
console.log('Gas paid by: Platform');
|
|
94
|
+
console.log('User paid: ZERO ETH');
|
|
375
95
|
```
|
|
376
96
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
### KamiGaslessDeployerWithLibraries
|
|
380
|
-
|
|
381
|
-
Main class for deploying KAMI contracts gaslessly.
|
|
382
|
-
|
|
383
|
-
#### Constructor
|
|
97
|
+
### 5. Mint Token (Sponsored)
|
|
384
98
|
|
|
385
99
|
```typescript
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
100
|
+
// User signs message for minting (no ETH needed)
|
|
101
|
+
const mintSignature = createSponsoredOperationSignature(
|
|
102
|
+
userAddress,
|
|
103
|
+
'mint',
|
|
104
|
+
contractAddress,
|
|
105
|
+
{
|
|
106
|
+
recipient: userAddress,
|
|
107
|
+
tokenPrice: parseEther('0.001'),
|
|
108
|
+
uri: 'https://api.example.com/metadata/1',
|
|
109
|
+
mintRoyalties: [
|
|
110
|
+
{ receiver: userAddress, percentage: 500 },
|
|
111
|
+
{ receiver: platformAddress, percentage: 250 },
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
userSignature
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
// Platform mints token with sponsored gas
|
|
118
|
+
const result = await sponsoredOps.mintToken(
|
|
119
|
+
contractAddress,
|
|
120
|
+
'KAMI721C',
|
|
121
|
+
{
|
|
122
|
+
recipient: userAddress,
|
|
123
|
+
tokenPrice: parseEther('0.001'),
|
|
124
|
+
uri: 'https://api.example.com/metadata/1',
|
|
125
|
+
mintRoyalties: [
|
|
126
|
+
{ receiver: userAddress, percentage: 500 },
|
|
127
|
+
{ receiver: platformAddress, percentage: 250 },
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
mintSignature
|
|
131
|
+
);
|
|
400
132
|
|
|
401
|
-
|
|
402
|
-
|
|
133
|
+
console.log('Token minted:', result.data?.tokenId);
|
|
134
|
+
console.log('Gas paid by: Platform');
|
|
135
|
+
console.log('User paid: ZERO ETH');
|
|
403
136
|
```
|
|
404
137
|
|
|
405
|
-
|
|
138
|
+
## 📋 Supported Operations
|
|
406
139
|
|
|
407
|
-
**
|
|
140
|
+
### **Deployment Operations**
|
|
408
141
|
|
|
409
|
-
-
|
|
410
|
-
-
|
|
411
|
-
-
|
|
412
|
-
- `baseTokenURI` (string): Base URI for token metadata
|
|
413
|
-
- `platformAddress` (Address): Platform fee recipient
|
|
414
|
-
- `platformCommissionPercentage` (number): Platform fee (250 = 2.5%)
|
|
415
|
-
- `adminAddress` (Address): Admin address for contract management
|
|
142
|
+
- ✅ **Deploy KAMI721C** - ERC721 with Creator features
|
|
143
|
+
- ✅ **Deploy KAMI721AC** - ERC721A with batch minting
|
|
144
|
+
- ✅ **Deploy KAMI1155C** - ERC1155 multi-token
|
|
416
145
|
|
|
417
|
-
**
|
|
146
|
+
### **Minting Operations**
|
|
418
147
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
contractAddress?: Address;
|
|
423
|
-
transactionHash?: string;
|
|
424
|
-
error?: string;
|
|
425
|
-
}
|
|
426
|
-
```
|
|
148
|
+
- ✅ **Mint tokens** with custom prices and royalties
|
|
149
|
+
- ✅ **Batch minting** for KAMI721AC
|
|
150
|
+
- ✅ **Multi-token minting** for KAMI1155C
|
|
427
151
|
|
|
428
|
-
|
|
152
|
+
### **Rental Operations**
|
|
429
153
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
154
|
+
- ✅ **Rent tokens** for specific durations
|
|
155
|
+
- ✅ **Extend rentals** with additional payment
|
|
156
|
+
- ✅ **End rentals** when duration expires
|
|
433
157
|
|
|
434
|
-
|
|
158
|
+
### **Sales Operations**
|
|
435
159
|
|
|
436
|
-
|
|
160
|
+
- ✅ **Sell tokens** to other users
|
|
161
|
+
- ✅ **Transfer ownership** with payment
|
|
437
162
|
|
|
438
|
-
|
|
163
|
+
### **Management Operations**
|
|
439
164
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
165
|
+
- ✅ **Set token prices** individually
|
|
166
|
+
- ✅ **Set token URIs** for metadata
|
|
167
|
+
- ✅ **Set token royalties** and recipients
|
|
168
|
+
- ✅ **Contract administration** (pause/unpause)
|
|
443
169
|
|
|
444
|
-
|
|
170
|
+
## 💰 Cost Analysis
|
|
445
171
|
|
|
446
|
-
**
|
|
172
|
+
### **User Costs**
|
|
447
173
|
|
|
448
|
-
-
|
|
449
|
-
-
|
|
450
|
-
-
|
|
451
|
-
- `platformCommissionPercentage` (number): Platform fee percentage
|
|
452
|
-
- `adminAddress` (Address): Admin address for contract management
|
|
174
|
+
- **Gas Fees**: **ZERO ETH** ✅
|
|
175
|
+
- **Transaction Fees**: **ZERO ETH** ✅
|
|
176
|
+
- **All Operations**: **ZERO ETH** ✅
|
|
453
177
|
|
|
454
|
-
|
|
178
|
+
### **Platform Costs**
|
|
455
179
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
180
|
+
- **Contract Deployment**: ~0.015 ETH per contract
|
|
181
|
+
- **Token Minting**: ~0.003 ETH per token
|
|
182
|
+
- **Other Operations**: ~0.001-0.002 ETH per operation
|
|
459
183
|
|
|
460
|
-
|
|
184
|
+
## 🔧 Environment Setup
|
|
461
185
|
|
|
462
|
-
|
|
186
|
+
Create a `.env` file:
|
|
463
187
|
|
|
464
|
-
```
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
// Deployment result
|
|
475
|
-
interface DeploymentResult {
|
|
476
|
-
success: boolean;
|
|
477
|
-
contractAddress?: Address;
|
|
478
|
-
transactionHash?: string;
|
|
479
|
-
error?: string;
|
|
480
|
-
}
|
|
188
|
+
```bash
|
|
189
|
+
# Platform Configuration
|
|
190
|
+
PLATFORM_PRIVATE_KEY="0x..." # Platform's private key (has ETH)
|
|
191
|
+
PLATFORM_SIMPLE_ACCOUNT_ADDRESS="0x..." # Platform's SimpleAccount (has ETH)
|
|
192
|
+
CONTRACT_DEPLOYER_ADDRESS="0x..." # ContractDeployer address
|
|
193
|
+
PLATFORM_ADDRESS="0x..." # Platform address
|
|
194
|
+
PAYMENT_TOKEN="0x..." # Payment token address (USDC, etc.)
|
|
195
|
+
|
|
196
|
+
# Network Configuration
|
|
197
|
+
RPC_URL="https://sepolia.base.org"
|
|
481
198
|
```
|
|
482
199
|
|
|
483
|
-
##
|
|
484
|
-
|
|
485
|
-
All costs are estimates on Base Sepolia. Mainnet costs may vary.
|
|
486
|
-
|
|
487
|
-
### One-Time Setup Costs
|
|
488
|
-
|
|
489
|
-
| Item | Who Pays | Cost | Frequency |
|
|
490
|
-
| -------------------- | ------------- | ---------- | ------------- |
|
|
491
|
-
| **SimpleAccount** | EOA | ~0.005 ETH | Once per user |
|
|
492
|
-
| **ContractDeployer** | EOA | ~0.001 ETH | Once ever |
|
|
493
|
-
| **KAMI Libraries** | SimpleAccount | ~0.008 ETH | Once ever |
|
|
494
|
-
|
|
495
|
-
**Total Setup**: ~0.014 ETH (one-time)
|
|
496
|
-
|
|
497
|
-
### Per-Deployment Costs
|
|
498
|
-
|
|
499
|
-
| Contract Type | Who Pays | Cost | Notes |
|
|
500
|
-
| ------------- | ------------- | ---------- | --------------- |
|
|
501
|
-
| **KAMI721C** | SimpleAccount | ~0.015 ETH | Standard ERC721 |
|
|
502
|
-
| **KAMI721AC** | SimpleAccount | ~0.015 ETH | ERC721A |
|
|
503
|
-
| **KAMI1155C** | SimpleAccount | ~0.015 ETH | ERC1155 |
|
|
504
|
-
|
|
505
|
-
**After Setup**: Deploy unlimited contracts for ~0.015 ETH each (from SimpleAccount)
|
|
506
|
-
|
|
507
|
-
### Gasless Benefits
|
|
508
|
-
|
|
509
|
-
- ✅ **Users pay nothing** - All gas paid by SimpleAccount
|
|
510
|
-
- ✅ **EOA only signs** - No ETH needed in user wallet
|
|
511
|
-
- ✅ **True gasless experience** - Best UX possible
|
|
200
|
+
## 📚 Documentation
|
|
512
201
|
|
|
513
|
-
|
|
202
|
+
- [Sponsored Deployment Guide](docs/SPONSORED_DEPLOYMENT_GUIDE.md) - Complete deployment guide
|
|
203
|
+
- [Sponsored Operations Guide](docs/SPONSORED_OPERATIONS_GUIDE.md) - Complete operations guide
|
|
204
|
+
- [Migration Guide](docs/MIGRATION_GUIDE.md) - Migrate from old gasless to sponsored
|
|
205
|
+
- [Examples](examples/README.md) - Working examples and frontend integration
|
|
514
206
|
|
|
515
|
-
|
|
207
|
+
## 🚀 Examples
|
|
516
208
|
|
|
517
209
|
### Infrastructure Setup
|
|
518
210
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
-
|
|
522
|
-
|
|
523
|
-
### Contract Deployment
|
|
524
|
-
|
|
525
|
-
- `true-gasless-deployment.ts` - Deploy KAMI721C
|
|
526
|
-
- `deploy-kami721ac-gasless.ts` - Deploy KAMI721AC
|
|
527
|
-
- `deploy-kami1155c-gasless.ts` - Deploy KAMI1155C
|
|
528
|
-
|
|
529
|
-
### SimpleAccount Setup
|
|
530
|
-
|
|
531
|
-
- `deploy-simple-deployer.ts` - Deploy SimpleAccountFactory
|
|
532
|
-
- `fund-simpleaccount.ts` - Fund SimpleAccount with ETH
|
|
533
|
-
|
|
534
|
-
## Gasless Paid Minting
|
|
535
|
-
|
|
536
|
-
**Important**: For mints with ERC20 payment tokens, the library handles ALL approvals gaslessly!
|
|
537
|
-
|
|
538
|
-
👉 **[Gasless Paid Minting Guide](docs/GASLESS_PAID_MINTING.md)**
|
|
539
|
-
|
|
540
|
-
**Quick Summary:**
|
|
541
|
-
|
|
542
|
-
- ✅ User has payment tokens (USDC, etc.) but NO ETH
|
|
543
|
-
- ✅ Library handles ERC20 approval gaslessly via SimpleAccount
|
|
544
|
-
- ✅ Library automatically checks transaction status
|
|
545
|
-
- ✅ Complete workflow with code examples
|
|
546
|
-
- ❌ Don't forget to check payment status and approve before minting!
|
|
547
|
-
|
|
548
|
-
See the guide for complete workflow, API examples, and common mistakes to avoid.
|
|
549
|
-
|
|
550
|
-
## SimpleAccount Strategy
|
|
551
|
-
|
|
552
|
-
**Important**: You only need **ONE SimpleAccount for your entire platform**, not one per user!
|
|
553
|
-
|
|
554
|
-
👉 **[SimpleAccount Strategy Guide](docs/SIMPLEACCOUNT_STRATEGY.md)**
|
|
555
|
-
|
|
556
|
-
**Quick Summary:**
|
|
557
|
-
|
|
558
|
-
- ✅ Use 1 SimpleAccount for your platform (saves $50+ on 100 users)
|
|
559
|
-
- ✅ Deploy NFT contracts for all users through it
|
|
560
|
-
- ✅ Users control their NFTs with their existing wallets
|
|
561
|
-
- ❌ Don't create SimpleAccount per user (unnecessary and expensive)
|
|
562
|
-
|
|
563
|
-
See the guide for cost analysis, implementation examples, and when users would need their own SimpleAccount.
|
|
564
|
-
|
|
565
|
-
## KAMI Handler APIs
|
|
566
|
-
|
|
567
|
-
**Important**: All three KAMI handlers now have consistent APIs! (v0.7.0+)
|
|
568
|
-
|
|
569
|
-
👉 **[KAMI721AC Handler API Reference](docs/KAMI721AC_HANDLER_API.md)**
|
|
570
|
-
|
|
571
|
-
**What Changed in v0.7.0:**
|
|
572
|
-
|
|
573
|
-
- ✅ **New Constructor Parameters**: All contracts now require `adminAddress` parameter
|
|
574
|
-
- ✅ **Removed `initialMintPrice`**: Price is now set per-token during minting
|
|
575
|
-
- ✅ **New Methods Added**: `setMintRoyalties`, `setTransferRoyalties`, `setPlatformCommission`, `hasClaimed`, `hasActiveRentals`
|
|
576
|
-
- ✅ **Enhanced Royalty Management**: Token-specific and global royalty controls
|
|
577
|
-
- ✅ **Platform Commission Management**: Dynamic platform fee updates
|
|
578
|
-
- ✅ **Claim Tracking**: Built-in claim status tracking for KAMI721AC
|
|
579
|
-
|
|
580
|
-
**What Changed in v0.5.3:**
|
|
581
|
-
|
|
582
|
-
- ✅ `KAMI721ACSimpleAccountHandler` now matches `KAMI721CSimpleAccountHandler` API
|
|
583
|
-
- ✅ `mint()` now requires `recipient`, `tokenPrice`, and `uri` parameters
|
|
584
|
-
- ✅ Added missing methods: `setPrice()`, `setTokenURI()`
|
|
585
|
-
- ✅ Batch methods now require `prices` and `uris` arrays
|
|
586
|
-
|
|
587
|
-
**Migration Examples:**
|
|
588
|
-
|
|
589
|
-
```typescript
|
|
590
|
-
// ❌ OLD Constructor (v0.6.x)
|
|
591
|
-
const params = {
|
|
592
|
-
paymentToken: '0x...',
|
|
593
|
-
name: 'My NFT',
|
|
594
|
-
symbol: 'NFT',
|
|
595
|
-
baseTokenURI: 'ipfs://...',
|
|
596
|
-
initialMintPrice: parseEther('0.001'), // ❌ Removed
|
|
597
|
-
platformAddress: '0x...',
|
|
598
|
-
platformCommissionPercentage: 250,
|
|
599
|
-
};
|
|
600
|
-
|
|
601
|
-
// ✅ NEW Constructor (v0.7.0+)
|
|
602
|
-
const params = {
|
|
603
|
-
paymentToken: '0x...',
|
|
604
|
-
name: 'My NFT',
|
|
605
|
-
symbol: 'NFT',
|
|
606
|
-
baseTokenURI: 'ipfs://...',
|
|
607
|
-
platformAddress: '0x...',
|
|
608
|
-
platformCommissionPercentage: 250,
|
|
609
|
-
adminAddress: '0x...', // ✅ Required
|
|
610
|
-
};
|
|
611
|
-
|
|
612
|
-
// ❌ OLD Mint (v0.5.2)
|
|
613
|
-
await handler.mint(recipientAddress);
|
|
211
|
+
```bash
|
|
212
|
+
# Deploy all infrastructure (one-time setup)
|
|
213
|
+
npx tsx setup-sponsored-infrastructure.ts
|
|
614
214
|
|
|
615
|
-
|
|
616
|
-
|
|
215
|
+
# Deploy individual components
|
|
216
|
+
npx tsx deploy-simpleaccount.ts
|
|
217
|
+
npx tsx deploy-contract-deployer.ts
|
|
218
|
+
npx tsx deploy-kami-libraries.ts
|
|
617
219
|
```
|
|
618
220
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
## Next.js Deployment
|
|
622
|
-
|
|
623
|
-
If you're using this library in a Next.js API route, you'll encounter artifact loading issues. See the complete guide:
|
|
624
|
-
|
|
625
|
-
👉 **[Next.js Deployment Guide](docs/NEXTJS_DEPLOYMENT.md)**
|
|
626
|
-
|
|
627
|
-
**Quick Summary**: The library loads contract artifacts using `fs.readFileSync()`, which doesn't work in Next.js production builds. You need to:
|
|
628
|
-
|
|
629
|
-
1. **Use the custom wrapper** (recommended) - See guide for ready-to-use `NextJsKamiDeployer` class
|
|
630
|
-
2. **Or configure Next.js** - Update `next.config.js` to include artifacts
|
|
631
|
-
3. **Or use Docker** - Ensure artifacts are copied to container
|
|
632
|
-
|
|
633
|
-
The guide includes complete code examples and troubleshooting steps.
|
|
634
|
-
|
|
635
|
-
## Troubleshooting
|
|
636
|
-
|
|
637
|
-
### Next.js "ENOENT: no such file or directory" Error
|
|
638
|
-
|
|
639
|
-
**Symptoms**: Error opening KAMI721C.json artifact file in production
|
|
640
|
-
|
|
641
|
-
**Solution**: See [Next.js Deployment Guide](docs/NEXTJS_DEPLOYMENT.md) for complete fix with ready-to-use wrapper class.
|
|
642
|
-
|
|
643
|
-
**Quick Fix**: Use the `NextJsKamiDeployer` wrapper that imports artifacts directly instead of loading from disk.
|
|
644
|
-
|
|
645
|
-
### Contract Not Appearing on BaseScan
|
|
646
|
-
|
|
647
|
-
**Wait 1-2 minutes** for block explorer indexing.
|
|
648
|
-
|
|
649
|
-
If still not visible:
|
|
650
|
-
|
|
651
|
-
1. Check transaction on BaseScan: `https://sepolia.basescan.org/tx/YOUR_TX`
|
|
652
|
-
2. Look for "Internal Transactions" tab
|
|
653
|
-
3. Verify "ContractDeployed" event in logs
|
|
654
|
-
4. Confirm ContractDeployer is deployed correctly
|
|
655
|
-
|
|
656
|
-
### "Insufficient Balance" Error
|
|
221
|
+
### Backend Examples
|
|
657
222
|
|
|
658
223
|
```bash
|
|
659
|
-
#
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
# Fund if needed
|
|
663
|
-
cast send $SIMPLE_ACCOUNT_ADDRESS \
|
|
664
|
-
--value 0.03ether \
|
|
665
|
-
--private-key $PRIVATE_KEY \
|
|
666
|
-
--rpc-url https://sepolia.base.org
|
|
667
|
-
```
|
|
224
|
+
# Deploy contracts with sponsored gas
|
|
225
|
+
npx tsx examples/sponsored-deployment-example.ts
|
|
668
226
|
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
Deploy ContractDeployer first:
|
|
672
|
-
|
|
673
|
-
```bash
|
|
674
|
-
npx tsx examples/gasless-deployment-complete.ts
|
|
227
|
+
# Perform all operations with sponsored gas
|
|
228
|
+
npx tsx examples/sponsored-operations-example.ts
|
|
675
229
|
```
|
|
676
230
|
|
|
677
|
-
###
|
|
231
|
+
### Frontend Examples
|
|
678
232
|
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
233
|
+
```typescript
|
|
234
|
+
// User signs message for any operation
|
|
235
|
+
const { userAddress, signature, nonce } = await requestUserSignatureForOperation(
|
|
236
|
+
'mint',
|
|
237
|
+
contractAddress,
|
|
238
|
+
{
|
|
239
|
+
recipient: userAddress,
|
|
240
|
+
tokenPrice: parseEther('0.001'),
|
|
241
|
+
uri: 'https://api.example.com/metadata/1',
|
|
242
|
+
mintRoyalties: [
|
|
243
|
+
{ receiver: userAddress, percentage: 500 },
|
|
244
|
+
{ receiver: platformAddress, percentage: 250 },
|
|
245
|
+
],
|
|
246
|
+
},
|
|
247
|
+
userAddress
|
|
248
|
+
);
|
|
683
249
|
```
|
|
684
250
|
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
1. **Check SimpleAccount has enough ETH** (~0.02 ETH minimum)
|
|
688
|
-
2. **Verify all library addresses** are correct and deployed
|
|
689
|
-
3. **Check ContractDeployer address** is valid
|
|
690
|
-
4. **Look at revert reason** on BaseScan transaction page
|
|
691
|
-
|
|
692
|
-
### "Invalid byte sequence" Error
|
|
693
|
-
|
|
694
|
-
This usually means:
|
|
251
|
+
## 🛡️ Security
|
|
695
252
|
|
|
696
|
-
-
|
|
697
|
-
-
|
|
253
|
+
- **Signature Verification**: All user signatures are verified
|
|
254
|
+
- **Replay Protection**: Nonce and timestamp prevent replay attacks
|
|
255
|
+
- **Parameter Validation**: All operation parameters are validated
|
|
256
|
+
- **Platform Security**: Platform private keys are kept secure
|
|
698
257
|
|
|
699
|
-
|
|
258
|
+
## 🎯 Benefits
|
|
700
259
|
|
|
701
|
-
**
|
|
260
|
+
1. **True Gasless Experience**: Users never need ETH
|
|
261
|
+
2. **Complete Operation Coverage**: All KAMI functions supported
|
|
262
|
+
3. **Platform Control**: Platform manages all gas costs
|
|
263
|
+
4. **User Ownership**: Operations affect user's contracts
|
|
264
|
+
5. **Scalable**: One platform SimpleAccount serves all users
|
|
265
|
+
6. **Cost Effective**: Platform pays only for actual operations
|
|
702
266
|
|
|
703
|
-
|
|
267
|
+
## 🔧 API Reference
|
|
704
268
|
|
|
705
|
-
|
|
269
|
+
### Sponsored Deployment
|
|
706
270
|
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
The fix ensures that when approval and mint transactions happen in quick succession, each transaction gets the correct nonce using `blockTag: 'pending'`.
|
|
712
|
-
|
|
713
|
-
## Architecture
|
|
271
|
+
```typescript
|
|
272
|
+
// Deploy KAMI721C
|
|
273
|
+
const result = await sponsoredDeployment.deployKAMI721C(params);
|
|
714
274
|
|
|
715
|
-
|
|
275
|
+
// Deploy KAMI721AC
|
|
276
|
+
const result = await sponsoredDeployment.deployKAMI721AC(params);
|
|
716
277
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
│ EOA │ signs │ SimpleAccount │ calls │ ContractDeployer │
|
|
720
|
-
│ (no gas) ├────────>│ (pays all gas) ├────────>│ (uses CREATE) │
|
|
721
|
-
└─────────────┘ └──────────────────┘ └────────┬───────────┘
|
|
722
|
-
│ deploys
|
|
723
|
-
v
|
|
724
|
-
┌────────────────────┐
|
|
725
|
-
│ KAMI Contract │
|
|
726
|
-
│ (your NFT) │
|
|
727
|
-
└────────────────────┘
|
|
278
|
+
// Deploy KAMI1155C
|
|
279
|
+
const result = await sponsoredDeployment.deployKAMI1155C(params);
|
|
728
280
|
```
|
|
729
281
|
|
|
730
|
-
###
|
|
282
|
+
### Sponsored Operations
|
|
731
283
|
|
|
732
|
-
|
|
284
|
+
```typescript
|
|
285
|
+
// Mint token
|
|
286
|
+
const result = await sponsoredOps.mintToken(contractAddress, contractType, params, signature);
|
|
733
287
|
|
|
734
|
-
|
|
288
|
+
// Rent token
|
|
289
|
+
const result = await sponsoredOps.rentToken(contractAddress, contractType, params, signature);
|
|
735
290
|
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
3. New contract is deployed with SimpleAccount as deployer
|
|
739
|
-
4. Contract appears on block explorer correctly
|
|
291
|
+
// Sell token
|
|
292
|
+
const result = await sponsoredOps.sellToken(contractAddress, contractType, params, signature);
|
|
740
293
|
|
|
741
|
-
|
|
294
|
+
// Set price
|
|
295
|
+
const result = await sponsoredOps.setPrice(contractAddress, contractType, params, signature);
|
|
742
296
|
|
|
743
|
-
|
|
297
|
+
// Set URI
|
|
298
|
+
const result = await sponsoredOps.setTokenURI(contractAddress, contractType, params, signature);
|
|
744
299
|
|
|
745
|
-
|
|
300
|
+
// Set royalties
|
|
301
|
+
const result = await sponsoredOps.setTokenRoyalties(contractAddress, contractType, params, signature);
|
|
746
302
|
|
|
747
|
-
|
|
303
|
+
// Pause contract
|
|
304
|
+
const result = await sponsoredOps.pauseContract(contractAddress, contractType, signature);
|
|
748
305
|
|
|
749
|
-
|
|
306
|
+
// Unpause contract
|
|
307
|
+
const result = await sponsoredOps.unpauseContract(contractAddress, contractType, signature);
|
|
308
|
+
```
|
|
750
309
|
|
|
751
|
-
|
|
752
|
-
- [MIGRATION_GUIDE.md](MIGRATION_GUIDE.md) - Migration from deprecated classes
|
|
753
|
-
- [UPDATED_SOLUTION.md](UPDATED_SOLUTION.md) - Technical details and rationale
|
|
754
|
-
- [docs/GASLESS_DEPLOYMENT_FIX.md](docs/GASLESS_DEPLOYMENT_FIX.md) - Deep dive into the solution
|
|
310
|
+
## 🚀 Getting Started
|
|
755
311
|
|
|
756
|
-
|
|
312
|
+
1. **Install the library**: `npm install @paulstinchcombe/gasless-nft-tx`
|
|
313
|
+
2. **Set up environment**: Create `.env` file with platform configuration
|
|
314
|
+
3. **Deploy infrastructure**: Deploy ContractDeployer and libraries (one-time setup)
|
|
315
|
+
4. **Start using**: Deploy contracts and perform operations with sponsored gas!
|
|
757
316
|
|
|
758
|
-
|
|
317
|
+
## 📄 License
|
|
759
318
|
|
|
760
|
-
|
|
319
|
+
MIT License - see LICENSE file for details.
|
|
761
320
|
|
|
762
|
-
|
|
321
|
+
## 🤝 Contributing
|
|
763
322
|
|
|
764
|
-
|
|
323
|
+
Contributions are welcome! Please read our contributing guidelines and submit pull requests.
|
|
765
324
|
|
|
766
|
-
|
|
325
|
+
## 📞 Support
|
|
767
326
|
|
|
768
|
-
|
|
327
|
+
For support and questions:
|
|
769
328
|
|
|
770
|
-
|
|
329
|
+
- Create an issue on GitHub
|
|
330
|
+
- Check the documentation
|
|
331
|
+
- Review the examples
|
|
771
332
|
|
|
772
|
-
|
|
773
|
-
- ✅ **Three contract types** - KAMI721C, KAMI721AC, KAMI1155C
|
|
774
|
-
- ✅ **Truly gasless** - SimpleAccount pays all gas
|
|
775
|
-
- ✅ **Production ready** - Battle-tested and documented
|
|
776
|
-
- ✅ **Type-safe** - Full TypeScript support
|
|
777
|
-
- ✅ **Creator features** - Royalties, rentals, platform fees built-in
|
|
333
|
+
---
|
|
778
334
|
|
|
779
|
-
|
|
335
|
+
**🎉 Enjoy truly gasless NFT operations with the Sponsored KAMI NFT Transactions Library!**
|