Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFirekeeper committed Apr 10, 2024
1 parent 8f12521 commit 9e26633
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ var contract = await ThirdwebContract.Create(client: client, address: "0x81ebd23
var readResult = await ThirdwebContract.Read<string>(contract, "name");
Console.WriteLine($"Contract read result: {readResult}");

// Create a smart account to unlock gasless features, with an embedded account as signer to unlock web2 auth
// Create embedded account as signer to unlock web2 auth
var embeddedAccount = await EmbeddedAccount.Create(client: client, email: "[email protected]"); // or email: null, phoneNumber: "+1234567890"
var smartAccount = await SmartAccount.Create(client: client, personalAccount: embeddedAccount, factoryAddress: "0xbf1C9aA4B1A085f7DA890a44E82B0A1289A40052", gasless: true, chainId: 421614);
// Relog if embedded account not logged in
if (!await embeddedAccount.IsConnected())
Expand All @@ -58,6 +57,9 @@ if (!await embeddedAccount.IsConnected())
}
}

// Create a smart account to unlock gasless features, with embedded account as a signer
var smartAccount = await SmartAccount.Create(client: client, personalAccount: embeddedAccount, factoryAddress: "0xbf1C9aA4B1A085f7DA890a44E82B0A1289A40052", gasless: true, chainId: 421614);

// Log addresses
Console.WriteLine($"Embedded Account: {await embeddedAccount.GetAddress()}");
Console.WriteLine($"Smart Account: {await smartAccount.GetAddress()}");
Expand Down
4 changes: 3 additions & 1 deletion Thirdweb.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ private static async Task Main(string[] args)
// Create accounts (this is an advanced use case, typically one account is plenty)
var privateKeyAccount = await PrivateKeyAccount.Create(client: client, privateKeyHex: privateKey);
var embeddedAccount = await EmbeddedAccount.Create(client: client, email: "[email protected]"); // or email: null, phoneNumber: "+1234567890"
var smartAccount = await SmartAccount.Create(client: client, personalAccount: embeddedAccount, factoryAddress: "0xbf1C9aA4B1A085f7DA890a44E82B0A1289A40052", gasless: true, chainId: 421614);

// // Reset embedded account (optional step for testing login flow)
// if (await embeddedAccount.IsConnected())
Expand Down Expand Up @@ -51,6 +50,9 @@ private static async Task Main(string[] args)
}
}

// Create smart account with embedded signer
var smartAccount = await SmartAccount.Create(client: client, personalAccount: embeddedAccount, factoryAddress: "0xbf1C9aA4B1A085f7DA890a44E82B0A1289A40052", gasless: true, chainId: 421614);

// Connect the smart account with embedded signer and grant a session key to pk account (advanced use case)
_ = await smartAccount.CreateSessionKey(
signerAddress: await privateKeyAccount.GetAddress(),
Expand Down

0 comments on commit 9e26633

Please sign in to comment.