SmartWallet class
A class that represents a Smart Wallet on an Ethereum-like blockchain.
The SmartWallet class implements the SmartWalletBase
interface and provides
various methods for interacting with the wallet, such as sending transactions,
estimating gas, and retrieving balances. It uses various plugins for different
functionalities, such as contract interaction, gas estimation, and signing operations.
The class utilizes the _PluginManager
and _GasSettings
mixins for managing plugins
and gas settings, respectively.
Example usage:
// Create a new instance of the SmartWallet
final wallet = SmartWallet(chain, walletAddress, initCode);
// Get the wallet balance
final balance = await wallet.balance;
// Send a transaction
final recipient = EthereumAddress.fromHex('0x...');
final amount = EtherAmount.fromUnitAndValue(EtherUnit.ether, 1);
final response = await wallet.send(recipient, amount);
Constructors
- SmartWallet.new(NetworkConfig _network, EthereumAddress _walletAddress, Uint8List _initCode)
- Creates a new instance of the SmartWallet class.
Properties
- address → EthereumAddress
-
The Ethereum address of the Smart Wallet.
no setter
-
balance
→ Future<
EtherAmount> -
Returns the balance of the Smart Wallet.
no setter
- dummySignature → String
-
Retrieves the dummy signature required for gas estimation from the Smart Wallet.
no setter
- gasSettings ← GasSettings
-
Sets the gas settings for user operations.
no getterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- initCode → String
-
Returns the initialization code for deploying the Smart Wallet contract.
no setter
-
initCodeGas
→ Future<
BigInt> -
Returns the estimated gas required for deploying the Smart Wallet contract.
no setter
-
isDeployed
→ Future<
bool> -
Checks if the Smart Wallet is deployed on the blockchain.
no setter
-
nonce
→ Future<
Uint256> -
Returns the nonce for the Smart Wallet from the entrypoint.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- toHex → String?
-
Returns the hexadecimal representation of the Smart Wallet address in EIP-55 format.
no setter
Methods
-
activePlugins(
) → List< String> -
returns a list of all active plugins
inherited
-
addPlugin<
T> (String name, T module) → void -
Adds a plugin by name.
inherited
-
applyCustomGasSettings(
UserOperation op, double version) → UserOperation -
Applies the gas settings to a user operation, by multiplying the gas limits by a certain percentage.
inherited
-
buildUserOperation(
{required Uint8List callData, BigInt? customNonce}) → UserOperation - Builds a UserOperation instance with the specified parameters.
-
dropAndReplaceUserOperation(
String opHash) → Future< ReplaceUserOperationResult> -
estimateGasForBatchedOperation(
List< EthereumAddress> recipients, List<Uint8List> calls, {List<EtherAmount> ? amounts}) → Future<BigInt> - Estimates transaction fee price for batched user operation. Useful in case you want to know transaction fee, one of the use cases is if you want to deduct tx fee from user wallet to compensate paymaster expenses in case you want users to pay fees in your tokens
-
estimateGasForSingleOperation(
EthereumAddress to, Uint8List encodedFunctionData, {EtherAmount? amount}) → Future< BigInt> - Estimates transaction fee price for single user operation. Useful in case you want to know transaction fee, one of the use cases is if you want to deduct tx fee from user wallet to compensate paymaster expenses in case you want users to pay fees in your tokens
-
hasPlugin(
String name) → bool -
checks if a plugin exists
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
plugin<
T> ([String? name]) → T -
Gets a plugin by name.
inherited
-
prepareUserOperation(
UserOperation op, {bool update = true, bool shouldPaymasterIntercept = true}) → Future< UserOperation> - Prepares a user operation by updating it with the latest nonce, intercepting it with a paymaster, and validating it.
-
removePlugin(
String name) → void -
Removes an unwanted plugin by name.
inherited
-
send(
EthereumAddress recipient, EtherAmount amount) → Future< UserOperationResponse> - Asynchronously transfers native Token (ETH) to the specified recipient with the given amount.
-
sendBatchedTransaction(
List< EthereumAddress> recipients, List<Uint8List> calls, {List<EtherAmount> ? amounts}) → Future<UserOperationResponse> - Asynchronously sends a batched Ethereum transaction to multiple recipients with the given calls and optional amounts.
-
sendSignedUserOperation(
UserOperation op) → Future< UserOperationResponse> - Asynchronously sends a signed user operation to the bundler for execution.
-
sendTransaction(
EthereumAddress to, Uint8List encodedFunctionData, {EtherAmount? amount}) → Future< UserOperationResponse> - Asynchronously sends an Ethereum transaction to the specified address with the provided encoded function data and optional amount.
-
sendUserOperation(
UserOperation op) → Future< UserOperationResponse> - Asynchronously sends a user operation after signing it and obtaining the required signatures.
-
signUserOperation(
UserOperation op) → Future< UserOperation> - Asynchronously signs a user operation with the required signatures.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited