Interacting with Particle Auth within applications made using Flutter.
projectId
, clientKey
, and appId
.
particle_auth_core
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 your build.gradle
file, you’ll need to add four new lines to ensure Particle Auth runs appropriately:
minSdkVersion
, which in most cases 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
.
build.gradle
you’ll need to ensure that the repositories
object in both buildscript
and allprojects
has maven { setUrl("https://jitpack.io") }
present, such as is shown below.
apps/{project name}.xcworkspace
.
At the root of your Xcode project, create a new file, ParticleNetwork-Info.plist
. Ensure this is marked under Target Membership
.
Now, 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.
To enable Face ID for your app, add a usage description to your Info.plist
file by including the following code:
particle_auth_core
is properly imported. Head over to the linked guide to complete this, if you haven’t already.
Another important note before continuing.
Our SDK is a static library (XCFramework). When using the Particle Auth Flutter SDK, you’ll need to specify that you’re using a static framework through the following:
init
, passing in the specific chain to which you intend to primarily onboard within Particle’s Wallet-as-a-Service. This is represented as an object containing chain info (often derived from ChainInfo.{Chain}
).
ParticleAuthCore.connect
. This triggers a social login prompt, and upon successful authentication, a user account is created, unlocking the full SDK functionality.
ParticleAuthCore.connect
takes the following parameters:
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 . If passing a phone number, it must be in E.164 format. |
prompt | SocialLoginPrompt? | (Optional) 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) Controls login UI customization: contains project name, icon and description. |
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. |
ParticleAuthCore.isConnected
(server-side check).
ParticleAuthCore.disconnect
.
ParticleAuthCore.getUserInfo
.
Evm.getAddress
or Solana.getAddress
.
Evm.personalSign
or Evm.personalSignUnique
method.
If you need the same message to return a unique signature each time, use the Evm.personalSignUnique
method. Otherwise, the Evm.personalSign
method is generally recommended. On Solana, you can call Solana.signMessage
, you can pass in a UTF-8/readable string.
Field | Type | Description |
---|---|---|
message | String | On Evm requires a hexadeciaml string, on Solana, requires a UTF-8/readable string |
Field | Type | Description |
---|---|---|
transaction | String | Requires a base58 string |
Solana.signAllTransactions
to propose a collection of Solana transactions for signature, rather than just a single transaction.
Field | Type | Description |
---|---|---|
transactions | List<String> | Each element requires a base58 string |
Evm.sendTransaction
and sendTransactionand
Solana.signAndSendTransaction` will be the primary smethods used in virtually every scenario.
This will propose a signature (on both EVM and Solana) and then immediately push it to the network once confirmed.
Field | Type | Description |
---|---|---|
transaction | String | On Evm requires a hexadeciaml string, on Solana, requires a base58 string |
Evm.signTypedData
or Evm.signTypedDataUnique
method.
If you need the same message to return a unique signature each time, use the Evm.signTypedDataUnique
method. Otherwise, the Evm.signTypedData
method is generally recommended.
Field | Type | Description |
---|---|---|
message | String | Requires a hexadeciaml string |
init
, you can use ParticleBase.setChainInfo
for a synchronous update or ParticleAuthCore.switchChain
for an asynchronous update, both typically using ChainInfo.{Chain}
.
ParticleBase.getChainInfo
. This returns a ChainInfo
object containing:
name
: The chain’s name (e.g., Ethereum).id
: The ID of the chain (e.g., 11155111).network
: The specific network associated with the chain ID (e.g., Sepolia).ParticleBase.setSecurityAccountConfig
, where you pass in a SecurityAccountConfig
object with two parameters:
Field | Type | Description |
---|---|---|
promptSettingWhenSign | int | The security account config prompts (default is 1). |
promptMasterPasswordSettingWhenLogin | int | The master password prompts (default is 0). |
0
means a prompt is never shown requesting this setting.1
means a prompt is shown only upon the first startup.2
means a prompt is shown every time.3
means force set payment password before sign.ParticleAuthCore.openAccountAndSecurity
.
isConnected
function covered prior, there are various scenarios in which knowing whether or not a user has specific security settings enabled may be useful.
In the case of the Particle Auth Flutter SDK, this can happen in one of two ways:
With the built-in ParticleAuthCore.hasMasterPassword
, ParticleAuthCore.hasPaymentPassword
, and ParticleAuthCore.changeMasterPassword
methods.
ParticleBase.setAppearance
. By default, it will follow the current system setting.
Field | Type | Description |
---|---|---|
appearance | Appearance | The specific appearance to be used. This can be either .system , .dark , .light . |
ParticleBase.setLanguage
, with the retrieval of the currently active language facilitated by ParticleBase.getLanguage
. By default, this is set to English.
Field | Type | Description |
---|---|---|
language | Language | The specific language to be used. This can be either .en , .ja , .zh_hans , .zh_hant , .ko . |
ParticleBase.setSecurityAccountConfig
to update its value.Field | Type | Description |
---|---|---|
isoCodeList | List<String> | ISO 3166-1 alpha-2 code list, such as the US, the UK, etc. |
EvmService
utilization examplesParticleAuthCore
for authentication and interaction with Particle’s Wallet-as-a-Service, the Flutter SDK also includes a class, EvmService
, for general interaction with EVM chains.
EvmService.writeContract
allows you to execute a write contract call defined by a specific method and set of parameters. This requires a corresponding ABI, contract address, and requester public address.
Field | Type | Description |
---|---|---|
address | String | The user’s public address. |
contractAddress | String | The contract address. |
methodName | String | The method name that defined in the contract, such as mint , balanceOf . |
parameters | List<Object> | The parameters of this method. |
abiJsonString | String | The abi json string of this method. |
gasFeeLevel | GasFeeLevel | (Optional) The gas fee level, high , medium or low , default is high . |
EvmService.readContract
allows you to execute a read-only contract call defined by a specific method and set of parameters. This requires a corresponding ABI, contract address, and requester public address.
Field | Type | Description |
---|---|---|
address | String | The user’s public address. |
contractAddress | String | The contract address. |
methodName | String | The method name that defined in the contract, such as mint , balanceOf . |
parameters | List<Object> | The parameters of this method. |
abiJsonString | String | The abi json string of this method. |
EvmService.createTransaction
facilitates the construction of a transaction object derived from the standard from
, to
(receiver
in this example), amount
(value
), and data
fields. This transaction, once constructed with EvmService.createTransaction
, can be passed for in-UI proposal with ParticleAuthCore.sendTransaction
.
Field | Type | Description |
---|---|---|
from | String | The user’s public address. |
data | String | The transaction’s data. |
value | BigInt | The native amount. |
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. |
gasFeeLevel | GasFeeLevel | (Optional) the gas fee level, high , medium or low , default is high . |
EvmService.ethEstimateGas
method.
This acts as a wrapper for eth_estimateGas
to simulate and retrieve the estimated gas required.
EvmService.suggestedGasFees
.
EvmService
also extends to Data API methods such as getTokensAndNFTs
, which returns a highly detailed JSON list of ERC20 tokens and ERC721 NFTs belonging to a specified address.
This is accessible through EvmService.getTokensAndNFTs
, passing in the public address to retrieve the tokens and NFTs. Also, you can retrieve tokens from getTokens
or NFTs from getNFTs
Field | Type | Description |
---|---|---|
address | String | The user’s public address. |
tokenAddresses | List<String> | The specific tokens’ addresses |
EvmService.getTransactionsByAddress
enables the retrieval of a detailed JSON response containing a complete list of transactions involving a specified address.
EvmService.getPrice
.
Field | Type | Description |
---|---|---|
tokenAddresses | List<String> | The tokens’s addresses, for native token, you can pass "native" |
currencies | List<String> | The price unity, such as "usd" |
EvmService.rpc
SolanaService
utilization examplesParticleAuth
for authentication and interaction with Particle’s Wallet-as-a-Service, the Flutter SDK also includes a class, SolanaService
, for general interaction with Solana chains.
SolanaService
also extends to Data API methods such as getTokensAndNFTs
, which returns a highly detailed JSON list of SPL tokens and NFTs belonging to a specified address. This is accessible through SolanaService.getTokensAndNFTs
, passing in the public address to retrieve the tokens and NFTs of.
Field | Type | Description |
---|---|---|
address | String | The user’s public address. |
parseMetadataUri | bool | if parse the nft meta data. |
SolanaService.serializeSolTransaction
facilitates the construction of a SOL transaction object,
SolanaService.serializeSplTokenTransaction
facilitates the construction of a Spl-token transaction object,
SolanaService.serializeWSolTokenTransaction
facilitates the construction of a unwrap WSOL transaction object.
These transactions, once constructed, can be passed for in-UI proposal with Solana.signAndSendTransaction
.
SolanaService.getPrice
.
Field | Type | Description |
---|---|---|
tokenAddresses | List<String> | The tokens’s addresses, for native token, you can pass "native" |
currencies | List<String> | The price unity, such as "usd" |
SolanaService.getTransactionsByAddress
.
SolanaService.getTokenByTokenAddresses
Field | Type | Description |
---|---|---|
address | String | The user’s public address. |
tokenAddresses | List<String> | The tokens’ addresses |
SolanaService.rpc
.