Skip to content

Commit db26733

Browse files
committed
Celo USD TokenPaymaster
1 parent ea5254e commit db26733

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

Thirdweb.Console/Program.cs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
var client = ThirdwebClient.Create(secretKey: secretKey, fetchTimeoutOptions: new TimeoutOptions(storage: 120000, rpc: 120000, other: 120000));
2323

2424
// Create a private key wallet
25-
var privateKeyWallet = await PrivateKeyWallet.Generate(client: client);
25+
var privateKeyWallet = await PrivateKeyWallet.Generate(client);
2626

2727
// var walletAddress = await privateKeyWallet.GetAddress();
2828
// Console.WriteLine($"PK Wallet address: {walletAddress}");
@@ -324,6 +324,31 @@
324324

325325
#endregion
326326

327+
#region ERC20 Smart Wallet - Celo Dollar
328+
329+
// var erc20SmartWallet = await SmartWallet.Create(
330+
// personalWallet: privateKeyWallet,
331+
// chainId: 42220, // celo mainnet
332+
// gasless: true,
333+
// factoryAddress: Constants.DEFAULT_FACTORY_ADDRESS_V07,
334+
// entryPoint: Constants.ENTRYPOINT_ADDRESS_V07,
335+
// tokenPaymaster: TokenPaymaster.CELO_CUSD
336+
// );
337+
// var erc20SmartWalletAddress = await erc20SmartWallet.GetAddress();
338+
// Console.WriteLine($"ERC20 Smart Wallet address: {erc20SmartWalletAddress}");
339+
340+
// var selfTransfer = await ThirdwebTransaction.Create(wallet: erc20SmartWallet, txInput: new ThirdwebTransactionInput(chainId: 42220, to: erc20SmartWalletAddress, value: 0, data: "0x"));
341+
342+
// var estimateGas = await ThirdwebTransaction.EstimateGasCosts(selfTransfer);
343+
// Console.WriteLine($"Self transfer gas estimate: {estimateGas.Ether}");
344+
// Console.WriteLine("Make sure you have enough cUSD!");
345+
// Console.ReadLine();
346+
347+
// var receipt = await ThirdwebTransaction.SendAndWaitForTransactionReceipt(selfTransfer);
348+
// Console.WriteLine($"Self transfer receipt: {JsonConvert.SerializeObject(receipt, Formatting.Indented)}");
349+
350+
#endregion
351+
327352
#region Chain Data Fetching
328353

329354
// var chainData = await Utils.GetChainMetadata(client, 421614);
@@ -368,6 +393,21 @@
368393

369394
#endregion
370395

396+
#region InAppWallet - Email
397+
398+
// var inAppWalletEmail = await InAppWallet.Create(client: client, email: "[email protected]");
399+
// if (!await inAppWalletEmail.IsConnected())
400+
// {
401+
// _ = await inAppWalletEmail.SendOTP();
402+
// Console.WriteLine("Enter OTP:");
403+
// var otp = Console.ReadLine();
404+
// _ = await inAppWalletEmail.LoginWithOtp(otp);
405+
// }
406+
// var inAppWalletOAuthAddress = await inAppWalletEmail.GetAddress();
407+
// Console.WriteLine($"InAppWallet address: {inAppWalletOAuthAddress}");
408+
409+
#endregion
410+
371411
#region Smart Wallet - Gasless Transaction
372412

373413
// var smartWallet = await SmartWallet.Create(privateKeyWallet, 78600);

Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public enum TokenPaymaster
1515
{
1616
NONE,
1717
BASE_USDC,
18+
CELO_CUSD,
1819
}
1920

2021
public class SmartWallet : IThirdwebWallet
@@ -70,6 +71,16 @@ private struct TokenPaymasterConfig
7071
TokenAddress = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
7172
BalanceStorageSlot = 9
7273
}
74+
},
75+
{
76+
TokenPaymaster.CELO_CUSD,
77+
new TokenPaymasterConfig()
78+
{
79+
ChainId = 42220,
80+
PaymasterAddress = "0x61382940b029f8Df0c9FfB12638f20EF6B526853",
81+
TokenAddress = "0x765DE816845861e75A25fCA122bb6898B8B1282a",
82+
BalanceStorageSlot = 9,
83+
}
7384
}
7485
};
7586

0 commit comments

Comments
 (0)