Standard

Follow this guide to do a standard integration of Vessel within your app:

Minimum requirements:

Unity

  • Unity version 2019.4+

  • Unity IAP 4.+

Android

  • Android API level 24 (Android OS 7.0) or higher.

iOS

  • iOS 13.0 or higher

Integrate the Vessel SDK

Follow one of the following sets of instructions to integrate Vessel SDK into your project:

  1. Download the latest version of Unity SDK from https://artifacts.openvessel.io/unity/OpenVessel-1.17.1.unitypackage

  2. In Unity, select Assets > Import Package > Custom Package…

  3. Choose the Unity Plugin file you downloaded.

  4. In the Import Unity Package dialog, click Import.

When you want to update the SDK version, you need to run the command below.

iOS

Run pod update in a root directory of an iOS project.

Android

1) Assets > External Dependency Manager > Android > Delete Resolved Libraries

2) Assets > External Dependency Manager > Android Resolver > Force Resolve

Import Packages

using OVSdk;

Staging Environment

AppLovin recommends that you test your integration in the staging environment. Before you release your project, make sure to change your release version so that it points to production instead. You can point your project to the staging environment with code like the following:

OVSdk.Sdk.Environment = VesselEnvironment.Staging;

Read the Staging Environment page for more information about environment management:

Staging Environment

Add a Connect Listener

Add a listener that is notified when your application connects to the Vessel Wallet:

OVSdk.AppConnectManagerCallbacks.OnStateUpdated += HandleStateUpdate;

// Listener definition
private void HandleStateUpdate(OVSdk.AppConnectState state)
{
    // ...
}

The AppConnectState object has the following attributes:

Name
Type
Description

Status

AppConnectStatus

The current connection status (see below).

WalletAddress

string

The address of the connected user wallet. This is null if the wallet is not connected

AccessToken

string

JWT token of user session.

AccessToken example
eyJhbGciOiJFUzI1NiJ9.eyJpc3MiOiJodHRwczovL3dhbGxldC5zdGFnZS5vcGVudmVzc2VsLmlvIiwiZXhwIjoxNjc2NTU0MTkyLCJzdWIiOiJ1YTczOTUzOTgxZWE0NDQzMmZmMTc4NWNiYmI2MTYwMDI3IiwiYXVkIjoiYSIsImlhdCI6MTY3NjUzNjE5MiwiciI6IlRYIiwic2kiOiJ1czAxNjA1M2YwZGFiMjQzM2ViNmM0ZDEwYTU1ZjMzNzlkIiwic2UiOjE2NzY1MzYxOTIsIndhIjoiMHhlMTE3MTVmYTI4MTI2Y2Y5ZjAwYjEwYzQxYTcyMDY0ZWQzZGY0ZDk3Iiwid3QiOiJDVVNUT0RJQUwiLCJ2ZXJpZmllZCI6IlAiLCJzIjoiV0VCOnBvcnRhbC5zdGFnZS5vcGVudmVzc2VsLmlvIiwibCI6ImVuLUdCIiwidSI6IiIsImt2IjoyLCJ0dWFpZCI6InVhNzM5NTM5ODFlYTQ0NDMyZmYxNzg1Y2JiYjYxNjAwMjcifQ.UEg9ycYLJb-2BRiBzfniMQNpTpGkIpbtUa_ZjEIsi6KPmLRJ2FiOg3CwCaFFbAE16tOc8AzHgM0463TnFTqjOg

Decoding

{
  "iss": "https://wallet.stage.openvessel.io",
  "exp": 1676554192,
  "sub": "ua73953981ea44432ff1785cbbb6160027",
  "aud": "a",
  "iat": 1676536192,
  "r": "TX",
  "si": "us016053f0dab2433eb6c4d10a55f3379d",
  "se": 1676536192,
  "wa": "0xe11715fa28126cf9f00b10c41a72064ed3df4d97",
  "wt": "CUSTODIAL",
  "verified": "P",
  "s": "WEB:portal.stage.openvessel.io",
  "l": "en-GB",
  "u": "",
  "kv": 2,
  "tuaid": "ua73953981ea44432ff1785cbbb6160027"
}
wa - User wallet address
u - In-game user id
iss - Environment
verified - Verification type(P - phone number; E - email; P,E - both verified)

The AppConnectStatus enum has the following possible values:

Type
Description

NotInitialized

SDK is not initialized. This is the initial status.

Disconnected

The wallet is not connected yet or is disconnected.

Connected

The wallet is connected.

ErrorCanceled

A user has explicitly canceled the app connect operation.

ErrorDeclined

A user declined an app connect operation or the operation is expired.

ErrorWalletNotInstalled

Vessel Wallet is not installed on user’s device.

Error

A non-recoverable error has occurred.

Initialize the SDK

You must initialize the Vessel SDK before you can use it. Initializing the SDK triggers the first notification of the App Connect Listener that contains the initial state.

Important: You must pass a unique in-game user ID during initialization.

Important: You need to initialize the SDK at launch of your application to track wallet connections accurately.

Use the following code snippet below to initialize our SDK:

OVSdk.Sdk.Initialize("in-game-user-id");

In-game user ID

You need to pass your own in-game user ID or you need to create a user specific ID. This can be any string and it isn't something provided by Vessel.

Connect Wallet

When your game connects to the wallet application, this opens up our Vessel wallet app and prompts the user to confirm the connection with your game.

Vessel delivers the result of this app connect operation via the App Connect Listener.

Important: You must pass a unique in-game user ID when connecting the wallet.

The code snippet below will invoke the pre-built UI provided by the Vessel SDK:

OVSdk.Sdk.AppConnectManager.LoadConnectWalletView("in-game-user-id");

If you want to use your own UI to connect wallet, please refer to Connect Wallet - Native section.

Show User Wallet

After your application connects to the user’s wallet, you can show an In-app WebView that allows the user to inspect and interact with their wallet.

OVSdk.Sdk.WalletPresenter.ShowWallet();

Show the Game/Collection/Token Page

You can render your Vessel Game Store, Collection, and Token page within your application in a WebView using the following code below:

// Show the game level info
// fqgn: Fully Qualified Game Name ("com.studio.game")
OVSdk.Sdk.WalletPresenter.ShowGame(fqgn);

// Show the collection level info
// fqcn: Fully Qualified Collection Name ("com.studio.game.collection")
OVSdk.Sdk.WalletPresenter.ShowCollection(fqcn);

// Show the token level info
// fqtn: Fully Qualified Token Name ("com.studio.game.collection.token")
OVSdk.Sdk.WalletPresenter.ShowToken(fqtn);

Callbacks for opening/closing the WebView

OVSdk.WalletPresenterCallbacks.OnWalletShow += HandleWalletShow;
OVSdk.WalletPresenterCallbacks.OnWalletDismiss += HandleWalletDismiss;

private void HandleWalletShow()
{
    // a wallet is about to present
}

private void HandleWalletDismiss()
{
    // a wallet is about to dismiss
}

Show the Wallet/Game/Collection/Token Page in the Vessel application

You can render your Vessel Wallet, Game, Collection, and Token page directly in the Vessel application. If the Vessel application is not installed on the device, you will be offered with installing it from the store page.

// Show the wallet info
OVSdk.Sdk.WalletPresenter.OpenWalletApplication();

// Show the game level info
// fqgn: Fully Qualified Game Name ("com.studio.game")
OVSdk.Sdk.WalletPresenter.OpenGameInWalletApplication(fqgn);

// Show the collection level info
// fqcn: Fully Qualified Collection Name ("com.studio.game.collection")
OVSdk.Sdk.WalletPresenter.OpenCollectionInWalletApplication(fqcn);

// Show the token level info
// fqtn: Fully Qualified Token Name ("com.studio.game.collection.token")
OVSdk.Sdk.WalletPresenter.OpenTokenInWalletApplication(fqtn);

Confirm the transaction

You can confirm the transaction detail in the Vessel wallet app.

OVSdk.Sdk.WalletPresenter.ConfirmTransactionInWalletApplication(transactionId);

Last updated

Was this helpful?