Working with Particle Wallet within Unity applications.
projectId
, clientKey
, and appId
.
These directly connect your Unity project with the Particle dashboard, enabling customization, analytics, tracking, etc.
particle-unity
GitHub repository, and download the latest release (.unitypackage
), then import this into your project.
Edit
-> Project Settings
-> Player Settings
-> iOS
).Other
, then scroll down to Configuration
.Supported URL schemes
section, and within the Element 0
field, paste in your projectId
with a prefix of pn
.projectId
(from the Particle dashboard) is something like 63bfa427-cf5f-4742-9ff1-e8f5a1b9828f
, then the scheme URL, in this case, would be pn63bfa427-cf5f-4742-9ff1-e8f5a1b9828f
.Remove other services, if needed
Within ParticleNetworkIOSBridge.cs
, you’ll have a number of services
included in the SDK:
- ParticleNetworkBase
- required universally.
- ParticleAuthCore
- required for Particle Auth Core.
- ParticleConnect
- required for Particle Connect.
ParticleWalletGUI
- usage of the Particle Wallet UI, contains all
services.- ParticleAA
- usage of the Particle AA, contains all services.
pod init
to generate one.
Open this Podfile, and insert the specific pods (services) you’d like to use within your project. In this case, ParticleWalletGUI
will generally suffice, but additional services can be added if needed.
Additionally, you’ll need to paste in the below code snippet for installation handling:
pod install
and open your .xcworkspace
file, as shown below:
projectId
, clientKey
, and appId
previously retrieved. To do this, head into the root of your Xcode project and create a file, ParticleNetwork-Info.plist
. Within this file, paste the following text, then replace the placeholders:
Assets/Plugins/Android/launcherTemplate.gradle
within your project. Here, you’ll need to ensure that you have the necessary dependencies included.
You’ll need the following dependencies at a minimum:
network.particle:wallet-service
, required for Particle Wallet.network.particle:auth-service
, if you’re planning on using Particle Auth directly.network.particle:connect
, if you’re planning on using Particle Connect directly.network.particle:unity-bridge
, required universally.projectId
, clientKey
, and appId
within gradleTemplate.properties
, found at Assets/Plugins/Android/gradleTemplate.properties
.
ParticleWalletGUI.prefab
file into your first scene.
ParticleWalletGUI
will need to be initialized before Particle Wallet will work properly.
To do this, you’ll need to call ParticleWalletGUI.ParticleWalletConnectInitialize
, passing in metadata
, which contains the following:
walletConnectProjectId
, your WalletConnect project ID retrieved from the WalletConnect dashboard.name
, the name of your project.icon
, a URL linking to the icon/logo of your project - ideally 512x512.url
, the URL of your project’s website.description
, a short description of your project.redirect
and verifyUrl
can also be added.ParticleNetwork
and ParticleConnectInteraction
for Particle Connect or Auth, you can initialize them in the same place and using the same metadata
.
ParticleWalletGUI
is initialized and set to go, you can move onto configuring and customizing the wallet interface itself, choosing the specific options that are enabled and disabled within the wallet, the language used, and more. This can be done through ParticleWalletGUI.{configuration method}
. The specific methods available here include the following:
SetSupportChain
, sets the array of supported blockchain networks. It accepts an array of chain information, with the default being all chains.
SetPayDisabled
, toggles the ability to perform buy transactions within the interface. It takes a Boolean, true
or false
, with no default value specified.
SetShowTestNetwork
, controls the visibility of the test network. It accepts a Boolean value, true
or false
.
SetShowManageWallet
, determines whether the manage wallet page is displayed. It takes a Boolean parameter, true
or false
.
SetDisplayTokenAddresses
, specifies which token addresses are displayed, filtering out others. It accepts an array of token addresses to be displayed.
SetDisplayNFTContractAddresses
, sets specific NFT contract addresses to be displayed, hiding others. It takes an array of NFT addresses.
SetPriorityTokenAddresses
, prioritizes certain tokens to be shown at the top of the list. It accepts an array of token addresses.
SetPriorityNFTContractAddresses
, sets certain NFTs to appear at the top of the list. It requires an array of NFT addresses. Similar to SetPriorityTokenAddresses
.
SetSupportAddToken
, toggles the display of the add token button in the main wallet page. It takes a Boolean value, true
or false
.
SetSupportWalletConnect
, controls support for wallet connect as a wallet option. It accepts a Boolean value, true
or false
.
SetSupportDappBrowser
, determines whether the dApp browser should be shown on the wallet page. It takes a Boolean parameter, true
, or false
.
SetShowLanguageSetting
, controls the visibility of the language setting button in the settings page. It accepts a Boolean parameter, either true
or false
.
SetShowAppearanceSetting
, toggles the display of the appearance setting button in the settings page. It takes a Boolean value, true
or false
.
ParticleWalletGUI
, you can also force specific pages of Particle Wallet to open, passing in specific preset configurations. In this case, you can programmatically open the main page of the wallet with NavigatorWallet
and pass in a binary (0
or 1
), indicating whether the main page should display ERC20/SPL tokens (0
), or NFTs (1
). E.g.:
ParticleWalletGUI.NavigatorTokenReceive
. If you’d like, you can pass in a specific tokenAddress
to create a token-specific QR code, including its icon/logo at the center. E.g.:
ParticleWalletGUI.NavigatorTokenSend
, optionally passing in various parameters such as tokenAddress
, toAddress
, and amount
to predefine values within the interface. E.g.:
ParticleWalletGUI.NavigatorTokenTransactionRecords
, which optionally takes one parameter, tokenAddress
, for filtering the results only to include transactions that involve a specified ERC20/721 token address. E.g.:
ParticleWalletGUI.NavigatorNFTSend
, taking:
Field | Type | Description |
---|---|---|
mint | string | (contractAddress ) of a given NFT. |
tokenId | string | The token ID of an NFT (within the collection defined by mint ). This can be left as null for Solana. |
receiveAddress | string? | The recipient address, a blank string by default. |
amount | string? | The volume of NFT (mint ) to be sent, ERC172 NFT should set 1 |
ParticleWalletGUI.NavigatorNFTDetails
, passing in the contractAddress
of the NFT and the specific tokenId
. For Solana, tokenId
can be left blank. E.g.:
ParticleWalletGUI.NavigatorBuyCrypto
, passing in several optional parameters to customize the values used within the onramp. Upon calling, this will throw a popup or total redirect over to a corresponding configuration of https://ramp.particle.network.
The specific parameters that can be used within ParticleWalletGUI.NavigatorBuyCrypto
are listed below:
Field | Type | Description |
---|---|---|
WalletAddress | string? | (Optional) The wallet address to receive the cryptocurrency, default is current user address. |
ChainInfo | ChainInfo? | (Optional) The chainInfo, default is current chainInfo. |
CryptoCoin | string? | (Optional) Cryptocurrency denomination. Default is current chain native token symbol. |
FiatCoin | String? | (Optional) Fiat currency denomination. Default is current fiat coin. |
FiatAmt | int? | (Optional) The amount of fiat to be automatically filled in as the purchase volume. |
FixFiatCoin | bool | (Optional) Lock selection of fiat coin in the buy menu, default is false. |
FixCryptoCoin | bool | (Optional) Lock selection of fiat amount in the buy menu, default is false. |
Theme | Theme? | (Optional) The buy page theme, Dark or Light , default is false. |
Language | Language? | (Optional) The buy page lanuage, default is current language. |
modalStyle | iOSModalPresentStyle? | (Optional) Control iOS presentation style, default is PageSheet . |
ParticleWalletGUI.NavigatorSwap
, which alone will open the default swap menu without values filled in, although you can pass in several optional parameters, including:
Field | Type | Description |
---|---|---|
fromTokenAddress | string | (Optional) the swap pair from token address |
toTokenAddress | string | (Optional) the swap pair to token address |
amount | string | (Optional) the swap from token amount, should pass the minimal unit string, for example 0.01 ETH, it’s decimals is 18, should pass “10000000000000000” |
modalStyle | iOSModalPresentStyle | (Optional) control iOS presentation style, default is PageSheet . |
WalletType
(walletType
in this case) reflected and used within the wallet itself, you can use ParticleWalletGUI.Instance.SwitchWallet
, passing in the specific walletType
(see Particle Connect iOS for more information) and targeted user address, publicAddress
. E.g.: