From 52e3a71bbb9a37ed8ac47719bce55fa91310835f Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Wed, 20 Nov 2024 19:43:00 +0700 Subject: [PATCH 1/3] TokenPaymaster v3 Lisk LSK Paymaster --- Thirdweb.Console/Program.cs | 37 +++++++++---------- .../SmartWallet/SmartWallet.cs | 10 ++--- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/Thirdweb.Console/Program.cs b/Thirdweb.Console/Program.cs index 905e3ea..a95d3bd 100644 --- a/Thirdweb.Console/Program.cs +++ b/Thirdweb.Console/Program.cs @@ -299,28 +299,27 @@ #endregion -#region ERC20 Smart Wallet - Base USDC +#region TokenPaymaster - Lisk LSK -// var erc20SmartWallet = await SmartWallet.Create( -// personalWallet: privateKeyWallet, -// chainId: 8453, // base mainnet -// gasless: true, -// factoryAddress: "0xEc87d96E3F324Dcc828750b52994C6DC69C8162b", -// entryPoint: Constants.ENTRYPOINT_ADDRESS_V07, -// tokenPaymaster: TokenPaymaster.BASE_USDC -// ); -// var erc20SmartWalletAddress = await erc20SmartWallet.GetAddress(); -// Console.WriteLine($"ERC20 Smart Wallet address: {erc20SmartWalletAddress}"); +var erc20SmartWallet = await SmartWallet.Create( + personalWallet: privateKeyWallet, + chainId: 1135, // lisk + gasless: true, + entryPoint: Constants.ENTRYPOINT_ADDRESS_V07, + tokenPaymaster: TokenPaymaster.LISK_LSK +); +var erc20SmartWalletAddress = await erc20SmartWallet.GetAddress(); +Console.WriteLine($"ERC20 Smart Wallet address: {erc20SmartWalletAddress}"); -// var selfTransfer = await ThirdwebTransaction.Create(wallet: erc20SmartWallet, txInput: new ThirdwebTransactionInput(chainId: 8453, to: erc20SmartWalletAddress, value: 0, data: "0x")); +var selfTransfer = await ThirdwebTransaction.Create(wallet: erc20SmartWallet, txInput: new ThirdwebTransactionInput(chainId: 1135, 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 USDC!"); -// Console.ReadLine(); +var estimateGas = await ThirdwebTransaction.EstimateGasCosts(selfTransfer); +Console.WriteLine($"Self transfer gas estimate: {estimateGas.Ether}"); +Console.WriteLine("Make sure you have enough ERC20s!"); +Console.ReadLine(); -// var receipt = await ThirdwebTransaction.SendAndWaitForTransactionReceipt(selfTransfer); -// Console.WriteLine($"Self transfer receipt: {JsonConvert.SerializeObject(receipt, Formatting.Indented)}"); +var receipt = await ThirdwebTransaction.SendAndWaitForTransactionReceipt(selfTransfer); +Console.WriteLine($"Receipt: {JsonConvert.SerializeObject(receipt, Formatting.Indented)}"); #endregion @@ -349,7 +348,7 @@ #region InAppWallet - OAuth -// var inAppWalletOAuth = await InAppWallet.Create(client: client, authProvider: AuthProvider.Twitch); +// var inAppWalletOAuth = await InAppWallet.Create(client: client, authProvider: AuthProvider.Google); // if (!await inAppWalletOAuth.IsConnected()) // { // _ = await inAppWalletOAuth.LoginWithOauth( diff --git a/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs b/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs index 641205b..dfb66a7 100644 --- a/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs @@ -14,7 +14,7 @@ namespace Thirdweb; public enum TokenPaymaster { NONE, - BASE_USDC, + LISK_LSK } public class SmartWallet : IThirdwebWallet @@ -62,12 +62,12 @@ private struct TokenPaymasterConfig } }, { - TokenPaymaster.BASE_USDC, + TokenPaymaster.LISK_LSK, new TokenPaymasterConfig() { - ChainId = 8453, - PaymasterAddress = "0xff4d12b1f8d276aa4a9e8cc80539e806791bfe28", - TokenAddress = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", + ChainId = 1135, + PaymasterAddress = "0xD1D1408b198C151bbe66F34D84b404a6e94f816f", + TokenAddress = "0xac485391EB2d7D88253a7F1eF18C37f4242D1A24", BalanceStorageSlot = 9 } } From 629f845cd27c07ee01915b98d0674ebce84423c2 Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Wed, 20 Nov 2024 23:26:33 +0700 Subject: [PATCH 2/3] Celo Dollar and Base USDC --- Thirdweb.Console/Program.cs | 71 ++++++++++++++----- .../SmartWallet/SmartWallet.cs | 24 ++++++- 2 files changed, 75 insertions(+), 20 deletions(-) diff --git a/Thirdweb.Console/Program.cs b/Thirdweb.Console/Program.cs index a95d3bd..3171021 100644 --- a/Thirdweb.Console/Program.cs +++ b/Thirdweb.Console/Program.cs @@ -299,27 +299,60 @@ #endregion +#region TokenPaymaster - Celo CUSD + +// var erc20SmartWallet = await SmartWallet.Create( +// personalWallet: privateKeyWallet, +// chainId: 42220, // celo +// gasless: true, +// 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 receipt = await ThirdwebTransaction.SendAndWaitForTransactionReceipt(selfTransfer); +// Console.WriteLine($"Receipt: {JsonConvert.SerializeObject(receipt, Formatting.Indented)}"); + +#endregion + +#region TokenPaymaster - Base USDC + +// var erc20SmartWallet = await SmartWallet.Create( +// personalWallet: privateKeyWallet, +// chainId: 8453, // base +// gasless: true, +// entryPoint: Constants.ENTRYPOINT_ADDRESS_V07, +// tokenPaymaster: TokenPaymaster.BASE_USDC +// ); +// var erc20SmartWalletAddress = await erc20SmartWallet.GetAddress(); +// Console.WriteLine($"ERC20 Smart Wallet address: {erc20SmartWalletAddress}"); + +// var selfTransfer = await ThirdwebTransaction.Create(wallet: erc20SmartWallet, txInput: new ThirdwebTransactionInput(chainId: 8453, to: erc20SmartWalletAddress, value: 0, data: "0x")); + +// var receipt = await ThirdwebTransaction.SendAndWaitForTransactionReceipt(selfTransfer); +// Console.WriteLine($"Receipt: {JsonConvert.SerializeObject(receipt, Formatting.Indented)}"); + +#endregion + #region TokenPaymaster - Lisk LSK -var erc20SmartWallet = await SmartWallet.Create( - personalWallet: privateKeyWallet, - chainId: 1135, // lisk - gasless: true, - entryPoint: Constants.ENTRYPOINT_ADDRESS_V07, - tokenPaymaster: TokenPaymaster.LISK_LSK -); -var erc20SmartWalletAddress = await erc20SmartWallet.GetAddress(); -Console.WriteLine($"ERC20 Smart Wallet address: {erc20SmartWalletAddress}"); - -var selfTransfer = await ThirdwebTransaction.Create(wallet: erc20SmartWallet, txInput: new ThirdwebTransactionInput(chainId: 1135, 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 ERC20s!"); -Console.ReadLine(); - -var receipt = await ThirdwebTransaction.SendAndWaitForTransactionReceipt(selfTransfer); -Console.WriteLine($"Receipt: {JsonConvert.SerializeObject(receipt, Formatting.Indented)}"); +// var erc20SmartWallet = await SmartWallet.Create( +// personalWallet: privateKeyWallet, +// chainId: 1135, // lisk +// gasless: true, +// entryPoint: Constants.ENTRYPOINT_ADDRESS_V07, +// tokenPaymaster: TokenPaymaster.LISK_LSK +// ); +// var erc20SmartWalletAddress = await erc20SmartWallet.GetAddress(); +// Console.WriteLine($"ERC20 Smart Wallet address: {erc20SmartWalletAddress}"); + +// var selfTransfer = await ThirdwebTransaction.Create(wallet: erc20SmartWallet, txInput: new ThirdwebTransactionInput(chainId: 1135, to: erc20SmartWalletAddress, value: 0, data: "0x")); + +// var receipt = await ThirdwebTransaction.SendAndWaitForTransactionReceipt(selfTransfer); +// Console.WriteLine($"Receipt: {JsonConvert.SerializeObject(receipt, Formatting.Indented)}"); #endregion diff --git a/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs b/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs index dfb66a7..dbe2094 100644 --- a/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs @@ -14,6 +14,8 @@ namespace Thirdweb; public enum TokenPaymaster { NONE, + BASE_USDC, + CELO_CUSD, LISK_LSK } @@ -61,6 +63,26 @@ private struct TokenPaymasterConfig BalanceStorageSlot = 0 } }, + { + TokenPaymaster.BASE_USDC, + new TokenPaymasterConfig() + { + ChainId = 8453, + PaymasterAddress = "0x34d19b49Eae24Ce4334c25f61865aA0C78467cF3", + TokenAddress = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", + BalanceStorageSlot = 9 + } + }, + { + TokenPaymaster.CELO_CUSD, + new TokenPaymasterConfig() + { + ChainId = 42220, + PaymasterAddress = "0xBD17517383512E5b9eEEB7320A1BCfde66B78ac5", + TokenAddress = "0x765DE816845861e75A25fCA122bb6898B8B1282a", + BalanceStorageSlot = 9 + } + }, { TokenPaymaster.LISK_LSK, new TokenPaymasterConfig() @@ -719,7 +741,7 @@ private async Task SignUserOp(ThirdwebTransactionInput transactionInput, partialUserOp.VerificationGasLimit = new HexBigInteger(gasEstimates.VerificationGasLimit).Value; partialUserOp.PreVerificationGas = new HexBigInteger(gasEstimates.PreVerificationGas).Value; partialUserOp.PaymasterVerificationGasLimit = new HexBigInteger(gasEstimates.PaymasterVerificationGasLimit).Value; - partialUserOp.PaymasterPostOpGasLimit = new HexBigInteger(gasEstimates.PaymasterPostOpGasLimit).Value; + partialUserOp.PaymasterPostOpGasLimit = this.UseERC20Paymaster && !this._isApproving ? 500_000 : new HexBigInteger(gasEstimates.PaymasterPostOpGasLimit).Value; } // Hash, sign and encode the user operation From e4b48405dfc03c94ed576833a34e6840cae4ec3e Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Fri, 22 Nov 2024 23:26:18 +0700 Subject: [PATCH 3/3] Final deployments --- Thirdweb.Console/Program.cs | 45 +++++++------------ .../SmartWallet/SmartWallet.cs | 8 ++-- 2 files changed, 19 insertions(+), 34 deletions(-) diff --git a/Thirdweb.Console/Program.cs b/Thirdweb.Console/Program.cs index 3171021..9f480aa 100644 --- a/Thirdweb.Console/Program.cs +++ b/Thirdweb.Console/Program.cs @@ -301,57 +301,42 @@ #region TokenPaymaster - Celo CUSD -// var erc20SmartWallet = await SmartWallet.Create( -// personalWallet: privateKeyWallet, -// chainId: 42220, // celo -// gasless: true, -// entryPoint: Constants.ENTRYPOINT_ADDRESS_V07, -// tokenPaymaster: TokenPaymaster.CELO_CUSD -// ); +// var chainId = 42220; // celo + +// var erc20SmartWallet = await SmartWallet.Create(personalWallet: privateKeyWallet, chainId: chainId, 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 receipt = await ThirdwebTransaction.SendAndWaitForTransactionReceipt(selfTransfer); +// var receipt = await erc20SmartWallet.Transfer(chainId: chainId, toAddress: erc20SmartWalletAddress, weiAmount: 0); // Console.WriteLine($"Receipt: {JsonConvert.SerializeObject(receipt, Formatting.Indented)}"); #endregion #region TokenPaymaster - Base USDC -// var erc20SmartWallet = await SmartWallet.Create( -// personalWallet: privateKeyWallet, -// chainId: 8453, // base -// gasless: true, -// entryPoint: Constants.ENTRYPOINT_ADDRESS_V07, -// tokenPaymaster: TokenPaymaster.BASE_USDC -// ); +// var chainId = 8453; // base + +// var erc20SmartWallet = await SmartWallet.Create(personalWallet: privateKeyWallet, chainId: chainId, tokenPaymaster: TokenPaymaster.BASE_USDC); + // var erc20SmartWalletAddress = await erc20SmartWallet.GetAddress(); // Console.WriteLine($"ERC20 Smart Wallet address: {erc20SmartWalletAddress}"); -// var selfTransfer = await ThirdwebTransaction.Create(wallet: erc20SmartWallet, txInput: new ThirdwebTransactionInput(chainId: 8453, to: erc20SmartWalletAddress, value: 0, data: "0x")); - -// var receipt = await ThirdwebTransaction.SendAndWaitForTransactionReceipt(selfTransfer); +// var receipt = await erc20SmartWallet.Transfer(chainId: chainId, toAddress: erc20SmartWalletAddress, weiAmount: 0); // Console.WriteLine($"Receipt: {JsonConvert.SerializeObject(receipt, Formatting.Indented)}"); #endregion #region TokenPaymaster - Lisk LSK -// var erc20SmartWallet = await SmartWallet.Create( -// personalWallet: privateKeyWallet, -// chainId: 1135, // lisk -// gasless: true, -// entryPoint: Constants.ENTRYPOINT_ADDRESS_V07, -// tokenPaymaster: TokenPaymaster.LISK_LSK -// ); +// var chainId = 1135; // lisk + +// var erc20SmartWallet = await SmartWallet.Create(personalWallet: privateKeyWallet, chainId: chainId, tokenPaymaster: TokenPaymaster.LISK_LSK); + // var erc20SmartWalletAddress = await erc20SmartWallet.GetAddress(); // Console.WriteLine($"ERC20 Smart Wallet address: {erc20SmartWalletAddress}"); -// var selfTransfer = await ThirdwebTransaction.Create(wallet: erc20SmartWallet, txInput: new ThirdwebTransactionInput(chainId: 1135, to: erc20SmartWalletAddress, value: 0, data: "0x")); - -// var receipt = await ThirdwebTransaction.SendAndWaitForTransactionReceipt(selfTransfer); +// var receipt = await erc20SmartWallet.Transfer(chainId: chainId, toAddress: erc20SmartWalletAddress, weiAmount: 0); // Console.WriteLine($"Receipt: {JsonConvert.SerializeObject(receipt, Formatting.Indented)}"); #endregion diff --git a/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs b/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs index dbe2094..0208604 100644 --- a/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs @@ -68,7 +68,7 @@ private struct TokenPaymasterConfig new TokenPaymasterConfig() { ChainId = 8453, - PaymasterAddress = "0x34d19b49Eae24Ce4334c25f61865aA0C78467cF3", + PaymasterAddress = "0x2222f2738BE6bB7aA0Bfe4AEeAf2908172CF5539", TokenAddress = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", BalanceStorageSlot = 9 } @@ -78,7 +78,7 @@ private struct TokenPaymasterConfig new TokenPaymasterConfig() { ChainId = 42220, - PaymasterAddress = "0xBD17517383512E5b9eEEB7320A1BCfde66B78ac5", + PaymasterAddress = "0x3feA3c5744D715ff46e91C4e5C9a94426DfF2aF9", TokenAddress = "0x765DE816845861e75A25fCA122bb6898B8B1282a", BalanceStorageSlot = 9 } @@ -88,7 +88,7 @@ private struct TokenPaymasterConfig new TokenPaymasterConfig() { ChainId = 1135, - PaymasterAddress = "0xD1D1408b198C151bbe66F34D84b404a6e94f816f", + PaymasterAddress = "0x9eb8cf7fBa5ed9EeDCC97a0d52254cc0e9B1AC25", TokenAddress = "0xac485391EB2d7D88253a7F1eF18C37f4242D1A24", BalanceStorageSlot = 9 } @@ -176,7 +176,7 @@ public static async Task Create( } } - entryPoint ??= Constants.ENTRYPOINT_ADDRESS_V06; + entryPoint ??= tokenPaymaster == TokenPaymaster.NONE ? Constants.ENTRYPOINT_ADDRESS_V06 : Constants.ENTRYPOINT_ADDRESS_V07; var entryPointVersion = Utils.GetEntryPointVersion(entryPoint);