Skip to content

Solidity API

PropsDiamondFactory

Factory contract for creating new PropsDiamond instances with predictable addresses

Deploys new diamond contracts using CREATE2 for address predictability Supports metatransactions through ERC2771Context Provides functionality for diamond initialization and pre-approval operations

templateDiamond

solidity
address templateDiamond

Address of the template diamond contract to be cloned

Immutable value set during construction

diamondCutFacet

solidity
address diamondCutFacet

Address of the DiamondCutFacet contract

Immutable value set during construction, used for diamond initialization

DiamondCreated

solidity
event DiamondCreated(address diamondAddress)

Emitted when a new diamond is created

Parameters

NameTypeDescription
diamondAddressaddressThe address of the newly created diamond

constructor

solidity
constructor(address _templateDiamond, address _diamondCutFacet) public

Constructs the PropsDiamondFactory

Sets up the factory with template references and initializes the trusted forwarder

Parameters

NameTypeDescription
_templateDiamondaddressAddress of the template diamond contract
_diamondCutFacetaddressAddress of the DiamondCutFacet contract

createDiamond

solidity
function createDiamond(bytes32 _salt, struct IPropsInitCall.InitCall[] _initCalls, struct IPropsPreApprovalCall.PropsPreApprovalCall[] _preApprovalCalls) external returns (address)

Creates a new diamond with initialization calls

Deploys a new diamond with CREATE2 and executes initialization calls

Parameters

NameTypeDescription
_saltbytes32Unique value to determine the contract address
_initCallsstruct IPropsInitCall.InitCall[]Array of initialization calls to be executed on the new diamond
_preApprovalCallsstruct IPropsPreApprovalCall.PropsPreApprovalCall[]Array of pre-approval calls to be executed before initialization

Return Values

NameTypeDescription
[0]addressAddress of the newly created diamond

createDiamond

solidity
function createDiamond(bytes32 _salt, struct IDiamondCut.FacetCut[] _initialDiamondCuts, struct IPropsInitCall.InitCall[] _initCalls, struct IPropsPreApprovalCall.PropsPreApprovalCall[] _preApprovalCalls) external returns (address)

Creates a new diamond with initial facet cuts and initialization calls

Deploys a new diamond with CREATE2, applies facet cuts, and executes initialization calls

Parameters

NameTypeDescription
_saltbytes32Unique value to determine the contract address
_initialDiamondCutsstruct IDiamondCut.FacetCut[]Array of initial facet cuts to be applied to the new diamond
_initCallsstruct IPropsInitCall.InitCall[]Array of initialization calls to be executed on the new diamond
_preApprovalCallsstruct IPropsPreApprovalCall.PropsPreApprovalCall[]Array of pre-approval calls to be executed before initialization

Return Values

NameTypeDescription
[0]addressAddress of the newly created diamond

_createDiamond

solidity
function _createDiamond(bytes32 _salt, struct IDiamondCut.FacetCut[] _initialDiamondCuts, struct IPropsInitCall.InitCall[] _initCalls, struct IPropsPreApprovalCall.PropsPreApprovalCall[] _preApprovalCalls) internal returns (address clone)

Core function to create a diamond with all necessary initializations

Uses CREATE2 to deploy the diamond with a deterministic address Executes pre-approval calls and initializes the diamond

Parameters

NameTypeDescription
_saltbytes32Unique value to determine the contract address
_initialDiamondCutsstruct IDiamondCut.FacetCut[]Array of initial facet cuts to be applied
_initCallsstruct IPropsInitCall.InitCall[]Array of initialization calls to be executed
_preApprovalCallsstruct IPropsPreApprovalCall.PropsPreApprovalCall[]Array of pre-approval calls to be executed

Return Values

NameTypeDescription
cloneaddressAddress of the newly created diamond

_executePreApprovalCalls

solidity
function _executePreApprovalCalls(address _diamond, struct IPropsPreApprovalCall.PropsPreApprovalCall[] _preApprovalCalls) internal

Executes pre-approval calls before diamond initialization

Handles special cases where addresses are substituted with the diamond address Currently supports ERC20 permit operations

Parameters

NameTypeDescription
_diamondaddressAddress of the diamond being created
_preApprovalCallsstruct IPropsPreApprovalCall.PropsPreApprovalCall[]Array of pre-approval calls to execute

_msgSender

solidity
function _msgSender() internal view virtual returns (address sender)

Internal function to get the sender of the current call

_Overrides ERC2771Context.msgSender() for meta-transaction support

Return Values

NameTypeDescription
senderaddressThe address of the sender (either the direct caller or the meta-tx originator)

_msgData

solidity
function _msgData() internal view virtual returns (bytes)

Internal function to get the calldata of the current call

_Overrides ERC2771Context.msgData() for meta-transaction support

Return Values

NameTypeDescription
[0]bytesThe calldata of the current call, potentially modified for meta-transactions

getPropsDiamondCreationCode

solidity
function getPropsDiamondCreationCode() public view returns (bytes)

Returns the creation code for PropsDiamond contract

Useful for client-side address prediction

Return Values

NameTypeDescription
[0]bytesThe bytecode used to deploy new diamonds

predictDiamondAddress

solidity
function predictDiamondAddress(address _sender, bytes32 _salt) public view returns (address)

Predicts the address where a diamond will be deployed

Uses CREATE2 address calculation formula

Parameters

NameTypeDescription
_senderaddressThe address that will deploy the diamond
_saltbytes32The salt to use for the deployment

Return Values

NameTypeDescription
[0]addressThe predicted address of the diamond