diff --git a/dictionary.txt b/dictionary.txt index 18aba77..909fa9f 100644 --- a/dictionary.txt +++ b/dictionary.txt @@ -5,11 +5,17 @@ A1 A2 ABI +Addons +addons +addon Algorand all-1155s all-721s All1155s All721s +analytics +async +APIs AppStore backend BalanceOf @@ -22,14 +28,31 @@ Blockchains BSC BuyItemWebGL BuyItemWebWallet +blockchain-enabled +blockchain's +BuildAsync +codebase +ChainSafe's +CRO +Chainstack's +cryptographic +Cheatsheet +CLR +call-custom-contracts-through-web3auth +customizations +changelogs +Chain721 call-custom-blockchain-tokens call-custom-blockchains chainID ChainId chainsafe ChainSafe +ChainSafe's Chainstack +ChainID's Chainlist +cheatsheet Cloudflare config contract-abi-to-json-format @@ -42,13 +65,25 @@ crypto cryptographically Ctrl Docusaurus +DApp +devs +dev +devsetup +ECDSA +EVM-compatible +EVM-compatible +Etherscan +Ethereum's +EVM-based eg. EIP712 +ERC ERC-1155 ERC-20 ERC-721 erc1155 ERC1155 +Erc2771 erc20 ERC20 erc721 @@ -62,39 +97,76 @@ ethereum Ethereum EVM evm-blockchain +extending-the-sdk faq +fix-namespaces +fullscreen +frictionless +Frictionless +gasless-transactions-using-Gelato +gamepad +gamified +Gasless +gasless GitHub +Gelato getting-started-v1 getting-started-v2 goerli Goerli goerli's +GasLimit +getter +gamers +gameplay +GitHub +github +Goerli's +goerliETH how-tos +HTTPS +Infura-enabled +IChainConfig +Integrable +IRpcProvider IDE implementing-social-logins-to-webgl-builds importing-nfts infura +interacting-with-nfts IPFS +IProjectConfig javascript JSON +JsonRpcProvider +KPIs Kwame LazyMinter +Lootbox +lootbox +LootBoxes +Lootboxes +lootboxes libcurl ListItemWebGL ListItemWebWallet LoginScene mainnet Mainnet +mainnets mainnetgoerli metamask MetaMask minter-evm +minting-nft +MonoBehaviour namespace Nethereum networkID Newtonsoft NewtonSoft newtonsoft +non-EVM NFT NFTPixels nft-textures @@ -103,29 +175,50 @@ NFTPixels NFTs nodeJS NodeJS +npm onboarding OpenSea +OPM +openupm-cli +OpenUPM prebuilt preconfigured Preconfigured +QuickNode repo Rinkeby rpc RPC +RPCs +scalable +scrollable SampleScene -SKALE +scriptable SDK SDK. SDK's +SendTransaction send-contract-through-webgl send-transaction-through-webgl Sepolia sha3 SHA3 sign-through-webgl +SKALE Sneakz Solana src +Rpc +RpcProvider +sign-through-web3auth +SHA-3 +setting-up-an-rpc-node +tokenIds +tokenId +transfer-erc-20-token-through-web3auth +testnets +TransactionRequest +TransactionExecutor testnet Testnet ToS @@ -141,6 +234,10 @@ TypedData TypeError uncomment Uncomment +UnityEnvironment +UPM +url +USDT Unity3D UNPKG uri @@ -154,7 +251,18 @@ V2 v2 VoucherMint VSCode +wei +Woohoo +uptime +UX +URIs +UI +verify-through-web3auth walletscene +Web2-like +Web2-Like +web2-like-authentication-using-web3auth +Web2 web3 Web3 Web3Auth @@ -178,59 +286,15 @@ webpage webserver WebTemplates WebWallet -Woohoo -xdai -XDai -YourGame -EVM-compatible -Chainlist -ChainID's -non-EVM -EVM-compatible -uptime -UX -devs -codebase -QuickNode -RPCs -ChainSafe's Web3GL-based -scalable -dev -Infura-enabled web3-enabled Web3GL-enabled -analytics -GitHub -github -blockchain-enabled -EVM-based -UI -Integrable -tokenId -mainnets -testnets -SHA-3 -gamers +Web3AuthSigner +Web3Builder +WebGLWallet +WebPageWallet WebAssembly -Goerli's -goerliETH -customizations -changelogs -Ethereum's -wei -CRO -Chain721 -tokenIds -URIs -url -cryptographic -setting-up-an-rpc-node -Chainstack's -APIs -HTTPS -KPIs -sign-through-web3auth -verify-through-web3auth -transfer-erc-20-token-through-web3auth -call-custom-contracts-through-web3auth \ No newline at end of file +xdai +XDai +YourGame +Zenject diff --git a/docs/v1/20_faq.md b/docs/v1/20_faq.md index ad9b5a2..b6cd790 100644 --- a/docs/v1/20_faq.md +++ b/docs/v1/20_faq.md @@ -19,7 +19,7 @@ Frequently asked questions about the ChainSafe gaming SDK. **Q:** I'm seeing the following error when I install the package. **The type or namespace name 'Newtonsoft' could not be found** -**A:** NewtonSoft is a dependency of the SDK and needs to be installed for the SDK to work. This can be found by going to window->package manager->pressing the + button on the top left, pressing add via git url and pasting in "com.unity.nuget.newtonsoft-json@3.0.1". +**A:** NewtonSoft is a dependency of the SDK and needs to be installed for the SDK to work. If you see a newtonsoft error you can manually install the package by going to window->package manager->pressing the + button on the top left, pressing add via git url and pasting in "com.unity.nuget.newtonsoft-json@3.0.1". **Q:** I'm getting the following error when trying to import an NFT texture into the SDK. **Curl error 1: Protocol "ipfs" not supported or disabled in libcurl** diff --git a/docs/v2.5/10_minting-nft.md b/docs/v2.5/10_minting-nft.md new file mode 100644 index 0000000..4453f58 --- /dev/null +++ b/docs/v2.5/10_minting-nft.md @@ -0,0 +1,80 @@ +--- +slug: /current/minting-nft +sidebar_position: 10 +sidebar_label: Minting NFT +--- + + +# Minting NFTs + +:::info + +This pages explains minting an NFT using ECDSA to authorize transactions with the SDK. + +::: +## Minting an NFT Via The Marketplace +NFTs can easily be minted via our marketplace [here](https://marketplace.chainsafe.io/) These NFTs follow ERC standards and be used with our all NFT calls without much hassle at all. Simply add your NFT details, an image and away you go! + +## Minting an NFT In Game Via ECDSA Verification +We've decided to move away from server voucher minting and replace it with ECDSA verification. This is a lot easier to setup and maintain as it's done solidity side and can be controlled solely by the developer for their users. For examples sake we've included an ERC20 private key to show you how it all works. Please do not use this in production. You can generate your own key [here](https://vanity-eth.tk/) to replace the example one. It is entirely up to you how you would like to secure this key, Please do not send an app into production without locking this down properly. As there are many ways to secure this we've decided to leave this up to you as any methods we offer would undoubtedly be reverse engineered. + +## What Is ECDSA? +ECDSA stands for elliptical curve digital signature algorithm. It is the process of reverse engineering a signature to check which wallet it originated from. This way you can place a private key within the game files and make it fire off a signature whenever you need something authorized. This can be anything from allowing a claim to minting NFTs, the possibilities are endless. More information can be found [here](https://cryptobook.nakov.com/digital-signatures/ecdsa-sign-verify-messages) + +## Using ECDSA With A Private Key In Unity +The sign with private key methods may be used here to generate a signature from your authorization wallet. This can then passed into a function and read solidity side as bytes. You may then use the functions below solidity side to reverse engineer the signature via ECDSA to check that it has actually originated from your authorization wallet. In the next step we'll show you how this can be checked solidity side. + +## Passing The signature Into A Transaction For Verification Purposes In A Solidity Contract +```solidity + // SPDX-License-Identifier: MIT + pragma solidity ^0.8.19; + import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; + import "@openzeppelin/contracts/utils/Strings.sol"; + + contract ExampleContract is ReentrancyGuard { + /// @dev Variables & mappings + authWallet = "Your auth wallet here"; + mapping(uint256 => address) public userWalletScores; + + /// @dev Example function for saving a score + function saveScore(uint _score, bytes memory _sig) external nonReentrant() returns (bool) { + bytes32 messageHash = getMessageHash(Strings.toString(_score)); + bytes32 ethSignedMessageHash = getEthSignedMessageHash(messageHash); + require(recover(ethSignedMessageHash, _sig) == authWallet, "Sig not made by auth"); + // Add score to wallet mapping + userWalletScores[_score] = msg.sender; + return true; + } + + /// @dev Used for ECDSA verification to check if values came from a specific address following solidity standards + function VerifySig(address _signer, string memory _message, bytes memory _sig) external pure returns (bool) { + bytes32 messageHash = getMessageHash(_message); + bytes32 ethSignedMessageHash = getEthSignedMessageHash(messageHash); + return recover(ethSignedMessageHash, _sig) == _signer; + } + + function getMessageHash(string memory _message) internal pure returns (bytes32) { + return keccak256(abi.encodePacked(_message)); + } + + function getEthSignedMessageHash(bytes32 _messageHash) internal pure returns (bytes32) { + return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32",_messageHash)); + } + + function recover(bytes32 _ethSignedMessageHash, bytes memory _sig) internal pure returns (address) { + (bytes32 r, bytes32 s, uint8 v) = _split(_sig); + return ecrecover(_ethSignedMessageHash, v, r, s); + } + + function _split (bytes memory _sig) internal pure returns (bytes32 r, bytes32 s, uint8 v) { + require(_sig.length == 65, "Invalid signature length"); + assembly { + r := mload(add(_sig, 32)) + s := mload(add(_sig, 64)) + v := byte(0, mload(add(_sig, 96))) + } + } + } +``` + +Adding the above require function with the methods below it will enable a function to check the origin of a signature. If the origin matches your defined address in the require step, the call will pass, If not it will fail. This adds a much needed layer of security to sensitive transactions. diff --git a/docs/v2.5/11_interacting-with-smart-contracts.md b/docs/v2.5/11_interacting-with-smart-contracts.md new file mode 100644 index 0000000..faa14ef --- /dev/null +++ b/docs/v2.5/11_interacting-with-smart-contracts.md @@ -0,0 +1,104 @@ +--- +slug: /current/interacting-with-smart-contracts +sidebar_position: 11 +sidebar_label: Interacting With Smart Contracts +--- + + +# Interacting with Smart Contracts + +:::info + +This page explains smart contract interactions within the SDK. + +::: + +Smart contracts in Ethereum are like digital agreements that run on the blockchain. +They are computer programs that automatically execute and enforce predefined actions +and rules when certain conditions are fulfilled. Imagine a vending machine: you put +in money, select a product, and it delivers the item without needing a human in between. Similarly, +in Ethereum's smart contracts, you input cryptocurrency, trigger a specific action, and the contract +autonomously carries out the agreed-upon task, like transferring ownership of a digital asset or +distributing funds. This eliminates the need for intermediaries and ensures transparent, +tamper-proof, and reliable execution of agreements. + +Each smart contract has it's own ABI (Application Binary Interface). You can get the ABI +from sources like contract compilation, blockchain explorers like Etherscan, DApp development +libraries, or third-party tools. It helps you understand how to communicate with the contract +on the blockchain. + +### Creating a Smart Contract Instance + +To interact with a smart contract you first have to create an instance of one on your side. +This is done by calling the `Build(string abi, string contractAddress)` method of `ContractBuilder`: + +TODO: Add using statements after fix-namespaces branch is merged +```csharp +var abi = "%YOUR_ABI_IN_JSON_FORMAT%"; +var address = "0x1d6f31b71e12a1a584ca20853495161c48ba491f"; +var contract = web3.ContractBuilder.Build(abi, address); +``` + +You can also preregister a contract during the initialization phase of your game: + +```csharp +var web3 = await new Web3Builder(ProjectConfigUtilities.Load()) + .Configure(services => + { + // ... + services.ConfigureRegisteredContracts(contracts => + { + var abi = "%YOUR_ABI_IN_JSON_FORMAT%"; + var address = "0x1d6f31b71e12a1a584ca20853495161c48ba491f"; + contracts.RegisterContract("shiba", abi, address); + }); + }) + .BuildAsync(); +``` + +Now you can simply create a new instance of the contract using the contract name: + +```csharp +var contract = web3.ContractBuilder.Build("shiba"); +``` + +### Invoking Smart Contract Methods + +After acquiring your Smart Contract instance, you're free to invoke any of its methods. + +These method calls can be categorized into two types - read and write: +- Read method call is an interaction with a smart contract that retrieves information from the blockchain without making any changes to the contract's state. +- Write method call is an interaction with a smart contract that alters the blockchain's state by executing a function that can modify the contract's data or trigger other actions. + +To execute a read method call use `Call` method of your smart contract instance: + +```csharp +object[] response = await contract.Call("getRank", new object[] { accountAddress }); +BigInteger rank = BigInteger.Parse(response[0].ToString()); +``` + +Write calls alter the blockchain's state, meaning player have to provide gas in ETH to execute such call. +You can set any amount for the gas, but you can also estimate the required gas fee amount using +the `EstimateGas` method: + +```csharp +var gasLimit = await contract.EstimateGas("add", new object[] { 1 }); +``` + +To actually call write method you can use `Send` method of `Contract`: + +```csharp +object[] response = await contract.Send("add", new object[] { 1 }); +BigInteger total = BigInteger.Parse(response[0].ToString()); +``` + +You can set gas limit (as well as any other transaction option) by creating a prototype +transaction request. Fill only those properties that you wish to override and the contract will +set all the info that's left: + +TODO: make sure I should use GasLimit property of TransactionRequest here +```csharp +var gasLimitHex = await contract.EstimateGas("add", new object[] { 1 }); +var transactionRequest = new TransactionRequest { GasLimit = gasLimitHex }; +await contract.Send("add", new object[] { 1 }, transactionRequest); +``` \ No newline at end of file diff --git a/docs/v2/12_web3auth.md b/docs/v2.5/12_web2-like-authentication-using-web3auth.md similarity index 94% rename from docs/v2/12_web3auth.md rename to docs/v2.5/12_web2-like-authentication-using-web3auth.md index 53d6271..fdd8a55 100644 --- a/docs/v2/12_web3auth.md +++ b/docs/v2.5/12_web2-like-authentication-using-web3auth.md @@ -1,9 +1,10 @@ ---- -slug: /current/web3auth +--- +slug: /current/web2-like-authentication-using-web3auth sidebar_position: 12 -sidebar_label: Web3Auth Builds +sidebar_label: Web2-Like Authentication Using Web3Auth --- + # Web3Auth Builds :::info @@ -12,13 +13,17 @@ The Web3Auth build option allows game developers to build Unity games that run o ::: -### Building To Web3Auth ### +## Building To Web3Auth Web3Auth builds will work alongside both Web3Wallet and WebGL scripts/prefabs. You may select either platform provided any other scripts you're using match the build platform. Check out our amazing fully functional in game wallet below! -![]() +![](v2Assets/Web3Auth-Wallet.png) + +# Web3Auth Wallet Coming Soon -### Sign Web3Auth {#sign-through-web3auth} +The code below refers to a work in progress which will be ready for release shortly. + +## Sign Web3Auth {#sign-through-web3auth} Generates a cryptographic signature for a given string or message via Web3Auth. @@ -61,7 +66,7 @@ public class SignW3A : MonoBehaviour } ``` -### Verify Web3Auth {#verify-through-web3auth} +## Verify Web3Auth {#verify-through-web3auth} Verify a signed message via Web3Auth. @@ -121,7 +126,7 @@ public class VerifyW3A : MonoBehaviour } ``` -### Transfer ERC-20 Token Through Web3Auth {#transfer-erc-20-token-through-web3auth} +## Transfer ERC-20 Token Through Web3Auth {#transfer-erc-20-token-through-web3auth} Send an ERC-20 token transfer through Unity via Web3Auth. @@ -214,11 +219,11 @@ public class TransferW3A: MonoBehaviour } ``` -### Call Custom Contracts Web3Auth {#call-custom-contracts-through-web3auth} +## Call Custom Contracts Web3Auth {#call-custom-contracts-through-web3auth} Call will execute a smart contract method without altering the smart contract state via Web3Auth. -### Solidity Contract Example +## Solidity Contract Example This code snippet defines a simple smart contract example where the `myTotal` variable (initialized at 0) is added to (by the input value `_myArg`) and updated to a new total. @@ -235,7 +240,7 @@ contract AddTotal { } ``` -### Reading & Writing A Value From A Solidity Contract Web3Auth +## Reading & Writing A Value From A Solidity Contract Web3Auth Retrieves the value of a specified variable (`myTotal`) from a smart contract. @@ -329,3 +334,5 @@ public class ContractCallSignW3A : MonoBehaviour } } ``` + +We hope you enjoy social logins as it offers a unique way to onboard users to the blockchain without actually requiring a wallet. \ No newline at end of file diff --git a/docs/v2.5/13_gasless-transactions-using-gelato.md b/docs/v2.5/13_gasless-transactions-using-gelato.md new file mode 100644 index 0000000..0bf1268 --- /dev/null +++ b/docs/v2.5/13_gasless-transactions-using-gelato.md @@ -0,0 +1,209 @@ +--- +slug: /current/gasless-transactions-using-Gelato +sidebar_position: 13 +sidebar_label: Gasless Transactions Using Gelato +--- + + +# Gasless Transactions Using The SDK + +:::info + +This area will explain basic interactions for using Gelato and gasless transactions with the SDK. + +::: + +We've now integrated Gelato gasless transactions into the SDK to help reduce friction that some users any face when entering the blockchain world. You simply need a Gelato API key which can be obtained [here](https://relay.Gelato.network/) We have an example API key for testing purposes but this shouldn't be used in a production app. Please ensure that you're replacing this with your own key before going to production. + +## Logging In With Gelato +In order to make use of our Gelato functions you need to ensure the chain has Gelato capability enabled. You can check this by logging into our sample scene. If the Gelato functions are there then you're good to go, if not you will need to wait for Gelato to update on their end in order to provide functionality for your chain. Our SDKs sample scene provides a variety of Gelato functions for you to test out. + +![](v2Assets/GelatoGasless.png) + +## Call With Sync Fee +Once logged in you can scroll to the Gelato area in the cool new scrollable canvas that we've created for example purposes. Here you find our Gelato functions, the first being Call with sync fee. + +```csharp +public async Task CallWithSyncFee() + { + const string vitalik = "0xd8da6bf26964af9d7eed9e03e53415d37aa96045"; + const string target = "0xA045eb75e78f4988d42c3cd201365bDD5D76D406"; + const string feeToken = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; + const string abi = "[{\"inputs\": [" + + "{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"}," + + "{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"}," + + "{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}" + + "]," + + "\"name\":\"sendToFriend\"," + + "\"outputs\":[]," + + "\"stateMutability\":\"nonpayable\"," + + "\"type\":\"function\"" + + "}]"; + var contract = _web3.ContractBuilder.Build(abi, target); + var data = contract.Calldata("sendToFriend", new object[] + { + feeToken, + vitalik, + new BigInteger(5 * 10E12), + }); + + var relayResponse = await _web3.Gelato().CallWithSyncFee(new CallWithSyncFeeRequest() + { + Data = data, + FeeToken = feeToken, + IsRelayContext = true, + Target = target, + }); + + while (true) + { + var status = await _web3.Gelato().GetTaskStatus(relayResponse.TaskId); + + switch (status.TaskState) + { + case TaskState.ExecSuccess: + case TaskState.ExecReverted: + case TaskState.Cancelled: + return new TaskResult(relayResponse.TaskId, status); + default: + await WaitForSeconds(2); + continue; + } + } + } +``` + +## Sponsor Call +The second function you will find is Sponsor call. + +```csharp +public async Task SponsorCall() + { + const string counterContract = "0x763D37aB388C5cdd2Fb0849d6275802F959fbF30"; + + const string abi = "[{\"inputs\": []," + + "\"name\":\"increment\"," + + "\"outputs\":[]," + + "\"stateMutability\":\"nonpayable\"," + + "\"type\":\"function\"" + + "}]"; + var contract = _web3.ContractBuilder.Build(abi, counterContract); + + var data = contract.Calldata("increment"); + + var relayResponse = await _web3.Gelato().SponsoredCall(new SponsoredCallRequest() + { + Target = counterContract, + Data = data, + }); + + while (true) + { + var status = await _web3.Gelato().GetTaskStatus(relayResponse.TaskId); + + switch (status.TaskState) + { + case TaskState.ExecSuccess: + case TaskState.ExecReverted: + case TaskState.Cancelled: + return new TaskResult(relayResponse.TaskId, status); + default: + await WaitForSeconds(2); + continue; + } + } + } +``` + +## Call With Sync Fee Erc2771 +The third function you will find is Call with sync fee Erc2771. + +```csharp +public async Task CallWithSyncFeeErc2771() + { + const string target = "0x5dD1100f23278e0e27972eacb4F1B81D97D071B7"; + const string feeToken = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"; + const string abi = "[{\"inputs\": []," + + "\"name\":\"increment\"," + + "\"outputs\":[]," + + "\"stateMutability\":\"nonpayable\"," + + "\"type\":\"function\"" + + "}]"; + var contract = _web3.ContractBuilder.Build(abi, target); + + var data = contract.Calldata("increment", new object[] + { + }); + + var relayResponse = await _web3.Gelato().CallWithSyncFeeErc2771(new CallWithSyncFeeErc2771Request() + { + Target = target, + Data = data, + FeeToken = feeToken, + IsRelayContext = true, + }); + + while (true) + { + var status = await _web3.Gelato().GetTaskStatus(relayResponse.TaskId); + + switch (status.TaskState) + { + case TaskState.ExecSuccess: + case TaskState.ExecReverted: + case TaskState.Cancelled: + return new TaskResult(relayResponse.TaskId, status); + default: + await WaitForSeconds(2); + continue; + } + } + } +``` + +## Sponsor Call Erc2771 +The last function you will find in the example area is Sponsor call Erc2771. + +```csharp +public async Task SponsorCallErc2771() + { + const string target = "0x00172f67db60E5fA346e599cdE675f0ca213b47b"; + + const string abi = "[{\"inputs\": []," + + "\"name\":\"increment\"," + + "\"outputs\":[]," + + "\"stateMutability\":\"nonpayable\"," + + "\"type\":\"function\"" + + "}]"; + + var contract = _web3.ContractBuilder.Build(abi, target); + + var data = contract.Calldata("increment"); + + var relayResponse = await _web3.Gelato().SponsoredCallErc2771(new SponsoredCallErc2771Request() + { + Target = target, + Data = data, + User = await _web3.Signer.GetAddress(), + }); + + while (true) + { + var status = await _web3.Gelato().GetTaskStatus(relayResponse.TaskId); + + switch (status.TaskState) + { + case TaskState.ExecSuccess: + case TaskState.ExecReverted: + case TaskState.Cancelled: + return new TaskResult(relayResponse.TaskId, status); + default: + await WaitForSeconds(2); + continue; + } + } + } +``` + +## A Frictionless Experience For Users +These functions will allow a developer to grant access to games without the user needing to have gas funds. This will overall provide a frictionless experience for users that are either new to the crypto space. It also opens up gameplay for other countries who may not be able to pay for gas themselves. \ No newline at end of file diff --git a/docs/v2.5/14_extending-the-sdk.md b/docs/v2.5/14_extending-the-sdk.md new file mode 100644 index 0000000..7f7e095 --- /dev/null +++ b/docs/v2.5/14_extending-the-sdk.md @@ -0,0 +1,239 @@ +--- +slug: /current/extending-the-sdk +sidebar_position: 14 +sidebar_label: Extending The SDK +--- + + +# Extending the SDK + +:::info + +This area will explain how we've made use of Dependency Injections as well as how the SDK may be extended. + +::: + +This SDK was designed to be extendable. This was achieved by utilizing the Dependency Injection framework. +There are different implementations of DI frameworks that you can use in Unity, Zenject being +the most popular one. However as this SDK aims to be cross-engine Microsoft's DI framework was chosen +as the one that can run in any CLR environment. You can read more about Microsoft's DI framework [using this link](https://learn.microsoft.com/en-us/dotnet/core/extensions/dependency-injection#multiple-constructor-discovery-rules). + +As any DI framework it works with contract-implementation pairs. So, when you request the RpcProvider +with `web3.RpcProvider`, the SDK looks for the implementation of `IRpcProvider` +(`JsonRpcProvider` being one of them) that's been registered with the `IRpcProvider` contract type. +If it indeed was registered, then an instance of implementation type is returned. + +### Adding a New Implementation for the Existing Slot + +There are a number of default slots like: IRpcProvider, ISigner, ITransactionExecutor, etc. +And you can bind your custom implementation to any of those. Let's add a fake XML implementation +for the IRpcProvider: + +```csharp +public class MyXmlRpcProvider : IRpcProvider +{ + // ... +} +``` + +To actually bind our implementation to a Web3 instance we should also add an extension method +for `IWeb3ServiceCollection`: + +```csharp +using Microsoft.Extensions.DependencyInjection + +public static class MyXMLRpcProviderExtensions +{ + public static IWeb3ServiceCollection UseMyXmlProvider(this IWeb3ServiceCollection services) + { + services.AddSingleton(); + return services; + } +} +``` + +It is also a good idea to check whether the slot that you're binding to was not yet occupied. +If it's already occupied, your new contract-implementation will be ignored when resolving the component. +You can check if the slot is not bound using `AssertServiceNotBound()` extension method like so: + +```csharp +public static void UseMyXmlProvider(this IWeb3ServiceCollection services) +{ + services.AssertServiceNotBound(); + services.AddSingleton(); +} +``` + +As we've created a method that adds `` contract-implementation pair +to the list of registered services, lets actually call this method from within `Web3Builder.Configure()`: + +```csharp +var web3 = await new Web3Builder(ProjectConfigUtilities.Load()) + .Configure(services => + { + services.UseMyXmlProvider(); + }) + .BuildAsync(); +``` + +Now when you request `Web3.RpcProvider` your new and shiny `IRpcProvider` implementation is returned. +More so, each component that depends on `IRpcProvider` will use an instance of your newly created implementation. + +### Service Configuration + +You might want to make your new service configurable during Web3 build time, like so: + +```csharp +var web3 = await new Web3Builder(ProjectConfigUtilities.Load()) + .Configure(services => + { + services.UseJsonRpcProvider(new JsonRpcProviderConfig + { RpcNodeUrl = "letsplayvideogamesallday.org/json-rpc" } + ); + }) + .BuildAsync(); +``` + +Basically, you just have to create a new class for the configuration data and add a dependency +of our newly created type to your service: + +```csharp +public class MyXmlRpcProviderConfig +{ + public string CustomRpcNodeUrl { get; set; } +} + +public class MyXmlRpcProvider : IRpcProvider +{ + private MyXmlRpcProviderConfig config; + + public MyXmlRpcProvider(MyXmlRpcProviderConfig config) + { + this.config = config; + } + + // ... +} +``` + +You'd also want to create two new extension methods to keep your Web3 build process +clean and easy to use: + +```csharp +public static class MyXMLRpcProviderExtensions +{ + public static readonly MyXmlRpcProviderConfig DefaultConfig = new(); + + public static IWeb3ServiceCollection UseMyXmlProvider(this IWeb3ServiceCollection services, MyXmlRpcProviderConfig config) + { + ConfigureMyXmlProvider(services, config); + UseMyXmlProvider(services); + return services; + } + + public static IWeb3ServiceCollection ConfigureMyXmlProvider(this IWeb3ServiceCollection services, MyXmlRpcProviderConfig config) + { + services.Replace(ServiceDescriptor.Singleton(config)); + return services; + } + + public static IWeb3ServiceCollection UseMyXmlProvider(this IWeb3ServiceCollection services) + { + services.AssertServiceNotBound(); + + services.TryAddSingleton(DefaultConfig); + services.AddSingleton(); + return services; + } +} +``` + +### Creating Brand New Service Slots + +You can also add completely new contract types (slots) to your Web3 client. +The process is very similar to adding new implementation to the existing slot, but you also +have to create an interface for the new contract type and a getter extension method. + +Let's create the interface and one implementation: + +```csharp +public interface ITrueRandom +{ + int GetRandomValue(); +} + +public class NotReallyTrueRandom : ITrueRandom +{ + public int GetRandomValue() => new Random().Next(); +} +``` + +Now let's create an extension method to bind `NotReallyTrueRandom` to `ITrueRandom` slot +in our Web3 instance: + +```csharp +public static class TrueRandomExtensions +{ + public static IWeb3ServiceCollection UseNotReallyTrueRandom(this IWeb3ServiceCollection services) + { + services.AssertServiceNotBound(); + services.AddSingleton(); + return services; + } +} +``` + +We'd also need a getter method for our new custom slot. It can be added to `TrueRandomExtensions` +as another extension method: + +```csharp +public static class TrueRandomExtensions +{ + public static ITrueRandom TrueRandom(this Web3 web3) => web3.ServiceProvider.GetRequiredService(); + + // ... +} +``` + +To use your `TrueRandom` component, you'd first have to bind it using `UseNotReallyTrueRandom` and +then simply access it using the `TrueRandom` method like so: + +```csharp +var web3 = await new Web3Builder(ProjectConfigUtilities.Load()) + .Configure(services => + { + services.UseNotReallyTrueRandom(); + }) + .BuildAsync(); + +var myRandomValue = web3.TrueRandom().GetRandomValue(); +``` + +It is of course accessible by any component created using the DI system: + +```csharp +public class RandomApplier +{ + private IRpcProvider rpcProvider; + private ITrueRandom random; + + public RandomApplier( + IRpcProvider rpcProvider, + ITrueRandom random // instance of NotReallyTrueRandom + ) + { + this.random = random; + this.rpcProvider = rpcProvider; + } + + // ... +} +``` + +### Creating Your Own UPM Package + +This modular approach allows you to create your own UPM (Unity Package Manager) packages that +extend ChainSafe Gaming SDK. Just put your new services in a separate package and add a +reference to `io.chainsafe.web3-unity` in your manifest file. + +To learn more on how to create a new UPM package [visit this page](https://docs.unity3d.com/Manual/CustomPackages.html). \ No newline at end of file diff --git a/docs/v2.5/15_lootboxes.md b/docs/v2.5/15_lootboxes.md new file mode 100644 index 0000000..e569e51 --- /dev/null +++ b/docs/v2.5/15_lootboxes.md @@ -0,0 +1,286 @@ +--- +slug: /current/lootboxes +sidebar_position: 15 +sidebar_label: Lootboxes +--- + + +# LootBoxes + +:::info + +This page will walk you through our newest feature, lootboxes. It's a nifty little way to offer in game sales of items with a sense of randomness. + +::: + +Lootboxes are a great way to offer your users NFTs, tokens & variety of other things in a gamified way. Many things from cosmetics to in game items can be offered with a sense of randomness to help facilitate anticipation and hopefully a fun way to bring developers some much needed revenue. + +## Solidity Contracts +The repo for the lootbox contracts can be found [here](https://github.com/ChainSafe/vrf-lootbox-contracts) + +![](v2Assets/RepoLootbox.png) + +## Explaining The Lootbox Dashboard +There is a great video [here](https://www.loom.com/share/e06bd85195f546db9d8311b7654257f0?sid=8b8b9fbb-6bbb-4c2a-bf1f-909f07c64896) Explaining how lootbox functionality works via our marketplace. + +## Addons Area +This addons area will be used to grant you access to all of our new features as we implements them. Upon entering you'll see an option to connect a wallet. You'll then be displayed with any lootbox you already have and presented with the option to create a new one. + +![](v2Assets/AddonsLootBox.png) + +## Deploying a new Lootbox +New lootboxes can be deployed by press the green deploy button on the top right of the dashboard in the addons area. This will give you a brief explanation on what lootboxes are as well as the requirements needed to use them. + +![](v2Assets/DeployLootbox.png) + +## Adding Token Contracts To Your Lootbox +Token contracts for use within your lootboxes may be added here, you can see more of they function in the lootbox rewards area below. + +![](v2Assets/AddTokenContractsLootbox.png) + +## Granting Depositor Access To Your Lootbox +These addresses can be nominated as suppliers for your lootbox content. + +![](v2Assets/GrantDepositorAccessLootbox.png) + +## Sending Loot To A Contract +This area can be used to send loot to a contract. + +![](v2Assets/SendLootToContractLootbox.png) + +## Updating Your Lootbox Rewards +Here you can update all of the various reward amounts that your lootboxes contain as well as any remaining balances from your suppliers. + +![](v2Assets/UpdateRewardUnitsLootbox.png) + +## Minting & Transferring +Here you can send some lootboxes with reward amounts out to your friends as they are created. + +![](v2Assets/MintAndTransferLootbox.png) + +## Review Summary +This section contains a summary of everything inside your lootboxes. + +![](v2Assets/ReviewSummaryLootbox.png) + +# Lootbox Functions Within The SDK + +## Get Loot box Types +This method returns all lootbox type ids registered in the smart-contract. Lootbox type id also represents the number of rewards, that can be claimed by user when he opens the lootbox. + +```csharp + public async Task> GetLootboxTypes() + { + var response = await contract.Call("getLootboxTypes"); + var bigIntTypes = (List)response[0]; + + if (bigIntTypes.Any(v => v > int.MaxValue)) + { + throw new Web3Exception( + "Internal Error. Lootbox type is greater than int.MaxValue."); + } + + var types = bigIntTypes.Select(bigInt => (uint)bigInt).ToList(); + + return types; + } +``` + +## Balance Of +This method returns the balance of lootboxes by type or specific user. Similar to how some games work, this may be used to display lootboxes in an inventory. + +```csharp + public async Task BalanceOf(uint lootboxType) + { + if (signer is null) + { + throw new Web3Exception($"No {nameof(ISigner)} was registered. Can't get current user's address."); + } + + var playerAddress = await signer.GetAddress(); + + return await BalanceOf(playerAddress, lootboxType); + } + + public async Task BalanceOf(string account, uint lootboxType) + { + var response = await contract.Call( + "balanceOf", + new object[] { account, lootboxType }); + var bigIntBalance = (BigInteger)response[0]; + + if (bigIntBalance > int.MaxValue) + { + throw new Web3Exception( + "Internal Error. Balance is greater than int.MaxValue."); + } + + var balance = (uint)bigIntBalance; + + return balance; + } +``` + +## Calculate Open Price +Calculates open price for the player. This can be used to display the total cost a user would need to pay for opening X amount of lootboxes. + +```csharp + public async Task CalculateOpenPrice(uint lootboxType, uint lootboxCount) + { + var rewardCount = lootboxType * lootboxCount; + var rawGasPrice = (await rpcProvider.GetGasPrice()).AssertNotNull("gasPrice").Value; + var safeGasPrice = rawGasPrice + BigInteger.Divide(rawGasPrice, new BigInteger(10)); // 110% + + var response = await contract.Call( + "calculateOpenPrice", + new object[] { 50000 + GasPerUnit * rewardCount, safeGasPrice, rewardCount, }); + var openPrice = (BigInteger)response[0]; + + return openPrice; + } +``` + +## Can Claim Rewards +This method checks if a user can claim their lootbox rewards. It's a great little security check you can run before claiming. + +```csharp + public async Task CanClaimRewards(string account) + { + var response = await contract.Call( + "canClaimRewards", + new object[] { account }); + var canClaimRewards = (bool)response[0]; + + return canClaimRewards; + } +``` + +## Claim Rewards +This method allows a user to claim their lootbox rewards. This can be placed after the call for payment. + +```csharp + public async Task ClaimRewards(string account) + { + var (_, receipt) = await contract.SendWithReceipt("claimRewards", new object[] { account }); + var logs = receipt.Logs.Select(jToken => JsonConvert.DeserializeObject(jToken.ToString())); + var eventAbi = EventExtensions.GetEventABI(); + var eventLogs = logs + .Select(log => eventAbi.DecodeEvent(log)) + .Where(l => l != null); + + if (!eventLogs.Any()) + { + throw new Web3Exception("No \"RewardsClaimed\" events were found in log's receipt."); + } + + return ExtractRewards(eventLogs); + + LootboxRewards ExtractRewards(IEnumerable> eventLogs) + { + var rewards = LootboxRewards.Empty; + + foreach (var eventLog in eventLogs) + { + var eventData = eventLog.Event; + var rewardType = rewardTypeByTokenAddress[eventData.TokenAddress]; + + switch (rewardType) + { + // Erc20 Tokens + case RewardType.Erc20: + rewards.Erc20Rewards.Add(new Erc20Reward + { + ContractAddress = eventData.TokenAddress, + AmountRaw = eventData.Amount, + }); + break; + // Erc721 NFTs + case RewardType.Erc721: + rewards.Erc721Rewards.Add(new Erc721Reward + { + ContractAddress = eventData.TokenAddress, + TokenId = eventData.TokenId, + }); + break; + // Erc1155 NFTs + case RewardType.Erc1155: + rewards.Erc1155Rewards.Add(new Erc1155Reward + { + ContractAddress = eventData.TokenAddress, + TokenId = eventData.TokenId, + Amount = eventData.Amount, + }); + break; + // Single Erc1155 NFT + case RewardType.Erc1155Nft: + rewards.Erc1155NftRewards.Add(new Erc1155NftReward + { + ContractAddress = eventData.TokenAddress, + TokenId = eventData.TokenId, + }); + break; + case RewardType.Unset: + default: + throw new ArgumentOutOfRangeException(); + } + } + + return rewards; + } + } +``` + +## Open Lootbox +This method allows a user to open a lootbox. This should be called last after all of the payment steps have been completed. + +```csharp + public async Task OpenLootbox(uint lootboxType, uint lootboxCount = 1) + { + var rewardCount = lootboxType * lootboxCount; + var openPrice = await CalculateOpenPrice(lootboxCount, lootboxCount); + + await contract.Send( + "open", + new object[] { 50000 + GasPerUnit * rewardCount, new[] { lootboxType }, new[] { lootboxCount } }, + new TransactionRequest { Value = new HexBigInteger(openPrice) }); + } +``` + +## Lootbox Example Scene +We have an example scene setup if you want to check it out. It goes through different lootbox rarities and allows you to see what happens during the lootbox process. This will be converted to an addon for modularization purposes and a prefab for ease of use. For now you can check the example scene by cloning the lootboxes branch of the SDK and opening up Assets/Lootboxes/LootBoxes.scene. + +![](v2Assets/LootBoxesScene.png) + +# Setting Up A Local Node For Testing With The Example Scene +Once you've cloned the contracts repo, go ahead and run ```npm run node``` to boot up a local chain. + +![](v2Assets/LootBoxesRunNode.png) + +After this node is active you can open up another terminal and run ```npm run hardhat -- devsetup``` to initialize everything. + +![](v2Assets/LootBoxesNpmInitialize.png) + +If you check the node window you can see everything that's happening during this process. Once complete, hit play within unity on the lootbox example scene and you'll be presented with a nice display area to test out. Here you can check different rarity levels of each lootbox and what they may contain as well as some great animations to go along with it. + +## Opening LootBoxes & Rarity +Now in Unity you can click play and interact with the lootboxes. +You can switch between different lootboxes using the keys "A" and "D" and switch between rarity using "A" and "S" + +Once you find your box, select it by pressing "space" key and open it by pressing "enter" key. +You need to wait a little bit on the Unity scene so the transaction goes through + +![](v2Assets/OpeningLootBoxes.png) + +Next, in the terminal, run ```npm run hardhat -- fulfill``` to manually open the lootboxes. + +![](v2Assets/LootBoxesNpmFulfill.png) + +Go back to Unity and the lootboxes will be ready to open + +![](v2Assets/ClaimRewardsLootBoxes.png) + +Click on the lootbox and you will receive the rewards! + +![](v2Assets/RewardsLootBoxes.png) + +We hope you enjoy bringing our new feature to life! We've found it's a great way to easily offer virtual items to any and all users with a gamified feel. \ No newline at end of file diff --git a/docs/v2.5/16_block-racers-game.md b/docs/v2.5/16_block-racers-game.md new file mode 100644 index 0000000..9912f4c --- /dev/null +++ b/docs/v2.5/16_block-racers-game.md @@ -0,0 +1,141 @@ +--- +slug: /current/block-racers-game +sidebar_position: 16 +sidebar_label: Block Racers Game +--- + + +# Block Racers Example Game + +:::info + +This game was built to show you how our SDK would function in a game environment. Please feel free to use the code as you wish, please don't take any of the assets as they are here entirely for educational purposes and should not be reused for financial gain. + +::: + +The repo contains a fun multiplayer racing game which was build to help explain the functionality of the SDK complete with code examples. + +## Block Racers Project Files +The repo for the Block Racers project files can be found [here](https://github.com/ChainSafe/BlockRacers/) + +## Block Racers Playable Demo +The Block Racers game demo can be found [here](https://chainsafe.github.io/BlockRacersGame/) + +## Booting Up The Game & Connecting Your Wallet +Once the game has booted up, simply connect your wallet and have a look around through the menus. + +![](v2Assets/BlockRacers1.png) +![](v2Assets/BlockRacers18.png) + +## Tutorial Examples +There is a tutorial area which will take you through some of the SDKs basic functions, drive up to one of the floating texts to bring up an example menu. + +![](v2Assets/BlockRacers2.png) + +## Signing +This will generate a unique signature from a user that you may use for authorization purposes. + +![](v2Assets/BlockRacers3.png) + +```csharp +// Csharp here +``` + +## Verify +This will verify a signature from a wallet to prove its owners address. + +![](v2Assets/BlockRacers4.png) + +```csharp +// Csharp here +``` + +## Mint +This can be used to mint ERC20 Race tokens or even native tokens via the faucet to pay for things within game. + +![](v2Assets/BlockRacers5.png) + +```csharp +// Csharp here +``` + +## Transfer +This will allow you to transfer ERC20 Race tokens between wallets. + +![](v2Assets/BlockRacers6.png) + +```csharp +// Csharp here +``` + +## Custom Call +This will allow you to make a custom call, we've included 2 examples here. 1 being read which checks a contracts state variable and another being write which adds to the sate variable of a contract. You may read it again after to see changes. + +![](v2Assets/BlockRacers7.png) + +```csharp +// Csharp here +``` + +## Docs +Clicking this button will take you to ChainSafe's documentation [here](https://docs.gaming.chainsafe.io/) + +![](v2Assets/BlockRacers8.png) + +```csharp +// Csharp here +``` + +## Voucher +This will generate a unique voucher via ECDSA which can be used for things like claims & minting. + +![](v2Assets/BlockRacers9.png) + +```csharp +// Csharp here +``` + +## Dashboard +Clicking this button will take you to the chainsafe dashboard when you can do things like signing up for a project ID and set various other project information. + +![](v2Assets/BlockRacers10.png) + +```csharp +// Csharp here +``` + +## Pause & Controls +Pressing tab will bring up the pause menu allowing you to either go back to the main menu, select fullscreen or even view the games controls. We have both keyboard and gamepad inputs available. + +![](v2Assets/BlockRacers11.png) +![](v2Assets/BlockRacers12.png) + +## The Garage +The garage will let you change cars which are actually NFTs which is pretty cool. + +![](v2Assets/BlockRacers13.png) + +## Choosing Your Car +By pressing change car you'll be presented with options to change your model, colour, stats and even the NFT displayed on the back of your car. + +![](v2Assets/BlockRacers14.png) +## Upgrades +In the upgrade area of the garage you may use tokens to upgrade things like your engine, handling and nos levels as the NFTs are also dynamic. + +![](v2Assets/BlockRacers15.png) + +## All NFT Call +To show off our new all NFT call, we're giving you the ability to call any NFT you own and display it as your cars back window too. + +![](v2Assets/BlockRacers16.png) + +## Marketplace +This are will show off our marketplace functionality. + +![](v2Assets/BlockRacers17.png) + +## Ready, Set, Race! +Once you're set and happy with your car feel free to enter the race area, set your region for a lag free experience and search for a multiplayer match! + +![](v2Assets/BlockRacers19.png) +![](v2Assets/BlockRacers20.png) \ No newline at end of file diff --git a/docs/v2.5/17_example-scene.md b/docs/v2.5/17_example-scene.md new file mode 100644 index 0000000..2f37910 --- /dev/null +++ b/docs/v2.5/17_example-scene.md @@ -0,0 +1,87 @@ +--- +slug: /current/example-scene +sidebar_position: 17 +sidebar_label: Example Scene +--- + + +# Example Scene + +:::info + +This example scene was built to show off working functions for your reference. + +::: + +By going to the login screen in web3unity/scenes/ you can see the SDK's functions with working examples. + +## Connecting To A Wallet +In the login scene you'll be presented with a few different login options. You may choose either Web3Auth options, gelato, standard wallet connections or wallet connect if you're on WebGL. + +## Web3Auth Functionality +Most functions will work with Web3Auth. If your chain is supported by Gelato and you have an API key you may use them as well. + +## Gelato Functionality +If you have an API key present with some native tokens set you'll be able to call the Gelato functions. + +![](v2Assets/BlockRacers1.png) +![](v2Assets/BlockRacers18.png) + +## Scene Layout +Continuing on, there are a bunch of standard functions which we'll go through below. + +![](v2Assets/BlockRacers2.png) + +## Signing +This will generate a unique signature from a user that you may use for authorization purposes. + +![](v2Assets/BlockRacers3.png) + +```csharp +// Csharp here +``` + +## Verify +This will verify a signature from a wallet to prove its owners address. + +![](v2Assets/BlockRacers4.png) + +```csharp +// Csharp here +``` + +## Mint +This can be used to mint ERC20 Race tokens or even native tokens via the faucet to pay for things within game. + +![](v2Assets/BlockRacers5.png) + +```csharp +// Csharp here +``` + +## Transfer +This will allow you to transfer ERC20 Race tokens between wallets. + +![](v2Assets/BlockRacers6.png) + +```csharp +// Csharp here +``` + +## Custom Call +This will allow you to make a custom call, we've included 2 examples here. 1 being read which checks a contracts state variable and another being write which adds to the sate variable of a contract. You may read it again after to see changes. + +![](v2Assets/BlockRacers7.png) + +```csharp +// Csharp here +``` + +## Docs +Clicking this button will take you to ChainSafe's documentation [here](https://docs.gaming.chainsafe.io/) + +![](v2Assets/BlockRacers8.png) + +```csharp +// Csharp here +``` \ No newline at end of file diff --git a/docs/v2/18_faq.md b/docs/v2.5/18_faq.md similarity index 97% rename from docs/v2/18_faq.md rename to docs/v2.5/18_faq.md index 1bc6522..20b1817 100644 --- a/docs/v2/18_faq.md +++ b/docs/v2.5/18_faq.md @@ -1,5 +1,5 @@ --- -slug: /current/faq +slug: /2.5.0/faq sidebar_position: 18 sidebar_label: FAQ --- @@ -129,7 +129,7 @@ Yes, the SDK will remain free to use. ### I'm seeing the following error when I install the package. `The type or namespace name 'Newtonsoft' could not be found` -NewtonSoft is a dependency of the SDK and needs to be installed for the SDK to work. This can be found by going to window->package manager->pressing the + button on the top left, pressing add via git url and pasting in "com.unity.nuget.newtonsoft-json@3.0.1". +NewtonSoft is a dependency of the SDK and needs to be installed for the SDK to work. If you see a newtonsoft error you can manually install the package by going to window->package manager->pressing the + button on the top left, pressing add via git url and pasting in "com.unity.nuget.newtonsoft-json@3.0.1". ### I'm getting the following error when trying to import an NFT texture into the SDK. `Curl error 1: Protocol "ipfs" not supported or disabled in libcurl` diff --git a/docs/v2.5/1_cheatsheet.md b/docs/v2.5/1_cheatsheet.md new file mode 100644 index 0000000..0731df7 --- /dev/null +++ b/docs/v2.5/1_cheatsheet.md @@ -0,0 +1,89 @@ +--- +slug: /current/cheatsheet +sidebar_position: 1 +sidebar_label: CheatSheet +--- + + +# Cheatsheet + +:::info + +This is a Cheatsheet which can be used as a shorthand reference for the new ways of accomplishing tasks with the SDK. Refer to this if you need help with the new code structure. + +::: + +[Install the package using UPM](https://docs.gaming.chainsafe.io/current/getting-started#install-upm-package) before you start writing your own code. + +```csharp +async void Start() +{ + // Configure & build Web3 client using Web3Builder + var projectConfig = ProjectConfigUtilities.Load(); + var web3 = await new Web3Builder(projectConfig) + .Configure(services => + { + services.UseUnityEnvironment(); + services.UseJsonRpcProvider(); + + if (Application.platform == RuntimePlatform.WebGLPlayer) + services.UseWebGLWallet(); + else + services.UseWebPageWallet(); + }) + .BuildAsync(); + + // Read from blockchain using RpcProvider + var ethBalance = await web3.RpcProvider.GetBalance( + address: "0xaBed4239E4855E120fDA34aDBEABDd2911626BA1"); + + // Read player address & sign messages using Signer + var playerAddress = await web3.Signer.GetAddress(); + var signedMessageHash = await web3.Signer.SignMessage("Hello web3!"); // todo check if it really returns hash + + // Write to blockchain using TransactionExecutor + var transactionResponse = await web3.TransactionExecutor.SendTransaction( + new TransactionRequest + { + To = "0xdD4c825203f97984e7867F11eeCc813A036089D1", + Value = new HexBigInteger(12300000000000000), + }); + + // Build contract objects using ContractBuilder + var shibaContract = web3.ContractBuilder.Build("shiba"); // preregistered contracts + var customContract = web3.ContractBuilder.Build( + contractAbiJson, + address: "0x7286Cf0F6E80014ea75Dbc25F545A3be90F4904F"); + + // Read from contracts using Contract.Call() + object[] response = await shibaContract.Call(EthMethod.BalanceOf, new object[] { playerAddress }); + + // Write to contracts using Contract.Send() + object[] response = await customContract.Send(method: "addTotal", new object[] { 1 }); + + // Balance of custom coin ERC-20 + var tokenBalance = await ERC20.BalanceOf( + web3, + contractAddress: "0x3E0C0447e47d49195fbE329265E330643eB42e6f", + account: "0xd25b827D92b0fd656A1c829933e9b0b836d5C3e2"); + + // Balance of NFT ERC-721 + var contract721 = "0x9123541E259125657F03D7AD2A7D1a8Ec79375BA"; + var balance = await ERC721.BalanceOf(contract721, playerAddress); + + // Owner of NFT ERC-721 + var tokenId = "0x01559ae4021a565d5cc4740f1cefa95de8c1fb193949ecd32c337b03047da501"; + var ownerOf = await ERC721.OwnerOf(contract721, tokenId); + + // URI of NFT ERC-721 + var uri = await ERC721.URI(contract721, tokenId); + + // Balance of NFT ERC-1155 + var contract1155 = "0x2c1867bc3026178a47a677513746dcc6822a137a"; + var tokenId = "5"; + var balanceOf = await ERC1155.BalanceOf(contract1155, playerAddress, tokenId); + + // URI of NFT ERC-1155 + var uri = await ERC1155.URI(contract1155, tokenId); +} +``` \ No newline at end of file diff --git a/docs/v2.5/2_getting-started.md b/docs/v2.5/2_getting-started.md new file mode 100644 index 0000000..b28675d --- /dev/null +++ b/docs/v2.5/2_getting-started.md @@ -0,0 +1,128 @@ +--- +slug: /current/getting-started +sidebar_position: 2 +sidebar_label: Getting Started +--- + + +# Getting Started + +:::info + +This page will walk you through the process of setting up a project ID and using the new API. + +::: + + + +### Install via Open UPM + +1. Open up your project in editor +2. Follow the OpenUPM guide [here](https://openupm.com/docs/getting-started.html) to install openupm-cli +3. Navigate to your Unity Project folder and run the commands ```openupm add io.chainsafe.web3-unity``` & ```openupm add io.chainsafe.web3-unity.web3auth``` +4. Import Samples from Package Manager web3.unity Package Page +![](v2Assets/openupmInstall.png) +5. Packages will be installed and the SDK will be available to you. + +### Set Project ID + +As the package is installed, you'll be prompted with settings window. +First of all you have to setup your Project ID. You can get one [here](https://dashboard.gaming.chainsafe.io/). + +For more information on Project ID, see [Project ID Registration](https://docs.gaming.chainsafe.io/current/project-id-registration). + +After you've completed the registration process, copy your Project ID into the project settings +window. Save settings. You should see a message in the console saying your project id is valid. + +### Other settings + +![](v2Assets/project-settings.png) + +You should also setup default settings for the RPC node you're going to use. + +- Chain ID - search using you chain name here https://chainlist.org, 5 for goerli. +- Chain name - To Do description +- Network - To Do description +- Symbol - To Do description +- Rpc - enter URL to your RPC node here. For information on setting up an RPC Node visit [this page](https://docs.gaming.chainsafe.io/current/setting-up-an-rpc-node). + +### Introduction to API + +Now let's create a script that will access user's eth balance with the account address provided. +Create new MonoBehaviour class. Use "Start" method to initialize your web3 instance. + +```csharp +public class MyWeb3Behaviour : MonoBehaviour +{ + private async void Start() + { + var projectConfig = ProjectConfigUtilities.Load(); + var web3 = await new Web3Builder(projectConfig) + .Configure(services => { }) + .BuildAsync(); + } +} +``` + +Notice that Start method is marked as `async` to be able to build web3 instance +as it is an asynchronous operation. + +Next let's configure our web3 instance for our specific purposes. +We would need to bind a UnityEnvironment and a JsonRpcProvider services to be able +to do basic read operations. + +```csharp +var web3 = await new Web3Builder(projectConfig) + .Configure(services => + { + services.UseUnityEnvironment(); + services.UseJsonRpcProvider(); + }) + .BuildAsync(); +``` + +Configuration complete. Now let's get eth balance for the provided account address. + +```csharp +var address = "0xaBed4239E4855E120fDA34aDBEABDd2911626BA1"; +var ethBalance = await web3.RpcProvider.GetBalance(address); +``` + +That's how you configure a web3 instance and get balance using ChainSafe Gaming SDK. +You can find more cool features with examples in this documentation. + +Complete script file for this section: + +```csharp +using ChainSafe.Gaming.Build; +using ChainSafe.Gaming.Evm.JsonRpcProvider; +using ChainSafe.Gaming.Unity.Environment; +using ChainSafe.Gaming.UnityPackage; +using UnityEngine; + +public class MyWeb3Behaviour : MonoBehaviour +{ + private async void Start() + { + var projectConfig = ProjectConfigUtilities.Load(); + var web3 = await new Web3Builder(projectConfig) + .Configure(services => + { + services.UseUnityEnvironment(); + services.UseJsonRpcProvider(); + }) + .BuildAsync(); + + var address = "0xaBed4239E4855E120fDA34aDBEABDd2911626BA1"; + var ethBalance = await web3.RpcProvider.GetBalance(address); + } +} +``` \ No newline at end of file diff --git a/docs/v2.5/3_project-id-registration.md b/docs/v2.5/3_project-id-registration.md new file mode 100644 index 0000000..ff93fd1 --- /dev/null +++ b/docs/v2.5/3_project-id-registration.md @@ -0,0 +1,79 @@ +--- +slug: /current/project-id-registration +sidebar_position: 3 +sidebar_label: Project ID Registration +--- + + +# Project ID Registration + +:::info + +In order to configure the web3.unity SDK properly, you must first register your projects with ChainSafe Gaming, and then setup your own RPC node. +The following section goes over how to register your projects with ChainSafe Gaming to gain access to various features in the web3.unity SDK. +::: + +### Setting The Context + +As the user base for web3.unity grows and we look toward decentralizing the SDK, we’re finding it more important than ever to scale our ability to keep in touch with users. We want to continue learning what features and bug fixes matter most to you, share important security and feature updates, assess web3.unity’s impact as a public good, and start building more substantial relationships with studios and devs so we can help you succeed. + +Historically, we’ve relied on a combination of Discord conversations and API-level aggregate analytics to understand how devs use our tools and get in touch with updates. To make sure we’re getting a clear picture of user patterns and reliable contact info on a per-game basis (including devs who aren’t here in Discord often), we need your help registering projects you create. + +### Registering Your Project With ChainSafe Gaming + +Registration of your Unity game project will allow us to offer a more hands-on approach when it comes to debugging and catching errors in your blockchain calls. In the following sections, we will walk you through signing up and validating your Project ID within Unity, as well as all of the initial project steps you will need to follow in order to get started with your Unity NFT game project. + +### Sign-up On The Dashboard Via Email + +Please sign up via email. You can get to our sign-up dashboard by clicking the link [here](https://dashboard.gaming.chainsafe.io/). + +The email you provide will be used for ChainSafe Gaming feature and security updates, onboarding support, requesting your product feedback, and exploring partnership opportunities with ChainSafe for your game. We will also eventually deploy a developer dashboard as a place to give you visibility on your games’ performance, add details about your game so we can showcase and drive traffic to it, and organize your assets to make building even easier. + +![](v2Assets/dashboardsignup.png) + +### Enter The Verification Code Sent To Your Email + +Our sign-up process is password-free for security purposes. You will be sent an authorization code to your chosen email. Please enter this verification code during registration to unlock your dashboard. This verification process is implemented in a way that mitigates opportunities for malicious third parties from stealing your data. + +![](v2Assets/authcode.png) + +### Press The Create Button To Create Your Project + +![](v2Assets/createbutton.png) + +### Enter A Project Name + +Please enter your game title and press create. + +![](v2Assets/createproject.png) + +### You Will Be Presented With A Project ID + +This is your Project ID. Copy it and please keep it safe! Please don't give it away to other users. We use this to help identify and support you within the blockchain gaming space. You can press the edit or delete buttons to alter your project name or delete the ID as needed. + +![](v2Assets/projectID.png) + + +Please keep your Project ID handy as you'll need it once you've installed the SDK package from our [GitHub](https://github.com/ChainSafe/web3.unity/releases). + +### Open Unity And Install The web3.unity Package + +Upon installing the newest release, you'll be presented with a debug error that will stop you from editing or building. This is where you will enter your Project ID to unlock all of web3.unity's build features. + +![](v2Assets/notvalid.png) + +### Saving Your Project ID Within Unity + +In the menu bar near the top, you can press `Window` -> `ChainSafe Server Settings`, which will prompt a pop-up. From here, you can enter your Project ID along with chain information associated with your game. Once complete, press save, and that's it! You're ready to start building with web3.unity! + +![](v2Assets/savesettings.png) + +### Additional Support + +Thank you for signing up with us. You're now free to explore the web3.unity SDK at your own pace. We hope you enjoy the build experience with ChainSafe Gaming, and we are looking forward to exploring the frontiers of blockchain gaming with you. + +### How To Register A Project With web3.unity Video Tutorial + +Here is NFTPixels with a video tutorial on signing up and registering for a project ID with web3.unity: + + \ No newline at end of file diff --git a/docs/v2.5/4_setting-up-an-rpc-node.md b/docs/v2.5/4_setting-up-an-rpc-node.md new file mode 100644 index 0000000..10c58ff --- /dev/null +++ b/docs/v2.5/4_setting-up-an-rpc-node.md @@ -0,0 +1,74 @@ +--- +slug: /current/setting-up-an-rpc-node +sidebar_position: 4 +sidebar_label: Setting Up An RPC Node +--- + + +# Setting Up An RPC Node For web3.unity + +:::info + +This section walks through the process of setting up an RPC node to be used with the web3.unity SDK. We use [Chainstack](https://console.chainstack.com/user/account/create?utm_campaign=Referrals&utm_source=chainsafe&utm_medium=referrals) as an example, but this can also be done with other providers. Setting up an RPC node is a requirement for the SDK and will enable interactions with selected EVM chains in Unity-based blockchain games. + +::: + +# Prerequisites + +- A Chainstack account (sign up at [Chainstack](https://console.chainstack.com/user/account/create?utm_campaign=Referrals&utm_source=chainsafe&utm_medium=referrals) if you don't have one) +- Familiarity with the web3.unity SDK + +# Creating a project in Chainstack + +1. Create (or log in) to your Chainstack account and navigate to the Dashboard. + +2. Click on “Projects” in the left sidebar, then click on “Create project”. + +![](v2Assets/chainstack_dashboard.png) + +3. Give your project a name and select “Public chain” for the Type. + +![](v2Assets/chainstack_createprojectname.png) + +4. You will appear back on the dashboard. Select your newly created project. + +![](v2Assets/chainstack_newlycreatedproject.png) + +5. Inside the project, choose "Networks" from the ribbon menu, and then click on “Get Started” to begin deploying an RPC node. + +![](v2Assets/chainstack_getstartedbutton.png) + +# Deploying an RPC node + +1. After clicking on the “Get started” button, you will be presented with 3 required steps. In the first step “Network details”, you will select the EVM chain that your blockchain game will be making interactions with. + +2. Depending on which EVM chain you select, you will be prompted to select a network under a given chain. In our example, we have selected Polygon and its Mumbai testnet. Click “Next”. + +![](v2Assets/chainstack_selectingchainandnetwork.png) + +3. If you are under Chainstack’s Developer plan, you will only be able to select the default options presented in the “Node deployment” step. This means you will choose “Elastic” for node type, “Full” for full node, “Off” for Debug and trace APIs, “Chainstack” for Hosting, and any available provider under the Cloud provider drop-down menu. Finally, name your node and click “Next”. + +![](v2Assets/chainstack_joinnetwork.png) + +![](v2Assets/chainstack_namingnode.png) + +:::info + +Note that Chainstack’s Developer plan provides 3 million free API requests per month. This should be enough for most testing and app development purposes. If your game requires more calls per month, we would suggest [upgrading your plan](https://console.chainstack.com/user/account/create?utm_campaign=Referrals&utm_source=chainsafe&utm_medium=referrals). + +::: + +4. Review the details under the “Summary” step and then click “Join network”. +You will appear back in your project dashboard. Your newly created node will take a moment to deploy while under a “Pending” status. + +5. Once deployed, the node’s status will turn green under a “Running” status. You can now expand the details of your node by clicking on its name. + +![](v2Assets/chainstack_nodestatus.png) + +# Retrieving your HTTPS endpoint + +1. Within the node dashboard, you will be presented with a number of KPIs and metrics. Please scroll down to the “Access and credentials” section. + +2. From here, take note of the HTTPS endpoint, which will be the RPC URL you will use to configure web3.unity and allow your Unity game to interact with the blockchain. + +![](v2Assets/chainstack_httpsendpoints.png) diff --git a/docs/v2.5/5_configuration.md b/docs/v2.5/5_configuration.md new file mode 100644 index 0000000..a64ab3a --- /dev/null +++ b/docs/v2.5/5_configuration.md @@ -0,0 +1,205 @@ +--- +slug: /current/configuration +sidebar_position: 5 +sidebar_label: Configuration +--- + + +# Configuration + +:::info + +This page walks you through our new Web3 builder and it's functionality in terms of binding services and using a web3 provider. + +::: + +## Web3 as the entry point to the SDK + +To access most features provided by the SDK, you first have to create an instance of Web3 object. +You can think of it as a preconfigured entry point to the SDK or a facade. +It usually makes sense to keep 1 instance of Web3 for the active player for the lifetime of 1 session. +When player connects his wallet, you build a new instance that's associated with him. +This makes Web3 a good candidate to be stored in a singleton of some sort. + +With all that in mind, nobody stops you from creating as many Web3 instances as you need. +You can think of one instance that's created before user even logged into the game just for blockchain reading purposes. +Or even 4 instances for each player in a couch-party-game, to load their credits, preferences +or any other web3 goodness you can think of. + +## Web3Builder + +To build a new instance of Web3 you'd have to use Web3Builder object. +You can simply create one using a constructor with one required parameter being the +Project Configuration scriptable object. This object contains the data you entered when setting up +the SDK and can be obtained using `ProjectConfigUtilities.Load()`: + +```csharp +using ChainSafe.Gaming.Build; +using ChainSafe.Gaming.UnityPackage; + +private void Start() +{ + var projectConfig = ProjectConfigUtilities.Load(); + var web3Builder = new Web3Builder(projectConfig); +} +``` + +You can also provide another instance of `ProjectConfigScriptableObject`, +if you want to support multiple chains: + +```csharp +public void InitializeModel(ProjectConfigScriptableObject web3ProjectConfig) +{ + var web3Builder = new Web3Builder(web3ProjectConfig); +} +``` + +Another option is to implement IProjectConfig and/or IChainConfig +and use them for the very same purposes: + +```csharp +using ChainSafe.Gaming.Configuration; + +private class CustomChainConfig : IChainConfig +{ + public string ChainId => "27"; + public string Chain => "shiba"; + public string Network => "ethereum"; + public string Rpc => "https://custom.rpc.io"; +} + +private void Start() +{ + var projectConfig = ProjectConfigUtilities.Load(); + var customChainConfig = new CustomChainConfig(); + var web3Builder = new Web3Builder(projectConfig, customChainConfig); +} +``` + +## Binding services + +To actually enable a feature you'd have to bind it using the `Configure` method of `Web3Builder`: + +```csharp +var web3Builder = new Web3Builder(projectConfig) + .Configure(services => + { + // todo: bind services here + }); +``` + +### Environment + +Any Web3 instance requires environment it's gonna be running in bound. +If running within Unity, go with UnityEnvironment. +To bind it call `UseUnityEnvironment()` extension method: + +```csharp +using ChainSafe.Gaming.Unity.Environment; + +var web3Builder = new Web3Builder(projectConfig) + .Configure(services => + { + services.UseUnityEnvironment(); + }); +``` + +### Rpc Provider + +RpcProvider is another required service. It enables reading from blockchain. +This one binds via `UseJsonRpcProvider` extension method: + +```csharp +using ChainSafe.Gaming.Evm.JsonRpcProvider; + +var web3Builder = new Web3Builder(projectConfig) + .Configure(services => + { + services.UseUnityEnvironment(); + services.UseJsonRpcProvider(); + }); +``` + +It's worth noting you can pass a configuration object to `UseJsonRpcProvider` method to +provide custom settings for this instance of `JsonRpcProvider`. + +Most of `Use$Service$()` methods support custom configuration objects, +but in many cases a default one would be enough. + +### Signer + +Another core component for Web3 game-development is Signer. Using Signer you can +get active player account address and also sign data. + +There are many usages for Signer, one of the most common being verifying if player really owns +this account address or what's called authentication. + +### TransactionExecutor + +Transaction executor is used to send transactions to blockchain. +This results in broadcasting transaction through network therefore writing to blockchain. + +### Wallet + +Some services fulfill obligations of both Signer and TransactionExecutor. +We call this services - Wallets. + +Binding wallet is similar to binding Rpc Provider: + +```csharp +using ChainSafe.Gaming.Wallets.WebPage; + +var web3Builder = new Web3Builder(projectConfig) + .Configure(services => + { + services.UseUnityEnvironment(); + services.UseJsonRpcProvider(); + services.UseWebPageWallet(); + }); +``` + +As the wallet is bound you can use both Signer & TransactionExecutor: + +```csharp +var playerAddress = web3.Signer.GetAddress(); +var transactionResponse = web3.TransactionExecutor.SendTransaction(new TransactionRequest()); +``` + +But first, you have to actually build Web3 object. + +## Building Web3 Client + +To build a Web3 object you must call BuildAsync of Web3Builder. +As you can see it's an asynchronous operation, +so you should also mark the method calling BuildAsync as `async`. Now let's build a Web3 object. + +```csharp +private async void Start() +{ + var projectConfig = ProjectConfigUtilities.Load(); + var web3 = await new Web3Builder(projectConfig) + .Configure(services => + { + services.UseUnityEnvironment(); + services.UseJsonRpcProvider(); + services.UseWebPageWallet(); + }) + .BuildAsync(); +} +``` + +Notice we added `await` keyword and replaced `web3Builder` variable with `web3`. +The reason is that `BuildAsync` returns a Web3 instance when you await it, +so we don't need to keep reference to Web3Builder object in this case. + +Building web3 instance is an async operation because there is some initialization code, +that has to be executed before you get access to the Web3 object. +Wallets, for example, try to connect user wallet, which is a long process, that might require input +from user outside the application. + +Once BuildAsync finished executing you can be sure all services are initialized +and you can safely use your new Web3 instance: + +```csharp +var signedMessage = await web3.Signer.SignMessage("Web3 Ready"); +``` \ No newline at end of file diff --git a/docs/v2.5/6_signers-and-wallets.md b/docs/v2.5/6_signers-and-wallets.md new file mode 100644 index 0000000..a7d445c --- /dev/null +++ b/docs/v2.5/6_signers-and-wallets.md @@ -0,0 +1,104 @@ +--- +slug: /current/signers-and-wallets +sidebar_position: 6 +sidebar_label: Signers And Wallets +--- + + +# Signers and Wallets + +:::info + +This page explains signers and how we've utilized them within the new SDK. + +::: + +As we learned in the previous section wallet is essentially Signer + Transaction executor. +Meaning it has access to key pairs of the currently active user and it can also send a transaction +for execution. + +It's not always the case, but when it is, you should use `Use$Name$Wallet()` to bind the wallet implementation. +This would bind both Signer & Transaction Executor. + +There are 2 implementations of wallet available at the moment: WebPageWallet and WebGLWallet. + +### WebPageWallet + +WebPageWallet is a cross-platform implementation, that you can use on most platforms. +It works by opening up a new browser page which delegates all calls to a wallet extension installed +in the browser. User than copies the result of the operation and when he comes back to the game, +result is read from the buffer and operation completes. + +You can bind it with `services.UseWebPageWallet()`: +```csharp +using ChainSafe.Gaming.Build; +using ChainSafe.Gaming.Wallets.WebPage; + +var web3 = await new Web3Builder(projectConfig) + .Configure(services => + { + ... + services.UseWebPageWallet(); + }) + .BuildAsync(); +``` + +You can also configure WebPageWallet like this: + +```csharp +services.UseWebPageWallet( + new WebPageWalletConfig + { + // Build a message that will be shown to user when he's prompted to sign a message + ConnectMessageBuilder = expireTime => $"Sign me till {expireTime:hh:mm:ss}}", + + // Timeout for a wallet connection request + ConnectRequestExpiresAfter = TimeSpan.FromMinutes(5), + + // Provide last connected user address if you want to skip authentication + SavedUserAddress = lastUserAddress, + + // How often should we check clipboard for the result + ClipboardCheckPeriod = TimeSpan.FromSeconds(0.1f), + + // Provide your own web service instead of Chainsafe's (complex topic) + ServiceUrl = "myawesomegame.com/webpagewallet" + }); +``` + +Notice `SavedUserAddress` property. You can use it to enable 'Remember Me' option for your players. +If a player enabled the 'Remember Me' toggle, store his public address somewhere and provide it +using `SavedUserAddress` next time when he starts the game. +Send null if you want to initiate wallet connection process. + +Note: We know this is not the best cross-platform wallet implementation, but that's the only one +available at the moment. Don't worry we are already working on a new, better version ;) + +### WebGLWallet + +Use WebGLWallet if you're targeting WebGL platform. When user first connects his account, +he'll be prompted to choose the wallet software. Later on all signing and sending operations +will be delegated to this wallet. + +![](v2Assets/webgl-available-wallets.png) + +To bind WebGLWallet call `services.UseWebGLWallet()`: +```csharp +using ChainSafe.Gaming.Build; +using ChainSafe.Gaming.Wallets.WebGLWallet; + +var web3 = await new Web3Builder(projectConfig) + .Configure(services => + { + ... + services.UseWebGLWallet(); + }) + .BuildAsync(); +``` + +### Web3AuthSigner + +In version 2.5 we've introduced a new type of signer. It provides simple Web2 like authentication +user experience for those who are new to ethereum or just don't wanna spend time creating new wallets. +You can learn what is Web3Auth and how to integrate it into your project using this link. +(TODO: add link to Web3Auth section) \ No newline at end of file diff --git a/docs/v2.5/7_connecting-a-wallet.md b/docs/v2.5/7_connecting-a-wallet.md new file mode 100644 index 0000000..860e642 --- /dev/null +++ b/docs/v2.5/7_connecting-a-wallet.md @@ -0,0 +1,64 @@ +--- +slug: /current/connecting-a-wallet +sidebar_position: 7 +sidebar_label: Connecting A Wallet +--- + + +# Connecting a Wallet + +:::info + +This page teaches you how to connect a wallet and our how our system is initialized. + +::: + +There is no separate state to connect player wallet. Connection procedure is triggered as part +of Web3 build process. This is due to the fact that after Web3 build process is completed, your Web3 instance +and all of it's components have to have their states fully initialized. Starting from this point you can safely +use each and every component and not worry you missed an initialization step. + +In simple words, wallet connection happens when you call `BuildAsync()` on `Web3Builder` object. +So, to handle connection error as well as any other initialization error you should wrap `BuildAsync` +call into a try/catch statement. + +```csharp +using System.Threading.Tasks; +using ChainSafe.Gaming; +using ChainSafe.Gaming.Build; +using ChainSafe.Gaming.Evm.JsonRpcProvider; +using ChainSafe.Gaming.Unity.Environment; +using ChainSafe.Gaming.Wallets.WebGLWallet; + +public class ConnectionExample : MonoBehaviour +{ + private Web3Builder builder; + + private void Start() + { + builder = new Web3Builder() + .Configure(services => + { + services.UseUnityEnvironment(); + services.UseJsonRpcProvider(); + services.UseWebGLWallet(); + }); + } + + public async Task Connect() + { + try + { + GlobalWeb3.Instance = await builder.BuildAsync(); + } + catch (Web3Exception e) + { + Debug.Log("Connection failed. Try again."); + throw; + } + } +} +``` + +It also makes sense to retry building the Web3 object when the connection +fails. It's up to you if you wanna do it automatically or when a player presses the button. \ No newline at end of file diff --git a/docs/v2.5/8_interacting-with-tokens.md b/docs/v2.5/8_interacting-with-tokens.md new file mode 100644 index 0000000..80d8c78 --- /dev/null +++ b/docs/v2.5/8_interacting-with-tokens.md @@ -0,0 +1,118 @@ +--- +slug: /current/interacting-with-tokens +sidebar_position: 8 +sidebar_label: Interacting With Tokens +--- + + +# Interacting with Tokens + +:::info + +This area will explain basic interactions for native and custom tokens with the SDK. + +::: + +You can interact with any EVM coins using our SDK. No matter if it's ETH, +USDT or your custom ERC-20 smart contract for fungible tokens. + +### Native Tokens + +To read balance of ETH for the specified user use: + +```csharp +using ChainSafe.Gaming; + +var address = "0xdD4c825203f97984e7867F11eeCc813A036089D1"; +var hexBalance = await web3.RpcProvider.GetBalance(address); +var balance = hexBalance.Value; +``` + +To send ETH over the network use the SendTransaction method of TransactionExecutor: + +```csharp +using ChainSafe.Gaming; +using ChainSafe.Gaming.Evm; +using Nethereum.Hex.HexTypes; + +var destinationAddress = "0xdD4c825203f97984e7867F11eeCc813A036089D1"; +var weiToSend = 1000000000000000000; // 10^18 wei = 1 eth +var request = new TransactionRequest +{ + To = destinationAddress, + Value = new HexBigInteger(weiToSend) +}; + +var response = await web3.TransactionExecutor.SendTransaction(request); +``` + +### Custom ERC-20 Tokens + +If your token implements ERC-20 standard you can request balance, name, symbol, +number of decimals and total supply using the ERC20 utility class: + +```csharp +using ChainSafe.Gaming; +using ChainSafe.Gaming.UnityPackage.Ethereum.Eip; + +var contractAddress = "0x07865c6E87B9F70255377e024ace6630C1Eaa37F"; + +var rawBalance = await ERC20.BalanceOf(contractAddress, "0xdD4c825203f97984e7867F11eeCc813A036089D1"); +var tokenName = await ERC20.Name(contractAddress); +var tokenSymbol = await ERC20.Symbol(contractAddress); +var decimals = await ERC20.Decimals(contractAddress); +var totalSupply = await ERC20.TotalSupply(contractAddress); + +var balance = rawBalance / decimals; +``` + +To send ERC-20 tokens over the network you'd have to use the Smart Contract API: + +```csharp +var contractAddress = "0xc778417e063141139fce010982780140aa0cd5ab"; +var abi = ABI.ERC_20; +var contract = web3.ContractBuilder.Build(abi, contractAddress); + +var method = EthMethod.Transfer; +var toAccount = "0xdD4c825203f97984e7867F11eeCc813A036089D1"; +var amount = "1000000000000000"; +var response = await contract.Send(method, new object[] +{ + toAccount, + amount +}); +``` + +To learn more about Smart Contract API visit "Interacting with Smart-Contracts" section [Here](https://docs.gaming.chainsafe.io/interacting-with-smart-contracts/). + +### Decimals and Conversion + +All operations with eth or any ERC-20 token expect amounts in smallest unit know as wei and you might want to convert this +number before showing it to a user. Converting units is as simple as dividing or multiplying it by a _10^n_, +where _n_ - is the number of decimals for the largest unit. + +- If you're working with eth, _n_ is equal to 18. +- For smart contracts use `ERC20.Decimals()` method to obtain +the number of decimals and cache it somewhere for later use. + +Example of converting custom token value from wei to eth: + +```csharp +using ChainSafe.Gaming; +using ChainSafe.Gaming.UnityPackage.Ethereum.Eip; + +var erc20ContractAddress = "0xc778417e063141139fce010982780140aa0cd5ab"; +long decimals = (long) await ERC20.Decimals(erc20ContractAddress); // 10^10 +decimal wei = 1000000000000; // 10^12 +decimal eth = wei / decimals; // 10^2 or 100 +``` + +From eth to wei: + +```csharp +var erc20ContractAddress = "0xc778417e063141139fce010982780140aa0cd5ab"; +long decimals = (long) await ERC20.Decimals(erc20ContractAddress); // 10^10 +decimal eth = 100; // 10^2 or 100 +decimal wei = eth * decimals; // 10^12 +``` + diff --git a/docs/v2.5/9_interacting-with-nfts.md b/docs/v2.5/9_interacting-with-nfts.md new file mode 100644 index 0000000..9f74d70 --- /dev/null +++ b/docs/v2.5/9_interacting-with-nfts.md @@ -0,0 +1,114 @@ +--- +slug: /current/interacting-with-nfts +sidebar_position: 9 +sidebar_label: Interacting With NFTs +--- + + +# Interacting with NFTs + +:::info + +This area will explain basic interactions for ERC721 and ERC1155 tokens with the SDK. + +::: + +There are 2 standards available for NFTs. ERC-721 and ERC-1155. Both are supported in the SDK. + +### ERC-721 NFTs + +ERC-721 is a standard for non-fungible tokens (NFTs) on the Ethereum blockchain. +Unlike cryptocurrencies such as Ether (ETH) that are interchangeable and have the +same value, each ERC-721 token is unique and represents a distinct digital asset or item. +These tokens are indivisible and cannot be exchanged on a one-to-one basis. + +To get a count of NFTs that player owns use `ERC721.BalanceOf()` method: + +```csharp +using ChainSafe.Gaming.UnityPackage.Ethereum.Eip; + +var contract = "0x9123541E259125657F03D7AD2A7D1a8Ec79375BA"; +var account = "0xd25b827D92b0fd656A1c829933e9b0b836d5C3e2"; +var balance = await ERC721.BalanceOf(contract, account); +``` + +Use `ERC721.OwnerOf()` to get the owner of an NFT: + +```csharp +using ChainSafe.Gaming.UnityPackage.Ethereum.Eip; + +var contract = "0x06dc21f89f01409e7ed0e4c80eae1430962ae52c"; +var tokenId = "0x01559ae4021a565d5cc4740f1cefa95de8c1fb193949ecd32c337b03047da501"; +var ownerOf = await ERC721.OwnerOf(contract, tokenId); +``` + +There is also a batch version `ERC721.OwnerOfBatch`: + +```csharp +using ChainSafe.Gaming.UnityPackage.Ethereum.Eip; + +var contract = "0x47381c5c948254e6e0E324F1AA54b7B24104D92D"; +string[] tokenIds = { "33", "29" }; +List batchOwners = await ERC721.OwnerOfBatch(contract, tokenIds); +``` + +To get a Uniform Resource Identifier (URI) associated with an NFT use `ERC721.URI`: + +```csharp +using ChainSafe.Gaming.UnityPackage.Ethereum.Eip; + +var contract = "0x9123541E259125657F03D7AD2A7D1a8Ec79375BA"; +var tokenId = "1"; +var uri = await ERC721.URI(contract, tokenId); +``` + +### ERC-1155 + +ERC-1155 is a versatile token standard that allows for the creation of both fungible +(identical and interchangeable) and +non-fungible tokens (NFTs) within the same smart contract. Developed as an improvement over +ERC-20 and ERC-721, ERC-1155 offers significant advantages in terms of efficiency and flexibility. + +Using ERC-1155, you can manage multiple token types within a single contract, reducing gas +costs and minimizing blockchain bloat. This means that a single smart contract can handle various +digital assets, including NFTs representing unique items and fungible tokens like currencies or +in-game resources. + +The standard supports batch transfers, making it easier to manage multiple tokens in one transaction. +This is particularly useful for gaming and virtual asset ecosystems where players can buy, sell, +and trade different items efficiently. + +Utility class `ERC1155` contains methods `BalanceOf`, `BalanceOfBatch` and `URI`. + +BalanceOf: + +```csharp +using ChainSafe.Gaming.UnityPackage.Ethereum.Eip; + +var contract = "0x2c1867bc3026178a47a677513746dcc6822a137a"; +var account = "0xd25b827D92b0fd656A1c829933e9b0b836d5C3e2"; +var tokenId = "5"; + +var balanceOf = await ERC1155.BalanceOf(contract, account, tokenId); +``` + +BalanceOfBatch: + +```csharp +using ChainSafe.Gaming.UnityPackage.Ethereum.Eip; +var contract = "0xdc4aff511e1b94677142a43df90f948f9ae181dd"; +string[] accounts = { "0x990aef1085b2f6480a94bba53cbc03215d321e25", "0x9cd14e32E3B1AAf35D61EBD9066Ef8e3B06b23ad" }; +string[] tokenIds = { "1", "2" }; + +List batchBalances = await ERC1155.BalanceOfBatch(contract, accounts, tokenIds); +``` + +URI: + +```csharp +using ChainSafe.Gaming.UnityPackage.Ethereum.Eip; + +var contract = "0x2c1867BC3026178A47a677513746DCc6822A137A"; +var tokenId = "5"; +var uri = await ERC1155.URI(contract, tokenId); +``` \ No newline at end of file diff --git a/docs/v2.5/v2Assets/0_79048ASwpmZ3xpMi.png b/docs/v2.5/v2Assets/0_79048ASwpmZ3xpMi.png new file mode 100644 index 0000000..847178c Binary files /dev/null and b/docs/v2.5/v2Assets/0_79048ASwpmZ3xpMi.png differ diff --git a/docs/v2.5/v2Assets/0_Qecm9eKn5uOqCPb_.png b/docs/v2.5/v2Assets/0_Qecm9eKn5uOqCPb_.png new file mode 100644 index 0000000..71de83b Binary files /dev/null and b/docs/v2.5/v2Assets/0_Qecm9eKn5uOqCPb_.png differ diff --git a/docs/v2.5/v2Assets/0_VwO4917nrN0CvI_t.png b/docs/v2.5/v2Assets/0_VwO4917nrN0CvI_t.png new file mode 100644 index 0000000..113e06d Binary files /dev/null and b/docs/v2.5/v2Assets/0_VwO4917nrN0CvI_t.png differ diff --git a/docs/v2.5/v2Assets/0_ZPccvQgU2xWKFzs6 (1).png b/docs/v2.5/v2Assets/0_ZPccvQgU2xWKFzs6 (1).png new file mode 100644 index 0000000..eddcb7b Binary files /dev/null and b/docs/v2.5/v2Assets/0_ZPccvQgU2xWKFzs6 (1).png differ diff --git a/docs/v2.5/v2Assets/0_ZPccvQgU2xWKFzs6.png b/docs/v2.5/v2Assets/0_ZPccvQgU2xWKFzs6.png new file mode 100644 index 0000000..eddcb7b Binary files /dev/null and b/docs/v2.5/v2Assets/0_ZPccvQgU2xWKFzs6.png differ diff --git a/docs/v2.5/v2Assets/0__5KXEn1udtcNaDDt.png b/docs/v2.5/v2Assets/0__5KXEn1udtcNaDDt.png new file mode 100644 index 0000000..5b99158 Binary files /dev/null and b/docs/v2.5/v2Assets/0__5KXEn1udtcNaDDt.png differ diff --git a/docs/v2.5/v2Assets/0_razsjFdIeX80SIbl.png b/docs/v2.5/v2Assets/0_razsjFdIeX80SIbl.png new file mode 100644 index 0000000..5d20d8e Binary files /dev/null and b/docs/v2.5/v2Assets/0_razsjFdIeX80SIbl.png differ diff --git a/docs/v2.5/v2Assets/AddTokenContractsLootbox.png b/docs/v2.5/v2Assets/AddTokenContractsLootbox.png new file mode 100644 index 0000000..6536fa3 Binary files /dev/null and b/docs/v2.5/v2Assets/AddTokenContractsLootbox.png differ diff --git a/docs/v2.5/v2Assets/AddonsLootBox.png b/docs/v2.5/v2Assets/AddonsLootBox.png new file mode 100644 index 0000000..c5d350c Binary files /dev/null and b/docs/v2.5/v2Assets/AddonsLootBox.png differ diff --git a/docs/v2.5/v2Assets/BlockRacers1.png b/docs/v2.5/v2Assets/BlockRacers1.png new file mode 100644 index 0000000..0e686c6 Binary files /dev/null and b/docs/v2.5/v2Assets/BlockRacers1.png differ diff --git a/docs/v2.5/v2Assets/BlockRacers10.png b/docs/v2.5/v2Assets/BlockRacers10.png new file mode 100644 index 0000000..67f38f2 Binary files /dev/null and b/docs/v2.5/v2Assets/BlockRacers10.png differ diff --git a/docs/v2.5/v2Assets/BlockRacers11.png b/docs/v2.5/v2Assets/BlockRacers11.png new file mode 100644 index 0000000..0a48273 Binary files /dev/null and b/docs/v2.5/v2Assets/BlockRacers11.png differ diff --git a/docs/v2.5/v2Assets/BlockRacers12.png b/docs/v2.5/v2Assets/BlockRacers12.png new file mode 100644 index 0000000..5736c20 Binary files /dev/null and b/docs/v2.5/v2Assets/BlockRacers12.png differ diff --git a/docs/v2.5/v2Assets/BlockRacers13.png b/docs/v2.5/v2Assets/BlockRacers13.png new file mode 100644 index 0000000..5f845ac Binary files /dev/null and b/docs/v2.5/v2Assets/BlockRacers13.png differ diff --git a/docs/v2.5/v2Assets/BlockRacers14.png b/docs/v2.5/v2Assets/BlockRacers14.png new file mode 100644 index 0000000..32be6c2 Binary files /dev/null and b/docs/v2.5/v2Assets/BlockRacers14.png differ diff --git a/docs/v2.5/v2Assets/BlockRacers15.png b/docs/v2.5/v2Assets/BlockRacers15.png new file mode 100644 index 0000000..c981358 Binary files /dev/null and b/docs/v2.5/v2Assets/BlockRacers15.png differ diff --git a/docs/v2.5/v2Assets/BlockRacers16.png b/docs/v2.5/v2Assets/BlockRacers16.png new file mode 100644 index 0000000..023465a Binary files /dev/null and b/docs/v2.5/v2Assets/BlockRacers16.png differ diff --git a/docs/v2.5/v2Assets/BlockRacers17.png b/docs/v2.5/v2Assets/BlockRacers17.png new file mode 100644 index 0000000..f8ff5cc Binary files /dev/null and b/docs/v2.5/v2Assets/BlockRacers17.png differ diff --git a/docs/v2.5/v2Assets/BlockRacers18.png b/docs/v2.5/v2Assets/BlockRacers18.png new file mode 100644 index 0000000..fbdfeac Binary files /dev/null and b/docs/v2.5/v2Assets/BlockRacers18.png differ diff --git a/docs/v2.5/v2Assets/BlockRacers19.png b/docs/v2.5/v2Assets/BlockRacers19.png new file mode 100644 index 0000000..402a187 Binary files /dev/null and b/docs/v2.5/v2Assets/BlockRacers19.png differ diff --git a/docs/v2.5/v2Assets/BlockRacers2.png b/docs/v2.5/v2Assets/BlockRacers2.png new file mode 100644 index 0000000..27d1e69 Binary files /dev/null and b/docs/v2.5/v2Assets/BlockRacers2.png differ diff --git a/docs/v2.5/v2Assets/BlockRacers20.png b/docs/v2.5/v2Assets/BlockRacers20.png new file mode 100644 index 0000000..5dd30de Binary files /dev/null and b/docs/v2.5/v2Assets/BlockRacers20.png differ diff --git a/docs/v2.5/v2Assets/BlockRacers3.png b/docs/v2.5/v2Assets/BlockRacers3.png new file mode 100644 index 0000000..e3c3086 Binary files /dev/null and b/docs/v2.5/v2Assets/BlockRacers3.png differ diff --git a/docs/v2.5/v2Assets/BlockRacers4.png b/docs/v2.5/v2Assets/BlockRacers4.png new file mode 100644 index 0000000..60e3f90 Binary files /dev/null and b/docs/v2.5/v2Assets/BlockRacers4.png differ diff --git a/docs/v2.5/v2Assets/BlockRacers5.png b/docs/v2.5/v2Assets/BlockRacers5.png new file mode 100644 index 0000000..31f58dd Binary files /dev/null and b/docs/v2.5/v2Assets/BlockRacers5.png differ diff --git a/docs/v2.5/v2Assets/BlockRacers6.png b/docs/v2.5/v2Assets/BlockRacers6.png new file mode 100644 index 0000000..d709b30 Binary files /dev/null and b/docs/v2.5/v2Assets/BlockRacers6.png differ diff --git a/docs/v2.5/v2Assets/BlockRacers7.png b/docs/v2.5/v2Assets/BlockRacers7.png new file mode 100644 index 0000000..fd95d4b Binary files /dev/null and b/docs/v2.5/v2Assets/BlockRacers7.png differ diff --git a/docs/v2.5/v2Assets/BlockRacers8.png b/docs/v2.5/v2Assets/BlockRacers8.png new file mode 100644 index 0000000..6789ff1 Binary files /dev/null and b/docs/v2.5/v2Assets/BlockRacers8.png differ diff --git a/docs/v2.5/v2Assets/BlockRacers9.png b/docs/v2.5/v2Assets/BlockRacers9.png new file mode 100644 index 0000000..fb5eee7 Binary files /dev/null and b/docs/v2.5/v2Assets/BlockRacers9.png differ diff --git a/docs/v2.5/v2Assets/ChainSafe Brand Assets (1).zip b/docs/v2.5/v2Assets/ChainSafe Brand Assets (1).zip new file mode 100644 index 0000000..9534108 Binary files /dev/null and b/docs/v2.5/v2Assets/ChainSafe Brand Assets (1).zip differ diff --git a/docs/v2.5/v2Assets/ChainSafe Brand Assets (2).zip b/docs/v2.5/v2Assets/ChainSafe Brand Assets (2).zip new file mode 100644 index 0000000..9534108 Binary files /dev/null and b/docs/v2.5/v2Assets/ChainSafe Brand Assets (2).zip differ diff --git a/docs/v2.5/v2Assets/ChainSafe Brand Assets.zip b/docs/v2.5/v2Assets/ChainSafe Brand Assets.zip new file mode 100644 index 0000000..9534108 Binary files /dev/null and b/docs/v2.5/v2Assets/ChainSafe Brand Assets.zip differ diff --git a/docs/v2.5/v2Assets/ChickenDemonTorusLogin.png b/docs/v2.5/v2Assets/ChickenDemonTorusLogin.png new file mode 100644 index 0000000..d48ee12 Binary files /dev/null and b/docs/v2.5/v2Assets/ChickenDemonTorusLogin.png differ diff --git a/docs/v2.5/v2Assets/ClaimRewardsLootBoxes.png b/docs/v2.5/v2Assets/ClaimRewardsLootBoxes.png new file mode 100644 index 0000000..2e560e2 Binary files /dev/null and b/docs/v2.5/v2Assets/ClaimRewardsLootBoxes.png differ diff --git a/docs/v2.5/v2Assets/DeployLootbox.png b/docs/v2.5/v2Assets/DeployLootbox.png new file mode 100644 index 0000000..5ae05bc Binary files /dev/null and b/docs/v2.5/v2Assets/DeployLootbox.png differ diff --git a/docs/v2.5/v2Assets/EnablingAlternateWallets.png b/docs/v2.5/v2Assets/EnablingAlternateWallets.png new file mode 100644 index 0000000..81b94cd Binary files /dev/null and b/docs/v2.5/v2Assets/EnablingAlternateWallets.png differ diff --git a/docs/v2.5/v2Assets/GelatoGasless.png b/docs/v2.5/v2Assets/GelatoGasless.png new file mode 100644 index 0000000..b6a25de Binary files /dev/null and b/docs/v2.5/v2Assets/GelatoGasless.png differ diff --git a/docs/v2.5/v2Assets/GrantDepositorAccessLootbox.png b/docs/v2.5/v2Assets/GrantDepositorAccessLootbox.png new file mode 100644 index 0000000..6354555 Binary files /dev/null and b/docs/v2.5/v2Assets/GrantDepositorAccessLootbox.png differ diff --git a/docs/v2.5/v2Assets/IntroImageChainsafe.png b/docs/v2.5/v2Assets/IntroImageChainsafe.png new file mode 100644 index 0000000..524c610 Binary files /dev/null and b/docs/v2.5/v2Assets/IntroImageChainsafe.png differ diff --git a/docs/v2.5/v2Assets/Lazy Minting (1).png b/docs/v2.5/v2Assets/Lazy Minting (1).png new file mode 100644 index 0000000..9d41b2f Binary files /dev/null and b/docs/v2.5/v2Assets/Lazy Minting (1).png differ diff --git a/docs/v2.5/v2Assets/Lazy Minting (2).png b/docs/v2.5/v2Assets/Lazy Minting (2).png new file mode 100644 index 0000000..d8b74d6 Binary files /dev/null and b/docs/v2.5/v2Assets/Lazy Minting (2).png differ diff --git a/docs/v2.5/v2Assets/Lazy Minting.png b/docs/v2.5/v2Assets/Lazy Minting.png new file mode 100644 index 0000000..677689e Binary files /dev/null and b/docs/v2.5/v2Assets/Lazy Minting.png differ diff --git a/docs/v2.5/v2Assets/Logo.png b/docs/v2.5/v2Assets/Logo.png new file mode 100644 index 0000000..1204d29 Binary files /dev/null and b/docs/v2.5/v2Assets/Logo.png differ diff --git a/docs/v2.5/v2Assets/LootBoxesNpmFulfill.png b/docs/v2.5/v2Assets/LootBoxesNpmFulfill.png new file mode 100644 index 0000000..28d03a6 Binary files /dev/null and b/docs/v2.5/v2Assets/LootBoxesNpmFulfill.png differ diff --git a/docs/v2.5/v2Assets/LootBoxesNpmInitialize.png b/docs/v2.5/v2Assets/LootBoxesNpmInitialize.png new file mode 100644 index 0000000..ce52306 Binary files /dev/null and b/docs/v2.5/v2Assets/LootBoxesNpmInitialize.png differ diff --git a/docs/v2.5/v2Assets/LootBoxesRunNode.png b/docs/v2.5/v2Assets/LootBoxesRunNode.png new file mode 100644 index 0000000..d18d584 Binary files /dev/null and b/docs/v2.5/v2Assets/LootBoxesRunNode.png differ diff --git a/docs/v2.5/v2Assets/LootBoxesScene.png b/docs/v2.5/v2Assets/LootBoxesScene.png new file mode 100644 index 0000000..075eb86 Binary files /dev/null and b/docs/v2.5/v2Assets/LootBoxesScene.png differ diff --git a/docs/v2.5/v2Assets/MintAndTransferLootbox.png b/docs/v2.5/v2Assets/MintAndTransferLootbox.png new file mode 100644 index 0000000..d1a3bee Binary files /dev/null and b/docs/v2.5/v2Assets/MintAndTransferLootbox.png differ diff --git a/docs/v2.5/v2Assets/OpeningLootBoxes.png b/docs/v2.5/v2Assets/OpeningLootBoxes.png new file mode 100644 index 0000000..9663cb1 Binary files /dev/null and b/docs/v2.5/v2Assets/OpeningLootBoxes.png differ diff --git a/docs/v2.5/v2Assets/ProjectRegistration.mp4 b/docs/v2.5/v2Assets/ProjectRegistration.mp4 new file mode 100644 index 0000000..3460254 Binary files /dev/null and b/docs/v2.5/v2Assets/ProjectRegistration.mp4 differ diff --git a/docs/v2.5/v2Assets/RepoLootbox.png b/docs/v2.5/v2Assets/RepoLootbox.png new file mode 100644 index 0000000..1aa945f Binary files /dev/null and b/docs/v2.5/v2Assets/RepoLootbox.png differ diff --git a/docs/v2.5/v2Assets/ReviewSummaryLootbox.png b/docs/v2.5/v2Assets/ReviewSummaryLootbox.png new file mode 100644 index 0000000..b630338 Binary files /dev/null and b/docs/v2.5/v2Assets/ReviewSummaryLootbox.png differ diff --git a/docs/v2.5/v2Assets/RewardsLootBoxes.png b/docs/v2.5/v2Assets/RewardsLootBoxes.png new file mode 100644 index 0000000..a09e7ad Binary files /dev/null and b/docs/v2.5/v2Assets/RewardsLootBoxes.png differ diff --git a/docs/v2.5/v2Assets/SendLootToContractLootbox.png b/docs/v2.5/v2Assets/SendLootToContractLootbox.png new file mode 100644 index 0000000..ee33020 Binary files /dev/null and b/docs/v2.5/v2Assets/SendLootToContractLootbox.png differ diff --git a/docs/v2.5/v2Assets/TorusConnectExample.png b/docs/v2.5/v2Assets/TorusConnectExample.png new file mode 100644 index 0000000..e17e2d1 Binary files /dev/null and b/docs/v2.5/v2Assets/TorusConnectExample.png differ diff --git a/docs/v2.5/v2Assets/TorusDashboard.png b/docs/v2.5/v2Assets/TorusDashboard.png new file mode 100644 index 0000000..5bb0eac Binary files /dev/null and b/docs/v2.5/v2Assets/TorusDashboard.png differ diff --git a/docs/v2.5/v2Assets/TorusLogin.png b/docs/v2.5/v2Assets/TorusLogin.png new file mode 100644 index 0000000..2ab4a2e Binary files /dev/null and b/docs/v2.5/v2Assets/TorusLogin.png differ diff --git a/docs/v2.5/v2Assets/TorusWalletInteraction.png b/docs/v2.5/v2Assets/TorusWalletInteraction.png new file mode 100644 index 0000000..496b16b Binary files /dev/null and b/docs/v2.5/v2Assets/TorusWalletInteraction.png differ diff --git a/docs/v2.5/v2Assets/UpdateRewardUnitsLootbox.png b/docs/v2.5/v2Assets/UpdateRewardUnitsLootbox.png new file mode 100644 index 0000000..e357fab Binary files /dev/null and b/docs/v2.5/v2Assets/UpdateRewardUnitsLootbox.png differ diff --git a/docs/v2.5/v2Assets/Web3Auth-Wallet.png b/docs/v2.5/v2Assets/Web3Auth-Wallet.png new file mode 100644 index 0000000..81e32b9 Binary files /dev/null and b/docs/v2.5/v2Assets/Web3Auth-Wallet.png differ diff --git a/docs/v2.5/v2Assets/WebLogin.png b/docs/v2.5/v2Assets/WebLogin.png new file mode 100644 index 0000000..060fcd8 Binary files /dev/null and b/docs/v2.5/v2Assets/WebLogin.png differ diff --git a/docs/v2.5/v2Assets/authcode.png b/docs/v2.5/v2Assets/authcode.png new file mode 100644 index 0000000..ebaf2f7 Binary files /dev/null and b/docs/v2.5/v2Assets/authcode.png differ diff --git a/docs/v2.5/v2Assets/chainstack_createprojectname.png b/docs/v2.5/v2Assets/chainstack_createprojectname.png new file mode 100644 index 0000000..9c1a13f Binary files /dev/null and b/docs/v2.5/v2Assets/chainstack_createprojectname.png differ diff --git a/docs/v2.5/v2Assets/chainstack_dashboard.png b/docs/v2.5/v2Assets/chainstack_dashboard.png new file mode 100644 index 0000000..ff66713 Binary files /dev/null and b/docs/v2.5/v2Assets/chainstack_dashboard.png differ diff --git a/docs/v2.5/v2Assets/chainstack_getstartedbutton.png b/docs/v2.5/v2Assets/chainstack_getstartedbutton.png new file mode 100644 index 0000000..49bb2b8 Binary files /dev/null and b/docs/v2.5/v2Assets/chainstack_getstartedbutton.png differ diff --git a/docs/v2.5/v2Assets/chainstack_httpsendpoints.png b/docs/v2.5/v2Assets/chainstack_httpsendpoints.png new file mode 100644 index 0000000..f54116f Binary files /dev/null and b/docs/v2.5/v2Assets/chainstack_httpsendpoints.png differ diff --git a/docs/v2.5/v2Assets/chainstack_joinnetwork.png b/docs/v2.5/v2Assets/chainstack_joinnetwork.png new file mode 100644 index 0000000..ed625f5 Binary files /dev/null and b/docs/v2.5/v2Assets/chainstack_joinnetwork.png differ diff --git a/docs/v2.5/v2Assets/chainstack_namingnode.png b/docs/v2.5/v2Assets/chainstack_namingnode.png new file mode 100644 index 0000000..c1cbf4d Binary files /dev/null and b/docs/v2.5/v2Assets/chainstack_namingnode.png differ diff --git a/docs/v2.5/v2Assets/chainstack_newlycreatedproject.png b/docs/v2.5/v2Assets/chainstack_newlycreatedproject.png new file mode 100644 index 0000000..42a7fce Binary files /dev/null and b/docs/v2.5/v2Assets/chainstack_newlycreatedproject.png differ diff --git a/docs/v2.5/v2Assets/chainstack_nodestatus.png b/docs/v2.5/v2Assets/chainstack_nodestatus.png new file mode 100644 index 0000000..dc70a60 Binary files /dev/null and b/docs/v2.5/v2Assets/chainstack_nodestatus.png differ diff --git a/docs/v2.5/v2Assets/chainstack_selectingchainandnetwork.png b/docs/v2.5/v2Assets/chainstack_selectingchainandnetwork.png new file mode 100644 index 0000000..40ba6be Binary files /dev/null and b/docs/v2.5/v2Assets/chainstack_selectingchainandnetwork.png differ diff --git a/docs/v2.5/v2Assets/createbutton.png b/docs/v2.5/v2Assets/createbutton.png new file mode 100644 index 0000000..2159c81 Binary files /dev/null and b/docs/v2.5/v2Assets/createbutton.png differ diff --git a/docs/v2.5/v2Assets/createproject.png b/docs/v2.5/v2Assets/createproject.png new file mode 100644 index 0000000..08ddaf1 Binary files /dev/null and b/docs/v2.5/v2Assets/createproject.png differ diff --git a/docs/v2.5/v2Assets/csg-support-assets.zip b/docs/v2.5/v2Assets/csg-support-assets.zip new file mode 100644 index 0000000..139aae3 Binary files /dev/null and b/docs/v2.5/v2Assets/csg-support-assets.zip differ diff --git a/docs/v2.5/v2Assets/dashboardsignup.png b/docs/v2.5/v2Assets/dashboardsignup.png new file mode 100644 index 0000000..7f2a2f6 Binary files /dev/null and b/docs/v2.5/v2Assets/dashboardsignup.png differ diff --git a/docs/v2.5/v2Assets/empty_login_scene.png b/docs/v2.5/v2Assets/empty_login_scene.png new file mode 100644 index 0000000..94603b6 Binary files /dev/null and b/docs/v2.5/v2Assets/empty_login_scene.png differ diff --git a/docs/v2.5/v2Assets/image (1).png b/docs/v2.5/v2Assets/image (1).png new file mode 100644 index 0000000..45739dc Binary files /dev/null and b/docs/v2.5/v2Assets/image (1).png differ diff --git a/docs/v2.5/v2Assets/image (10).png b/docs/v2.5/v2Assets/image (10).png new file mode 100644 index 0000000..26c3f3c Binary files /dev/null and b/docs/v2.5/v2Assets/image (10).png differ diff --git a/docs/v2.5/v2Assets/image (11).png b/docs/v2.5/v2Assets/image (11).png new file mode 100644 index 0000000..cb7307b Binary files /dev/null and b/docs/v2.5/v2Assets/image (11).png differ diff --git a/docs/v2.5/v2Assets/image (12).png b/docs/v2.5/v2Assets/image (12).png new file mode 100644 index 0000000..07d7f02 Binary files /dev/null and b/docs/v2.5/v2Assets/image (12).png differ diff --git a/docs/v2.5/v2Assets/image (13).png b/docs/v2.5/v2Assets/image (13).png new file mode 100644 index 0000000..8a19824 Binary files /dev/null and b/docs/v2.5/v2Assets/image (13).png differ diff --git a/docs/v2.5/v2Assets/image (14).png b/docs/v2.5/v2Assets/image (14).png new file mode 100644 index 0000000..eb39d74 Binary files /dev/null and b/docs/v2.5/v2Assets/image (14).png differ diff --git a/docs/v2.5/v2Assets/image (2).png b/docs/v2.5/v2Assets/image (2).png new file mode 100644 index 0000000..cab503a Binary files /dev/null and b/docs/v2.5/v2Assets/image (2).png differ diff --git a/docs/v2.5/v2Assets/image (3).png b/docs/v2.5/v2Assets/image (3).png new file mode 100644 index 0000000..26c3f3c Binary files /dev/null and b/docs/v2.5/v2Assets/image (3).png differ diff --git a/docs/v2.5/v2Assets/image (4).png b/docs/v2.5/v2Assets/image (4).png new file mode 100644 index 0000000..3c342c4 Binary files /dev/null and b/docs/v2.5/v2Assets/image (4).png differ diff --git a/docs/v2.5/v2Assets/image (5).png b/docs/v2.5/v2Assets/image (5).png new file mode 100644 index 0000000..309dbc3 Binary files /dev/null and b/docs/v2.5/v2Assets/image (5).png differ diff --git a/docs/v2.5/v2Assets/image (6).png b/docs/v2.5/v2Assets/image (6).png new file mode 100644 index 0000000..cab503a Binary files /dev/null and b/docs/v2.5/v2Assets/image (6).png differ diff --git a/docs/v2.5/v2Assets/image (7).png b/docs/v2.5/v2Assets/image (7).png new file mode 100644 index 0000000..587e03b Binary files /dev/null and b/docs/v2.5/v2Assets/image (7).png differ diff --git a/docs/v2.5/v2Assets/image (8).png b/docs/v2.5/v2Assets/image (8).png new file mode 100644 index 0000000..7757c0f Binary files /dev/null and b/docs/v2.5/v2Assets/image (8).png differ diff --git a/docs/v2.5/v2Assets/image (9).png b/docs/v2.5/v2Assets/image (9).png new file mode 100644 index 0000000..37094f0 Binary files /dev/null and b/docs/v2.5/v2Assets/image (9).png differ diff --git a/docs/v2.5/v2Assets/image.png b/docs/v2.5/v2Assets/image.png new file mode 100644 index 0000000..587e03b Binary files /dev/null and b/docs/v2.5/v2Assets/image.png differ diff --git a/docs/v2.5/v2Assets/image0.jpg b/docs/v2.5/v2Assets/image0.jpg new file mode 100644 index 0000000..159ad30 Binary files /dev/null and b/docs/v2.5/v2Assets/image0.jpg differ diff --git a/docs/v2.5/v2Assets/install_newton_soft.png b/docs/v2.5/v2Assets/install_newton_soft.png new file mode 100644 index 0000000..c8d8441 Binary files /dev/null and b/docs/v2.5/v2Assets/install_newton_soft.png differ diff --git a/docs/v2.5/v2Assets/my_assets.png b/docs/v2.5/v2Assets/my_assets.png new file mode 100644 index 0000000..1274014 Binary files /dev/null and b/docs/v2.5/v2Assets/my_assets.png differ diff --git a/docs/v2.5/v2Assets/new_project.png b/docs/v2.5/v2Assets/new_project.png new file mode 100644 index 0000000..ee7cc70 Binary files /dev/null and b/docs/v2.5/v2Assets/new_project.png differ diff --git a/docs/v2.5/v2Assets/newton_asset_store.png b/docs/v2.5/v2Assets/newton_asset_store.png new file mode 100644 index 0000000..8053a9b Binary files /dev/null and b/docs/v2.5/v2Assets/newton_asset_store.png differ diff --git a/docs/v2.5/v2Assets/newton_soft_install.png b/docs/v2.5/v2Assets/newton_soft_install.png new file mode 100644 index 0000000..109f6c7 Binary files /dev/null and b/docs/v2.5/v2Assets/newton_soft_install.png differ diff --git a/docs/v2.5/v2Assets/notvalid.png b/docs/v2.5/v2Assets/notvalid.png new file mode 100644 index 0000000..13afdd3 Binary files /dev/null and b/docs/v2.5/v2Assets/notvalid.png differ diff --git a/docs/v2.5/v2Assets/openupmInstall.png b/docs/v2.5/v2Assets/openupmInstall.png new file mode 100644 index 0000000..3f9d341 Binary files /dev/null and b/docs/v2.5/v2Assets/openupmInstall.png differ diff --git a/docs/v2.5/v2Assets/project-settings.png b/docs/v2.5/v2Assets/project-settings.png new file mode 100644 index 0000000..0a25857 Binary files /dev/null and b/docs/v2.5/v2Assets/project-settings.png differ diff --git a/docs/v2.5/v2Assets/projectID.png b/docs/v2.5/v2Assets/projectID.png new file mode 100644 index 0000000..27e1f58 Binary files /dev/null and b/docs/v2.5/v2Assets/projectID.png differ diff --git a/docs/v2.5/v2Assets/reqMetamask.png b/docs/v2.5/v2Assets/reqMetamask.png new file mode 100644 index 0000000..d897645 Binary files /dev/null and b/docs/v2.5/v2Assets/reqMetamask.png differ diff --git a/docs/v2.5/v2Assets/savesettings.png b/docs/v2.5/v2Assets/savesettings.png new file mode 100644 index 0000000..bc917ca Binary files /dev/null and b/docs/v2.5/v2Assets/savesettings.png differ diff --git a/docs/v2.5/v2Assets/sign_in_metamask.png b/docs/v2.5/v2Assets/sign_in_metamask.png new file mode 100644 index 0000000..3010cd2 Binary files /dev/null and b/docs/v2.5/v2Assets/sign_in_metamask.png differ diff --git a/docs/v2.5/v2Assets/step1.png b/docs/v2.5/v2Assets/step1.png new file mode 100644 index 0000000..0838158 Binary files /dev/null and b/docs/v2.5/v2Assets/step1.png differ diff --git a/docs/v2.5/v2Assets/step10.png b/docs/v2.5/v2Assets/step10.png new file mode 100644 index 0000000..e854650 Binary files /dev/null and b/docs/v2.5/v2Assets/step10.png differ diff --git a/docs/v2.5/v2Assets/step2.png b/docs/v2.5/v2Assets/step2.png new file mode 100644 index 0000000..958346c Binary files /dev/null and b/docs/v2.5/v2Assets/step2.png differ diff --git a/docs/v2.5/v2Assets/step3.png b/docs/v2.5/v2Assets/step3.png new file mode 100644 index 0000000..0ca93af Binary files /dev/null and b/docs/v2.5/v2Assets/step3.png differ diff --git a/docs/v2.5/v2Assets/step4.png b/docs/v2.5/v2Assets/step4.png new file mode 100644 index 0000000..d03e468 Binary files /dev/null and b/docs/v2.5/v2Assets/step4.png differ diff --git a/docs/v2.5/v2Assets/step5.png b/docs/v2.5/v2Assets/step5.png new file mode 100644 index 0000000..be068a5 Binary files /dev/null and b/docs/v2.5/v2Assets/step5.png differ diff --git a/docs/v2.5/v2Assets/step7.png b/docs/v2.5/v2Assets/step7.png new file mode 100644 index 0000000..b5451af Binary files /dev/null and b/docs/v2.5/v2Assets/step7.png differ diff --git a/docs/v2.5/v2Assets/step8.png b/docs/v2.5/v2Assets/step8.png new file mode 100644 index 0000000..bee6857 Binary files /dev/null and b/docs/v2.5/v2Assets/step8.png differ diff --git a/docs/v2.5/v2Assets/step9.png b/docs/v2.5/v2Assets/step9.png new file mode 100644 index 0000000..023c690 Binary files /dev/null and b/docs/v2.5/v2Assets/step9.png differ diff --git a/docs/v2.5/v2Assets/upm-git.png b/docs/v2.5/v2Assets/upm-git.png new file mode 100644 index 0000000..78f73de Binary files /dev/null and b/docs/v2.5/v2Assets/upm-git.png differ diff --git a/docs/v2.5/v2Assets/v2CollectionIdAdd.png b/docs/v2.5/v2Assets/v2CollectionIdAdd.png new file mode 100644 index 0000000..0b5a194 Binary files /dev/null and b/docs/v2.5/v2Assets/v2CollectionIdAdd.png differ diff --git a/docs/v2.5/v2Assets/v2CollectionNfts.png b/docs/v2.5/v2Assets/v2CollectionNfts.png new file mode 100644 index 0000000..4922c53 Binary files /dev/null and b/docs/v2.5/v2Assets/v2CollectionNfts.png differ diff --git a/docs/v2.5/v2Assets/v2Collections.png b/docs/v2.5/v2Assets/v2Collections.png new file mode 100644 index 0000000..c84e956 Binary files /dev/null and b/docs/v2.5/v2Assets/v2Collections.png differ diff --git a/docs/v2.5/v2Assets/v2CollectionsBuy.png b/docs/v2.5/v2Assets/v2CollectionsBuy.png new file mode 100644 index 0000000..989aa8a Binary files /dev/null and b/docs/v2.5/v2Assets/v2CollectionsBuy.png differ diff --git a/docs/v2.5/v2Assets/v2DeletePreviousSDKFiles.png b/docs/v2.5/v2Assets/v2DeletePreviousSDKFiles.png new file mode 100644 index 0000000..3b5e821 Binary files /dev/null and b/docs/v2.5/v2Assets/v2DeletePreviousSDKFiles.png differ diff --git a/docs/v2.5/v2Assets/v2InstallErrors.png b/docs/v2.5/v2Assets/v2InstallErrors.png new file mode 100644 index 0000000..6211601 Binary files /dev/null and b/docs/v2.5/v2Assets/v2InstallErrors.png differ diff --git a/docs/v2.5/v2Assets/v2createcontractdatanew.png b/docs/v2.5/v2Assets/v2createcontractdatanew.png new file mode 100644 index 0000000..cc711ff Binary files /dev/null and b/docs/v2.5/v2Assets/v2createcontractdatanew.png differ diff --git a/docs/v2.5/v2Assets/v2createcontractdataold.png b/docs/v2.5/v2Assets/v2createcontractdataold.png new file mode 100644 index 0000000..ac3fd9b Binary files /dev/null and b/docs/v2.5/v2Assets/v2createcontractdataold.png differ diff --git a/docs/v2.5/v2Assets/v2evmcallerror.png b/docs/v2.5/v2Assets/v2evmcallerror.png new file mode 100644 index 0000000..e5c1f74 Binary files /dev/null and b/docs/v2.5/v2Assets/v2evmcallerror.png differ diff --git a/docs/v2.5/v2Assets/v2evmcallnew.png b/docs/v2.5/v2Assets/v2evmcallnew.png new file mode 100644 index 0000000..4ac9bc9 Binary files /dev/null and b/docs/v2.5/v2Assets/v2evmcallnew.png differ diff --git a/docs/v2.5/v2Assets/v2evmcallold.png b/docs/v2.5/v2Assets/v2evmcallold.png new file mode 100644 index 0000000..57c40de Binary files /dev/null and b/docs/v2.5/v2Assets/v2evmcallold.png differ diff --git a/docs/v2.5/v2Assets/v2importcontractslib.png b/docs/v2.5/v2Assets/v2importcontractslib.png new file mode 100644 index 0000000..07e9150 Binary files /dev/null and b/docs/v2.5/v2Assets/v2importcontractslib.png differ diff --git a/docs/v2.5/v2Assets/v2importevmlib.png b/docs/v2.5/v2Assets/v2importevmlib.png new file mode 100644 index 0000000..942a921 Binary files /dev/null and b/docs/v2.5/v2Assets/v2importevmlib.png differ diff --git a/docs/v2.5/v2Assets/v2installv2unitypackage.png b/docs/v2.5/v2Assets/v2installv2unitypackage.png new file mode 100644 index 0000000..5f6cf79 Binary files /dev/null and b/docs/v2.5/v2Assets/v2installv2unitypackage.png differ diff --git a/docs/v2.5/v2Assets/v2web3walleterror.png b/docs/v2.5/v2Assets/v2web3walleterror.png new file mode 100644 index 0000000..f280493 Binary files /dev/null and b/docs/v2.5/v2Assets/v2web3walleterror.png differ diff --git a/docs/v2.5/v2Assets/v2web3walletlibimport.png b/docs/v2.5/v2Assets/v2web3walletlibimport.png new file mode 100644 index 0000000..2e4ece2 Binary files /dev/null and b/docs/v2.5/v2Assets/v2web3walletlibimport.png differ diff --git a/docs/v2.5/v2Assets/v2webglsignverifynew.png b/docs/v2.5/v2Assets/v2webglsignverifynew.png new file mode 100644 index 0000000..6f54a9f Binary files /dev/null and b/docs/v2.5/v2Assets/v2webglsignverifynew.png differ diff --git a/docs/v2.5/v2Assets/v2webglsignverifyold.png b/docs/v2.5/v2Assets/v2webglsignverifyold.png new file mode 100644 index 0000000..f102178 Binary files /dev/null and b/docs/v2.5/v2Assets/v2webglsignverifyold.png differ diff --git a/docs/v2.5/v2Assets/webgl-available-wallets.png b/docs/v2.5/v2Assets/webgl-available-wallets.png new file mode 100644 index 0000000..c6e1bd1 Binary files /dev/null and b/docs/v2.5/v2Assets/webgl-available-wallets.png differ diff --git a/docs/v2.5/v2Assets/webgl_template.png b/docs/v2.5/v2Assets/webgl_template.png new file mode 100644 index 0000000..4837334 Binary files /dev/null and b/docs/v2.5/v2Assets/webgl_template.png differ diff --git a/docs/v2/10_webgl-browser.md b/docs/v2/10_webgl-browser.md index 8f31ca5..51b7ff4 100644 --- a/docs/v2/10_webgl-browser.md +++ b/docs/v2/10_webgl-browser.md @@ -1,5 +1,5 @@ --- -slug: /current/webgl-browser +slug: /2.1.0/webgl-browser sidebar_position: 10 sidebar_label: WebGL Builds --- diff --git a/docs/v2/11_web3wallet-mobile-and-desktop.md b/docs/v2/11_web3wallet-mobile-and-desktop.md index 28bd169..606fbba 100644 --- a/docs/v2/11_web3wallet-mobile-and-desktop.md +++ b/docs/v2/11_web3wallet-mobile-and-desktop.md @@ -1,5 +1,5 @@ --- -slug: /current/web3wallet-mobile-and-desktop +slug: /2.1.0/web3wallet-mobile-and-desktop sidebar_position: 11 sidebar_label: Web3Wallet Builds --- diff --git a/docs/v2/13_keep-your-games-safe-from-cheaters.md b/docs/v2/12_keep-your-games-safe-from-cheaters.md similarity index 97% rename from docs/v2/13_keep-your-games-safe-from-cheaters.md rename to docs/v2/12_keep-your-games-safe-from-cheaters.md index 89df75a..b62b3b2 100644 --- a/docs/v2/13_keep-your-games-safe-from-cheaters.md +++ b/docs/v2/12_keep-your-games-safe-from-cheaters.md @@ -1,6 +1,6 @@ --- -slug: /current/keep-your-games-safe-from-cheaters -sidebar_position: 13 +slug: /2.1.0/keep-your-games-safe-from-cheaters +sidebar_position: 12 sidebar_label: Keeping Your Games Safe From Cheaters --- diff --git a/docs/v2/14_importing-nfts.md b/docs/v2/13_importing-nfts.md similarity index 89% rename from docs/v2/14_importing-nfts.md rename to docs/v2/13_importing-nfts.md index 33b5dcc..f280be5 100644 --- a/docs/v2/14_importing-nfts.md +++ b/docs/v2/13_importing-nfts.md @@ -1,6 +1,6 @@ --- -slug: /current/importing-nfts -sidebar_position: 14 +slug: /2.1.0/importing-nfts +sidebar_position: 13 sidebar_label: Importing NFTs --- diff --git a/docs/v2/15_how-tos.md b/docs/v2/14_how-tos.md similarity index 97% rename from docs/v2/15_how-tos.md rename to docs/v2/14_how-tos.md index 1a33864..dabe9f9 100644 --- a/docs/v2/15_how-tos.md +++ b/docs/v2/14_how-tos.md @@ -1,6 +1,6 @@ --- -slug: /current/how-tos -sidebar_position: 15 +slug: /2.1.0/how-tos +sidebar_position: 14 sidebar_label: How To Video Tutorials --- diff --git a/docs/v2/16_implementing-social-logins-to-webgl-builds.md b/docs/v2/15_implementing-social-logins-to-webgl-builds.md similarity index 97% rename from docs/v2/16_implementing-social-logins-to-webgl-builds.md rename to docs/v2/15_implementing-social-logins-to-webgl-builds.md index 1b83a3f..ed02c67 100644 --- a/docs/v2/16_implementing-social-logins-to-webgl-builds.md +++ b/docs/v2/15_implementing-social-logins-to-webgl-builds.md @@ -1,6 +1,6 @@ --- -slug: /current/implementing-social-logins-to-webgl-builds -sidebar_position: 16 +slug: /2.1.0/implementing-social-logins-to-webgl-builds +sidebar_position: 15 sidebar_label: Implementing Social Logins To WebGL Builds --- diff --git a/docs/v2/17_migration.md b/docs/v2/16_migration.md similarity index 99% rename from docs/v2/17_migration.md rename to docs/v2/16_migration.md index 9a471a6..cd8876e 100644 --- a/docs/v2/17_migration.md +++ b/docs/v2/16_migration.md @@ -1,6 +1,6 @@ --- -slug: /current/migration -sidebar_position: 17 +slug: /2.1.0/migration +sidebar_position: 16 sidebar_label: Migrating From v1.x To v2.x --- diff --git a/docs/v2/17_faq.md b/docs/v2/17_faq.md new file mode 100644 index 0000000..e9198b3 --- /dev/null +++ b/docs/v2/17_faq.md @@ -0,0 +1,164 @@ +--- +slug: /2.1.0/faq +sidebar_position: 17 +sidebar_label: FAQ +--- + + +# Frequently Asked Questions + +:::info + +Frequently asked questions about ChainSafe Gaming's SDK, web3.unity. + +::: + +1. [Common Questions](#common-questions) +2. [Common Questions About Upgrading To The Latest Version of web3.unity](#common-questions-about-upgrading-to-the-latest-version-of-web3unity) +3. [Common Error Messages](#common-error-messages) + + +## Common Questions + +### Is the SDK free to use? + +Yes, the SDK is free to use. + +### Can I make desktop games with the SDK? + +Yes, you can make desktop, web, and mobile games using our SDK. To create a desktop game with web3.unity, you will need to create a Web3GL build with web3.unity. + +### Does the SDK support other EVM-compatible chains besides Ethereum? + +Yes. The SDK will support other EVM-compatible chains. + +You will need to edit the `network.js` file found within the **WebTemplates** folder. Edit the `ChainId` to the one for the blockchain you want your game to interact with. See websites like [Chainlist](https://chainlist.org/) for a list of EVM ChainID's. You will then also need to an appropriate RPC endpoint for the chain you wish to connect with. + +Should you run into any issues with a particular chain, please reach out on our [Discord](https://discord.gg/zxHUgGGTGk). + +### Does the SDK support other non-EVM blockchains like Solana or Algorand? + +Not currently. Although, the SDK is mainly compatible with Ethereum Virtual Machine (EVM) blockchains, we do have plans for supporting non-EVM chains in the future depending on community support. + +### The Google Play / Apple AppStore is rejecting my application, what can I do? + +**Answer #1:** This usually happens because the game has not informed the user that a MetaMask pop up will occur. You can solve this by adding a simple notification as seen below. + +![](v2Assets/reqMetamask.png) + +**Answer #2:** Some stores may require a demo version of the game so that the stores teams can review the product without needing an external wallet. You can simply add a demo button within the game that takes the user to a free-to-play version of your game without blockchain calls to test. This should be enough for the store to accept your games application. Happy coding! + +### How do I enable Torus and other crypto wallets for the SDK? + +You can do this by editing the WebGLTemplates -> WebGL2020x -> Web3 -> index.js file. You need to uncomment the wallet at the top to allow the UNPKG javascript file to be used and then uncomment the wallet in the connect function below. Other wallets can be added the same way, provided the developers of the wallet supply a UNPKG javascript file and the wallet is EVM-compatible (such as MetaMask). + +![](v2Assets/EnablingAlternateWallets.png) + +## Common Questions About Upgrading To The Latest Version of web3.unity + +### How do I download the latest version? + +web3.unity is currently on v2. + +You can download the [latest release](https://github.com/ChainSafe/web3.unity/releases/tag/v1.6.3) and import it into your Unity build. We have an installation tutorial here: [https://docs.gaming.chainsafe.io/](https://docs.gaming.chainsafe.io/) + +### What are the benefits of moving to the latest version? + +* **Improves reliability -** This upgrade gives developers the flexibility to choose the best infrastructure for their use case and avoid possible downtime while also choosing fallback options if any infra provider fails. +* **Improves scalability -** Game studios will be able to pick and choose the infrastructure that serves their uptime requirements. +* **Improves SDK speed -** Removing the API server speeds up the blockchain gaming UX since reads and writes can happen either player-side or on dedicated infrastructure. +* **Improves transaction handling -** Improved event listening (getting a notification immediately when a transaction goes through, rather than pinging the API server repeatedly for a status update) is one of the most consistently requested features. Decentralizing provides more responsive event handling by allowing devs and players to check transactions directly. +* **Improves collaboration -** Open sourcing v2 invites the gaming community to contribute meaningfully to the codebase — helping to debug, optimize, and ultimately, determine for themselves where it may be undesirable or infeasible for service providers to run infrastructure. + +### Are code changes required when I update to the latest version? + +The latest version (v2) will require code changes for games using legacy versions of web3.unity (v1.6.x or lower). + +Some effort will be required to refactor games that use modified versions of our prefabs, as well as needing to configure an RPC provider for broadcasting transactions to the various networks we support. Without these changes, games will be impacted and players will no longer be able to make and sign transactions. + +### How long will it take to migrate my game from legacy versions (v1.6.x or lower) to the latest version? + +This largely depends on the amount of affected code you have in your game and the platform that you’re building on; both our team and the community are here to help. + +Join our [Discord](https://discord.gg/zxHUgGGTGk) for support or reach out to our team at `bd@chainsafe.io` for consulting engagements, we are happy to assist. + +### My game is currently running legacy versions (v1.6.x or lower). What are the steps I need to take to switch over to the latest version? + +1. Register for a project ID (including filling out profile and project info). See [this video](https://www.youtube.com/watch?v=TbDGaySQ1Io) for a tutorial on how project registration works +2. Sign up for a node provider and get an RPC endpoint (if you aren’t already using one). More on this below. +3. Update any code in your game that uses modified versions of our prefabs +4. Test your game to ensure all functions work the same way as before + +Without these changes, people will be unable to make transactions from within existing games. This will require some effort to refactor code based on legacy versions. Users can expect payoffs in the longer term, and we’re here to help make the transition as smooth as possible. + +### What is an RPC and how do I get one? + +A Remote Procedure Call or RPC node is a type of computer server that allows users to read data on the blockchain and send transactions to different networks. You can deploy one using either [QuickNode](https://www.quicknode.com/) or [Chainstack](https://chainstack.com/). + +### Why are RPCs required? + +The latest decentralized version of the SDK will significantly reduce the involvement our intermediary API servers play which previously was causing developers with intermittent outages and bottlenecks. Instead, we are encouraging users to assess and determine the uptime guarantees needed from infrastructure providers in supplying an RPC node. + +### Will I still be able to use legacy versions (v1.6.x or lower) with my game? + +The aim is to move away from supporting the API service once the community has had adequate time to upgrade to the latest version. + +The sunset date for the API is slated for May, 2023. + +### My current build is running just fine, is upgrading compulsory? + +While we appreciate and understand how this may impact some of our existing developers and their games/communities, an upgrade to the latest version is required. + +We believe the net positive as a result of ultimate developer control, transparency, and decentralization makes upgrading to the latest version a worthwhile endeavor in the long run. + +### Can someone help migrate my game to the latest version? + +Please join us in our [Discord](https://discord.gg/zxHUgGGTGk) ([#gaming-help](https://discord.gg/QKxVQBsyPt), [#community-code-support](https://discord.gg/sYhfpxrEHt)) for support from our core devs, ChainSages, and other SDK community members. + +If additional consulting is required, please contact us at `bd@chainsafe.io` to set up a call with our team. + +### Can I pay to keep my game running using ChainSafe’s API server? + +Please stay tuned to our [website](https://gaming.chainsafe.io) or on our [Discord](https://discord.gg/zxHUgGGTGk) for further information. + +### Will the web3.unity SDK remain free to use? + +Yes, the SDK will remain free to use. + +## Common Error Messages + +### I'm seeing the following error when I install the package. `The type or namespace name 'Newtonsoft' could not be found` + +NewtonSoft is a dependency of the SDK and needs to be installed for the SDK to work. If you see a newtonsoft error you can manually install the package by going to window->package manager->pressing the + button on the top left, pressing add via git url and pasting in "com.unity.nuget.newtonsoft-json@3.0.1". + +### I'm getting the following error when trying to import an NFT texture into the SDK. `Curl error 1: Protocol "ipfs" not supported or disabled in libcurl` + +IPFS has its own protocol that isn't supported in JSON.Net. In order to get around this, you will need to add something like the following code snippet: + +```csharp +string imageUri = data.image; +if (imageUri.StartsWith("ipfs://")) +{ + imageUri = imageUri.Replace("ipfs://", "https://ipfs.io/ipfs/"); +C#// Some code +``` + +### I'm getting the following error `Cannot read properties of undefined reading connect` when clicking the login button. What am I doing wrong? + +![](v2Assets/image0.jpg) + +This error typically happens when the user hasn't selected the Web3GL template for making WebGL Games. Make sure you have selected the provided template before making a Web3GL-based game. + +![](v2Assets/webgl\_template.png) + +### I'm having issues building with react or into a server and it's showing `Uncaught TypeError: Cannot read properties of undefined (reading 'connect')` on build, what should I do? + +You need to add the web3 component into your react build manually. To do so: + +1. In your public folder, add the web3 folder from a unity build. +2. Then import the following as a script at index.html. +3. + ```js + \ \ \ \ +``` + This should solve your issue. Happy coding! diff --git a/docs/v2/19_media.md b/docs/v2/18_media.md similarity index 89% rename from docs/v2/19_media.md rename to docs/v2/18_media.md index d3cf0a7..0b457e9 100644 --- a/docs/v2/19_media.md +++ b/docs/v2/18_media.md @@ -1,6 +1,6 @@ --- -slug: /current/media -sidebar_position: 19 +slug: /2.1.0/media +sidebar_position: 18 sidebar_label: Media --- diff --git a/docs/v2/1_project-id-registration.md b/docs/v2/1_project-id-registration.md index 47490bb..5315770 100644 --- a/docs/v2/1_project-id-registration.md +++ b/docs/v2/1_project-id-registration.md @@ -1,5 +1,5 @@ --- -slug: /current/project-id-registration +slug: /2.1.0/project-id-registration sidebar_position: 1 sidebar_label: Project ID Registration --- diff --git a/docs/v2/2_setting-up-an-rpc-node.md b/docs/v2/2_setting-up-an-rpc-node.md index 0531407..3ea10f7 100644 --- a/docs/v2/2_setting-up-an-rpc-node.md +++ b/docs/v2/2_setting-up-an-rpc-node.md @@ -1,5 +1,5 @@ --- -slug: /current/setting-up-an-rpc-node +slug: /2.1.0/setting-up-an-rpc-node sidebar_position: 2 sidebar_label: Setting Up An RPC Node --- diff --git a/docs/v2/3_installation.md b/docs/v2/3_installation.md index 3e8b11e..bec6f69 100644 --- a/docs/v2/3_installation.md +++ b/docs/v2/3_installation.md @@ -1,5 +1,5 @@ --- -slug: /current/installation +slug: /2.1.0/installation sidebar_position: 3 sidebar_label: Installation --- diff --git a/docs/v2/4_erc20-interactions.md b/docs/v2/4_erc20-interactions.md index 00ae8bf..bd01661 100644 --- a/docs/v2/4_erc20-interactions.md +++ b/docs/v2/4_erc20-interactions.md @@ -1,5 +1,5 @@ --- -slug: /current/erc20-interactions +slug: /2.1.0/erc20-interactions sidebar_position: 4 sidebar_label: ERC-20 Interactions --- diff --git a/docs/v2/5_erc721-interactions.md b/docs/v2/5_erc721-interactions.md index b14bca1..ebc1bbe 100644 --- a/docs/v2/5_erc721-interactions.md +++ b/docs/v2/5_erc721-interactions.md @@ -1,5 +1,5 @@ --- -slug: /current/erc721-interactions +slug: /2.1.0/erc721-interactions sidebar_position: 5 sidebar_label: ERC-721 Interactions --- diff --git a/docs/v2/6_erc1155-interactions.md b/docs/v2/6_erc1155-interactions.md index 72e145e..1009725 100644 --- a/docs/v2/6_erc1155-interactions.md +++ b/docs/v2/6_erc1155-interactions.md @@ -1,5 +1,5 @@ --- -slug: /current/erc1155-interactions +slug: /2.1.0/erc1155-interactions sidebar_position: 6 sidebar_label: ERC-1155 Interactions --- diff --git a/docs/v2/7_using-the-minter.md b/docs/v2/7_using-the-minter.md index cee6416..685bdfd 100644 --- a/docs/v2/7_using-the-minter.md +++ b/docs/v2/7_using-the-minter.md @@ -1,5 +1,5 @@ --- -slug: /current/using-the-minter +slug: /2.1.0/using-the-minter sidebar_position: 7 sidebar_label: Using The NFT Minter --- diff --git a/docs/v2/8_in-game-marketplace.md b/docs/v2/8_in-game-marketplace.md index c3a09fa..d18ddc8 100644 --- a/docs/v2/8_in-game-marketplace.md +++ b/docs/v2/8_in-game-marketplace.md @@ -1,5 +1,5 @@ --- -slug: /current/in-game-marketplace +slug: /2.1.0/in-game-marketplace sidebar_position: 8 sidebar_label: In-game NFT Marketplace --- diff --git a/docs/v2/9_minting-with-voucher.md b/docs/v2/9_minting-with-voucher.md index a424d08..82d4559 100644 --- a/docs/v2/9_minting-with-voucher.md +++ b/docs/v2/9_minting-with-voucher.md @@ -1,5 +1,5 @@ --- -slug: /current/minting-with-voucher +slug: /2.1.0/minting-with-voucher sidebar_position: 9 sidebar_label: Voucher-based NFT Minting --- diff --git a/sidebars.js b/sidebars.js index 0761618..9eaea44 100644 --- a/sidebars.js +++ b/sidebars.js @@ -10,12 +10,17 @@ module.exports = { 'chainsafe-gaming', { type: 'category', - label: 'SDK Documentation (v2.x)', - items: ['v2/project-id-registration', 'v2/setting-up-an-rpc-node', 'v2/installation', 'v2/erc20-interactions', 'v2/erc721-interactions', 'v2/erc1155-interactions', 'v2/using-the-minter', 'v2/in-game-marketplace', 'v2/minting-with-voucher', 'v2/webgl-browser', 'v2/web3wallet-mobile-and-desktop', 'v2/web3auth', 'v2/keep-your-games-safe-from-cheaters', 'v2/importing-nfts', 'v2/implementing-social-logins-to-webgl-builds', 'v2/how-tos', 'v2/migration', 'v2/faq', 'v2/media'], + label: 'Current SDK Documentation (v2.5.0+)', + items: ['v2.5/cheatsheet', 'v2.5/getting-started', 'v2.5/project-id-registration', 'v2.5/setting-up-an-rpc-node', 'v2.5/configuration', 'v2.5/signers-and-wallets', 'v2.5/connecting-a-wallet', 'v2.5/cheatsheet', 'v2.5/interacting-with-tokens', 'v2.5/interacting-with-nfts', 'v2.5/minting-nft', 'v2.5/interacting-with-smart-contracts', 'v2.5/web2-like-authentication-using-web3auth', 'v2.5/gasless-transactions-using-gelato', 'v2.5/extending-the-sdk', 'v2.5/lootboxes', 'v2.5/block-racers-game', 'v2.5/example-scene'], }, { type: 'category', - label: 'Legacy Documentation (v1.x)', + label: 'Previous SDK Documentation (v2.1.0)', + items: ['v2/project-id-registration', 'v2/setting-up-an-rpc-node', 'v2/installation', 'v2/erc20-interactions', 'v2/erc721-interactions', 'v2/erc1155-interactions', 'v2/using-the-minter', 'v2/in-game-marketplace', 'v2/minting-with-voucher', 'v2/webgl-browser', 'v2/web3wallet-mobile-and-desktop', 'v2/keep-your-games-safe-from-cheaters', 'v2/importing-nfts', 'v2/implementing-social-logins-to-webgl-builds', 'v2/how-tos', 'v2/migration', 'v2/faq', 'v2/media'], + }, + { + type: 'category', + label: 'Legacy API Documentation (v1.6.3)', items: ['v1/getting-started', 'v1/tutorial', 'v1/installation', 'v1/project-id-registration', 'v1/evm-blockchain', 'v1/erc1155', 'v1/erc721', 'v1/erc20', 'v1/custom-interactions', 'v1/minter-evm', 'v1/in-game-marketplace', 'v1/minting-with-voucher', 'v1/webgl', 'v1/mobile-and-desktop', 'v1/keep-your-games-safe-from-cheaters', 'v1/importing-nfts', 'v1/implementing-social-logins-to-webgl-builds', 'v1/how-tos', 'v1/media', 'v1/faq',], }, ],