Working with Particle Wallet within Android applications.
projectId
, clientKey
, and appId
. During configuration, you’ll need these to connect your project with the Particle dashboard, unlocking customization, analytics, tracking, etc.
build.gradle
file to use the necessary dependencies. As mentioned, Particle Wallet is complimentary to Particle Connect, and thus, there are several requirements needed to use the wallet SDK, network.particle:wallet-service
:
org.bouncycastle:bcprov-jdk15to18
and org.bouncycastle:bcprov-jdk15on
.network.particle:auth-core
.network.particle:connect
.network.particle:connect-auth-core-adapter
.network.particle:wallet-service
.ParticleWallet
(imported from com.particle.gui.ParticleWallet
) with ParticleWallet.init
. Additional methods won’t function until this happens. This method, init
, takes a number of optional parameters:
supportChains
, an array of ChainInfo
objects dictating the chains available within the Particle Wallet interface.setShowTestNetworks
, whether or not test networks (Testnets) should be shown within the chain selection menu on Particle Wallet. This takes one parameter, true
or false
(false
by default).setShowManageWalletSetting
, whether or not the “Manage Wallet” button within the Particle Wallet interface is shown. This takes one parameter, true
or false
(true
by default).hideMainBackIcon
, removes the “Back” icon on the main wallet page.setShowAppearanceSetting
, if the appearance (dark/light mode) setting is shown and available to the user. It takes one parameter, true
or false
(true
by default).setSupportDappBrowser
, whether or not the dApp browser is available within the wallet interface (custom browser instance using the account as a connection mechanism with dApps). It takes one parameter, true
or false
(true
by default).setWalletIcon
, the icon/logo shown within the wallet interface. It takes one parameter, a string representing an icon URL.setShowTestNetworkSetting
) after initial configuration through methods such as ParticleWallet.showTestNetworks()
, ParticleWallet.hideManageWallet()
, and so on.
Additionally, if you’d like to use a custom wallet within the Particle Wallet interface (for example, a wallet name, network, etc., specific to your project), then you’ll need to use WalletInfo.createWallet
to create a custom wallet object. This takes the following parameters:
Field | Type | Description |
---|---|---|
address | String | The user’s public address belonging to the current active session (connected via Particle Connect). |
chainName | String | The name of the chain to be used within Particle Wallet. |
chainId | Long | The ID of the chain to be used within Particle Wallet |
walletName | String | The name of your wallet/project to be shown in UI. |
adapterName | String | The name of the wallet adapter you’re using (such as MobileWCWalletName.AuthCore.name ). |
ParticleWallet.setWallet
, changing the active interface/wallet according to the parameters outlined within WalletInfo.createWallet
. E.g.:
PNRouter
, imported from com.particle.gui.router.PNRouter
, can be used to programmatically open different components of Particle Wallet. To open the main wallet interface (the page displaying address, balance, tokens, and buttons leading to other pages), you’ll need to call PNRouter.build
, passing in RouterPath.Wallet
(in which RouterPath
is imported from com.particle.gui.router.RouterPath
and dictates the page, or path, to be opened), then calling navigation
. E.g.:
PNRouter.build
, passing in RouterPath.TokenSend
. If you’re sending an ERC20/SPL token, you’ll need to fill in params
- a WalletSendParams
object (imported from com.particle.gui.ui.send.WalletSendParams
) containing the following:
tokenAddress
, the address of the token to be sent (required).toAddress
, the recipient address (optional).toAmount
, the amount to be sent (optional).RouterPath.TokenSend
alone without params
will open the same page with the native token of the network selected.
PNRouter.build
, using RouterPath.TokenReceive
. E.g.:
PNRouter.build
, using RouterPath.TokenTransactionRecords
. If you’re specifically looking for a given token, you’ll also need to use params
, a TokenTransactionRecordsParams
object (imported from com.particle.gui.ui.token_detail.TokenTransactionRecordsParams
) containing a given tokenAddress
. Otherwise, RouterPath.TokenTransactionRecords
can be used on its own. E.g.:
PNRouter.build
, passing both RouterPath.NftDetails
and params
, a NftDetailsParams
object (imported from com.particle.gui.ui.nft_detail.NftDetailParams
) containing a tokenAddress
(address of the ERC721 token), and the recipientAddress
(owner of the NFT). E.g.:
ParticleNetwork.openBuy
, 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 configuration of https://ramp.particle.network.
The specific parameters that can be used within ParticleNetwork.openBuy
are listed below:
Name | Description | Type | Required |
---|---|---|---|
network | [Solana, Ethereum, Binance Smart Chain, Polygon, Tron, Optimism, etc.]. | string | False (True if Particle not connected) |
fiatCoin | Fiat currency denomination. | string | False |
cryptoCoin | Cryptocurrency denomination. | string | False |
fiatAmt | The amount of fiat to be automatically filled in as the purchase volume. | number | False |
bool | Lock fiat currency in the buy menu. | bool | False |
fixCryptoCoin | Lock cryptocurrency in the buy menu. | bool | False |
fixFiatAmt | Lock fiat amount in the buy menu. | bool | False |
walletAddress | The wallet address to receive the cryptocurrency. | string | False (True if Particle not connected) |
PNRouter.navigatorSwap
, which alone will open the default swap menu without values filled in. However, you can pass in a SwapConfig
object (swapConfig
in this example), imported from com.particle.gui.ui.swap.SwapConfig
, containing:
fromTokenAddress
, the token to swap from.toTokenAddress
, the token to swap to.fromTokenUIAmount
, the amount of fromTokenAddress
to be automatically reflected within the UI.PNRouter.navigatorDappBrowser
, taking one parameter, url
, which will dictate the specific site opened, or ParticleNetwork.navigatorDAppBrowser
, which takes the same parameter. E.g.:
ParticleWallet
and PNRouter
that control Particle Wallet, it’s also worth mentioning a few APIs that can be accessed through ParticleNetwork
, which may be relevant to Particle Wallet.
getPrice
method on either ParticleNetwork.evm
or ParticleNetwork.solana
, both taking addresses
(either a singular or list of token addresses —for the native token, use 'native'
), and currencies
(either a singular or list of fiat currencies in which the prices are denominated (such as ['usd', 'cny']
). E.g.:
getTokensAndNFTs
or getTokensAndNFTsFromDB
(retrieves exclusively from DB) on ParticleNetwork.solana
or ParticleNetwork.evm
, taking one parameter, the address
of the account being queried. E.g.:
getTransactionsByAddress
or getTransactionsByAddressFromDB
(pulls data exclusively from DB) on ParticleNetwork.solana
or ParticleNetwork.evm
. Both of these take address
(the user address to be queried), although ParticleNetwork.solana
also takes an additional optional object, which in this example is optBody
. This can contain additional parameters, such as the boolean, parseMetadataUri
. E.g.: