dependencies {
// Particle AA Service
implementation("network.particle:aa-service:${latest_version}")
//find the latest version of the sdk:
//https://search.maven.org/search?q=g:network.particle
//...
}
Before Start
All testnets have Particle Verifying Paymaster enabled, you can send any gasless transaction;
Token Paymaster is automatically enabled (we are using Biconomy Token Paymaster).
Initialize
val apiKey =mapOf( Ethereum.id to "YOUR_DAPP_API_KEY", EthereumGoerli.id to "YOUR_DAPP_API_KEY", Polygon.id to "YOUR_DAPP_API_KEY" )// apiKey can be empty // aaService can be BiconomyV1AAService、BiconomyV2AAService、CyberConnectAAService、 SimpleAAService. It can be null, default BiconomyV2AAService.
ParticleNetwork.initAAMode(apiKey, aaService = BiconomyAAService)
Enable aa service
After enable AA service, The address displayed on the wallet page will display the SmartAccount address. and the signAndSendTransaction method will change the way transactions are sent.
ParticleNetwork.getAAService().enableAAMode()
Disable AA service
After disable AA service, smart account will not work.
ParticleNetwork.getAAService().disableAAMode()
Get AA service enable state
val isEnable = ParticleNetwork.getAAService().isAAModeEnable()
// 1. gasless// you can call the same method to send a transaction in AA mode.// send gasless transactionParticleNetwork.signAndSendTransaction(tranaction, callback ,FeeModeGasless())// 2. auto(default)// send user paid transaction, select native to pay gas fee.ParticleNetwork.signAndSendTransaction(tranaction, callback , FeeModeAuto())// 3.custom// send user paid transaction, select token to pay gas fee.// get a feeQuote from rpcGetFeeQuotes methodval feeQuote: Erc4337FeeQuote//get Erc4337FeeQuote by ParticleNetwork.getAAService().rpcGetFeeQuotes()ParticleNetwork.signAndSendTransaction(tranaction, callback , FeeModeCustom(feeQuote))
// 1. gasless// you can call the same method to send a transaction in AA mode.// send gasless transactionconnectAdapter.signAndSendTransaction(publicAddress = publicAddress, transaction = tranaction, FeeModeGasless(), callback)
// 2. auto(default)// send user paid transaction, select native to pay gas fee.connectAdapter.signAndSendTransaction(publicAddress = publicAddress, transaction = tranaction, FeeModeAuto(), callback)
// 3.custom// send user paid transaction, select token to pay gas fee.// get a feeQuote from rpcGetFeeQuotes methodval feeQuote: Erc4337FeeQuote//get Erc4337FeeQuote by ParticleNetwork.getAAService().rpcGetFeeQuotes()connectAdapter.signAndSendTransaction(publicAddress = publicAddress, transaction = tranaction, FeeModeCustom(feeQuote), callback)
Send batch transactions
you need create a AAService instance, then call quickSendTransactions mehod