Working with Particle Wallet within iOS applications.
projectId
, clientKey
, and appId
later.
ParticleWalletAPI
and ParticleWalletGUI
pod.
pn
added to your appId
.
appId
is 63bfa427-cf5f-4742-9ff1-e8f5a1b9828f
, then the scheme URL would be pn63bfa427-cf5f-4742-9ff1-e8f5a1b9828f
—simply adding pn
to the beginning of the appId
.
With the scheme URL configured, you’ll also need to head into info.plist
and add LSApplicationQueriesSchemes
according to your specific utilization of Web3 wallets (not Particle Auth, but independent wallet adapters). An example of this can be seen below (each of these is optional and dependent upon your given implementation)
ParticleWalletGUI
(which is optional if you’re using a custom interface), then you’ll also need to include the following:
ParticleWalletAPI
, you can use Particle Wallet to directly call data API methods and retrieve information that may be relevant to the underlying account and wallet. One of these methods includes getPrice
on either ParticleWalletAPI.getSolanaService
or ParticleWalletAPI.getEvmService
. getPrice
is used for the retrieval of the real-time price of tokens defined within the methods first parameter, addresses
(in which the native token is "native"
), denominated in currencies listed within currencies
. E.g.:
Field | Type | Description |
---|---|---|
addresses | [String] | The tokens’s addresses, for native token, you can pass "native" |
currencies | [String] | The price unity, such as "usd" |
getTokensAndNFTs
alongside getTokensAndNFTsFromDB
(returns from database without RPC calls) return a list of ERC20/721/SPL tokens associated with a given address. This can be called on either ParticleWalletAPI.getSolanaService
or ParticleWalletAPI.getEvmService
, both taking a singular parameter (address
), dictating the specific account to be queried. E.g.:
ParticleWalletAPI
is the retrieval of transaction history by address. Either getTransactions
or getTransactionsFromDB
(returns from database without RPC calls) will return a list of transactions associated with a given address. This can be called on either ParticleWalletAPI.getSolanaService
or ParticleWalletAPI.getEvmService
. For getEvmService
, you’ll only need to pass in a given targeted address
, otherwise for getSolanaService
, you have the option of passing additional parameters such as beforeSignature
, untilSignature
, and limit
. E.g.:
ParticleWalletAPI.createTransaction
facilitates the construction of a transaction object derived from the standard from, to, amount (value), and data fields. This transaction, once constructed with ParticleWalletAPI.createTransaction
, can be passed for in-UI proposal with auth.sendTransaction
or adapter.signAndSendTransaction
. Specifically, eight key parameters are available within ParticleWalletAPI.getEvmService().createTransaction
:
Field | Type | Description |
---|---|---|
from | String | The user’s public address, which to sign the transaction. |
to | String? | If you send a erc20, erc721, erc1155 or interact with a contract, this is the contract address, if you send native, this is receiver address, if you want to deploy a contract, this to should be nil |
value | String? | Native value, default is nil, expressed as a hex string. |
data | String | If you send a erc20, erc721, erc1155 or interact with a contract, this is the data field, if you send native, this should be 0x , default value is 0x |
contractParams | ContractParams? | You can use this object to describe a write contract function |
type | String | Default is 0x2. Support EIP1559, you can ignore this parameter |
gasFeeLevel | gasFeeLevel | The specific gas fee level to be used. This can be either .low , .medium , .high , default is .medium |
action | Action | Transaction execution mechanism. This can be either .normal , .cancel , .speedUp , default is .normal , which means send a new transaction |
ParticleWalletAPI.getEvmService().readContract
:
Field | Type | Description |
---|---|---|
contractAddress | String | The contract address. |
methodName | String | The method’s name in the contract. |
params | [Encodable] | The parameters of the method, each parameter requires a hexadecimal string. |
abiJsonString | String? | (Optional) The ABI JSON string for the method. |
ParticleWalletAPI.getEvmService().writeContract
:
The first four parameters are the same as readContract.
Field | Type | Description |
---|---|---|
from | String | The user’s public address, which to sign the transaction. |
ParticleWalletAPI
, you can also use ParticleWalletGUI
as the primary means of programmatically configuring and interacting with Particle Wallet. To begin, ParticleWalletGUI
relies on WalletConnect through Particle Connect to enable usage of external Web3 wallet (such as Metamask or Phantom) within Particle Wallet.
ParticleWalletGUI
is drived by wallet adapters; after initializing the SDK, you’ll be able to retrieve all relevant adapters through ParticleConnect.getAdapters
, which can be plugged into ParticleWalletGUI.setAdapters
to initiate the custom wallet interface, as is shown below.
ParticleWalletGUI
, one of the primary functions is configuring the wallet interface for your specific application. This is managed through numerous methods, all of which toggle different interface components, enabling deep customization. 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
.setSupportWalletConnect
, controls the visibility of the WalletConnect feature within the interface. It accepts a Boolean parameter, true
or false
, and is set to true
by default.setSupportDappBrowser
, determines whether the DApp browser is available on the wallet page. It takes a Boolean parameter, true
or false
, with true
as the default valuesetShowTestNetwork
, decides if the test network should be shown or hidden. This accepts a Boolean value, true
or false
, defaulting to false
setSupportChain
, specifies the blockchain networks supported by Particle Connect. Accepts an array of chains.setShowManageWallet
, toggles the visibility of the manage wallet page. It takes a Boolean value, true
or false
, with true
as the default.setShowLanguageSetting
, controls the display of language settings in the settings page. It accepts a Boolean value, true
or false
, with the default being false
.setShowAppearanceSetting
, decides whether the appearance settings are shown in the settings page. It takes a Boolean value, true
or false
, defaulting to false
.setSupportAddToken
, toggles the option to add tokens, with true
showing the add token button and false
hiding it. The default value is true
.setDisplayTokenAddresses
, sets specific token addresses to be displayed in the wallet; other tokens won’t be displayed. It accepts an array of token addresses or nil
to reset.setDisplayNFTContractAddresses
, configures the wallet to display NFTs exclusively from specified NFT contract addresses. It accepts an array of addresses or nil
to reset.setPriorityTokenAddresses
, sets priority token addresses that will appear at the top of the list. It accepts an array of token addresses or nil
to reset (reflected on the wallet page’s token list and token send page).setPriorityNFTContractAddresses
, specifies NFT contract addresses for priority display at the top of the list. It takes an array of NFT contract addresses.setCustomTokenAddresses
, allows for the specification of custom token addresses to be displayed in the token list, unless hidden by the user. This method is overridden if setDisplayTokenAddresses
is used (reflected on the wallet page token list and token send select page).loadCustomUIJsonString
, sets a custom UI by passing a JSON string.setCustomWalletName
, configures a custom name and icon for the wallet, supported for the WalletType
of particle
and authcore
. It requires specifying the wallet type, name, and icon URL.setCustomLocalizable
, allows for setting custom localizable stringsAppDelegate.swift
and paste in the below snippet:
WalletType
(walletType
in this case) reflected and used within the wallet itself, you can use ParticleWalletGUI.switchWallet
, passing in the specific walletType
(see for more information) and targeted user address, publicAddress
:
Field | Type | Description |
---|---|---|
walletType | WalletType | The walletType is used to identify a unique user. |
publicAddress | String | The publicAddress is used to identify a unique user. |
PNRouter
. This will act as the primary mechanism for opening and managing specific pages of Particle Wallet. In this case, you can call PNRouter.navigatorWallet
to throw the main page within Particle Wallet. E.g.:
tabViewController
, you’ll need to call PNRouter.extractWallet
, passing in optional parameters such as hiddenBackButton
for configuration before extraction. This will return a navigation controller, which can then be used within tabViewController.viewControllers
. E.g.:
PNRouter.navigatorTokenSend
; if you’re sending a specific ERC20/SPL token, you can also pass in tokenSendConfig
, a TokenSendConfig
object containing the following:
Field | Type | Description |
---|---|---|
tokenAddress | String? | The address of the token to be sent, default is the native token |
toAddress | String? | (Optional) The recipient’s address |
amount | BInt? | (Optional) The amount to be sent, should pass the minimal unit amount |
PNRouter.navigatorTokenReceive
. If you’d like to generate a specific QR code for a token, placing the token logo at the center of the QR code, you can pass in tokenReceiveConfig
, a TokenReceiveConfig
object containing the tokenAddress
of the token in question. E.g.:
Field | Type | Description |
---|---|---|
tokenAddress | String? | The address of the token, default is the native token |
PNRouter.navigatorTokenTransactionRecords
, passing in tokenTransactionRecordsConfig
, a TokenTransactionRecordsConfig
object taking the tokenAddress
of a specific token to search for.
Field | Type | Description |
---|---|---|
tokenAddress | String | The address of the token, default is the native token |
PNRouter.navigatorNFTSend
, passing in nftSendConfig
, a NFTSendConfig
object that takes the following parameters:
Field | Type | Description |
---|---|---|
address | String | The contract address of the NFT being sent. |
toAddress | String? | The recipient’s address. |
tokenId | String? | The specific token ID of the NFT you’d like to send (belonging to the collection under address ). |
amount | BInt ? | The volume of NFTs that you’d like to send, for NFT 721, the amount should always be 1. |
PNRouter.navigatorNFTDetails
, passing in nftDetailsConfig
, a NFTDetailsConfig
object that takes the address
of the NFT and the specific tokenId
; for Solana. tokenId
can be left blank. E.g.:
Field | Type | Description |
---|---|---|
address | String | The contract address of the NFT being sent. |
tokenId | String? | The specific token ID of the NFT you’d like to send (belonging to the collection under address ). |
PNRouter.navigatorBuy
, passing in several optional parameters to customize the values used within the onramp. Upon calling, this will throw a popup or total redirect to a corresponding configuration of https://ramp.particle.network.
The specific parameters that can be used within PNRouter.navigatorBuy
are listed below:
Field | Type | Description |
---|---|---|
walletAddress | String? | (Optional) the wallet address to receive the cryptocurrency, default is current user address. |
network | ChainInfo? | (Optional) The chainInfo, default is current chainInfo. |
cryptoCoin | String? | (Optional) Cryptocurrency denomination. default is current chain native token symbol. |
fiatAmt | int? | (Optional) The amount of fiat to be automatically filled in as the purchase volume. |
fiatCoin | String? | (Optional) Fiat currency denomination. Default is current fiat coin. |
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 | String | (Optional) The buy page theme, dark or light , default is current appearance. |
language | Language? | (Optional) The buy page lanuage, default is current language. |
modalStyle | IOSModalPresentStyle? | (Optional) Control iOS presentation style, default is pageSheet . |
PNRouter.navigatorSwap
, which alone will open the default swap menu without values filled in, although you can pass in a SwapConfig
object, containing:
fromTokenAddress
, the token to swap from.toTokenAddress
, the token to swap to.fromTokenAmount
, the amount of fromTokenAddress
to be automatically reflected within the UI.PNRouter.navigatorDappBrowser
, taking one parameter, url
, which will dictate the site opened. E.g.: