account_abstraction_alchemy 0.0.3 copy "account_abstraction_alchemy: ^0.0.3" to clipboard
account_abstraction_alchemy: ^0.0.3 copied to clipboard

Account Abstraction smart wallet client for Alchemy, only supports usage with gas manager

ERC-4337: Account Abstraction, for usage with Alchemy Account Abstraction #

enter image description here

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

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);

Additional information #

This library designed to be used only with gas manager, to sponsor gas for transactions.

Currently supports only Entry point version 0.6, and Simple account.

Tested on Android and Web platforms, but should work on all platforms.

3
likes
0
points
95
downloads

Publisher

unverified uploader

Weekly Downloads

Account Abstraction smart wallet client for Alchemy, only supports usage with gas manager

Homepage
Repository (GitHub)
View/report issues

Topics

#wallets #ethereum #web3 #account-abstraction #alchemy

License

unknown (license)

Dependencies

asn1lib, blockchain_utils, flutter, http, web3dart

More

Packages that depend on account_abstraction_alchemy