Last updated:
0 purchases
account abstraction alchemy
ERC-4337: Account Abstraction, for usage with Alchemy Account Abstraction #
Read more about Alchemy account abstraction
Alchemy AA API documentation
Features #
Create private key signer
Create smart wallet
ABI Encoding/Decoding
Sent transactions with sponsored gas
Wait for transaction receipt
Getting started #
To get started, you need to add account_abstraction_alchemy to your project.
flutter pub add account_abstraction_alchemy
copied to clipboard
Create Alchemy app and get your Alchemy API key from dashboard.
Create gas policy for created app, and get gas policy ID.
Usage #
// Import the package
import 'package:account_abstraction_alchemy/account_abstraction_alchemy.dart';
// Create EthPrivateKey from private key hex string
// it's up to you how you obtain the private key hex you can create random or
// use private key provided by web3auth for example
// created private key will be used to create "signer"
final privateKey = EthPrivateKey.fromHex(PRIVATE KEY HEX HERE);
// Setup network config
// Currently supporting ethereum mainnet, polygon, and sepolia testnet networks.
final network = NetworkConfigs.getConfig(
Network.sepolia,
AccountType.simple,
EntryPointVersion.v06,
"ALCHEMY-API-KEY-HERE",
"ALCHEMY-GAS-POLICY-ID-HERE");
// Generate salt
final salt = Uint256.fromHex(hexlify(
keccak256(EthereumAddress.fromHex(signer.getAddress()).addressBytes)));
// Create wallet factory
final SmartWalletFactory walletFactory = SmartWalletFactory(network, signer);
// Finally create simple smart account
final wallet = await walletFactory.createSimpleAccount(salt);
print('Wallet address: ${wallet?.address.hex}');
// Now you need send some sepolia eth to your newly created wallet address
// and send your first transaction
final recipient = EthereumAddress.fromHex('0x502FE2DCc50DfFec11317f26363fcb44D507D81C');
final amountWei = EtherAmount.inWei(BigInt.from(10000000000000000)); // 0.01 eth
// send it
final transaction = await wallet.send(recipient, amountWei);
// than we wait for receipt
final response = await transaction.wait();
// done, you can check transactions details on sepolia explorer
print(response!.receipt.transactionHash);
copied to clipboard
Additional information #
This library designed to be used only with gas manager, to sponsor gas for transactions.
Important: if you want to send batch transactions use Light account type.
Currently supported entry point versions:
0.6
Currently supported smart accounts:
Simple (does not support batch transactions)
Light (supports batch transactions)
Tested on Android and Web platforms, but should work on all platforms.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.