|
360 | 360 |
|
361 | 361 | #region EIP-7702
|
362 | 362 |
|
363 |
| -// var chain = 11155111; // sepolia |
364 |
| - |
365 |
| -// // Connect to EOA |
366 |
| -// var smartEoa = await InAppWallet.Create(client, authProvider: AuthProvider.Google, executionMode: ExecutionMode.EIP7702Sponsored); |
367 |
| -// if (!await smartEoa.IsConnected()) |
368 |
| -// { |
369 |
| -// _ = await smartEoa.LoginWithOauth( |
370 |
| -// isMobile: false, |
371 |
| -// (url) => |
372 |
| -// { |
373 |
| -// var psi = new ProcessStartInfo { FileName = url, UseShellExecute = true }; |
374 |
| -// _ = Process.Start(psi); |
375 |
| -// } |
376 |
| -// ); |
377 |
| -// } |
378 |
| -// var smartEoaAddress = await smartEoa.GetAddress(); |
379 |
| -// Console.WriteLine($"User Wallet address: {await smartEoa.GetAddress()}"); |
380 |
| - |
381 |
| -// // Upgrade EOA - This wallet explicitly uses EIP-7702 delegation to the thirdweb MinimalAccount (will delegate upon first tx) |
382 |
| - |
383 |
| -// // Transact, will upgrade EOA |
384 |
| -// var receipt = await smartEoa.Transfer(chainId: chain, toAddress: await Utils.GetAddressFromENS(client, "vitalik.eth"), weiAmount: 0); |
385 |
| -// Console.WriteLine($"Transfer Receipt: {receipt.TransactionHash}"); |
386 |
| - |
387 |
| -// // Double check that it was upgraded |
388 |
| -// var isDelegated = await Utils.IsDelegatedAccount(client, chain, smartEoaAddress); |
389 |
| -// Console.WriteLine($"Is delegated: {isDelegated}"); |
390 |
| - |
391 |
| -// // Create a session key |
392 |
| -// var sessionKeyReceipt = await smartEoa.CreateSessionKey( |
393 |
| -// chain, |
394 |
| -// new SessionSpec() |
395 |
| -// { |
396 |
| -// Signer = await Utils.GetAddressFromENS(client, "0xfirekeeper.eth"), |
397 |
| -// IsWildcard = true, |
398 |
| -// ExpiresAt = Utils.GetUnixTimeStampNow() + 86400, // 1 day |
399 |
| -// CallPolicies = new List<CallSpec>(), |
400 |
| -// TransferPolicies = new List<TransferSpec>(), |
401 |
| -// Uid = Guid.NewGuid().ToByteArray().PadTo32Bytes() |
402 |
| -// } |
403 |
| -// ); |
404 |
| -// Console.WriteLine($"Session key receipt: {sessionKeyReceipt.TransactionHash}"); |
| 363 | +var chain = 11155111; // sepolia |
| 364 | + |
| 365 | +// Connect to EOA |
| 366 | +var smartEoa = await InAppWallet.Create(client, authProvider: AuthProvider.Google, executionMode: ExecutionMode.EIP7702Sponsored); |
| 367 | +if (!await smartEoa.IsConnected()) |
| 368 | +{ |
| 369 | + _ = await smartEoa.LoginWithOauth( |
| 370 | + isMobile: false, |
| 371 | + (url) => |
| 372 | + { |
| 373 | + var psi = new ProcessStartInfo { FileName = url, UseShellExecute = true }; |
| 374 | + _ = Process.Start(psi); |
| 375 | + } |
| 376 | + ); |
| 377 | +} |
| 378 | +var smartEoaAddress = await smartEoa.GetAddress(); |
| 379 | +Console.WriteLine($"User Wallet address: {await smartEoa.GetAddress()}"); |
| 380 | + |
| 381 | +// Upgrade EOA - This wallet explicitly uses EIP-7702 delegation to the thirdweb MinimalAccount (will delegate upon first tx) |
| 382 | + |
| 383 | +// Transact, will upgrade EOA |
| 384 | +var receipt = await smartEoa.Transfer(chainId: chain, toAddress: await Utils.GetAddressFromENS(client, "vitalik.eth"), weiAmount: 0); |
| 385 | +Console.WriteLine($"Transfer Receipt: {receipt.TransactionHash}"); |
| 386 | + |
| 387 | +// Double check that it was upgraded |
| 388 | +var isDelegated = await Utils.IsDelegatedAccount(client, chain, smartEoaAddress); |
| 389 | +Console.WriteLine($"Is delegated: {isDelegated}"); |
| 390 | + |
| 391 | +// Create a session key |
| 392 | +var sessionKeyReceipt = await smartEoa.CreateSessionKey( |
| 393 | + chain, |
| 394 | + new SessionSpec() |
| 395 | + { |
| 396 | + Signer = await Utils.GetAddressFromENS(client, "vitalik.eth"), |
| 397 | + IsWildcard = true, |
| 398 | + ExpiresAt = Utils.GetUnixTimeStampNow() + 86400, // 1 day |
| 399 | + CallPolicies = new List<CallSpec>(), |
| 400 | + TransferPolicies = new List<TransferSpec>(), |
| 401 | + Uid = "my-session-key-uid".HashMessage().HexToBytes() |
| 402 | + } |
| 403 | +); |
| 404 | +Console.WriteLine($"Session key receipt: {sessionKeyReceipt.TransactionHash}"); |
405 | 405 |
|
406 | 406 | #endregion
|
407 | 407 |
|
|
0 commit comments