Skip to main content

LSP6KeyManager

Standard Specifications
Solidity implementation

Implementation of a contract acting as a controller of an ERC725 Account, using permissions stored in the ERC725Y storage.

All the permissions can be set on the ERC725 Account using setData(bytes32,bytes) or setData(bytes32[],bytes[]).

Public Methods

Public methods are accessible externally from users, allowing interaction with this function from dApps or other smart contracts. When marked as 'public', a method can be called both externally and internally, on the other hand, when marked as 'external', a method can only be called externally.

constructor

References
constructor(address target_);

Deploying a LSP6KeyManager linked to the contract at address target_.

Deploy a Key Manager and set the target_ address in the contract storage, making this Key Manager linked to this target_ contract.

Parameters

NameTypeDescription
target_addressThe address of the contract to control and forward calldata payloads to.

VERSION

References
function VERSION() external view returns (string);

Contract version.

Returns

NameTypeDescription
0string-

execute

References
function execute(bytes payload) external payable returns (bytes);

Executing the following payload on the linked contract: payload

Execute A payload on the linked target contract after having verified the permissions associated with the function being run. The payload MUST be a valid abi-encoded function call of one of the functions present in the linked target, otherwise the call will fail. The linked target will return some data on successful execution, or revert on failure.

Emitted events:

  • PermissionsVerified event when the permissions related to payload have been verified successfully.

Parameters

NameTypeDescription
payloadbytesThe abi-encoded function call to execute on the linked target.

Returns

NameTypeDescription
0bytesThe abi-decoded data returned by the function called on the linked target.

executeBatch

References
function executeBatch(
uint256[] values,
bytes[] payloads
) external payable returns (bytes[]);

*Executing the following batch of payloads and sensind on the linked contract.

  • payloads: payloads

  • values transferred for each payload: values*

Same as execute but execute a batch of payloads (abi-encoded function calls) in a single transaction.

Emitted events:

  • PermissionsVerified event for each permissions related to each payload that have been verified successfully.

Parameters

NameTypeDescription
valuesuint256[]An array of amount of native tokens to be transferred for each payload.
payloadsbytes[]An array of abi-encoded function calls to execute successively on the linked target.

Returns

NameTypeDescription
0bytes[]An array of abi-decoded data returned by the functions called on the linked target.

executeRelayCall

References
  • Specification details: LSP-6-KeyManager
  • Solidity implementation: LSP6KeyManager.sol
  • Function signature: executeRelayCall(bytes,uint256,uint256,bytes)
  • Function selector: 0x4c8a4e74
Hint

If you are looking to learn how to sign and execute relay transactions via the Key Manager, see our Javascript step by step guide "Execute Relay Transactions". See the LSP6 Standard page for more details on how to generate a valid signature for Execute Relay Call.

function executeRelayCall(
bytes signature,
uint256 nonce,
uint256 validityTimestamps,
bytes payload
) external payable returns (bytes);

Executing the following payload given the nonce nonce and signature signature. Payload: payload

Allows any address (executor) to execute a payload (= abi-encoded function call), given they have a valid signature from a signer address and a valid nonce for this signer. The signature MUST be generated according to the signature format defined by the LSP25 standard. The signer that generated the signature MUST be a controller with some permissions on the linked target. The payload will be executed on the target contract once the LSP25 signature and the permissions of the signer have been verified.

Emitted events:

  • PermissionsVerified event when the permissions related to payload have been verified successfully.

Parameters

NameTypeDescription
signaturebytesA 65 bytes long signature for a meta transaction according to LSP25.
nonceuint256The nonce of the address that signed the calldata (in a specific _channel), obtained via getNonce. Used to prevent replay attack.
validityTimestampsuint256Two uint128 timestamps concatenated together that describes when the relay transaction is valid "from" (left uint128) and "until" as a deadline (right uint128).
payloadbytesThe abi-encoded function call to execute.

Returns

NameTypeDescription
0bytesThe data being returned by the function executed.

executeRelayCallBatch

References
  • Specification details: LSP-6-KeyManager
  • Solidity implementation: LSP6KeyManager.sol
  • Function signature: executeRelayCallBatch(bytes[],uint256[],uint256[],uint256[],bytes[])
  • Function selector: 0xa20856a5
function executeRelayCallBatch(
bytes[] signatures,
uint256[] nonces,
uint256[] validityTimestamps,
uint256[] values,
bytes[] payloads
) external payable returns (bytes[]);

Executing a batch of relay calls (= meta-transactions).

Same as executeRelayCall but execute a batch of signed calldata payloads (abi-encoded function calls) in a single transaction. The signatures can be from multiple controllers, not necessarely the same controller, as long as each of these controllers that signed have the right permissions related to the calldata payload they signed.

Requirements:

  • the length of signatures, nonces, validityTimestamps, values and payloads MUST be the same.
  • the value sent to this function (msg.value) MUST be equal to the sum of all values in the batch. There should not be any excess value sent to this function.

Parameters

NameTypeDescription
signaturesbytes[]An array of 65 bytes long signatures for meta transactions according to LSP25.
noncesuint256[]An array of nonces of the addresses that signed the calldata payloads (in specific channels). Obtained via getNonce. Used to prevent replay attack.
validityTimestampsuint256[]An array of two uint128 concatenated timestamps that describe when the relay transaction is valid "from" (left uint128) and "until" (right uint128).
valuesuint256[]An array of amount of native tokens to be transferred for each calldata payload.
payloadsbytes[]An array of abi-encoded function calls to be executed successively.

Returns

NameTypeDescription
0bytes[]An array of abi-decoded data returned by the functions executed.

getNonce

References
Hint

A signer can choose its channel number arbitrarily. The recommended practice is to:

  • use channelId == 0 for transactions for which the ordering of execution matters.abi Example: you have two transactions A and B, and transaction A must be executed first and complete successfully before transaction B should be executed).
  • use any other channelId number for transactions that you want to be order independant (out-of-order execution, execution "in parallel"). _Example: you have two transactions A and B. You want transaction B to be executed a) without having to wait for transaction A to complete, or b) regardless if transaction A completed successfully or not.
function getNonce(
address from,
uint128 channelId
) external view returns (uint256);

Reading the latest nonce of address from in the channel ID channelId.

Get the nonce for a specific from address that can be used for signing relay transactions via executeRelayCall.

Parameters

NameTypeDescription
fromaddressThe address of the signer of the transaction.
channelIduint128The channel id that the signer wants to use for executing the transaction.

Returns

NameTypeDescription
0uint256The current nonce on a specific channelId.

isValidSignature

References
Warning

This function does not enforce by default the inclusion of the address of this contract in the signature digest. It is recommended that protocols or applications using this contract include the targeted address (= this contract) in the data to sign. To ensure that a signature is valid for a specific LSP6KeyManager and prevent signatures from the same EOA to be replayed across different LSP6KeyManager.

function isValidSignature(
bytes32 dataHash,
bytes signature
) external view returns (bytes4 returnedStatus);

Checks if a signature was signed by a controller that has the permission SIGN. If the signer is a controller with the permission SIGN, it will return the ERC1271 success value.

Parameters

NameTypeDescription
dataHashbytes32-
signaturebytesSignature byte array associated with _data

Returns

NameTypeDescription
returnedStatusbytes40x1626ba7e on success, or 0xffffffff on failure.

lsp20VerifyCall

References
  • Specification details: LSP-6-KeyManager
  • Solidity implementation: LSP6KeyManager.sol
  • Function signature: lsp20VerifyCall(address,address,address,uint256,bytes)
  • Function selector: 0xde928f14
Hint

This function can call by any other address than the target. This allows to verify permissions in a "read-only" manner. Anyone can call this function to verify if the caller has the right permissions to perform the abi-encoded function call data on the target contract (while sending msgValue alongside the call). If the permissions have been verified successfully and caller is authorized, one of the following two LSP20 success value will be returned:

  • 0x1a238000: LSP20 success value without post verification (last byte is 0x00).
  • 0x1a238001: LSP20 success value with post-verification (last byte is 0x01).
function lsp20VerifyCall(
address,
address targetContract,
address caller,
uint256 msgValue,
bytes callData
) external nonpayable returns (bytes4);

Parameters

NameTypeDescription
_0address-
targetContractaddress-
calleraddressThe address who called the function on the target contract.
msgValueuint256-
callDatabytesThe calldata sent by the caller to the msg.sender

Returns

NameTypeDescription
0bytes4MUST return the first 3 bytes of lsp20VerifyCall(address,uint256,bytes) function selector if the call to the function is allowed, concatened with a byte that determines if the lsp20VerifyCallResult function should be called after the original function call. The byte that invoke the lsp20VerifyCallResult function is strictly 0x01.

lsp20VerifyCallResult

References
  • Specification details: LSP-6-KeyManager
  • Solidity implementation: LSP6KeyManager.sol
  • Function signature: lsp20VerifyCallResult(bytes32,bytes)
  • Function selector: 0xd3fc45d3
function lsp20VerifyCallResult(
bytes32,
bytes
) external nonpayable returns (bytes4);

Parameters

NameTypeDescription
_0bytes32-
_1bytes-

Returns

NameTypeDescription
0bytes4MUST return the lsp20VerifyCallResult function selector if the call to the function is allowed

supportsInterface

References
function supportsInterface(bytes4 interfaceId) external view returns (bool);

See IERC165-supportsInterface.

Parameters

NameTypeDescription
interfaceIdbytes4-

Returns

NameTypeDescription
0bool-

target

References
function target() external view returns (address);

Get The address of the contract linked to this Key Manager.

Returns

NameTypeDescription
0addressThe address of the linked contract

Internal Methods

Any method labeled as internal serves as utility function within the contract. They can be used when writing solidity contracts that inherit from this contract. These methods can be extended or modified by overriding their internal behavior to suit specific needs.

Internal functions cannot be called externally, whether from other smart contracts, dApp interfaces, or backend services. Their restricted accessibility ensures that they remain exclusively available within the context of the current contract, promoting controlled and encapsulated usage of these internal utilities.

_verifyCanSetData

function _verifyCanSetData(
address controlledContract,
address controllerAddress,
bytes32 controllerPermissions,
bytes32 inputDataKey,
bytes inputDataValue
) internal view;

verify if the controllerAddress has the permissions required to set a data key on the ERC725Y storage of the controlledContract.

Parameters

NameTypeDescription
controlledContractaddressthe address of the ERC725Y contract where the data key is set.
controllerAddressaddressthe address of the controller who wants to set the data key.
controllerPermissionsbytes32the permissions of the controller address.
inputDataKeybytes32the data key to set on the controlledContract.
inputDataValuebytesthe data value to set for the inputDataKey.

_verifyCanSetData

function _verifyCanSetData(
address controlledContract,
address controller,
bytes32 permissions,
bytes32[] inputDataKeys,
bytes[] inputDataValues
) internal view;

verify if the controllerAddress has the permissions required to set an array of data keys on the ERC725Y storage of the controlledContract.

Parameters

NameTypeDescription
controlledContractaddressthe address of the ERC725Y contract where the data key is set.
controlleraddressthe address of the controller who wants to set the data key.
permissionsbytes32the permissions of the controller address.
inputDataKeysbytes32[]an array of data keys to set on the controlledContract.
inputDataValuesbytes[]an array of data values to set for the inputDataKeys.

_getPermissionRequiredToSetDataKey

function _getPermissionRequiredToSetDataKey(
address controlledContract,
bytes32 controllerPermissions,
bytes32 inputDataKey,
bytes inputDataValue
) internal view returns (bytes32);

retrieve the permission required based on the data key to be set on the controlledContract.

Parameters

NameTypeDescription
controlledContractaddressthe address of the ERC725Y contract where the data key is verified.
controllerPermissionsbytes32-
inputDataKeybytes32the data key to set on the controlledContract. Can be related to LSP6 Permissions, LSP1 Delegate or LSP17 Extensions.
inputDataValuebytesthe data value to set for the inputDataKey.

Returns

NameTypeDescription
0bytes32the permission required to set the inputDataKey on the controlledContract.

_getPermissionToSetPermissionsArray

function _getPermissionToSetPermissionsArray(
address controlledContract,
bytes32 inputDataKey,
bytes inputDataValue,
bool hasBothAddControllerAndEditPermissions
) internal view returns (bytes32);

retrieve the permission required to update the AddressPermissions[] array data key defined in LSP6.

Parameters

NameTypeDescription
controlledContractaddressthe address of the ERC725Y contract where the data key is verified.
inputDataKeybytes32either AddressPermissions[] (array length) or AddressPermissions[index] (array index)
inputDataValuebytesthe updated value for the inputDataKey. MUST be:
hasBothAddControllerAndEditPermissionsbool-

Returns

NameTypeDescription
0bytes32either ADD or CHANGE PERMISSIONS.

_getPermissionToSetControllerPermissions

function _getPermissionToSetControllerPermissions(
address controlledContract,
bytes32 inputPermissionDataKey
) internal view returns (bytes32);

retrieve the permission required to set permissions for a controller address.

Parameters

NameTypeDescription
controlledContractaddressthe address of the ERC725Y contract where the data key is verified.
inputPermissionDataKeybytes32AddressPermissions:Permissions:<controller-address>.

Returns

NameTypeDescription
0bytes32either ADD or CHANGE PERMISSIONS.

_getPermissionToSetAllowedCalls

function _getPermissionToSetAllowedCalls(
address controlledContract,
bytes32 dataKey,
bytes dataValue,
bool hasBothAddControllerAndEditPermissions
) internal view returns (bytes32);

Retrieve the permission required to set some AllowedCalls for a controller.

Parameters

NameTypeDescription
controlledContractaddressThe address of the ERC725Y contract from which to fetch the value of dataKey.
dataKeybytes32A data key ion the format AddressPermissions:AllowedCalls:<controller-address>.
dataValuebytesThe updated value for the dataKey. MUST be a bytes32[CompactBytesArray] of Allowed Calls.
hasBothAddControllerAndEditPermissionsbool-

Returns

NameTypeDescription
0bytes32Either ADD or EDIT PERMISSIONS.

_getPermissionToSetAllowedERC725YDataKeys

function _getPermissionToSetAllowedERC725YDataKeys(
address controlledContract,
bytes32 dataKey,
bytes dataValue,
bool hasBothAddControllerAndEditPermissions
) internal view returns (bytes32);

Retrieve the permission required to set some Allowed ERC725Y Data Keys for a controller.

Parameters

NameTypeDescription
controlledContractaddressthe address of the ERC725Y contract from which to fetch the value of dataKey.
dataKeybytes32A data key in the format AddressPermissions:AllowedERC725YDataKeys:<controller-address>.
dataValuebytesThe updated value for the dataKey. MUST be a bytes[CompactBytesArray] of Allowed ERC725Y Data Keys.
hasBothAddControllerAndEditPermissionsbool-

Returns

NameTypeDescription
0bytes32Either ADD or EDIT PERMISSIONS.

_getPermissionToSetLSP1Delegate

function _getPermissionToSetLSP1Delegate(
address controlledContract,
bytes32 lsp1DelegateDataKey
) internal view returns (bytes32);

retrieve the permission required to either add or change the address of a LSP1 Universal Receiver Delegate stored under a specific LSP1 data key.

Parameters

NameTypeDescription
controlledContractaddressthe address of the ERC725Y contract where the data key is verified.
lsp1DelegateDataKeybytes32either the data key for the default LSP1UniversalReceiverDelegate,

Returns

NameTypeDescription
0bytes32either ADD or CHANGE UNIVERSALRECEIVERDELEGATE.

_getPermissionToSetLSP17Extension

function _getPermissionToSetLSP17Extension(
address controlledContract,
bytes32 lsp17ExtensionDataKey
) internal view returns (bytes32);

Verify if controller has the required permissions to either add or change the address of an LSP0 Extension stored under a specific LSP17Extension data key

Parameters

NameTypeDescription
controlledContractaddressthe address of the ERC725Y contract where the data key is verified.
lsp17ExtensionDataKeybytes32the dataKey to set with _LSP17_EXTENSION_PREFIX as prefix.

_verifyAllowedERC725YSingleKey

function _verifyAllowedERC725YSingleKey(
address controllerAddress,
bytes32 inputDataKey,
bytes allowedERC725YDataKeysCompacted
) internal pure;

Verify if the inputKey is present in the list of allowedERC725KeysCompacted for the controllerAddress.

Parameters

NameTypeDescription
controllerAddressaddressthe address of the controller.
inputDataKeybytes32the data key to verify against the allowed ERC725Y Data Keys for the controllerAddress.
allowedERC725YDataKeysCompactedbytesa CompactBytesArray of allowed ERC725Y Data Keys for the controllerAddress.

_verifyAllowedERC725YDataKeys

function _verifyAllowedERC725YDataKeys(
address controllerAddress,
bytes32[] inputDataKeys,
bytes allowedERC725YDataKeysCompacted,
bool[] validatedInputKeysList,
uint256 allowedDataKeysFound
) internal pure;

Verify if all the inputDataKeys are present in the list of allowedERC725KeysCompacted of the controllerAddress.

Parameters

NameTypeDescription
controllerAddressaddressthe address of the controller.
inputDataKeysbytes32[]the data keys to verify against the allowed ERC725Y Data Keys of the controllerAddress.
allowedERC725YDataKeysCompactedbytesa CompactBytesArray of allowed ERC725Y Data Keys of the controllerAddress.
validatedInputKeysListbool[]an array of booleans to store the result of the verification of each data keys checked.
allowedDataKeysFounduint256the number of data keys that were previously validated for other permissions like ADDCONTROLLER, EDITPERMISSIONS, etc...

_requirePermissions

function _requirePermissions(
address controller,
bytes32 addressPermissions,
bytes32 permissionRequired
) internal pure;

Check if the controller has the permissionRequired among its permission listed in controllerPermissions If not, this function will revert with the error NotAuthorised and the name of the permission missing by the controller.

Parameters

NameTypeDescription
controlleraddressthe caller address
addressPermissionsbytes32the caller's permissions BitArray
permissionRequiredbytes32the required permission

_verifyCanExecute

function _verifyCanExecute(
address controlledContract,
address controller,
bytes32 permissions,
uint256 operationType,
address to,
uint256 value,
bytes data
) internal view;

verify if controllerAddress has the required permissions to interact with other addresses using the controlledContract.

Parameters

NameTypeDescription
controlledContractaddressthe address of the ERC725 contract where the payload is executed and where the permissions are verified.
controlleraddressthe address who want to run the execute function on the ERC725Account.
permissionsbytes32the permissions of the controller address.
operationTypeuint256-
toaddress-
valueuint256-
databytes-

_verifyCanDeployContract

function _verifyCanDeployContract(
address controller,
bytes32 permissions,
bool isFundingContract
) internal view;

_verifyCanStaticCall

function _verifyCanStaticCall(
address controlledContract,
address controller,
bytes32 permissions,
address to,
uint256 value,
bytes data
) internal view;

_verifyCanCall

function _verifyCanCall(
address controlledContract,
address controller,
bytes32 permissions,
address to,
uint256 value,
bytes data
) internal view;

_verifyAllowedCall

function _verifyAllowedCall(
address controlledContract,
address controllerAddress,
uint256 operationType,
address to,
uint256 value,
bytes data
) internal view;

_extractCallType

function _extractCallType(
uint256 operationType,
uint256 value,
bytes data
) internal pure returns (bytes4 requiredCallTypes);

extract the bytes4 representation of a single bit for the type of call according to the operationType

Parameters

NameTypeDescription
operationTypeuint2560 = CALL, 3 = STATICCALL or 3 = DELEGATECALL
valueuint256-
databytes-

Returns

NameTypeDescription
requiredCallTypesbytes4a bytes4 value containing a single 1 bit for the callType

_isAllowedAddress

function _isAllowedAddress(
bytes allowedCall,
address to
) internal pure returns (bool);

_isAllowedStandard

function _isAllowedStandard(
bytes allowedCall,
address to
) internal view returns (bool);

_isAllowedFunction

function _isAllowedFunction(
bytes allowedCall,
bytes data
) internal pure returns (bool);

_isAllowedCallType

function _isAllowedCallType(
bytes allowedCall,
bytes4 requiredCallTypes
) internal pure returns (bool);

_verifyExecuteRelayCallPermission

function _verifyExecuteRelayCallPermission(
address controllerAddress,
bytes32 controllerPermissions
) internal pure;

_verifyOwnershipPermissions

function _verifyOwnershipPermissions(
address controllerAddress,
bytes32 controllerPermissions
) internal pure;

_getNonce

function _getNonce(
address from,
uint128 channelId
) internal view returns (uint256 idx);

Read the nonce for a from address on a specific channelId. This will return an idx, which is the concatenation of two uint128 as follow:

  1. the channelId where the nonce was queried for.

  2. the actual nonce of the given channelId. For example, if on channelId number 5, the latest nonce is 1, the idx returned by this function will be:

// in decimals = 1701411834604692317316873037158841057281
idx = 0x0000000000000000000000000000000500000000000000000000000000000001

This idx can be described as follow:

            channelId => 5          nonce in this channel => 1
v------------------------------v-------------------------------v
0x0000000000000000000000000000000500000000000000000000000000000001

Parameters

NameTypeDescription
fromaddressThe address to read the nonce for.
channelIduint128The channel in which to extract the nonce.

Returns

NameTypeDescription
idxuint256The idx composed of two uint128: the channelId + nonce in channel concatenated together in a single uint256 value.

_recoverSignerFromLSP25Signature

function _recoverSignerFromLSP25Signature(
bytes signature,
uint256 nonce,
uint256 validityTimestamps,
uint256 msgValue,
bytes callData
) internal view returns (address);

Recover the address of the signer that generated a signature using the parameters provided nonce, validityTimestamps, msgValue and callData. The address of the signer will be recovered using the LSP25 signature format.

Parameters

NameTypeDescription
signaturebytesA 65 bytes long signature generated according to the signature format specified in the LSP25 standard.
nonceuint256The nonce that the signer used to generate the signature.
validityTimestampsuint256The validity timestamp that the signer used to generate the signature (See _verifyValidityTimestamps to learn more).
msgValueuint256The amount of native tokens intended to be sent for the relay transaction.
callDatabytesThe calldata to execute as a relay transaction that the signer signed for.

Returns

NameTypeDescription
0addressThe address that signed, recovered from the signature.

_verifyValidityTimestamps

function _verifyValidityTimestamps(uint256 validityTimestamps) internal view;

Verify that the current timestamp is within the date and time range provided by validityTimestamps.

Parameters

NameTypeDescription
validityTimestampsuint256Two uint128 concatenated together, where the left-most uint128 represent the timestamp from which the transaction can be executed,

_isValidNonce

function _isValidNonce(address from, uint256 idx) internal view returns (bool);

Verify that the nonce _idx for _from (obtained via getNonce) is valid in its channel ID. The "idx" is a 256bits (unsigned) integer, where:

  • the 128 leftmost bits = channelId

  • and the 128 rightmost bits = nonce within the channel

Parameters

NameTypeDescription
fromaddressThe signer's address.
idxuint256The concatenation of the channelId + nonce within a specific channel ID.

Returns

NameTypeDescription
0booltrue if the nonce is the latest nonce for the signer, false otherwise.

_execute

function _execute(
uint256 msgValue,
bytes payload
) internal nonpayable returns (bytes);

_executeRelayCall

Warning

Be aware that this function can also throw an error if the callData was signed incorrectly (not conforming to the signature format defined in the LSP25 standard). This is because the contract cannot distinguish if the data is signed correctly or not. Instead, it will recover an incorrect signer address from the signature and throw an InvalidRelayNonce error with the incorrect signer address as the first parameter.

function _executeRelayCall(
bytes signature,
uint256 nonce,
uint256 validityTimestamps,
uint256 msgValue,
bytes payload
) internal nonpayable returns (bytes);

Validate that the nonce given for the signature signed and the payload to execute is valid and conform to the signature format according to the LSP25 standard.

Parameters

NameTypeDescription
signaturebytesA valid signature for a signer, generated according to the signature format specified in the LSP25 standard.
nonceuint256The nonce that the signer used to generate the signature.
validityTimestampsuint256Two uint128 concatenated together, where the left-most uint128 represent the timestamp from which the transaction can be executed,
msgValueuint256-
payloadbytesThe abi-encoded function call to execute.

_executePayload

function _executePayload(
address targetContract,
uint256 msgValue,
bytes payload
) internal nonpayable returns (bytes);

Execute the payload passed to execute(...) or executeRelayCall(...)

Parameters

NameTypeDescription
targetContractaddress-
msgValueuint256-
payloadbytesThe abi-encoded function call to execute on the target contract.

Returns

NameTypeDescription
0bytesbytes The data returned by the call made to the linked target contract.

_verifyPermissions

function _verifyPermissions(
address targetContract,
address from,
bool isRelayedCall,
bytes payload
) internal view;

Verify if the from address is allowed to execute the payload on the target contract linked to this Key Manager.

Parameters

NameTypeDescription
targetContractaddressThe contract that is owned by the Key Manager
fromaddressEither the caller of execute or the signer of executeRelayCall.
isRelayedCallbool-
payloadbytesThe abi-encoded function call to execute on the target contract.

_nonReentrantBefore

function _nonReentrantBefore(
address targetContract,
bool isSetData,
address from
) internal nonpayable returns (bool reentrancyStatus);

Check if we are in the context of a reentrant call, by checking if the reentrancy status is true.

  • If the status is true, the caller (or signer for relay call) MUST have the REENTRANCY permission. Otherwise, the call is reverted.

  • If the status is false, it is set to true only if we are not dealing with a call to the functions setData or setDataBatch. Used at the beginning of the lsp20VerifyCall, _execute and _executeRelayCall functions, before the methods execution starts.


_nonReentrantAfter

function _nonReentrantAfter(address targetContract) internal nonpayable;

Resets the reentrancy status to false Used at the end of the lsp20VerifyCall, _execute and _executeRelayCall functions after the functions' execution is terminated.


Events

PermissionsVerified

References
  • Specification details: LSP-6-KeyManager
  • Solidity implementation: LSP6KeyManager.sol
  • Event signature: PermissionsVerified(address,uint256,bytes4)
  • Event topic hash: 0xc0a62328f6bf5e3172bb1fcb2019f54b2c523b6a48e3513a2298fbf0150b781e
event PermissionsVerified(address indexed signer, uint256 indexed value, bytes4 indexed selector);

Verified the permissions of signer for calling function selector on the linked account and sending value of native token.

Emitted when the LSP6KeyManager contract verified the permissions of the signer successfully.

Parameters

NameTypeDescription
signer indexedaddressThe address of the controller that executed the calldata payload (either directly via execute or via meta transaction using executeRelayCall).
value indexeduint256The amount of native token to be transferred in the calldata payload.
selector indexedbytes4The bytes4 function of the function that was executed on the linked target

Errors

BatchExecuteParamsLengthMismatch

References
error BatchExecuteParamsLengthMismatch();

The array parameters provided to the function executeBatch(...) do not have the same number of elements. (Different array param's length).

Reverts when the array parameters uint256[] value and bytes[] payload have different sizes. There should be the same number of elements for each array parameters.


BatchExecuteRelayCallParamsLengthMismatch

References
error BatchExecuteRelayCallParamsLengthMismatch();

The array parameters provided to the function executeRelayCallBatch(...) do not have the same number of elements. (Different array param's length).

Reverts when providing array parameters of different sizes to executeRelayCallBatch(bytes[],uint256[],bytes[])


CallingKeyManagerNotAllowed

References
error CallingKeyManagerNotAllowed();

Calling the Key Manager address for this transaction is disallowed.

Reverts when calling the KeyManager through execute(uint256,address,uint256,bytes).


DelegateCallDisallowedViaKeyManager

References
error DelegateCallDisallowedViaKeyManager();

Performing DELEGATE CALLS via the Key Manager is currently disallowed.

Reverts when trying to do a delegatecall via the ERC725X.execute(uint256,address,uint256,bytes) (operation type 4) function of the linked target. DELEGATECALL is disallowed by default on the LSP6KeyManager.


ERC725X_ExecuteParametersEmptyArray

References
error ERC725X_ExecuteParametersEmptyArray();

Reverts when one of the array parameter provided to the executeBatch function is an empty array.


ERC725X_ExecuteParametersLengthMismatch

References
error ERC725X_ExecuteParametersLengthMismatch();

Reverts when there is not the same number of elements in the operationTypes, targets addresses, values, and datas array parameters provided when calling the executeBatch function.


ERC725Y_DataKeysValuesLengthMismatch

References
error ERC725Y_DataKeysValuesLengthMismatch();

Reverts when there is not the same number of elements in the datakeys and dataValues array parameters provided when calling the setDataBatch function.


InvalidDataValuesForDataKeys

References
error InvalidDataValuesForDataKeys(bytes32 dataKey, bytes dataValue);

Data value: dataValue length is different from the required length for the data key which is set.

Reverts when the data value length is not one of the required lengths for the specific data key.

Parameters

NameTypeDescription
dataKeybytes32The data key that has a required length for the data value.
dataValuebytesThe data value that has an invalid length.

InvalidERC725Function

References
error InvalidERC725Function(bytes4 invalidFunction);

The Key Manager could not verify the calldata of the transaction because it could not recognise the function being called. Invalid function selector: invalidFunction.

Reverts when trying to call a function on the linked target, that is not any of the following:

  • setData(bytes32,bytes) (ERC725Y)

  • setDataBatch(bytes32[],bytes[]) (ERC725Y)

  • execute(uint256,address,uint256,bytes) (ERC725X)

  • transferOwnership(address) (LSP14)

  • acceptOwnership() (LSP14)

  • renounceOwnership() (LSP14)

Parameters

NameTypeDescription
invalidFunctionbytes4The bytes4 selector of the function that was attempted to be called on the linked target but not recognised.

InvalidEncodedAllowedCalls

References
error InvalidEncodedAllowedCalls(bytes allowedCallsValue);

Could not decode the Allowed Calls. Value = allowedCallsValue.

Reverts when allowedCallsValue is not properly encoded as a (bytes4,address,bytes4,bytes4)[CompactBytesArray] (CompactBytesArray made of tuples that are 32 bytes long each). See LSP2 value type CompactBytesArray for more infos.

Parameters

NameTypeDescription
allowedCallsValuebytesThe list of allowedCalls that are not encoded correctly as a (bytes4,address,bytes4,bytes4)[CompactBytesArray].

InvalidEncodedAllowedERC725YDataKeys

References
  • Specification details: LSP-6-KeyManager
  • Solidity implementation: LSP6KeyManager.sol
  • Error signature: InvalidEncodedAllowedERC725YDataKeys(bytes,string)
  • Error hash: 0xae6cbd37
error InvalidEncodedAllowedERC725YDataKeys(bytes value, string context);

Error when reading the Allowed ERC725Y Data Keys. Reason: context, Allowed ERC725Y Data Keys value read: value.

Reverts when value is not encoded properly as a bytes32[CompactBytesArray]. The context string provides context on when this error occurred (_e.g: when fetching the AllowedERC725YDataKeys to verify the permissions of a controller, or when validating the AllowedERC725YDataKeys when setting them for a controller).

Parameters

NameTypeDescription
valuebytesThe value that is not a valid bytes32[CompactBytesArray]
contextstringA brief description of where the error occurred.

InvalidLSP6Target

References
error InvalidLSP6Target();

Invalid address supplied to link this Key Manager to (address(0)).

Reverts when the address provided to set as the target linked to this KeyManager is invalid (e.g. address(0)).


InvalidPayload

References
error InvalidPayload(bytes payload);

Invalid calldata payload sent.

Reverts when the payload is invalid.

Parameters

NameTypeDescription
payloadbytes-

InvalidRelayNonce

References
error InvalidRelayNonce(address signer, uint256 invalidNonce, bytes signature);

The relay call failed because an invalid nonce was provided for the address signer that signed the execute relay call. Invalid nonce: invalidNonce, signature of signer: signature.

Reverts when the signer address retrieved from the signature has an invalid nonce: invalidNonce.

Parameters

NameTypeDescription
signeraddressThe address of the signer.
invalidNonceuint256The nonce retrieved for the signer address.
signaturebytesThe signature used to retrieve the signer address.

InvalidWhitelistedCall

References
error InvalidWhitelistedCall(address from);

Invalid allowed calls (0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff) set for address from. Could not perform external call.

Reverts when a from address has "any whitelisted call" as allowed call set. This revert happens during the verification of the permissions of the address for its allowed calls. A from address is not allowed to have 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff in its list of AddressPermissions:AllowedCalls:<address>, as this allows any STANDARD:ADDRESS:FUNCTION. This is equivalent to granting the SUPER permission and should never be valid.

Parameters

NameTypeDescription
fromaddressThe controller address that has "any allowed calls" whitelisted set.

KeyManagerCannotBeSetAsExtensionForLSP20Functions

References
  • Specification details: LSP-6-KeyManager
  • Solidity implementation: LSP6KeyManager.sol
  • Error signature: KeyManagerCannotBeSetAsExtensionForLSP20Functions()
  • Error hash: 0x4a9fa8cf
error KeyManagerCannotBeSetAsExtensionForLSP20Functions();

Key Manager cannot be used as an LSP17 extension for LSP20 functions.

Reverts when the address of the Key Manager is being set as extensions for lsp20 functions


LSP6BatchExcessiveValueSent

References
  • Specification details: LSP-6-KeyManager
  • Solidity implementation: LSP6KeyManager.sol
  • Error signature: LSP6BatchExcessiveValueSent(uint256,uint256)
  • Error hash: 0xa51868b6
error LSP6BatchExcessiveValueSent(uint256 totalValues, uint256 msgValue);

Too much funds sent to forward each amount in the batch. No amount of native tokens should stay in the Key Manager.

This error occurs when there was too much funds sent to the batch functions execute(uint256[],bytes[]) or executeRelayCall(bytes[],uint256[],uint256[],bytes[]) to cover the sum of all the values forwarded on Reverts to avoid the KeyManager to holds some remaining funds sent to the following batch functions:

  • execute(uint256[],bytes[])

  • executeRelayCall(bytes[],uint256[],uint256[],bytes[]) This error occurs when msg.value is more than the sum of all the values being forwarded on each payloads (values[] parameter from the batch functions above).

Parameters

NameTypeDescription
totalValuesuint256-
msgValueuint256-

LSP6BatchInsufficientValueSent

References
  • Specification details: LSP-6-KeyManager
  • Solidity implementation: LSP6KeyManager.sol
  • Error signature: LSP6BatchInsufficientValueSent(uint256,uint256)
  • Error hash: 0x30a324ac
error LSP6BatchInsufficientValueSent(uint256 totalValues, uint256 msgValue);

Not enough funds sent to forward each amount in the batch.

This error occurs when there was not enough funds sent to the batch functions execute(uint256[],bytes[]) or executeRelayCall(bytes[],uint256[],uint256[],bytes[]) to cover the sum of all the values forwarded on each payloads (values[] parameter from the batch functions above). This mean that msg.value is less than the sum of all the values being forwarded on each payloads (values[] parameters).

Parameters

NameTypeDescription
totalValuesuint256The sum of all the values forwarded on each payloads (values[] parameter from the batch functions above).
msgValueuint256The amount of native tokens sent to the batch functions execute(uint256[],bytes[]) or executeRelayCall(bytes[],uint256[],uint256[],bytes[]).

NoCallsAllowed

References
error NoCallsAllowed(address from);

The address from is not authorised to use the linked account contract to make external calls, because it has no Allowed Calls set.

Reverts when the from address has no AllowedCalls set and cannot interact with any address using the linked target.

Parameters

NameTypeDescription
fromaddressThe address that has no AllowedCalls.

NoERC725YDataKeysAllowed

References
error NoERC725YDataKeysAllowed(address from);

The address from is not authorised to set data, because it has no ERC725Y Data Key allowed.

Reverts when the from address has no AllowedERC725YDataKeys set and cannot set any ERC725Y data key on the ERC725Y storage of the linked target.

Parameters

NameTypeDescription
fromaddressThe address that has no AllowedERC725YDataKeys set.

NoPermissionsSet

References
error NoPermissionsSet(address from);

The address from does not have any permission set on the contract linked to the Key Manager.

Reverts when address from does not have any permissions set on the account linked to this Key Manager

Parameters

NameTypeDescription
fromaddressthe address that does not have permissions

NotAllowedCall

References
error NotAllowedCall(address from, address to, bytes4 selector);

The address from is not authorised to call the function selector on the to address.

Reverts when from is not authorised to call the execute(uint256,address,uint256,bytes) function because of a not allowed callType, address, standard or function.

Parameters

NameTypeDescription
fromaddressThe controller that tried to call the execute(uint256,address,uint256,bytes) function.
toaddressThe address of an EOA or contract that from tried to call using the linked target
selectorbytes4If to is a contract, the bytes4 selector of the function that from is trying to call. If no function is called (e.g: a native token transfer), selector = 0x00000000

NotAllowedERC725YDataKey

References
error NotAllowedERC725YDataKey(address from, bytes32 disallowedKey);

The address from is not authorised to set the data key disallowedKey on the contract linked to the Key Manager.

Reverts when address from is not authorised to set the key disallowedKey on the linked target.

Parameters

NameTypeDescription
fromaddressaddress The controller that tried to setData on the linked target.
disallowedKeybytes32A bytes32 data key that from is not authorised to set on the ERC725Y storage of the linked target.

NotAuthorised

References
error NotAuthorised(address from, string permission);

The address from is not authorised to permission on the contract linked to the Key Manager.

Reverts when address from is not authorised and does not have permission on the linked target

Parameters

NameTypeDescription
fromaddressaddress The address that was not authorised.
permissionstringpermission The permission required (_e.g: SETDATA, CALL, TRANSFERVALUE)

NotRecognisedPermissionKey

References
error NotRecognisedPermissionKey(bytes32 dataKey);

The data key dataKey starts with AddressPermissions prefix but is none of the permission data keys defined in LSP6.

Reverts when dataKey is a bytes32 value that does not adhere to any of the permission data keys defined by the LSP6 standard

Parameters

NameTypeDescription
dataKeybytes32The dataKey that does not match any of the standard LSP6 permission data keys.

RelayCallBeforeStartTime

References
error RelayCallBeforeStartTime();

Relay call not valid yet.

Reverts when the relay call is cannot yet bet executed. This mean that the starting timestamp provided to executeRelayCall function is bigger than the current timestamp.


RelayCallExpired

References
error RelayCallExpired();

Relay call expired (deadline passed).

Reverts when the period to execute the relay call has expired.