-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Firekeeper <[email protected]>
- Loading branch information
1 parent
0dd395e
commit 7fe9a2b
Showing
3 changed files
with
101 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,8 +22,37 @@ | |
Console.WriteLine($"Contract read result: {readResult}"); | ||
|
||
// Create wallets (this is an advanced use case, typically one wallet is plenty) | ||
var privateKeyWallet = await PrivateKeyWallet.Create(client: client, privateKeyHex: privateKey); | ||
// var privateKeyWallet = await PrivateKeyWallet.Create(client: client, privateKeyHex: privateKey); | ||
var privateKeyWallet = await PrivateKeyWallet.Generate(client: client); | ||
var walletAddress = await privateKeyWallet.GetAddress(); | ||
Console.WriteLine($"PK Wallet address: {walletAddress}"); | ||
|
||
var erc20SmartWalletSepolia = await SmartWallet.Create( | ||
personalWallet: privateKeyWallet, | ||
chainId: 11155111, // sepolia | ||
gasless: true, | ||
erc20PaymasterAddress: "0xEc87d96E3F324Dcc828750b52994C6DC69C8162b", // deposit paymaster | ||
erc20PaymasterToken: "0x94a9D9AC8a22534E3FaCa9F4e7F2E2cf85d5E4C8" // usdc | ||
); | ||
var erc20SmartWalletSepoliaAddress = await erc20SmartWalletSepolia.GetAddress(); | ||
Console.WriteLine($"ERC20 Smart Wallet Sepolia address: {erc20SmartWalletSepoliaAddress}"); | ||
|
||
var selfTransfer = await ThirdwebTransaction.Create( | ||
wallet: erc20SmartWalletSepolia, | ||
txInput: new ThirdwebTransactionInput() { From = erc20SmartWalletSepoliaAddress, To = erc20SmartWalletSepoliaAddress, }, | ||
chainId: 11155111 | ||
); | ||
|
||
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 receipt = await ThirdwebTransaction.SendAndWaitForTransactionReceipt(selfTransfer); | ||
Console.WriteLine($"Self transfer receipt: {JsonConvert.SerializeObject(receipt, Formatting.Indented)}"); | ||
|
||
// var chainData = await Utils.FetchThirdwebChainDataAsync(client, 421614); | ||
// Console.WriteLine($"Chain data: {JsonConvert.SerializeObject(chainData, Formatting.Indented)}"); | ||
Console.WriteLine($"Wallet address: {walletAddress}"); | ||
|
||
// // Self transfer 0 on chain 842 | ||
|
@@ -139,7 +168,7 @@ | |
// } | ||
|
||
|
||
var inAppWallet = await InAppWallet.Create(client: client, email: "[email protected]"); // or email: null, phoneNumber: "+1234567890" | ||
// var inAppWallet = await InAppWallet.Create(client: client, email: "[email protected]"); // or email: null, phoneNumber: "+1234567890" | ||
|
||
// var inAppWallet = await InAppWallet.Create(client: client, authprovider: AuthProvider.Google); // or email: null, phoneNumber: "+1234567890" | ||
|
||
|
@@ -165,27 +194,27 @@ | |
// Console.WriteLine($"InAppWallet address: {address}"); | ||
// } | ||
|
||
if (await inAppWallet.IsConnected()) | ||
{ | ||
Console.WriteLine($"InAppWallet address: {await inAppWallet.GetAddress()}"); | ||
return; | ||
} | ||
await inAppWallet.SendOTP(); | ||
Console.WriteLine("Please submit the OTP."); | ||
retry: | ||
var otp = Console.ReadLine(); | ||
(var inAppWalletAddress, var canRetry) = await inAppWallet.SubmitOTP(otp); | ||
if (inAppWalletAddress == null && canRetry) | ||
{ | ||
Console.WriteLine("Please submit the OTP again."); | ||
goto retry; | ||
} | ||
if (inAppWalletAddress == null) | ||
{ | ||
Console.WriteLine("OTP login failed. Please try again."); | ||
return; | ||
} | ||
Console.WriteLine($"InAppWallet address: {inAppWalletAddress}"); | ||
// if (await inAppWallet.IsConnected()) | ||
// { | ||
// Console.WriteLine($"InAppWallet address: {await inAppWallet.GetAddress()}"); | ||
// return; | ||
// } | ||
// await inAppWallet.SendOTP(); | ||
// Console.WriteLine("Please submit the OTP."); | ||
// retry: | ||
// var otp = Console.ReadLine(); | ||
// (var inAppWalletAddress, var canRetry) = await inAppWallet.SubmitOTP(otp); | ||
// if (inAppWalletAddress == null && canRetry) | ||
// { | ||
// Console.WriteLine("Please submit the OTP again."); | ||
// goto retry; | ||
// } | ||
// if (inAppWalletAddress == null) | ||
// { | ||
// Console.WriteLine("OTP login failed. Please try again."); | ||
// return; | ||
// } | ||
// Console.WriteLine($"InAppWallet address: {inAppWalletAddress}"); | ||
// } | ||
|
||
// Prepare a transaction directly, or with Contract.Prepare | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters