Skip to content

Releases: thirdweb-dev/dotnet

v2.20.1

02 May 13:09
0dd7293
Compare
Choose a tag to compare

What's Changed

  • Ronin and its testnet Saigon have been added to the forced type 1 transaction list, making use of gas price all the time. This is due to instability in type 2 transaction behavior on that chain in some cases.

v2.20.0

29 Apr 13:58
a668d2c
Compare
Choose a tag to compare

What's Changed

  • Nebula model t0-003 Integration
    • New NebulaContext constructor, only a list of chain ids are now needed, and an optional wallet address can be passed.
    • Results are a lot more predictable now, model t0-003 is now the default model when creating a ThirdwebNebula instance.
    • Execution methods returns receipts more consistently.
    • Session is now properly passed to every call, improving contextual responses.
  • Fixed an bug where using the extension DropERC20_Claim would fail if the claim condition was set to be in native tokens.

v2.19.1

21 Apr 14:33
b8788c1
Compare
Choose a tag to compare

What's Changed

  • Fixed an encoding issue when using Account Abstraction v0.7 (Smart Wallet with Entrypoint v0.7) without a paymaster (gasless: false).
  • Fixed an issue where ThirdwebInsight's ToNFT and ToNFTList extensions would throw "Unknown NFT type" due to new response model.

v2.19.0

21 Mar 23:50
59f7ed8
Compare
Choose a tag to compare

[Beta] Universal Bridge .NET Integration - Successor to Thirdweb Pay

We've built Universal Bridge to allow your users to use any asset on any chain, and it's ready for you to try.

This integration simplifies onchain asset trading, and we've added extensions in .NET to integrate with any IThirdwebWallet nicely.

Core APIs

The design is akin to letting us know what your intent is.

  • Buy: "I want to buy x USDC on y Chain using z Token"
  • Sell: "I want to sell x USDC on y Chain for z Token"
  • Transfer: "Just transfer all my money to vitalik"

We will return the transactions needed to achieve whatever you desire.
You may then handle execution yourself or use our extensions.

Instantiation

using Thirdweb.Bridge;

// Create a ThirdwebBridge instance
var bridge = await ThirdwebBridge.Create(client);

Buy - Get a quote for buying a specific amount of tokens

var buyQuote = await bridge.Buy_Quote(
    originChainId: 1,
    originTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum
    destinationChainId: 324,
    destinationTokenAddress: Constants.NATIVE_TOKEN_ADDRESS, // ETH on zkSync
    buyAmountWei: BigInteger.Parse("0.1".ToWei())
);
Console.WriteLine($"Buy quote: {JsonConvert.SerializeObject(buyQuote, Formatting.Indented)}");

Buy - Get an executable set of transactions (alongside a quote) for buying a specific amount of tokens

var preparedBuy = await bridge.Buy_Prepare(
    originChainId: 1,
    originTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum
    destinationChainId: 324,
    destinationTokenAddress: Constants.NATIVE_TOKEN_ADDRESS, // ETH on zkSync
    buyAmountWei: BigInteger.Parse("0.1".ToWei()),
    sender: await Utils.GetAddressFromENS(client, "vitalik.eth"),
    receiver: await myWallet.GetAddress()
);
Console.WriteLine($"Prepared Buy contains {preparedBuy.Transactions.Count} transaction(s)!");

Sell - Get a quote for selling a specific amount of tokens

var sellQuote = await bridge.Sell_Quote(
    originChainId: 324,
    originTokenAddress: Constants.NATIVE_TOKEN_ADDRESS, // ETH on zkSync
    destinationChainId: 1,
    destinationTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum
    sellAmountWei: BigInteger.Parse("0.1".ToWei())
);
Console.WriteLine($"Sell quote: {JsonConvert.SerializeObject(sellQuote, Formatting.Indented)}");

Sell - Get an executable set of transactions (alongside a quote) for selling a specific amount of tokens

var preparedSell = await bridge.Sell_Prepare(
    originChainId: 324,
    originTokenAddress: Constants.NATIVE_TOKEN_ADDRESS, // ETH on zkSync
    destinationChainId: 1,
    destinationTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum
    sellAmountWei: BigInteger.Parse("0.1".ToWei()),
    sender: await Utils.GetAddressFromENS(client, "vitalik.eth"),
    receiver: await myWallet.GetAddress()
);
Console.WriteLine($"Prepared Sell contains {preparedSell.Transactions.Count} transaction(s)!");

Transfer - Get an executable transaction for transferring a specific amount of tokens

Why not just transfer with the SDK? Stay tuned for webhooks, think direct payments!

var preparedTransfer = await bridge.Transfer_Prepare(
    chainId: 137,
    tokenAddress: Constants.NATIVE_TOKEN_ADDRESS, // ETH on zkSync
    transferAmountWei: BigInteger.Parse("0.1".ToWei()),
    sender: await Utils.GetAddressFromENS(client, "vitalik.eth"),
    receiver: await myWallet.GetAddress()
);
Console.WriteLine($"Prepared Transfer: {JsonConvert.SerializeObject(preparedTransfer, Formatting.Indented)}");

Manual Execution

This is not production code, we're just showcasing some of the APIs that would help you execute and poll status here.

// You may use our extensions to execute yourself...
var myTx = await preparedTransfer.Transactions[0].ToThirdwebTransaction(myWallet);
var myHash = await ThirdwebTransaction.Send(myTx);

// ...and poll for the status...
var status = await bridge.Status(transactionHash: myHash, chainId: 1);
var isComplete = status.StatusType == StatusType.COMPLETED;
Console.WriteLine($"Status: {JsonConvert.SerializeObject(status, Formatting.Indented)}");

// Or use our Execute extensions directly to handle everything for you!

Managed Execution

The SDK comes with some extensions that you'll see on a lot of ThirdwebBridge objects, and the main one is Execute.

// Execute a prepared Buy
var buyResult = await bridge.Execute(myWallet, preparedBuy);
var buyHashes = buyResult.Select(receipt => receipt.TransactionHash).ToList();
Console.WriteLine($"Buy hashes: {JsonConvert.SerializeObject(buyHashes, Formatting.Indented)}");

// Execute a prepared Sell
var sellResult = await bridge.Execute(myWallet, preparedSell);
var sellHashes = sellResult.Select(receipt => receipt.TransactionHash).ToList();
Console.WriteLine($"Sell hashes: {JsonConvert.SerializeObject(sellHashes, Formatting.Indented)}");

// Execute a prepared Transfer
var transferResult = await bridge.Execute(myWallet, preparedTransfer);
var transferHashes = transferResult.Select(receipt => receipt.TransactionHash).ToList();
Console.WriteLine($"Transfer hashes: {JsonConvert.SerializeObject(transferHashes, Formatting.Indented)}");

Full Bridge .NET Reference

v2.18.6

19 Mar 21:26
fc2d1a6
Compare
Choose a tag to compare

What's Changed

  • EngineWallet connections will now show up in your dashboard analytics, alongside other wallets.
  • Fixes issues fetching ERC721A NFTs (without the ERC721AQueryable extension) where burned token ids would throw an error due to a OwnerQueryForNonexistentToken revert.
  • GetEcosystemDetails now throws early if called on an InAppWallet rather than fetching and failing, slightly improving SmartWallet creation speed when using InAppWallet.

v2.18.5

13 Mar 14:51
613177f
Compare
Choose a tag to compare

What's Changed

// Instantiate Insight
var insight = await ThirdwebInsight.Create(client);

// Fetch current token price
var ethPriceToday = await insight.GetTokenPrice(addressOrSymbol: "ETH", chainId: 1);
Console.WriteLine($"ETH price today: {ethPriceToday.PriceUsd}");

// Fetch token price at specified timestamp
var ethPriceYesterday = await insight.GetTokenPrice(
  addressOrSymbol: "ETH",
  chainId: 1, 
  timestamp: Utils.GetUnixTimeStampNow() - 86400
);
Console.WriteLine($"ETH price yesterday: {ethPriceYesterday.PriceUsd}");

// Fetch multiple token prices across multiple chains
var multiTokenPrices = await insight.GetTokenPrices(
  addressOrSymbols: new string[] { "POL", "APE" },
  chainIds: new BigInteger[] { 137, 33139 }
);
Console.WriteLine($"Multi token prices: {JsonConvert.SerializeObject(multiTokenPrices, Formatting.Indented)}");

v2.18.4

12 Mar 17:57
06241aa
Compare
Choose a tag to compare

What's Changed

  • Fixed an issue where using InAppWallet or EcosystemWallet with AuthProvider.Siwe with a permissioned client id could lead to an Unauthorized error being thrown. AuthProvider.SiweExternal unaffected.

v2.18.3

12 Mar 14:36
d8a5637
Compare
Choose a tag to compare

What's Changed

  • Removed EngineWallet.Create's backend wallet validity check, this fixes issues instantiating when you had more than 10 backend wallets.
  • EngineWallet.Create is now synchronous.

v2.18.2

28 Feb 20:58
9faa319
Compare
Choose a tag to compare

What's Changed

  • ThirdwebInsight can now return additional rich NFT Metadata when using GetTokens_ERC721 or GetTokens_ERC1155.
    • limit, page and withMetadata optional arguments have been added.
    • The Token_ERC721 and Token_ERC1155 return types can now be converted into a base SDK NFT type
    • Extensions can be used with said NFT type.
// Fetch ERC721s with extra metadata returned
var erc721Tokens = await insight.GetTokens_ERC721(address, chains, withMetadata: true);

// Use ToNFT or ToNFTList extensions
var convertedNft = erc721Tokens[0].ToNFT();
var convertedNfts = erc721Tokens.ToNFTList();

// Use NFT Extensions (GetNFTImageBytes, or GetNFTSprite in Unity)
var imageBytes = await convertedNft.GetNFTImageBytes(client);
var pathToSave = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "nft.png");
await File.WriteAllBytesAsync(pathToSave, imageBytes);
Console.WriteLine($"NFT image saved to: {pathToSave}");

v2.18.1

21 Feb 22:53
a65e8c0
Compare
Choose a tag to compare

What's Changed

Similar filters to GetEvents available.

// Fetch transactions (great amount of optional filters available)
var transactions = await insight.GetTransactions(
    chainIds: new BigInteger[] { 1 }, // ethereum
    contractAddress: "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d", // bored apes
    fromTimestamp: Utils.GetUnixTimeStampNow() - 3600, // last hour
    sortBy: SortBy.TransactionIndex, // block number, block timestamp or transaction index
    sortOrder: SortOrder.Desc, // latest first
    limit: 5 // last 5 transactions
);
Console.WriteLine($"Transactions: {JsonConvert.SerializeObject(transactions, Formatting.Indented)}");