|
1 |
| -# thirdweb Unity SDK |
| 1 | +<p align="center"> |
| 2 | +<br /> |
| 3 | +<a href="https://thirdweb.com"><img src="https://github.com/thirdweb-dev/js/blob/main/packages/sdk/logo.svg?raw=true" width="200" alt=""/></a> |
| 4 | +<br /> |
| 5 | +</p> |
| 6 | +<h1 align="center">thirdweb Unity SDK</h1> |
| 7 | +<p align="center"> |
| 8 | +<a href="https://discord.gg/thirdweb"><img alt="Join our Discord!" src="https://img.shields.io/discord/834227967404146718.svg?color=7289da&label=discord&logo=discord&style=flat"/></a> |
| 9 | + |
| 10 | +</p> |
| 11 | +<p align="center"><strong>Best in class Web3 SDK for Unity games</strong></p> |
| 12 | +<br /> |
| 13 | + |
| 14 | +## Supported platforms |
| 15 | + |
| 16 | +- [x] WebGL |
| 17 | +- [ ] Desktop (coming soon) |
| 18 | +- [ ] Android (coming soon) |
| 19 | +- [ ] iOS (coming soon) |
2 | 20 |
|
3 | 21 | ## Installation
|
4 | 22 |
|
5 |
| -See [Unity docs](https://docs.unity3d.com/Manual/webgl-templates.html) on how to customize WebGL Templates. |
| 23 | +Head over to the [releases](/releases) page and download the latest `.unitypackage` file. |
| 24 | + |
| 25 | +Drag and drop the file into your project. |
| 26 | + |
| 27 | +The package comes with a sample Scene showcasing the different capabilities of the SDK. |
| 28 | + |
| 29 | +## Build |
| 30 | + |
| 31 | +- Open your `Build settings`, select `WebGL` as the target platform. |
| 32 | +- Open `Player settings` > `Resolution and Presentation` and under `WebGLTemplate` choose `Thirdweb`. |
| 33 | +- Save and click `Build and Run` to test out your game in a browser. |
| 34 | + |
| 35 | +## Usage |
| 36 | + |
| 37 | +```csharp |
| 38 | +// instantiate a read only SDK on any EVM chain |
| 39 | +var sdk = new ThirdwebSDK("goerli"); |
| 40 | + |
| 41 | +// connect a wallet via browser extension |
| 42 | +var walletAddress = await sdk.wallet.Connect(); |
| 43 | + |
| 44 | +// get an instance of a deployed contract (no ABI requried!) |
| 45 | +var contract = sdk.GetContract("0x..."); |
| 46 | + |
| 47 | +// fetch data from any ERC20/721/1155 or marketplace contract |
| 48 | +CurrencyValue currencyValue = await contract.ERC20.TotalSupply(); |
| 49 | +NFT erc721NFT = await contract.ERC721.Get(tokenId); |
| 50 | +List<NFT> erc1155NFTs = await contract.ERC1155.GetAll(); |
| 51 | +List<Listing> listings = await marketplace.GetAllListings(); |
| 52 | + |
| 53 | +// execute transactions from the connected wallet |
| 54 | +await contract.ERC20.Mint("1.2"); |
| 55 | +await contract.ERC721.signature.Mint(signedPayload); |
| 56 | +await contract.ERC1155.Claim(tokenId, quantity); |
| 57 | +await marketplace.BuyListing(listingId, quantity); |
| 58 | + |
| 59 | +// deploy contracts from the connected wallet |
| 60 | +var address = await sdk.deployer.DeployNFTCollection(new NFTContractDeployMetadata { |
| 61 | + name = "My Personal Unity Collection", |
| 62 | + primary_sale_recipient = await sdk.wallet.GetAddress(), |
| 63 | +}); |
| 64 | +``` |
| 65 | + |
| 66 | +See full documentation on the [thirdweb portal](https://portal.thirdweb.com). |
0 commit comments