Dynamic Account Factory
import "@thirdweb-dev/contracts/smart-wallet/dynamic/DynamicAccountFactory.sol";
This contract inherits from the BaseAccountFactory
contract.
This factory smart contract is intended to be used to distribute 'DynamicAccounts` programmatically.
If you modify the DynamicAccount
contract, it is recommended that you write your own
factory contract by inheriting from the BaseAccountFactory
extension.
Detected Extensions
Once deployed, you can use the features made available by these extensions on the SDK and dashboard:
Click on each feature to learn more about what functions are available.
Usage
Use the CLI create
command to create a DynamicAccountFactory
smart contract:
npx thirdweb create contract
Deploy your contract using the deploy cli command:
npx thirdweb create
Or import the contract into your existing project and inherit from it.
import "@thirdweb-dev/contracts/smart-wallet/dynamic/DynamicAccountFactory.sol";
contract MyDynamicAccountFactory is DynamicAccountFactory {
constructor(
IEntryPoint _entrypoint
)
DynamicAccountFactory(
_entrypoint
)
{}
}
Full Reference
_initializeAccount
Called in createAccount
. Initializes the account contract created in createAccount
.
function _initializeAccount(
address _account,
address _admin,
bytes calldata _data
) internal override {
DynamicAccount(payable(_account)).initialize(_admin, _data);
}
_account
The address of the smart account smart contract to initialize.
_admin
The address to be set as default admin role for the contract. Must be of type address
.
_data
If extra storage variables are required in your account contract, override this function, abi encode the variables,
pass them to this function as the bytes
argument.
For example:
function initializeAccount(
address _admin,
bytes calldata _data
) public override initializer {
DynamicAccount(payable(_account)).initialize(_admin, _data);
}
_account
The address of the smart account smart contract to initialize.
_admin
The address to be set as default admin role for the contract. Must be of type address
.
_data
If extra storage variables are required in your account contract, abi encode the variables,
pass them to this function as the bytes
argument.
For example:
function initializeAccount(
address _admin,
bytes calldata _data
) public override initializer {
DynamicAccount.initialize(_admin, _data);
}