Leveraging Particle Connect within applications built using Flutter.
wallet-adapter
, and private key imports, thus reducing the barrier to entry within your application.
Instructions and examples for implementing Particle Connect within Flutter applications can be found below.
projectId
, clientKey
, and appId
.
These values tie a given implementation to the Particle dashboard, enabling configuration, analytics, tracking, etc.
particle_connect
to your Flutter application. This is a requirement before moving onto platform-specific configuration.
build.gradle
file, typically at ${project_name}/android/app/build.gradle
.
In your build.gradle
file, add the following four lines to ensure Particle Connect is properly configured:
minSdkVersion
. In most cases, this will 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.”
From here, 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 head over to your AppDelegate.swift
file to add an import of ParticleConnect
.
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.
Head over to the linked guide to complete this if you haven’t already.
ParticleInfo.set
and pass in your projectId
and client key (clientK
). Next, initialization can happen through the init
function on ParticleConnect
, which can be imported from package:particle_connect/particle_connect.dart
.
init
takes the following parameters:
Field | Type | Description |
---|---|---|
chainInfo | ChainInfo | The primary blockchain and network (e.g., testnet) your application will use. For instance, you might choose .Ethereum or .EthereumSepolia , depending on the specific network required for your use case. |
dAppData | DAppMetadata | Metadata outlining the description of your application; this should be an instance of DAppMetadata with the following parameters: name , the name of your project. icon , a URL linking to the icon of your project; this should be 512x512, ideally. url , the URL of your project’s website. description , the description of your project, redirect , optional, redirect universal link of you project, verifyUrl , optional. |
env | Env | The specific environmennt to be used. This can be either .dev , .staging , or .production . |
rpcUrlConfig | RpcUrlConfig? | Customize the RPC URL. |
ChainInfo
objects (chainInfos
in this example) and use it within ParticleConnect.setWalletConnectV2SupportChainInfos
. E.g.:
ParticleConnect.connectWithConnectKitConfig
is the core method driving Particle Connect’s customizable login modal, enabling one-click onboarding.
As detailed below, the parameters available to configure this modal can be found through ConnectKitConfig
.
Field | Type | Description | |
---|---|---|---|
connectOptions | List<ConnectOption> | Methods supported for connection, EMAIL , PHONE , SOCIAL and WALLET ; the order in which these are placed will be reflected within the modal. | |
socialProviders | List<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 | List<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. |
WalletType
, the connect
method on ParticleConnect
will be the primary mechanism for wallet connection within the Particle Connect SDK. ParticleConnect.connect
takes one parameter, the WalletType
to be requested for connection. Upon calling, the wallet specified in this field will throw an interface initiating the connection.
WalletType
is an enum
containing the following:
authCore
, social logins through Particle Auth.evmPrivateKey
, custom EVM wallet imports/exports.solanaPrivateKey
, custom Solana wallet imports/exports.metaMask
.rainbow
.trust
.imToken
.bitKeep
.walletConnect
.zerion
.math
.zengo
.alpha
.okx
.phantom
, intended for Solana.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 or .phone , you can use the code parameter to pass the verification code. |
supportAuthTypes | List<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? | Changes what the OAuth provider prompts a user to do; either .none , .consent , or .select_account . Only Google, Discord and Microsoft support it. |
loginPageConfig | LoginPageConfig? | (Optional) To customize the UI page, contains project name, icon and description. |
ParticleConnect.disconnect
, which requires a targeted WalletType
and address
(publicAddress
in this case). This pair dictates that the specific session (user) be disconnected. E.g.:
ParticleConnect.isConnected
, returning a Boolean representing whether or not a user (defined by a paired WalletType
and address
) is currently connected to your application. E.g.:
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.:
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, or for Solana, this should be 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.:
evmPrivateKey
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 ParticleConnect.exportPrivateKey
, passing in the address (of the evmPrivateKey
or solanaPrivateKey
imported/generated wallet) that you’d like to export.
particle_connect
includes particle_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 reference the docs from Auth SDK reference