> For the complete documentation index, see [llms.txt](/llms.txt).

# Integrate Embedded Wallets with the Flare Blockchain in Unity

While using the Web3Auth Unity SDK, you get the private key within the user scope. This private key can interact with the [Nethereum Library](https://nethereum.com/) to make EVM based blockchain calls, like getting user's `account`, fetch `balance`, `sign transaction`, `send transaction`, `read` from and `write` to the smart contract, etc. We have highlighted a few here for getting you started quickly on that.

## Chain details for Flare[​](#chain-details-for-flare "Direct link to Chain details for Flare")

- Mainnet
- Coston2 Testnet

- **Chain ID:** 0xE
- **Public RPC URL:** `https://flare-api.flare.network/ext/C/rpc`
- **Display Name:** Flare Mainnet
- **Block Explorer Link:** `https://flare-explorer.flare.network`
- **Ticker:** FLR
- **Ticker Name:** Flare

- **Chain ID:** 0x72
- **Public RPC URL:** `https://coston2-api.flare.network/ext/C/rpc`
- **Display Name:** Flare Coston2 Testnet
- **Block Explorer Link:** `https://coston2-explorer.flare.network`
- **Ticker:** C2FLR
- **Ticker Name:** Coston2 Flare

## Installation[​](#installation "Direct link to Installation")

In this reference, we're using the `Nethereum` library to demonstrate how to make blockchain calls using it with Web3Auth.

### Package installation instructions[​](#package-installation-instructions "Direct link to Package installation instructions")

See the [Official repository](https://github.com/Nethereum/Nethereum.Unity).

Install via **Package Manager** using OpenUpm:

- open Edit/Project Settings/Package Manager
- add a new **Scoped Registry** (or edit the existing OpenUPM entry)

  - Name package.openupm.com
  - URL <https://package.openupm.com>
  - `Scope(s)` com.nethereum.unity
- click Save or Apply
- Open **Window/Package Manager**
- click **+**
- select Add package by name... or Add package from git URL...
- paste **com.nethereum.unity** into name
- paste **4.19.2** into version (or your preferred one)
- click **Add**

### Installing package for old version[​](#installing-package-for-old-version "Direct link to Installing package for old version")

- Download the latest `net461dllsAOT.zip` package from Nethereum's [latest release](https://github.com/Nethereum/Nethereum/releases)
- Extract and the rename the folder to `NethereumLib` for easy identification.
- Move the folder to the `Assets/Plugins` folder of your Unity project.
- You might have to delete a few files from the `NethereumLib` folder, if you're getting any errors while building the project. For our implementation, we deleted the following files: `Newtonsoft.Json.dll`, all the files starting with `System.*`, `UnityEngine.dll`, `Nethereum.Web3Lite.dll`, `Nethereum.HdWallet.dll`, `NBitcoin.dll`, `Nethereum.RPC.Reactive.dll`and `Common.Logging.Core.dll`.

info

We have followed [this guide](https://docs.nethereum.com/) to set up the `Nethereum` package in our app. You can check their sample applications as well for a decent reference.

You can also check the [Web3Auth Unity Sample Apps](https://github.com/Web3Auth/web3auth-unity-examples), where we have added the required packages.

## Initialize[​](#initialize "Direct link to Initialize")

```
using Nethereum.Web3;
using Nethereum.Util;
using Nethereum.Signer;
using Nethereum.Hex.HexConvertors.Extensions;
using Nethereum.ABI.Encoders;
using Nethereum.Hex.HexTypes;
using Nethereum.Web3.Accounts;
using Nethereum.Web3.Accounts.Managed;

public class Web3AuthScript : MonoBehaviour
{
    Web3 web3;
    Web3Auth web3Auth;
    private string privateKey;
    private Account account;

    const string rpcURL = "" // EVM chain RPC URL

    void Start()
    {

      web3Auth = GetComponent<Web3Auth>();

      // Add Web3Auth Unity SDK Initialisation Code here

      web3Auth.onLogin += onLogin;
      web3Auth.onLogout += onLogout;
      web3 = new Web3(rpcURL);
    }

    private void onLogin(Web3AuthResponse response)
    {
        privateKey = response.privKey;
        var newAccount = new Account(privateKey);
        account = newAccount;
    }
// ...
}

```

## Get account[​](#get-account "Direct link to Get account")

In this reference, we're using the `Nethereum` library to demonstrate how to make blockchain calls using it with Web3Auth.

# Package installation instructions

See the [official repository](https://github.com/Nethereum/Nethereum.Unity)

Install via **Package Manager** using OpenUpm:

- open Edit/Project Settings/Package Manager
- add a new **Scoped Registry** (or edit the existing OpenUPM entry)

  - Name package.openupm.com
  - URL <https://package.openupm.com>
  - `Scope(s)` com.nethereum.unity
- click Save or Apply
- Open **Window/Package Manager**
- click **+**
- select Add package by name... or Add package from git URL...
- paste **com.nethereum.unity** into name
- paste **4.19.2** into version (or your preferred one)
- click **Add**

# Installing package for old version

- Download the latest `net461dllsAOT.zip` package from Nethereum's [latest release](https://github.com/Nethereum/Nethereum/releases)
- Extract and the rename the folder to `NethereumLib` for easy identification.
- Move the folder to the `Assets/Plugins` folder of your Unity project.
- You might have to delete a few files from the `NethereumLib` fold er, if you're getting any errors while building the project. For our implementation, we deleted the following files: `Newtonsoft.Json.dll`, all the files starting with `System.*`, `UnityEngine.dll`, `Nethereum.Web3Lite.dll`, `Nethereum.HdWallet.dll`, `NBitcoin.dll`, `Nethereum.RPC.Reactive.dll`and `Common.Logging.Core.dll`.

info

We have followed [this guide](https://docs.nethereum.com/) to set up the `Nethereum` package in our app. You can check their sample applications as well for a decent reference.

You can also check the [Web3Auth Unity Sample Apps](https://github.com/Web3Auth/web3auth-unity-examples), where we have added the required packages.

## Get balance[​](#get-balance "Direct link to Get balance")

```
public void getBalance() {
  if (account == null) {
    Debug.Log("Please Login First");
    return;
  }
  var balance = web3.Eth.GetBalance.SendRequestAsync(account.Address).Result.Value;

  Debug.Log(balance);
}

```

## Sign a message[​](#sign-a-message "Direct link to Sign a message")

```
public void signMessage() {
  if (account == null) {
    Debug.Log("Please Login First");
    return;
  }
  var msg = "test message 19/01/2023 02:55PM";
  var signer = new EthereumMessageSigner();
  var signature = signer.EncodeUTF8AndSign(msg, new EthECKey(privateKey));

  Debug.Log(signature);
}

```

## Send transaction[​](#send-transaction "Direct link to Send transaction")

```
public async void sendTransaction() {
  if (account == null) {
    Debug.Log("Please Login First");
    return;
  }
  var toAddress = "0x2E464..82D5057fB507Cc21";
  var transaction = await web3.TransactionManager.SendTransactionAsync(account.Address, toAddress, new Nethereum.Hex.HexTypes.HexBigInteger(1));

  Debug.Log(transaction);
}

```
