Leveraging Particle Connect within applications built using React Native.
projectId
, clientKey
, and appId
. These can be retrieved from the Particle dashboard.
@particle-network/rn-connect
, either through npm or Yarn, depending on your preference, as is shown below.
projectId
, clientKey
, and appId
) within your build.grade
file (generally found at ${project name}/android/app/build.gradle
). These directly link your application’s instance of Particle Connect with the dashboard.
Specifically, within build.gradle
, you’ll need to set four different values:
dataBinding
, this should be enabled with enabled = true
.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.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.”
From here, with a fresh ParticleNetwork-Info.plist
file, go ahead and fill it in with the following:
PROJECT_UUID
(projectId
), PROJECT_CLIENT_KEY
(clientKey
), and PROJECT_APP_UUID
(appId
) with the corresponding values retrieved from the Particle dashboard.
Next, you’ll need to head over to your AppDelegate.swift
file to add an import of react_native_particle_connect
.
application
method (as shown below), you’ll need to include a handler condition derived from ParticleConnectSchemeManager handleUrl:url
. This should be as simple as a YES
(true) return upon a true value of ParticleConnectSchemeManager handleUrl:url
.
projectId
(retrieved and configured prior), resulting in a scheme URL that looks something like the following:
Info.plist
file and include the following snippet.
particle_connect
is correctly imported. If you haven’t already, head over to the linked guide to complete this
@particle-network/rn-connect
, which generally can be imported in whole as a singular variable (in the example below, particleConnect
.)
init
on your imported instance of @particle-network/rn-connect
, particleConnect
in this case. init
takes the following parameters:
chainInfo
contains relevant information that determines the primary chain to be used within Particle Connect. (ChainInfo
objects, such as Ethereum
, Polygon
, etc. can be imported from @particle-network/chains
)env
, imported from @particle-network/rn-connect
, and can be either:Env.Production
.Env.Staging
.Env.Dev
.metadata
, an instance of DappMetaData
containing the following parameters:walletConnectProjectId
, your WalletConnect project ID retrieved from the WalletConnect dashboard.name
is the name of your project.icon
, your project’s logo, ideally 512x512.url
, the URL of your project’s website.description
is a description of your project.redirect
is a provided redirect that can be left blank.verifyUrl
, a URL for verification, can be left blank.setWalletConnectV2SupportChainInfos
and passing in an array of ChainInfo
objects representing the different chains you’d like to be supported by your instance of WalletConnect. E.g.:
particleConnect.connectWithConnectKitConfig
is a one-click login function that can present a customizable login UI. The parameter config can be derived from ConnectKitConfig
.
ConnectKitConfig.init
includes the following parameters:
Field | Type | Description |
---|---|---|
connectOptions | ConnectOption[] | Methods supported for connection, EMAIL , PHONE , SOCIAL and WALLET ; the order in which these are placed will be reflected within the modal. |
socialProviders | EnableSocialProvider[]? | Supported social login methods, such as GOOGLE , APPLE and other social options; the order in which these are placed will be reflected within the modal. |
walletProviders | EnableWalletProvider[]? | Supported wallet providers, such as MetaMask , Trust and other wallet options; the order in which these are placed will be reflected. |
additionalLayoutOptions | AdditionalLayoutOptions? | Layout options. |
logo | string? | Image URL or base64 string representing the logo used within the modal. |
connect
. Within connect
, you’ll need to pass in a given walletType
, an item selected from WalletType
, imported from @particle-network/rn-connect
. WalletType
can be set to any of the following:
AuthCore
, Particle Auth Core, an alternative to Particle Auth (Particle
).EvmPrivateKey
, custom EVM wallet imports/exports.SolanaPrivateKey
, custom Solana wallet imports/exports.MetaMask
.Rainbow
.Trust
.ImToken
.BitKeep
.WalletConnect
.Phantom
, intended for Solana.Zerion
.Math
.Inch1
, 1inch.Zengo
.Alpha
.Bitpie
.OKX
.TokenPocket
, not supported by iOS.AuthCore
, you’ll also need to pass in a ParticleConnectConfig
object containing:
Field | Type | Description |
---|---|---|
loginType | LoginType | The specific social login to be used. This can be either .email , .phone , .google , .apple , .jwt , .facebook , .twitter , .discord , .github , .twitch , .microsoft or linkedin . |
account | string? | (Optional) When type is set to either .email , .phone , or .jwt , you can use the account parameter to pass in an expected email, phone number, or JWT. This is optional for the former two, but required for .jwt . When passing a phone number, it must be in E.164 format. |
code | string? | (Optional) when type is set to either .email pr .phone , you can use the code parameter to pass the verification code. |
supportAuthType | SupportAuthType[] | The methods of authentication visible on the authentication popup UI. By default, this will be exclusive to the chosen social login method, although by passing in additional types, you can expand the UI to include the ability to login with those as an alternative to type. |
socialLoginPrompt | SocialLoginPrompt? | (Optional) either .None , .Consent , or .SelectAccount |
loginPageConfig | LoginPageConfig? | (Optional) Changes what the OAuth provider prompts a user to do; either .none , .consent , or .select_account . Only Google, Discord and Microsoft support it. |
WalletType
) from your application through disconnect
. This requires both the relevant WalletType
and associated address as parameters. E.g.:
isConnected
and passing in the corresponding WalletType
and address. E.g.:
ParticleConnect.signMessage
, passing in the WalletType
, address
(publicAddress
in this example), and the message
in question. message
should either be a hex-encoded string for EVM, or a base58 string for Solana. E.g.:
signAndSendTransaction
, you can sign a given transaction without pushing it to the network with particleConnect.signTransaction
, taking WalletType
, address
(publicAddress
), and a base58 transaction
string representing a structured transaction object.
Alternatively, the plural of this method is particleConnect.signAllTransactions
, which instead takes an array of base58 transaction
strings to be prompted for signature.
particleConnect.signAndSendTransaction
takes in a transaction and prompts a user (through a UI corresponding with WalletType
) for confirmation/signature.
Specifically, particleConnect.signAndSendTransaction
takes a WalletType
, address
(publicAddress
), and transaction
string. For EVM chains, this should be a hex-encoded string Solana and a base58 string. An example of this can be found below.
ParticleConnect.signTypedData
to prompt the signature of typed (structured) data adjacent to eth_signTypedData
.
ParticleConnect.signTypedData
requires WalletType
, address
(publicAddress
), and the typedData
to be signed. typedData
should be a hex-encoded string representing a data structure. E.g.:
or
SolanaPrivateKey` wallet types, you can import wallets through either a seed phrase or private key. These methods will associate an account instance derived from these keys, allowing utilization within your application.
These can be achieved through either importPrivateKey
for importing a private key, or importMnemonic
for importing a mnemonic (seed phrase). These methods require the WalletType
(either EvmPrivateKey
or SolanaPrivateKey
) and the private key/seed phrase to be imported.
Additionally, you can export one of these wallets with exportPrivateKey
, passing in the address (of the EvmPrivateKey
or SolanaPrivateKey
imported/generated wallet) that you’d like to export.
WalletType
(connection mechanism). This is done through getAccounts
and returns an array of addresses within the current session associated with a given WalletType
. E.g.:
@particle-network/rn-connect
includes @partcile-connect/rn-auth-core
.
If you log in with a Particle account, you can access additional functions such as getUserInfo
, openAccountAndSecurity
, hasMasterPassword
and hasPaymentPassword
and changeMasterPassword
. You can also reference the docs from Auth SDK reference.