From db26733b520b54d381bdb81c1cb01b38f09e8a60 Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Thu, 31 Oct 2024 00:30:43 +0700 Subject: [PATCH] Celo USD TokenPaymaster --- Thirdweb.Console/Program.cs | 42 ++++++++++++++++++- .../SmartWallet/SmartWallet.cs | 11 +++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/Thirdweb.Console/Program.cs b/Thirdweb.Console/Program.cs index 905e3eae..edc8723b 100644 --- a/Thirdweb.Console/Program.cs +++ b/Thirdweb.Console/Program.cs @@ -22,7 +22,7 @@ var client = ThirdwebClient.Create(secretKey: secretKey, fetchTimeoutOptions: new TimeoutOptions(storage: 120000, rpc: 120000, other: 120000)); // Create a private key wallet -var privateKeyWallet = await PrivateKeyWallet.Generate(client: client); +var privateKeyWallet = await PrivateKeyWallet.Generate(client); // var walletAddress = await privateKeyWallet.GetAddress(); // Console.WriteLine($"PK Wallet address: {walletAddress}"); @@ -324,6 +324,31 @@ #endregion +#region ERC20 Smart Wallet - Celo Dollar + +// var erc20SmartWallet = await SmartWallet.Create( +// personalWallet: privateKeyWallet, +// chainId: 42220, // celo mainnet +// gasless: true, +// factoryAddress: Constants.DEFAULT_FACTORY_ADDRESS_V07, +// entryPoint: Constants.ENTRYPOINT_ADDRESS_V07, +// tokenPaymaster: TokenPaymaster.CELO_CUSD +// ); +// var erc20SmartWalletAddress = await erc20SmartWallet.GetAddress(); +// Console.WriteLine($"ERC20 Smart Wallet address: {erc20SmartWalletAddress}"); + +// var selfTransfer = await ThirdwebTransaction.Create(wallet: erc20SmartWallet, txInput: new ThirdwebTransactionInput(chainId: 42220, to: erc20SmartWalletAddress, value: 0, data: "0x")); + +// var estimateGas = await ThirdwebTransaction.EstimateGasCosts(selfTransfer); +// Console.WriteLine($"Self transfer gas estimate: {estimateGas.Ether}"); +// Console.WriteLine("Make sure you have enough cUSD!"); +// Console.ReadLine(); + +// var receipt = await ThirdwebTransaction.SendAndWaitForTransactionReceipt(selfTransfer); +// Console.WriteLine($"Self transfer receipt: {JsonConvert.SerializeObject(receipt, Formatting.Indented)}"); + +#endregion + #region Chain Data Fetching // var chainData = await Utils.GetChainMetadata(client, 421614); @@ -368,6 +393,21 @@ #endregion +#region InAppWallet - Email + +// var inAppWalletEmail = await InAppWallet.Create(client: client, email: "firekeeper@thirdweb.com"); +// if (!await inAppWalletEmail.IsConnected()) +// { +// _ = await inAppWalletEmail.SendOTP(); +// Console.WriteLine("Enter OTP:"); +// var otp = Console.ReadLine(); +// _ = await inAppWalletEmail.LoginWithOtp(otp); +// } +// var inAppWalletOAuthAddress = await inAppWalletEmail.GetAddress(); +// Console.WriteLine($"InAppWallet address: {inAppWalletOAuthAddress}"); + +#endregion + #region Smart Wallet - Gasless Transaction // var smartWallet = await SmartWallet.Create(privateKeyWallet, 78600); diff --git a/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs b/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs index 641205b1..ab123e48 100644 --- a/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs @@ -15,6 +15,7 @@ public enum TokenPaymaster { NONE, BASE_USDC, + CELO_CUSD, } public class SmartWallet : IThirdwebWallet @@ -70,6 +71,16 @@ private struct TokenPaymasterConfig TokenAddress = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", BalanceStorageSlot = 9 } + }, + { + TokenPaymaster.CELO_CUSD, + new TokenPaymasterConfig() + { + ChainId = 42220, + PaymasterAddress = "0x61382940b029f8Df0c9FfB12638f20EF6B526853", + TokenAddress = "0x765DE816845861e75A25fCA122bb6898B8B1282a", + BalanceStorageSlot = 9, + } } };