Releases: thirdweb-dev/dotnet
v2.17.0
What's Changed
Nebula AI .NET Integration (Beta) in #122
The last piece of the puzzle required to create .NET apps and games leveraging a blockchain-powered AI assistant or NPC that also has the power to fully execute transactions. Further enhanced when combined with Server Wallets and Account Abstraction.
Read, Write, Reason.
The best way to understand is to look at examples.
We'll prepare some context for the AI - here, we'll generate a basic PrivateKeyWallet
and upgrade it to a SmartWallet
on Sepolia.
// Prepare some context
var myChain = 11155111; // Sepolia
var mySigner = await PrivateKeyWallet.Generate(client);
var myWallet = await SmartWallet.Create(mySigner, myChain);
var myContractAddress = "0xe2cb0eb5147b42095c2FfA6F7ec953bb0bE347D8"; // DropERC1155
var usdcAddress = "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"; // Sepolia USDC
A one liner creates a Nebula session.
// Create a Nebula session
var nebula = await ThirdwebNebula.Create(client);
You can Chat with Nebula. The Chat method accepts any IThirdwebWallet
as an optional parameter, context will automatically be updated.
// Chat, passing wallet context
var response1 = await nebula.Chat(message: "What is my wallet address?", wallet: myWallet);
Console.WriteLine($"Response 1: {response1.Message}");
You may also pass it smart contract context.
// Chat, passing contract context
var response2 = await nebula.Chat(
message: "What's the total supply of token id 0 for this contract?",
context: new NebulaContext(contractAddresses: new List<string> { myContractAddress }, chainIds: new List<BigInteger> { myChain })
);
Console.WriteLine($"Response 2: {response2.Message}");
You can have a full on conversation with it with our Chat override accepting multiple messages.
// Chat, passing multiple messages and context
var response3 = await nebula.Chat(
messages: new List<NebulaChatMessage>
{
new($"Tell me the name of this contract: {myContractAddress}", NebulaChatRole.User),
new("The name of the contract is CatDrop", NebulaChatRole.Assistant),
new("What's the symbol of this contract?", NebulaChatRole.User),
},
context: new NebulaContext(contractAddresses: new List<string> { myContractAddress }, chainIds: new List<BigInteger> { myChain })
);
Console.WriteLine($"Response 3: {response3.Message}");
Chatting is cool, but what if I just want it to do things and stop talking so much?
You can Execute transactions directly with a simple prompt.
// Execute, this directly sends transactions
var executionResult = await nebula.Execute("Approve 1 USDC to vitalik.eth", wallet: myWallet, context: new NebulaContext(contractAddresses: new List<string>() { usdcAddress }));
if (executionResult.TransactionReceipts != null && executionResult.TransactionReceipts.Count > 0)
{
Console.WriteLine($"Receipt: {executionResult.TransactionReceipts[0]}");
}
else
{
Console.WriteLine($"Message: {executionResult.Message}");
}
Similarly, Execute can take in multiple messages.
// Batch execute
var batchExecutionResult = await nebula.Execute(
new List<NebulaChatMessage>
{
new("What's the address of vitalik.eth", NebulaChatRole.User),
new("The address of vitalik.eth is 0xd8dA6BF26964aF8E437eEa5e3616511D7G3a3298", NebulaChatRole.Assistant),
new("Approve 1 USDC to them", NebulaChatRole.User),
},
wallet: myWallet,
context: new NebulaContext(contractAddresses: new List<string>() { usdcAddress })
);
if (batchExecutionResult.TransactionReceipts != null && batchExecutionResult.TransactionReceipts.Count > 0)
{
Console.WriteLine($"Receipts: {JsonConvert.SerializeObject(batchExecutionResult.TransactionReceipts, Formatting.Indented)}");
}
else
{
Console.WriteLine($"Message: {batchExecutionResult.Message}");
}
Enhanced Analytics in #125
We've added transaction and connection analytics that will show up on your thirdweb dashboard and give you a better sense of your users' activities - make sure you grab this version to get the benefits!
If you've read this far, access Nebula and start building cool things. You're early - a full stack blockchain integration powered by AI is not something you see in .NET land too often, make use of thirdweb to build next-gen applications, and reach out to us!
v2.16.0
What's Changed
AuthProvider.SiweExternal - SIWE, OAuth style
Depending on the framework, or on the external wallet platform support, you may not have direct access to every single wallet out there.
This new AuthProvider allows you to login to otherwise native-unavailable wallets such as Abstract Wallet & Coinbase Smart Wallet through a flow similar to OAuth, using SIWE.
It'll redirect you to static.thirdweb.com and use our React SDK and other wallet SDKs as needed, unlocking the ability to login (or link) with any wallet thirdweb supports on web, from runtime platforms that would otherwise be unsupported by said wallet, and create an In-App or Ecosystem Wallet out of it.
Windows Console Example:
var inAppWalletSiweExternal = await InAppWallet.Create(client: client, authProvider: AuthProvider.SiweExternal);
var address = await inAppWalletSiweExternal.LoginWithSiweExternal(
isMobile: false,
browserOpenAction: (url) =>
{
var psi = new ProcessStartInfo { FileName = url, UseShellExecute = true };
_ = Process.Start(psi);
},
forceWalletIds: new List<string> { "io.metamask", "com.coinbase.wallet", "xyz.abs" }
);
You can now override the default session id used with Guest authentication
This is useful when you want your guest mode to be tied to a unique device identifier, and depending on your framework there may be various APIs to fetch such identifiers that you may want to use.
Example:
var guestWallet = await EcosystemWallet.Create(
ecosystemId: "ecosystem.the-bonfire",
client: client,
authProvider: AuthProvider.Guest
);
var address = await guestWallet.LoginWithGuest(SomeSystemInfoAPI.deviceUniqueIdentifier);
v2.15.0
v2.14.0
What's Changed
- Added
AuthProvider.Backend
as a server-side way to create In-App or Ecosystem Wallets. Simply pass awalletSecret
identifier.
var inAppWalletBackend = await InAppWallet.Create(
client: client,
authProvider: AuthProvider.Backend,
walletSecret: "very-secret"
);
var address = await inAppWalletBackend.LoginWithBackend();
v2.13.0
What's Changed
- Added
DropER721_Burn
,DropERC1155_BurnBatch
,TokenERC721_Burn
,TokenERC1155_Burn
,TokenERC1155_BurnBatch
contract extensions. - Overriding default RPCs is now allowed through a new
ThirdwebClient
creation parameterrpcOverrides
.
var client = ThirdwebClient.Create(
clientId: "myepicclientid",
bundleId: "my.bundle.id", // for native apps
rpcOverrides: new()
{
{ 1, "https://eth.llamarpc.com" },
{ 42161, "https://arbitrum.llamarpc.com" }
}
);
- Removed some leftover unnecessary logging.
v2.12.1
What's Changed
- Patch exposing
GetUserDetails
fields when using Ecosystem or In-App Wallets.
v2.12.0
IThirdwebWallet.UnlinkAccount
Adds the ability to Unlink a LinkedAccount
from your In-App or Ecosystem Wallet in #107
List<LinkedAccount> linkedAccounts = await inAppWallet.GetLinkedAccounts();
List<LinkedAccount> linkedAccountsAfterUnlinking = await inAppWallet.UnlinkAccount(linkedAccounts[0]);
EIP-7702 Integration (Experimental)
Integrates authorizationList
for any transactions in #108
This EIP essentially allows you to set code to an EOA, unlocking a world of possibilities to enhance their functionality.
The best way to understand it outside of reading the EIP is looking at the example below; to preface it: we sign an authorization using the wallet we want to set code to. Another wallet sends a transaction with said authorization passed in, essentially activating it. The authority wallet now has code set to it pointing to an (insecure) Delegation contract in this case, which allows any wallet to execute any call through it on behalf of the authority. In this example, we call the wallet executing both the authorization and the claim transaction afterwards, the exectuor.
An authority may execute its own authorization, the only difference is internal whereby the authorization nonce is incremented by 1.
// Chain and contract addresses
var chainWith7702 = 911867;
var erc20ContractAddress = "0xAA462a5BE0fc5214507FDB4fB2474a7d5c69065b"; // Fake ERC20
var delegationContractAddress = "0x654F42b74885EE6803F403f077bc0409f1066c58"; // BatchCallDelegation
// Initialize contracts normally
var erc20Contract = await ThirdwebContract.Create(client: client, address: erc20ContractAddress, chain: chainWith7702);
var delegationContract = await ThirdwebContract.Create(client: client, address: delegationContractAddress, chain: chainWith7702);
// Initialize a (to-be) 7702 EOA
var eoaWallet = await PrivateKeyWallet.Generate(client);
var eoaWalletAddress = await eoaWallet.GetAddress();
Console.WriteLine($"EOA address: {eoaWalletAddress}");
// Initialize another wallet, the "executor" that will hit the eoa's (to-be) execute function
var executorWallet = await PrivateKeyWallet.Generate(client);
var executorWalletAddress = await executorWallet.GetAddress();
Console.WriteLine($"Executor address: {executorWalletAddress}");
// Fund the executor wallet
var fundingWallet = await PrivateKeyWallet.Create(client, privateKey);
var fundingHash = (await fundingWallet.Transfer(chainWith7702, executorWalletAddress, BigInteger.Parse("0.001".ToWei()))).TransactionHash;
Console.WriteLine($"Funded Executor Wallet: {fundingHash}");
// Sign the authorization to make it point to the delegation contract
var authorization = await eoaWallet.SignAuthorization(chainId: chainWith7702, contractAddress: delegationContractAddress, willSelfExecute: false);
Console.WriteLine($"Authorization: {JsonConvert.SerializeObject(authorization, Formatting.Indented)}");
// Execute the delegation
var tx = await ThirdwebTransaction.Create(executorWallet, new ThirdwebTransactionInput(chainId: chainWith7702, to: executorWalletAddress, authorization: authorization));
var hash = (await ThirdwebTransaction.SendAndWaitForTransactionReceipt(tx)).TransactionHash;
Console.WriteLine($"Authorization execution transaction hash: {hash}");
// Prove that code has been deployed to the eoa
var rpc = ThirdwebRPC.GetRpcInstance(client, chainWith7702);
var code = await rpc.SendRequestAsync<string>("eth_getCode", eoaWalletAddress, "latest");
Console.WriteLine($"EOA code: {code}");
// Log erc20 balance of executor before the claim
var executorBalanceBefore = await erc20Contract.ERC20_BalanceOf(executorWalletAddress);
Console.WriteLine($"Executor balance before: {executorBalanceBefore}");
// Prepare the claim call
var claimCallData = erc20Contract.CreateCallData(
"claim",
new object[]
{
executorWalletAddress, // receiver
100, // quantity
Constants.NATIVE_TOKEN_ADDRESS, // currency
0, // pricePerToken
new object[] { Array.Empty<byte>(), BigInteger.Zero, BigInteger.Zero, Constants.ADDRESS_ZERO }, // allowlistProof
Array.Empty<byte>() // data
}
);
// Embed the claim call in the execute call
var executeCallData = delegationContract.CreateCallData(
method: "execute",
parameters: new object[]
{
new List<Thirdweb.Console.Call>
{
new()
{
Data = claimCallData.HexToBytes(),
To = erc20ContractAddress,
Value = BigInteger.Zero
}
}
}
);
// Execute from the executor wallet targeting the eoa which is pointing to the delegation contract
var tx2 = await ThirdwebTransaction.Create(executorWallet, new ThirdwebTransactionInput(chainId: chainWith7702, to: eoaWalletAddress, data: executeCallData));
var hash2 = (await ThirdwebTransaction.SendAndWaitForTransactionReceipt(tx2)).TransactionHash;
Console.WriteLine($"Token claim transaction hash: {hash2}");
// Log erc20 balance of executor after the claim
var executorBalanceAfter = await erc20Contract.ERC20_BalanceOf(executorWalletAddress);
Console.WriteLine($"Executor balance after: {executorBalanceAfter}");
Note that for the time being this only works on 7702-enabled chains such as Odyssey and the feature has only been integrated with PrivateKeyWallet
.
EcosystemWallet.GetUserAuthDetails
Adds the ability to retrieve auth provider specific user information from In-App and Ecosystem Wallets in #110
Other additions
SwitchNetwork
is now part of the mainIThirdwebWallet
interface. Smart Wallets now attempt to switch the underlying admin network automatically as well.ERC721_TotalSupply
extension now includes burned NFTs when using thirdweb contracts, allowing forERC721_GetAll
andERC721_GetOwned
functions to return said NFTs as well.- Various new utilities for conversions and transaction decoding, including decoding
authorizationList
.
Full Changelog: v2.11.1...v2.12.0
v2.11.1
What's Changed
- [SmartWallet] Fix SwitchNetwork from zksync stack to non zksync by @0xFirekeeper in #106
Full Changelog: v2.11.0...v2.11.1
v2.11.0
What's Changed
- [Pay] Allow passing purchaseData with quotes by @0xFirekeeper in #104
- ERC-6492 Predeploy Signature Verification by @0xFirekeeper in #105
- Adds ThirdwebContract.CreateCallData extension.
Full Changelog: v2.10.1...v2.11.0