Leveraging Particle’s AA SDK within on Unity applications with C#.
particle-unity
GitHub repository. This is where all of Particle Network’s Unity SDKs are open-sourced and available for download. Before beginning, feel free to take a look at the underlying architecture and demos within particle-unity
to contextualize the processes covered within this page.
Before initializing the SDK, there are a few key points to keep in mind, specifically regarding the utilization of Paymasters (to sponsor gas fees, pay for gas in ERC-20 tokens, etc.)
- All Testnets automatically have the Verifying Particle Network Omnichain Verifying Paymaster enabled, transactions (that request it) will automatically be sponsored and thus gasless.
- On the occasion that you’d like to use the Particle Network Omnichain Verifying Paymaster for Mainnets, you’ll need to deposit USDT on either Ethereum or BNB Chain within the Particle dashboard. This USDT will then automatically be converted as needed into the native token of the network you’re requesting (and qualifying for) sponsorship on.
- The Particle Network AA SDK automatically uses Biconomy’s Token Paymaster. Transactions that request it will be able to leverage it without additional configuration.
ParticleAA
prefab within your first scene. This can be retrieved through the AA package within the forenamed GitHub repository.
Before you can use the full extent of the SDK, you’ll need to initialize it through ParticleAAInteraction.Init
. This process will allow you to choose between a Biconomy or Particle Paymaster, alongside the specific smart account implementation you’d like your users to rely on. ParticleAAInteraction.Init
takes the following parameters:
accountName
, the name of the smart account implementation you’d like to use. Either:
BICONOMY_V1
, a Biconomy smart account.BICONOMY_V2
, a Biconomy smart account.CYBERCONNECT
, a CyberConnect smart account.SIMPLE_V1
, a SimpleAccount implementation.SIMPLE_V2
, a SimpleAccount implementation.LIGHT
, a Light Account implementation.ParticleAAInteraction
, you’ll need to go ahead and enable AA mode through ParticleAAInteraction.EnableAAMode
. From there, you can directly interact with the SDK (sending UserOperations, retrieving fee quotes, etc.)
E.g.:
ParticleAA.Instance.IsDeploy
, as shown below.
ParticleAAInteraction.IsAAModeEnable
, which will return a Boolean indicating eithertrue
or false
otherwise. E.g.:
feeQuote
object, containing constructed UserOperations for three different fee payment mechanisms, either gasless, native paid (native token), or token paid (ERC-20 token Paymaster). Thus, upon sending a transaction, you’ll need to pass in a complete response from the ParticleAA.Instance.RpcGetFeeQuotes
method. Specifically, ParticleAA.Instance.RpcGetFeeQuotes
takes the following parameters:
eoaAddress
, the address of the Signer/owner of the smart account in question (can be retrieved through ParticleAuthCoreInteraction.GetEvmAddress
for Particle Auth).transaction
, an array of multiple or a singular standard transactions to be sent from the smart account. The fee quote response will be based on the parameters defined within the transaction object.walletType
. This is the specific adapter or wallet being used through Particle Connect.eoaAddress
, the owner (or Signer) address of the smart account.transaction
(or for batched transaction, transactions
, an array), a standard transaction object (or objects) containing the parameters of the transaction in question (to
, value
, data
, etc.)AAFeeMode
, the mechanism used to pay gas fees. Either:
AAFeeMode.Native
, natively paid by the smart account (native referring to the network’s base token).AAFeeMode.Gasless
, sponsored by either the Particle Paymaster or a Biconomy Paymaster, depending on initialization settings.AAFeeMode.Token
, leverages a token Paymaster to pay the gas fee in an ERC-20 token.feeQuote
object. The SDK will automatically choose the fee quote corresponding to the previous choice. If you’ve chosen AAFeeMode.Token
, you’ll need to pass in the address of the token Paymaster alongside the feeQuote
object.