Cronos EVM Docs
  • Getting Started
    • Getting Started
    • Background
    • Architecture
    • Cronos roadmap
  • FOR USERS
    • 💳Crypto.com Card Top Up
    • 🔥Crypto Wallets
    • 🦊MetaMask Configuration
    • 🦁Brave Wallet
    • 🌉Bridges
      • From the Crypto.com App and Exchange
        • From the Crypto.com App
        • From the Crypto.com Exchange
      • IBC (Cronos POS Chain, other Cosmos chains)
        • Cronos Bridge Web App
      • Independent bridges
      • FAQs for Bridge transfers
      • FAQs for transactions from/to centralized exchanges
    • 🚰Testnet Faucet
    • 💡Tips & FAQs
    • 👮Key Principles for Wallet Security
    • GasTracker
  • FOR DAPP DEVELOPERS
    • 💡Founder FAQs
    • 🏅Hacker's Getting Started Resources
    • 📃Smart Contracts
      • Contract Development on Testnet
      • Contract Deployment and Verification
      • Contract Verification Export: Cronoscan To Cronos Explorer
      • Best Practices
      • Token Contract Addresses
    • 💻dApp Creation
      • Free and commercial RPC endpoints
      • Wallet integrations
      • Web3-wallet
      • JSON-RPC methods
      • Address Conversion
      • Swagger Playground
    • ⚙️Dev Tools & Integrations
      • All dev tools & integrations
      • Account Abstraction
      • Band Protocol
      • Banxa
      • GoldRush
      • Cronos Safe
      • Flair
      • Google Bigquery
      • Moralis
      • Pyth
      • Secret Network
      • SubQuery
      • Witnet
    • Crypto.com AI Agent SDK
  • FOR NODE HOSTS
    • Running nodes
      • Cronos Mainnet
        • Quicksync
        • State-sync
        • Public Node Sync
        • KSYNC
        • The "Huygen" upgrade guide (v0.6.* to v0.7.*)
        • The "v0.7.0-hotfix" upgrade guide (v0.7.* to v0.8.*)
        • The "Galileo" upgrade guide (v0.8.* to v1.0.*)
        • The "Titan" upgrade guide (v1.0.* to v1.1.0)
        • The "v1.2" upgrade guide (v1.1.* to v1.2.0)
        • The "v1.3" upgrade guide (v1.2.* to v1.3.0)
        • The "v1.4" Pallene upgrade guide (v1.3.* to v1.4.1)
        • Patching Unlucky & Duplicate Tx
      • Cronos Testnet
      • Devnet
      • Best Practices
      • Cronosd build with Nix
      • VersionDB
      • MemIAVL
      • Local State Sync
    • Cronosd
  • CRONOS PLAY
    • Introduction
    • Unity Engine
      • Current Version
      • Legacy Version
        • EVM
        • Login Example
        • Custom RPC
        • ERC20
        • ERC721
        • ERC1155
      • Useful Links
    • Unreal Engine
      • Installation and Enabling
      • Working with Blueprint
        • Actors and Blueprint Classes
        • Cronos Configuration
        • Connect Defi Desktop/Onchain Wallet with URI
        • Connect Wallets with QR Code
        • Connect WalletConnect Step by Step
        • WalletConnect 2.0 and Unreal Engine 5: Hello World Example
        • Wallet
        • ERC20
        • ERC721
        • ERC1155
        • Broadcast Transactions
        • Get Tokens or Transactions
      • Working with C++
        • Creating a C++ Project
        • Creating a child DefiWalletCoreActor
        • Querying a contract
        • Customizing Network
      • Demo
    • Cronos Play C++ SDK
    • Crypto.com Pay Integration
    • Cronos Play FAQ
  • Block Explorers
    • Block Explorer and API Keys
    • Cronos Explorer
    • Cronoscan
  • CRONOS CHAIN PROTOCOL
    • Chain ID and Address Format
    • Cronos General FAQ
    • Genesis
    • Modules
      • module_bank
      • module_distribution
      • module_slashing
      • module_feemarket
    • Chain Details
      • List of parameters
      • Technical glossary
      • Protocol Documentation
    • Common IBC Commands
  • Cronos zkEVM
    • Cronos zkEVM
  • Resources
    • Media / brand kit
Powered by GitBook
On this page
  • Install via Package Manager With Open UPM
  • Updating via The Package Manager
  • Set Project ID
  • Chain Settings
  • Example Scene
  • Cheat Sheet
  • Configuration

Was this helpful?

Edit on GitHub
  1. CRONOS PLAY
  2. Unity Engine

Current Version

PreviousUnity EngineNextLegacy Version

Last updated 5 months ago

Was this helpful?

Install via Package Manager With Open UPM

  1. On the top bar in unity, navigate to Window -> Package Manager -> Gear icon -> Advanced Project Settings.

  2. Add a new scoped registry or edit the existing OpenUPM entry if it's already there.

  3. Save the following details to the scope:

  • Name: package.openupm.com

  • URL:

  • Scope: io.chainsafe.web3-unity

  1. Add a new package by name by pressing + -> Add package by name io.chainsafe.web3-unity & io.chainsafe.web3-unity.web3auth.

  2. Next go to the web3.unity SDK package and install the examples by going to the samples tab and pressing import.

Please note that unity versions 2021 and below may require a restart if you experience assembly errors.

Updating via The Package Manager

Updating the SDK is easy. Simply go to window -> package manager -> select the ChainSafe SDK package & press update. The same can be done for any additional packages you have installed, web3auth, loot boxes etc.

Set Project ID

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.

If the Settings do not appear, please restart the project and they should appear under the windows tab.

Chain Settings

You need to set up default settings for the RPC node you're going to use for the Cronos chain.

  • Chain ID - 25

  • Chain name - Cronos

  • Network - Mainnet

  • Symbol - CRO

  • RPC - https://evm-dev.cronos.org

  • Chain ID - 338

  • Chain name - Cronos

  • Network - Testnet

  • Symbol - TCRO

  • RPC: - https://evm-t3.cronos.org

Example Scene

If you navigate to Window -> Package Manager -> Web3Unity SDK -> Samples, you can import an example package to help you understand the SDK. Press import and let it load into the project. You'll see some new files in your project under samples, these files contain everything we need to get started with the SDK. Have a look around, check out the script and the scene locations.

You'll notice when you import the samples into the project that some scenes are added to your build configuration. This is to show you a demo of how all the functions in the SDK work. Simply go to the sample log in scene and press play to connect a wallet to get started with some examples.

Once you've logged in it will take you to the main scene. You can play around in the menus and check out each script's functionality by pressing the show script button, this will highlight the script in the editor and allow you to inspect it further. If you're an advanced developer you should have enough to work with from the sample scripts in front of you. If you're just beginning we suggest you take a look at our easy to use prefabs below.

Cheat Sheet

This is a Cheat Sheet 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.

async void Start()
{
    // Configure & build Web3 client using Web3Builder
    var projectConfig = ProjectConfigUtilities.Load();
    var web3 = await new Web3Builder(projectConfig).Configure(services =>
        {
            services.UseUnityEnvironment();
            services.UseRpcProvider();


            var config = new WalletConnectConfig
            {
                // Set wallet to testing
                Testing = true,
                TestWalletAddress = "YOUR_WALLET_ADDRESS",
            };


            services.UseWalletConnect(config);
            services.UseWalletConnectSigner();
            services.UseWalletConnectTransactionExecutor();


            // Add any contracts we would want to use
            services.ConfigureRegisteredContracts(contracts =>
                contracts.RegisterContract("CsTestErc20", ABI.Erc20, Contracts.Erc20));
        }).LaunchAsync();


    // 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);
}

Configuration

As the package is installed, you'll be prompted with the settings window. First of all you have to set up your Project ID. You can get one .

For more information on Project ID, see .

For Additional configuration, please refer to the official Chainsafe Documentation .

here
Project ID Registration
here
https://package.openupm.com