Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 42 additions & 42 deletions Thirdweb.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,48 +360,48 @@

#region EIP-7702

// var chain = 11155111; // sepolia

// // Connect to EOA
// var smartEoa = await InAppWallet.Create(client, authProvider: AuthProvider.Google, executionMode: ExecutionMode.EIP7702Sponsored);
// if (!await smartEoa.IsConnected())
// {
// _ = await smartEoa.LoginWithOauth(
// isMobile: false,
// (url) =>
// {
// var psi = new ProcessStartInfo { FileName = url, UseShellExecute = true };
// _ = Process.Start(psi);
// }
// );
// }
// var smartEoaAddress = await smartEoa.GetAddress();
// Console.WriteLine($"User Wallet address: {await smartEoa.GetAddress()}");

// // Upgrade EOA - This wallet explicitly uses EIP-7702 delegation to the thirdweb MinimalAccount (will delegate upon first tx)

// // Transact, will upgrade EOA
// var receipt = await smartEoa.Transfer(chainId: chain, toAddress: await Utils.GetAddressFromENS(client, "vitalik.eth"), weiAmount: 0);
// Console.WriteLine($"Transfer Receipt: {receipt.TransactionHash}");

// // Double check that it was upgraded
// var isDelegated = await Utils.IsDelegatedAccount(client, chain, smartEoaAddress);
// Console.WriteLine($"Is delegated: {isDelegated}");

// // Create a session key
// var sessionKeyReceipt = await smartEoa.CreateSessionKey(
// chain,
// new SessionSpec()
// {
// Signer = await Utils.GetAddressFromENS(client, "0xfirekeeper.eth"),
// IsWildcard = true,
// ExpiresAt = Utils.GetUnixTimeStampNow() + 86400, // 1 day
// CallPolicies = new List<CallSpec>(),
// TransferPolicies = new List<TransferSpec>(),
// Uid = Guid.NewGuid().ToByteArray().PadTo32Bytes()
// }
// );
// Console.WriteLine($"Session key receipt: {sessionKeyReceipt.TransactionHash}");
var chain = 11155111; // sepolia

// Connect to EOA
var smartEoa = await InAppWallet.Create(client, authProvider: AuthProvider.Google, executionMode: ExecutionMode.EIP7702Sponsored);
if (!await smartEoa.IsConnected())
{
_ = await smartEoa.LoginWithOauth(
isMobile: false,
(url) =>
{
var psi = new ProcessStartInfo { FileName = url, UseShellExecute = true };
_ = Process.Start(psi);
}
);
}
var smartEoaAddress = await smartEoa.GetAddress();
Console.WriteLine($"User Wallet address: {await smartEoa.GetAddress()}");

// Upgrade EOA - This wallet explicitly uses EIP-7702 delegation to the thirdweb MinimalAccount (will delegate upon first tx)

// Transact, will upgrade EOA
var receipt = await smartEoa.Transfer(chainId: chain, toAddress: await Utils.GetAddressFromENS(client, "vitalik.eth"), weiAmount: 0);
Console.WriteLine($"Transfer Receipt: {receipt.TransactionHash}");

// Double check that it was upgraded
var isDelegated = await Utils.IsDelegatedAccount(client, chain, smartEoaAddress);
Console.WriteLine($"Is delegated: {isDelegated}");

// Create a session key
var sessionKeyReceipt = await smartEoa.CreateSessionKey(
chain,
new SessionSpec()
{
Signer = await Utils.GetAddressFromENS(client, "vitalik.eth"),
IsWildcard = true,
ExpiresAt = Utils.GetUnixTimeStampNow() + 86400, // 1 day
CallPolicies = new List<CallSpec>(),
TransferPolicies = new List<TransferSpec>(),
Uid = "my-session-key-uid".HashMessage().HexToBytes()
}
);
Console.WriteLine($"Session key receipt: {sessionKeyReceipt.TransactionHash}");

#endregion

Expand Down
Loading