Skip to content

AvoFactory

AvoFactory_V1

Deploys Avocado smart wallet contracts at deterministic addresses using Create2.

Upgradeable through AvoFactoryProxy

AvoFactoryErrors

AvoFactory__NotEOA

solidity
error AvoFactory__NotEOA()

thrown when trying to deploy an Avocado for a smart contract as owner

AvoFactory__Unauthorized

solidity
error AvoFactory__Unauthorized()

thrown when a caller is not authorized to execute a certain action

AvoFactory__InvalidParams

solidity
error AvoFactory__InvalidParams()

thrown when a method is called with invalid params (e.g. zero address)

AvoFactory__IndexNonSequential

solidity
error AvoFactory__IndexNonSequential()

thrown when deploy is called with an index where index-1 is not deployed yet. After index > 5, index must be used sequential.

AvoFactory__ImplementationNotDefined

solidity
error AvoFactory__ImplementationNotDefined()

thrown when deploy methods are called before an implementation is defined

AvoFactoryConstants

avocadoCreationCode

solidity
bytes avocadoCreationCode

hardcoded Avocado creation code.

avocadoBytecode

solidity
bytes32 avocadoBytecode

cached avocado (proxy) bytecode hash to optimize gas usage

avoRegistry

solidity
contract IAvoRegistry avoRegistry

registry holding the valid versions (addresses) for Avocado smart wallet implementation contracts. The registry is used to verify a valid version before setting a new avoImpl as default for new deployments.

AvoFactoryVariables

avoImpl

solidity
address avoImpl

Avocado logic contract address that new Avocado deployments point to. Modifiable only by avoRegistry.

AvoFactoryEvents

AvocadoDeployed

solidity
event AvocadoDeployed(address owner, uint32 index, uint16 avoType, address avocado)

Emitted when a new Avocado has been deployed

AvocadoDeployedWithVersion

solidity
event AvocadoDeployedWithVersion(address owner, uint32 index, uint16 avoType, address avocado, address version)

Emitted when a new Avocado has been deployed with a non-default version

AvoFactoryCore

AvoFactory

constructor

solidity
constructor(contract IAvoRegistry avoRegistry_) public

constructor sets the immutable avoRegistry address

initialize

solidity
function initialize() public

initializes the contract

isAvocado

solidity
function isAvocado(address avoSmartWallet_) external view returns (bool)

Checks if a certain address is an Avocado smart wallet. Only works for already deployed wallets.

Parameters

NameTypeDescription
avoSmartWallet_addressaddress to check

Return Values

NameTypeDescription
[0]booltrue if address is an Avocado

deploy

solidity
function deploy(address owner_, uint32 index_) external returns (address deployedAvocado_)

Deploys an Avocado for a certain owner_ deterministcally using Create2. Does not check if contract at address already exists (AvoForwarder does that)

Parameters

NameTypeDescription
owner_addressAvocado owner
index_uint32index number of Avocado for owner_ EOA

Return Values

NameTypeDescription
deployedAvocado_addressdeployed address for the Avocado contract

deployWithVersion

solidity
function deployWithVersion(address owner_, uint32 index_, address avoVersion_) external returns (address deployedAvocado_)

Deploys an Avocado with non-default version for an owner_ deterministcally using Create2. Does not check if contract at address already exists (AvoForwarder does that)

Parameters

NameTypeDescription
owner_addressAvocado owner
index_uint32index number of Avocado for owner_ EOA
avoVersion_addressVersion of Avocado logic contract to deploy

Return Values

NameTypeDescription
deployedAvocado_addressdeployed address for the Avocado contract

computeAvocado

solidity
function computeAvocado(address owner_, uint32 index_) public view returns (address computedAddress_)

Computes the deterministic Avocado address for owner_ based on Create2

Parameters

NameTypeDescription
owner_addressAvocado owner
index_uint32index number of Avocado for owner_ EOA

Return Values

NameTypeDescription
computedAddress_addresscomputed address for the Avocado contract

transientDeployData

solidity
function transientDeployData() external view returns (address version_, uint256 data_)

returns transient data used to pass variables into the Avocado proxy during deployment. Reduces gas cost and dependency of deterministic address on constructor args.

setAvoImpl

solidity
function setAvoImpl(address avoImpl_) external

registry can update the current Avocado implementation contract set as default _avoImpl logic contract address for new deployments

Parameters

NameTypeDescription
avoImpl_addressthe new avoImpl address