# Standard

{% hint style="info" %}
**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
  {% endhint %}

## Integrate the Vessel SDK&#x20;

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

{% tabs %}
{% tab title="Unity" %}

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**.
   {% endtab %}

{% tab title="Android" %}
Add the following to your app-level `build.gradle` file:

```groovy
repositories {
    google()
    mavenCentral()
    jcenter()
    maven {
        url "https://artifacts.openvessel.io/maven/"
    }
}
dependencies {
    implementation 'io.openvessel:sdk:1.17.+'
}
```

{% endtab %}

{% tab title="iOS (Cocoapods)" %}

1. Add the following lines to your `Podfile`:

```
source 'https://cdn.cocoapods.org' 
source 'https://github.com/OpenVesselIO/Wallet-Pods-iOS.git'
⋮
target '<YOUR PROJECT>' do
  pod 'OpenVesselSDK', '~> 1.17.1'
end

```

\
2\. Add `vesselwa` scheme to your `Info.plist`

```
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>vesselwa</string>
</array>
```

{% endtab %}
{% endtabs %}

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

{% tabs %}
{% tab title="Unity" %}

#### 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`
{% endtab %}

{% tab title="Android" %}

#### System

Clear the Gradle cache in your system in the following paths:

* On Windows: `%USERPROFILE%\.gradle\caches`
* On Mac / UNIX: `~/.gradle/caches/`

#### IntelliJ IDEA

Click the refresh arrows in the Gradle tool window.

#### Android Studio

Click the elephant + arrow icon in the toolbar.
{% endtab %}

{% tab title="iOS" %}
Run `pod update` in a root directory of an iOS project.
{% endtab %}
{% endtabs %}

## Import Packages

{% tabs %}
{% tab title="Unity" %}

```csharp
using OVSdk;
```

{% endtab %}

{% tab title="Android" %}

```java
import io.openvessel.wallet.sdk.VesselEnvironment;
import io.openvessel.wallet.sdk.VesselSdk;
```

{% endtab %}

{% tab title="iOS" %}

```objectivec
#import <OpenVessel/OpenVessel.h>
```

{% endtab %}
{% endtabs %}

## 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:

{% tabs %}
{% tab title="Unity" %}

```csharp
OVSdk.Sdk.Environment = VesselEnvironment.Staging;
```

{% endtab %}

{% tab title="Android" %}

```java
VesselSdk.getInstance( activity )
         .setEnvironment(VesselEnvironment.STAGING);
```

{% endtab %}

{% tab title="iOS" %}

```objectivec
[[OVLSdk sharedInstance] setEnvironment: OVLEnvironmentStaging]; 
```

{% endtab %}
{% endtabs %}

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

{% content-ref url="/pages/pcwGM64ULAqVQXVc6qXv" %}
[Staging Environment](/integration/EZzgG67O9oXGl9CReheF/misc/staging-environment.md)
{% endcontent-ref %}

## Add a Connect Listener

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

{% tabs %}
{% tab title="Unity" %}

```objectivec
OVSdk.AppConnectManagerCallbacks.OnStateUpdated += HandleStateUpdate;

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

{% endtab %}

{% tab title="Android" %}

```java
VesselSdk.getInstance( activity )
         .getAppConnectManager()
         .setAppConnectListener( listener );
         
// Listener definition
public void onStateUpdated(final AppConnectManager manager)
{
    final AppConnectState newState = manager.getState();
    // ...
}
```

{% endtab %}

{% tab title="iOS" %}

```objectivec
[[OVLSdk sharedInstance].appConnectManager setDelegate: delegate
                           delegateQueue: dispatch_get_main_queue()
];

// Delegate definition
- (void)appConnectManagerDidUpdateState:(OVLAppConnectManager *)appConnectManager
{
    OVLAppConnectState * newState = appConnectManager.state;
    // ...
}

```

{% endtab %}
{% endtabs %}

The `AppConnectState` object has the following attributes:

<table><thead><tr><th width="157.33333333333331">Name</th><th width="188.42105263157896">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>Status</code></td><td><code>AppConnectStatus</code></td><td>The current connection status (see below).</td></tr><tr><td><code>WalletAddress</code></td><td><code>string</code></td><td>The address of the connected user wallet. This is <code>null</code> if the wallet is not connected</td></tr><tr><td><code>AccessToken</code></td><td><code>string</code></td><td>JWT token of user session.</td></tr></tbody></table>

<details>

<summary><code>AccessToken</code> example</summary>

{% code overflow="wrap" %}

```
eyJhbGciOiJFUzI1NiJ9.eyJpc3MiOiJodHRwczovL3dhbGxldC5zdGFnZS5vcGVudmVzc2VsLmlvIiwiZXhwIjoxNjc2NTU0MTkyLCJzdWIiOiJ1YTczOTUzOTgxZWE0NDQzMmZmMTc4NWNiYmI2MTYwMDI3IiwiYXVkIjoiYSIsImlhdCI6MTY3NjUzNjE5MiwiciI6IlRYIiwic2kiOiJ1czAxNjA1M2YwZGFiMjQzM2ViNmM0ZDEwYTU1ZjMzNzlkIiwic2UiOjE2NzY1MzYxOTIsIndhIjoiMHhlMTE3MTVmYTI4MTI2Y2Y5ZjAwYjEwYzQxYTcyMDY0ZWQzZGY0ZDk3Iiwid3QiOiJDVVNUT0RJQUwiLCJ2ZXJpZmllZCI6IlAiLCJzIjoiV0VCOnBvcnRhbC5zdGFnZS5vcGVudmVzc2VsLmlvIiwibCI6ImVuLUdCIiwidSI6IiIsImt2IjoyLCJ0dWFpZCI6InVhNzM5NTM5ODFlYTQ0NDMyZmYxNzg1Y2JiYjYxNjAwMjcifQ.UEg9ycYLJb-2BRiBzfniMQNpTpGkIpbtUa_ZjEIsi6KPmLRJ2FiOg3CwCaFFbAE16tOc8AzHgM0463TnFTqjOg
```

{% endcode %}

**Decoding**

{% code overflow="wrap" %}

```json
{
  "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"
}
```

{% endcode %}

```
wa - User wallet address
u - In-game user id
iss - Environment
verified - Verification type(P - phone number; E - email; P,E - both verified)
```

</details>

The `AppConnectStatus` enum has the following possible values:

{% tabs %}
{% tab title="Unity" %}

<table><thead><tr><th width="282.51690294438384">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>NotInitialized</code></td><td>SDK is not initialized. This is the initial status.</td></tr><tr><td><code>Disconnected</code></td><td>The wallet is not connected yet or is disconnected.</td></tr><tr><td><code>Connected</code></td><td>The wallet is connected.</td></tr><tr><td><code>ErrorCanceled</code></td><td>A user has explicitly canceled the app connect operation.</td></tr><tr><td><code>ErrorDeclined</code></td><td>A user declined an app connect operation or the operation is expired.</td></tr><tr><td><code>ErrorWalletNotInstalled</code></td><td>Vessel Wallet is not installed on user’s device.</td></tr><tr><td><code>Error</code></td><td>A non-recoverable error has occurred.</td></tr></tbody></table>
{% endtab %}

{% tab title="Android" %}

<table><thead><tr><th width="282.51690294438384">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>NOT_INITIALIZED</code></td><td>SDK is not initialized. This is the initial status.</td></tr><tr><td><code>DISCONNECTED</code></td><td>The wallet is not connected yet or is disconnected.</td></tr><tr><td><code>CONNECTED</code></td><td>The wallet is connected.</td></tr><tr><td><code>ERROR_CANCELED</code></td><td>A user has explicitly canceled the app connect operation.</td></tr><tr><td><code>ERROR_DECLINED</code></td><td>A user declined an app connect operation or the operation is expired.</td></tr><tr><td><code>ERROR_WALLET_NOT_INSTALLED</code></td><td>Vessel Wallet is not installed on user’s device.</td></tr><tr><td><code>ERROR</code></td><td>A non-recoverable error has occurred.</td></tr></tbody></table>
{% endtab %}

{% tab title="iOS" %}

<table><thead><tr><th width="282.51690294438384">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>OVLAppConnectStatusNotInitialized</code></td><td>SDK is not initialized. This is the initial status.</td></tr><tr><td><code>OVLAppConnectStatusDisconnected</code></td><td>The wallet is not connected yet or is disconnected.</td></tr><tr><td><code>OVLAppConnectStatusConnected</code></td><td>The wallet is connected.</td></tr><tr><td><code>OVLAppConnectStatusCancelled</code></td><td>A user has explicitly canceled the app connect operation.</td></tr><tr><td><code>OVLAppConnectStatusDeclined</code></td><td>A user declined an app connect operation or the operation is expired.</td></tr><tr><td><code>OVLAppConnectStatusWalletNotInstalled</code></td><td>Vessel Wallet is not installed on user’s device.</td></tr><tr><td><code>OVLAppConnectStatusError</code></td><td>A non-recoverable error has occurred.</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

## 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](#undefined) that contains the initial state.

{% hint style="info" %}
**Important:** You must pass a unique in-game user ID during initialization.
{% endhint %}

{% hint style="info" %}
**Important:** You need to initialize the SDK at launch of your application to track wallet connections accurately.
{% endhint %}

Use the following code snippet below to initialize our SDK:

{% tabs %}
{% tab title="Unity" %}

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

{% endtab %}

{% tab title="Android" %}

```
VesselSdk.getInstance( activity )
         .initialize("in-game-user-id");
```

{% endtab %}

{% tab title="iOS" %}

```
[[[OVLSdk sharedInstance] startWithUserId: @"in-game-user-id"];
```

{% endtab %}
{% endtabs %}

### 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](#add-a-connect-listener).&#x20;

{% hint style="info" %}
**Important:** You must pass a unique in-game user ID when connecting the wallet.
{% endhint %}

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

{% tabs %}
{% tab title="Unity" %}

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

{% endtab %}

{% tab title="Android" %}

```objectivec
VesselSdk.getInstance( activity )
         .getAppConnectManager()
         .startConnectActivity( "in-game-user-id", activity )
```

{% endtab %}

{% tab title="iOS" %}

```
[[[OVLSdk sharedInstance] appConnectManager]
                 presentConnectFromViewController: currentController
                 withUserId: @"in-game-user-id"
                 animated: YES];
```

{% endtab %}
{% endtabs %}

If you want to use your own UI to connect wallet, please refer to [Connect Wallet - Native](/integration/EZzgG67O9oXGl9CReheF/sdk/advanced.md#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.

{% tabs %}
{% tab title="Unity" %}

```csharp
OVSdk.Sdk.WalletPresenter.ShowWallet();
```

{% endtab %}

{% tab title="Android" %}

```java
final VesselSdk sdk = VesselSdk.getInstance( currentActivity );
sdk.getWalletPresenter().showWallet( currentActivity );
```

{% endtab %}

{% tab title="iOS" %}

```objectivec
[[[OVLSdk sharedInstance] presentationController] presentWalletFromViewController:viewController 
                                                  animated:YES
];
```

{% endtab %}
{% endtabs %}

## 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:

{% tabs %}
{% tab title="Unity" %}

```csharp
// 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);
```

{% endtab %}

{% tab title="Android" %}

```java
final VesselSdk sdk = VesselSdk.getInstance( currentActivity );

// Show the game level info
// fqgn: Fully Qualified Game Name ("com.studio.game")
sdk.getWalletPresenter().showGame( fqgn, currentActivity );

// Show the collection level info
// fqcn: Fully Qualified Collection Name ("com.studio.game.collection")
sdk.getWalletPresenter().showCollection( fqcn, currentActivity );

// Show the token level info
// fqtn: Fully Qualified Token Name ("com.studio.game.collection.token")
sdk.getWalletPresenter().showToken( fqtn, currentActivity );
```

{% endtab %}

{% tab title="iOS" %}

```objectivec
// Show the game level info
// fqgn: Fully Qualified Game Name ("com.studio.game")
[[[OVLSdk sharedInstance] presentationController] presentGame:fqgn fromViewController:viewController animated:YES];

// Show the collection level info
// fqcn: Fully Qualified Collection Name ("com.studio.game.collection")
[[[OVLSdk sharedInstance] presentationController] presentCollection:fqcn fromViewController:viewController animated:YES];

// Show the token level info
// fqtn: Fully Qualified Token Name ("com.studio.game.collection.token")
[[[OVLSdk sharedInstance] presentationController] presentToken:fqtn fromViewController:viewController animated:YES];
```

{% endtab %}
{% endtabs %}

## Callbacks for opening/closing the WebView

{% tabs %}
{% tab title="Unity" %}

```csharp
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
}
```

{% endtab %}

{% tab title="Android" %}

```java
VesselSdkImpl.getInstance( activity )
             .getWalletPresenter()
             .setListener( listener );
        
// Listener definition
@Override
public void onWalletShow()
{
    // a wallet is about to present
}

@Override
public void onWalletDismiss()
{
    // a wallet is about to dismiss
}
```

{% endtab %}

{% tab title="iOS" %}

```objectivec
OVLSdk.sharedInstance.presentationController.delegate = delegate;

// Delegate definition
- (void)presentationControllerWillPresentWallet:(OVLPresentationController *)presentationController
{
    // a wallet is about to present
}

- (void)presentationControllerWillDismissWallet:(OVLPresentationController *)presentationController
{
    // a wallet is about to dismiss
}
```

{% endtab %}
{% endtabs %}

## 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.

{% tabs %}
{% tab title="Unity" %}

```csharp
// 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);
```

{% endtab %}

{% tab title="Android" %}

<pre class="language-java"><code class="lang-java">final VesselSdk sdk = VesselSdk.getInstance(currentActivity);

// Show the wallet level info
sdk.getWalletPresenter().openWalletApplication(currentActivity);

// Show the game level info
// fqgn: Fully Qualified Game Name ("com.studio.game")
sdk.getWalletPresenter().openGameInWalletApplication(fqgn, currentActivity);

// Show the collection level info
// fqcn: Fully Qualified Collection Name ("com.studio.game.collection")
sdk.getWalletPresenter().openCollectionInWalletApplication(fqcn, currentActivity);
<strong>
</strong>// Show the token level info
// fqtn: Fully Qualified Token Name ("com.studio.game.collection.token")
sdk.getWalletPresenter().openTokenInWalletApplication(fqtn, currentActivity);
</code></pre>

{% endtab %}

{% tab title="iOS" %}

```objectivec
// Show the wallet info
[[[OVLSdk sharedInstance] presentationController] openWalletApplication];

// Show the game level info
// fqgn: Fully Qualified Game Name ("com.studio.game")
[[[OVLSdk sharedInstance] presentationController] openGameInWalletApplication:fqgn];

// Show the collection level info
// fqcn: Fully Qualified Collection Name ("com.studio.game.collection")
[[[OVLSdk sharedInstance] presentationController] openCollectionInWalletApplication:fqcn];

// Show the token level info
// fqtn: Fully Qualified Token Name ("com.studio.game.collection.token")
[[[OVLSdk sharedInstance] presentationController] openTokenInWalletApplication:fqtn];
```

{% endtab %}
{% endtabs %}

## Confirm the transaction

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

{% tabs %}
{% tab title="Unity" %}

```csharp
OVSdk.Sdk.WalletPresenter.ConfirmTransactionInWalletApplication(transactionId);
```

{% endtab %}

{% tab title="Android" %}

```java
final VesselSdk sdk = VesselSdk.getInstance( currentActivity );

sdk.getWalletPresenter().confirmTransactionInWalletApplication(transactionId, currentActivity);
```

{% endtab %}

{% tab title="iOS" %}

```objectivec
[OVLSdk.sharedInstance.presentationController confirmTransactionInWalletApplication:transactionId];
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.openvessel.io/integration/EZzgG67O9oXGl9CReheF/sdk/standard.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
