Installation
The Phantasma Unity SDK is distributed as Unity Package Manager packages. Use
PhantasmaPhoenix.Unity.Core for RPC access and signing helpers, and
PhantasmaPhoenix.Unity.LinkClient when the project needs wallet connection
through Phantasma Link.
Both packages require Unity 2022.3 or later. The sample project in the SDK repository is built with Unity 6000.0 LTS.
Importing the Phantasma Unity SDK to your project
- Open your Unity project.
- Navigate to
Window > Package Managerfrom the top menu. - In the Package Manager window, click the
+button in the top left corner. - Select
Install package from git URL.... - Enter one of the following git URLs:
- To install PhantasmaPhoenix.Unity.Core package:
https://github.com/phantasma-io/phantasma-sdk-unity.git?path=PhantasmaPhoenix.Unity.Core - To install PhantasmaPhoenix.Unity.LinkClient package:
https://github.com/phantasma-io/phantasma-sdk-unity.git?path=PhantasmaPhoenix.Unity.LinkClient
- To install PhantasmaPhoenix.Unity.Core package:
- Click
Add. - Repeat the package import when the project needs both Core and LinkClient.
Note
Note: To pin a package to a specific source revision, append # and the
commit hash to the Git URL. Example:
https://github.com/phantasma-io/phantasma-sdk-unity.git?path=PhantasmaPhoenix.Unity.Core#704143b141129df210d83bf3d248f8873748b761
Connecting to the Wallet via the SDK
- Set up your Unity scene.
- Add the
PhantasmaLinkClientprefab to your scene. - Configure the following settings in the
PhantasmaLinkClientinspector:- Nexus: Choose the appropriate Nexus based on your deployment target:
- For local node deployments, set the Nexus to
simnet. - For testnet deployment, set the Nexus to
testnet. - For mainnet deployment, set the Nexus to
mainnet.
- For local node deployments, set the Nexus to
- DappID: Set the DappID to your dApp’s contract name. The wallet shows it when a user logs in to your dApp.
- Version: The recommended version is
2. - Wallet Endpoint: The default wallet endpoint is
localhost:7090. Do not change this unless required. - Platform and Signature:
PhantasmaandED25519. The other values of the two enums are not used by current wallets.
- Nexus: Choose the appropriate Nexus based on your deployment target:
Connecting to the Wallet via the SDK (Android)
- Follow the same setup from “Connecting to the Wallet via the SDK”.
- Add the
PhantasmaLinkClientPluginprefab to your scene. - Build your project for Android.