Skip to main content

Unity SDK Reference

Immutable's Unity SDK reference covers all publicly available Unity SDK methods, enabling you to easily integrate Passport into your Unity-based game.

Information includes method descriptions, parameters and return types.
sdk referencesdk reference
💡WHO IS THIS FOR?
Developers building a game in Unity.


Passport


Init

Initialises Passport with the specified parameters.

This sets up the Passport instance, configures the web browser, and waits for the ready signal.

Method parameters


stringclientIdREQUIRED

The user's client ID.

stringenvironmentREQUIRED

The environment to connect to.

stringredirectUri

(Android, iOS, and macOS only) The URL where the browser will redirect after successful authentication. Only required for the PKCE login flow.

stringlogoutRedirectUri

The URL where the browser will redirect after logout is complete.

intengineStartupTimeoutMs

(Windows only) Timeout duration in milliseconds to wait for the default Windows browser engine to start.

IWindowsWebBrowserClientwebBrowserClient

(Windows only) Custom Windows browser to use instead of the default browser in the SDK.

Returns


Passport

The initialised Passport object.


SetCallTimeout

Sets the timeout time for waiting for each call to respond (in milliseconds).

This only applies to functions that use the browser communications manager.

Method parameters


intmsREQUIRED

Length of timeout in milliseconds. Only required for the Device Code Authorisation login flow.

Returns


void

Login

Logs into Passport using Device Code Authorisation.

This will open the user's default browser and take them through Passport login.

If useCachedSession is true, stored credentials will be used to re-login the gamer. If re-login fails, it will not fall back to Device Code Authorisation.

Method parameters


booluseCachedSessionREQUIRED

If true, the saved access token or refresh token will be used to log the user in. If this fails, it will not fallback to Device Code Authorisation.

inttimeoutMs

The maximum time, in milliseconds, the function is allowed to take before a TimeoutException is thrown. If not set, the function will wait indefinitely.

Returns


bool

true if login is successful. Otherwise, false.


LoginPKCE

(Android, iOS and macOS only) Logs into Passport using Authorisation Code Flow with Proof Key for Code Exchange (PKCE).

Returns


UniTask

A UniTask object representing the asynchronous operation.


Logout

Logs the gamer out of Passport and removes any stored credentials.

It is recommended to be used alongside Login to keep the gamer experience consistent.

Method parameters


boolhardLogout

If false, the user will not be logged out of Passport in the browser. The default is true.

Returns


UniTask

A UniTask object representing the asynchronous operation.


LogoutPKCE

Logs the gamer out of Passport and removes any stored credentials.

It is recommended to be used alongside LoginPKCE to keep the gamer experience consistent.

Method parameters


boolhardLogout

If false, the user will not be logged out of Passport in the browser. The default is true.

Returns


UniTask

A UniTask object representing the asynchronous operation.


HasCredentialsSaved

Checks if credentials exist but does not check if they're valid.

Returns


bool

true if there are credentials saved. Otherwise, false.


GetAccessToken

Gets the currently saved access token without verifying its validity.

Returns


string

The current access token.


GetIDToken

Gets the currently saved ID token without verifying its validity.

Returns


string

The current ID token.


GetLinkedAddresses

Gets the list of external wallets the user has linked to their Passport account via the Dashboard.

Returns


List<string>

External wallet addresses linked to the user’s Passport account.


GetEmail

Retrieves the email address of the user whose credentials are currently stored.

Returns


string

The email address of the current user.


GetPassportId

Retrieves the Passport ID of the user whose credentials are currently stored.

Returns


string

The Passport ID of the current user.


ConnectEvm

Instantiates the zkEVM provider.

Returns


void

ZkEvmRequestAccounts

Returns a list of wallet addresses owned by the user.

Returns


List<string>

Wallet addresses owned by the user.


ZkEvmGetBalance

Gets the balance of the given address in wei.

Method parameters


stringaddressREQUIRED

Address to check for balance.

stringblockNumberOrTagREQUIRED

Integer block number, or the string "latest", "earliest" or "pending".

Returns


string

The balance of the given address in wei.


ZkEvmSendTransaction

Sends a transaction to the network and signs it using the logged-in Passport account.

Method parameters


TransactionRequestrequestREQUIRED

A transaction request containing to, data and value fields.

Returns


string

The transaction hash, or the zero hash if the transaction is not yet available.


ZkEvmSendTransactionWithConfirmation

Sends a transaction to the network, signs it using the logged-in Passport account, and waits for the transaction to be included in a block.

Similar to ZkEvmSendTransaction.

Method parameters


TransactionRequestrequestREQUIRED

A transaction request containing to, data and value fields.

Returns


TransactionReceiptResponse

The receipt of the transaction or null if it is still processing.


ZkEvmGetTransactionReceipt

Retrieves the transaction information of a given transaction hash using the Ethereum JSON-RPC eth_getTransactionReceipt method.

Method parameters


stringhashREQUIRED

The hash of the given transaction.

Returns


TransactionReceiptResponse

The receipt of the transaction or null if it is still processing.


ZkEvmSignTypedDataV4

Signs the EIP-712 structured message in JSON string format using the logged-in Passport account.

Method parameters


stringpayloadREQUIRED

The EIP-712 structured data in JSON string format.

Returns


string

The signed payload string.


ClearCache

Clears the underlying WebView resource cache. On Android, note that the cache is per-application, so this will clear the cache for all WebViews used.

Method parameters


boolincludeDiskFilesREQUIRED

If false, only the RAM/in-memory cache is cleared.

Returns


void

ClearStorage

Clears all the underlying WebView storage currently being used by the JavaScript storage APIs, including Web SQL Database and the HTML5 Web Storage APIs.

Returns


void


Orderbook


PrepareListing

Gets required transactions and messages for signing prior to creating a listing.

Method parameters


PrepareListingRequestprepareListingRequestREQUIRED

Request object for preparing a listing containing details about the listing to be created:

See PrepareListingRequest for more information.

Returns


PrepareListing200Response

A response object for the prepare listing endpoint containing properties:

See PrepareListing200Response for more information.


CreateListing

Creates a listing.

Method parameters


CreateListingRequestcreateListingRequestREQUIRED

Request object for creating a listing containing properties:

See CreateListingRequest for more information.

Returns


CreateListing200Response

A response object for the create listing endpoint containing properties:

See CreateListing200Response for further information.


FulfillOrder

Gets unsigned transactions that can be submitted to fulfil an open order. If the approval transaction exists it must be signed and submitted to the chain before the fulfilment transaction can be submitted or it will be reverted.

Method parameters


FulfillOrderRequestfulfillOrderRequestREQUIRED

Request object for fulfilling an order containing properties:

  • ListingId of type string - the listing ID to fulfil
  • TakerAddress of type string - the address of the account fulfilling the order
  • TakerFees of type List<FulfillOrderRequestTakerFeesInner> - taker ecosystem fees to be paid.
  • AmountToFill of type string - amount of the order to fill, defaults to sell item amount (only applies to ERC1155 orders) (optional)

See FulfillOrderRequest for more information.

Returns


FulfillOrder200Response

A response object for the fulfill order endpoint containing properties:

See FulfillOrder200Response for more information.


PrepareOrderCancellations

Prepares cancellations for one or more orders.

Cancelling orders is a gasless alternative to on-chain cancellation exposed with CancelOrdersOnChain. For the orderbook to authenticate the cancellation, the creator of the orders must sign an EIP712 message containing the orderIds.

Method parameters


PrepareOrderCancellationsRequestprepareOrderCancellationsRequestREQUIRED

Request object for preparing order cancellations containing properties:

  • OrderIds of type List<string> - the ID's of the orders to attempt to cancel

See PrepareOrderCancellationsRequest for more information.

Returns


PrepareOrderCancellations200Response

A response object for the prepare order cancellations endpoint containing properties:

  • SignableAction of type SignableAction - the signable action to cancel the orders

See PrepareOrderCancellations200Response for further information.


CancelOrders

Cancels one or more orders.

Cancelling orders is a gasless alternative to on-chain cancellation exposed with CancelOrdersOnChain. Orders cancelled this way cannot be fulfilled and will be removed from the orderbook. If there is pending fulfillment data outstanding for the order, its cancellation will be pending until the fulfillment window has passed. PrepareOrderCancellations can be used to get the signable action that is signed to get the signature required for this call.

Method parameters


CancelOrdersRequestcancelOrdersRequestREQUIRED

Request object for cancelling orders containing properties:

  • OrderIds of type List<string> - the order IDs to attempt to cancel
  • AccountAddress of type string - the address of the account cancelling the orders
  • Signature of type string - the signature obtained by signing the message obtained from PrepareOrderCancellations

See CancelOrdersRequest for more information.

Returns


CancelOrders200Response

A response object for the cancel orders endpoint containing properties:

See CancelOrders200Response for further information.


CancelOrdersOnChain

Cancels one or more orders on the blockchain.

Get an unsigned order cancellation transaction. Orders can only be cancelled by the account that created them. All of the orders must be from the same seaport contract. If trying to cancel orders from multiple seaport contracts, group the orderIds by seaport contract and call this method for each group.

Method parameters


CancelOrdersOnChainRequestcancelOrdersOnChainRequestREQUIRED

Request object for cancelling orders on the blockchain containing properties:

  • OrderIds of type List<string> - the order IDs to cancel
  • AccountAddress of type string - the address of the account cancelling the order

See CancelOrdersOnChainRequest for more information.

Returns


CancelOrdersOnChain200Response

A response object for the cancel orders on chain endpoint containing properties:

See CancelOrdersOnChain200Response for further information.


TokenBalance

Retrieves the token balance for a specified wallet and contract address.

Method parameters


stringwalletAddressREQUIRED

The wallet address to query for the token balance.

stringcontractAddressREQUIRED

The contract address of the token.

Returns


TokenBalance200Response

A response object for the token balance endpoint containing properties:

  • Quantity of type string - the quantity of the given token that the user has in their wallet.

See TokenBalance200Response for further information.