Working with Particle Wallet within flutter applications.
particle-flutter
GitHub repository. Before diving in, it may be worth looking through this repository to contextualize usage of the SDK with an understanding of its underlying architecture.
projectId
, clientKey
, and appId
to connect your Flutter project with the dashboard. This enables configuration, analytics, tracking, etc.
particle_wallet
to your Flutter application. This is a requirement before moving onto platform-specific configuration.
build.gradle
file, often found at the following file path: ${project name}/android/app/build.gradle
.
Within build.gradle
, you’ll need to add four new lines to ensure Particle Wallet runs properly:
minSdkVersion
, in most cases, this will simply be set to 23
.manifestPlaceholders["PN_PROJECT_ID"]
, the projectId
previously retrieved from the Particle dashboard.manifestPlaceholders["PN_PROJECT_CLIENT_KEY"]
, the clientKey
previously retrieved from the Particle dashboard.manifestPlaceholders["PN_APP_ID"]
, the appId
previously retrieved from the Particle dashboard.build.gradle
file, you’ll need to ensure that you’re using version 17 of Java in both compileOptions
and kotlinOptions
, alongside enabling dataBinding
.
ios/{project name}.xcworkspace
.
At the root of your Xcode project, create a new file, ParticleNetwork-Info.plist
. Ensure this is marked under “Target Membership.”
With a fresh ParticleNetwork-Info.plist
file, go ahead and fill it in with the following:
PROJECT_UUID
(projectId
), PROJECT_CLIENT_KEY
, and PROJECT_APP_UUID
(appId
) with the corresponding values retrieved from the Particle dashboard.
Next, you’ll need to go to your AppDelegate.swift
file to add an import of ParticleConnect
(which Particle Wallet is dependent on).
Additionally, within your application’s application
method (as shown below), you’ll need to include a handler condition derived from ParticleConnect.handleUrl
. This should be as simple as a true
return upon a truthy value of ParticleConnect.handleUrl
, and a super.application(app, open: url, options: options)
return upon a falsy value.
projectId
(retrieved and configured prior), resulting in a scheme URL that looks like the following:
Info.plist
file and include the following snippet:
particle_connect
is correctly imported. If you have not already, head over to the linked guide to complete this.
ParticleWallet.init
.
Field | Type | Description |
---|---|---|
name | String | Your project’s name. |
icon | String | The link to an icon/logo representing your project - ideally 512x512. |
url | String | The URL for your project’s website. |
description | String | A short description of your project. |
ParticleWallet.navigatorWallet
. navigatorWallet
takes one parameter, a binary selection indicating whether tokens or NFTs are displayed within the main wallet page. WalletDisplay.token
sets this to tokens, and WalletDisplay.nft
to NFTs. E.g.:
ParticleWallet.navigatorTokenReceive
. This optionally takes a parameter, tokenAddress
, representing the specific token you plan to receive, in which the QR code will include its logo at its center. E.g.:
ParticleWallet.navigatorTokenSend
. Specifically, navigatorTokenSend
optionally takes the following parameters:
Field | Type | Description |
---|---|---|
tokenAddress | String | The address of a token to be auto-filled within the send menu. This can be native for a default/native token. |
toAddress | String | The recipient’s address. |
amount | String? | (Optional) The volume of tokens (tokenAddress ) to be sent. |
ParticleWallet.navigatorTokenTransactionRecords
, optionally taking one parameter, tokenAddress
. If filled out, this will filter the transaction records to only display entries involving a specified tokenAddress
. E.g.:
navigatorTokenSend
, you can call ParticleWallet.navigatorNFTSend
to throw a page explicitly meant for sending a given NFT (one specific token). navigatorNFTSend
takes the following parameters:
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. |
amount | String? | The volume of NFT (mint ) to be sent, ERC172 NFT should set 1 |
receiveAddress | String? | The recipient address, a blank string by default. |
ParticleWallet.navigatorNFTDetails
, passing in the contractAddress
(mint
) of the NFT and the specific tokenId. For Solana, tokenId can be left blank. E.g.:
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. |
ParticleWallet.navigatorBuyCrypto
, passing in several optional parameters to customize the values used within the onramp. Upon calling, this will return a popup or total redirect over to a configuration of https://ramp.particle.network.
The specific parameters that can be used within ParticleWallet.navigatorBuyCrypto
are listed below:
Field | Type | Description |
---|---|---|
walletAddress | String? | (Optional) The wallet address to receive the cryptocurrency, default is current user address. |
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. |
chainInfo | ChainInfo? | (Optional) The chainInfo, default is current chainInfo. |
fixFiatCoin | bool | (Optional) Lock selection of fiat coin in the buy menu, default is false. |
fixFiatAmt | bool | (Optional) Lock selection of fiat amount in the buy menu, default is false. |
fixCryptoCoin | bool | (Optional) Lock selection of crypto coin in the buy menu, default is false. |
theme | Theme | (Optional) The buy page theme, dark or light , default is curreny appearance. |
language | Language? | (Optional) The buy page lanuage, default is current language. |
modalStyle | IOSModalPresentStyle? | (Optional) Control iOS presentation style, default is pageSheet . |
ParticleWallet.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”. |
ParticleWallet.navigatorDappBrowser
, taking one parameter, url
, which will dictate the specific site opened. E.g.:
ParticleWallet.setSupportChain
, which takes an array of ChainInfo
objects. Each object (representing different chains) will directly enable an additional chain within the wallet interface.
If you add a Testnet to this list and pass it to setSupportChain
, you’ll also need to ensure that ParticleWallet.setShowTestNetwork
is set to true
(by passing in true
). E.g.:
walletType
) active within the Particle Wallet interface, you’ll need to call ParticleWallet.switchWallet
by passing in a specified walletType
(of type WalletType
) and associated publicAddress
.
WalletType
contains the following:
authCore
, social logins through Particle Auth.evmPrivateKey
, custom EVM wallet imports/exports.solanaPrivateKey
, custom Solana wallet imports/exports.metaMask
.rainbow
.trust
.imToken
.bitget
.walletConnect
.zerion
.math
.zengo
.alpha
.okx
.phantom
, intended for Solana.ParticleWallet
. Each of these will change a specific configuration or UI element present within the Particle Wallet interface. These methods include:
setSwapDisabled
, whether or not the “Swap” functionality is displayed within the interface. This takes one parameter, either true
or false
, with the default being false
.
setPayDisabled
, whether or not the “Buy” functionality is displayed within the interface. This takes one parameter, either true
or false
, with the default being false
.
setBridgeDisabled
, whether or not the “Bridge” functionality is displayed within the interface. This takes one parameter, either true
or false
, with the default being false
.
setShowTestNetwork
, configures the visibility of the Testnets within the interface. It accepts a boolean value, true
or false
.
setShowManageWallet
, toggles the display of the wallet management page. It takes a boolean parameter, either true
or false
.
setShowLanguageSetting
, controls the visibility of the language setting option in the settings page. It accepts a boolean value, true
or false
.
setShowAppearanceSetting
, determines whether the appearance setting is shown in the settings page. It takes a boolean value, true
or false
.
setSupportDappBrowser
, configures the availability of the dApp browser feature. It accepts a boolean parameter, true
or false
.
setSupportWalletConnect
, sets whether WalletConnect is supported on the wallet page. It takes a boolean value, true
or false
.
setSupportAddToken
, toggles the option to add tokens, indicated by the variable isShow
.
setDisplayTokenAddresses
, specifies token addresses to be displayed. It accepts a list of token addresses.
setPriorityTokenAddresses
, sets specific tokens as a priority, making them appear at the top of the list. It requires a list of token addresses.
setDisplayNFTContractAddresses
, configures the wallet to display NFTs from specified contract addresses. It accepts a list of NFT contract addresses.
setPriorityNFTContractAddresses
, prioritizes specific NFT contract addresses to be shown at the top of the list. It takes a list of NFT contract addresses.
loadCustomUIJsonString
, allows setting a custom UI theme by passing a JSON string. This string can be customized according to the user’s preference.