Skip to content

Commit

Permalink
Celo USD TokenPaymaster
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFirekeeper committed Oct 30, 2024
1 parent ea5254e commit db26733
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
42 changes: 41 additions & 1 deletion Thirdweb.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -368,6 +393,21 @@

#endregion

#region InAppWallet - Email

// var inAppWalletEmail = await InAppWallet.Create(client: client, email: "[email protected]");
// 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);
Expand Down
11 changes: 11 additions & 0 deletions Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public enum TokenPaymaster
{
NONE,
BASE_USDC,
CELO_CUSD,
}

public class SmartWallet : IThirdwebWallet
Expand Down Expand Up @@ -70,6 +71,16 @@ private struct TokenPaymasterConfig
TokenAddress = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
BalanceStorageSlot = 9
}
},
{
TokenPaymaster.CELO_CUSD,
new TokenPaymasterConfig()
{
ChainId = 42220,
PaymasterAddress = "0x61382940b029f8Df0c9FfB12638f20EF6B526853",
TokenAddress = "0x765DE816845861e75A25fCA122bb6898B8B1282a",
BalanceStorageSlot = 9,
}
}
};

Expand Down

0 comments on commit db26733

Please sign in to comment.