Skip to main content

LSP6KeyManager

Solidity contract

The LSP6KeyManager is a contract that controls the LSP0ERC725Account contract. It comes with pre-defined permissions for addresses that could range from setting data, executing, changing owner, etc., as written in the Permissions Section** of the LSP6-KeyManager Standard.

warning

The current implementation of the Key Manager disallows the DELEGATECALL operation on the execute(...) function of the linked ERC725Account, because of its potential malicious impact on the account contract.

note

LSP6KeyManager contract also contains the methods from the ERC165 Standard:

function supportsInterface(bytes4 interfaceId) public view returns (bool)

Functions

constructor

constructor(address account)

Links the KeyManager to the address of an LSP0ERC725Account contract and registers the LSP6KeyManager InterfaceId on deployment.

Parameters:

NameTypeDescription
accountaddressThe address of the LSP0ER725Account contract to control.

target

function target() external view returns (address)

Returns the address of the account linked to this KeyManager.

This can be a contract that implements:

Returns

NameTypeDescription
targetaddressthe address of the linked account

execute

function execute(bytes memory _calldata) public payable returns (bytes memory result)

Executes a payload on the LSP0ERC725Account contract.

This payload must represent the abi-encoded function call of one of the LSP0ERC725Account contract functions: setData(...), execute(...), or transferOwnership(...).

Triggers the Executed event when a call is successfully executed.

Parameters:

NameTypeDescription
_calldatabytesThe payload to be executed.

Return Values:

NameTypeDescription
resultbytesThe returned data as ABI-encoded bytes if the call on the account succeeded.

getNonce

function getNonce(
address signer,
uint256 channel
) public view returns (uint256 nonce)

Returns the nonce that needs to be signed by an allowed key to be passed into the executeRelayCall(...) function. A signer can choose his channel number arbitrarily.

note

More info about channel can be found here: What are multi-channel nonces_

Parameters:

NameTypeDescription
signeraddressThe address of the signer of the transaction.
channeluint256The channel which the signer wants to use for executing the transaction.

Return Values:

NameTypeDescription
nonceuint256The current nonce.

executeRelayCall

function executeRelayCall(
bytes memory signature,
uint256 nonce,
bytes memory _calldata
) public

Allows anybody to execute a payload on the LSP0ERC725Account contract, if they have a signed message from an executor.

Triggers the Executed event when a call is successfully executed.

Parameters:

NameTypeDescription
signaturebytesThe bytes65 ethereum signature.
nonceuint256The nonce of the address that signed the message.
_calldatabytesThe payload to be executed.

isValidSignature

function isValidSignature(
bytes32 hash,
bytes memory signature
) public view returns (bytes4 magicValue)

Checks if a signature was signed by an address having at least the SIGN permission for this KeyManager, otherwise it will return the failure value.

Parameters:

NameTypeDescription
hashbytes32The hash of the data signed on the behalf of address.
signaturebytesThe Owner's signature(s) of the data.

Return Values:

NameTypeDescription
magicValuebytes4The magicValue either 0x1626ba7e on success or 0xffffffff failure.

Events

Executed

event Executed(
uint256 value,
bytes4 selector
)

MUST be fired when a transaction was successfully executed from the execute or executeRelayCall function.

Values:

NameTypeDescription
valueuint256The amount to be sent with the payload.
selectorbytes4The bytes4 selector of the function executed on the linked target().

References