ChainSafe SDK overview
ChainSafe is a library that provides an operational link between Unity and Caduceus. ChainSafe is easily pullable into Unity. Chainsafe utilizes prefabricated components primarily.
Prefabs are prebuilt components that supply pre-configured functionality. The SDK offers this for most general operations such as how to connect an NFT deployed on Caduceus to a game on Unity.
Games can then be packaged for the Web using OpenGL, or for mobile devices such as Android and iOS.
The ChainSafe SDK is comprised of independent compoinents that can work on their own, or together. These are the
- the Web3Wallet Library
- the EVM Library
- the Web3GL Library
- Prefabs that enable drag and drop of the libraries functionality into Unity games.
The SDK's assets are structured in the following hierarchy:
Library Under Web3Unity>Scripts
The library under the scripts folder powers the entire ChainSafe SDK service. This library contains scripts that drive all the prefabs, encapsulating functionality in easy to utilize objects such as ERC20.
The Web3Wallet Library is used for Wallet based or Signed Transactions. This would account for the majority of connection use cases that involve Wallets.
The EVM class is at web3.unity/Web3Unity/Scripts/Library/EVM.cs
This class connects to a permissioned API host endpoint at "https://api.gaming.chainsafe.io/evm"
Blockchain and network strings resolve to actual data at the above endpoint. In contrast to Web3Wallet, you cannot call the blockchain using the chain ID directly through the EVM Class.
EVM calls are utilized by upper level libraries such as ERC 20 and ERC 721. EVM calls utilize Unity's own WebRequest.POST methods
Typical fields utilized by EVM include:
string _chain, string _network, string _contract, string _abi, string _method, string _args, string _multicall
When used as an object, the class's methods are used as follows:
await EVM.CreateMint(chain, network, account, to, cid721, type721);
chain, network, and account must be provided as strings and are pre-set at API endpoint.
The IPFS library allows for Unity to connect to IPFS to perform NFT file upload and file related functions.
A typical call to IPFS is as follows:
(APIhost+ "/api/v1/bucket/" + bucketId + "/upload", formUpload);