Skip to content

Commit

Permalink
Add details about AllowedCalls
Browse files Browse the repository at this point in the history
  • Loading branch information
b00ste committed Oct 17, 2023
1 parent ccf6169 commit 9df3007
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/contracts/overview/KeyManager.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@ To illustrate, in the case of Universal Profile and the browser extension, you c

Afterwards, you can grant partial access to dApp and protocol (more specifically the smart contract addresses behind them), so that they can use your Universal Profile to interact on your behalf. This catalyze interactions on the blockchain, where your Universal Profile can do more and operate automatically in controlled manner, without requiring the main profile owner to have to do everything.

### Allowed Calls

:::note

If controller has `CALL` permission but has no `AllowedCalls`, controller will not be able to use the `CALL` permission at all.

:::

Key Manager allows for restricting controller addresses to be able to call specific functions on specific addresses which should be of a specific standard. In order to achieve such functionallity one could encode a set of type calls, addresses, standards and functions to [`bytes32[CompactBytesArray]`](https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-2-ERC725YJSONSchema.md#bytesncompactbytesarray), and store them under the [Allowed Calls](../../standards/universal-profile/lsp6-key-manager.md#allowed-calls) data key.

_E.g._

Supposedly we have the following `AllowedCalls`:
`0x002000000002cafecafecafecafecafecafecafecafecafecafe24871b3d7f23690c002000000003cafecafecafecafecafecafecafecafecafecafe24871b3d44c028fe`

It can be decoded as:

| Allowed Calls |
| :------------ | :- | :- |
| First allowed call | **Call Types** - `0x00000002` (Call) <br/> **Address** - `0xcafecafecafecafecafecafecafecafecafecafe` <br/> **Standard** - `0x24871b3d` (LSP0) <br/> **Function** - `0x7f23690c` (`setData(bytes32,bytes)`) | - This allowed call permits the controller to use the function `setData(bytes32,bytes)` in the contract deployed at address `0xcafecafecafecafecafecafecafecafecafecafe`. <br/> - When calling that function the operation type has to be `CALL` with no value being sent. <br/> - The address `0xcafecafecafecafecafecafecafecafecafecafe` has to return true to `ERC165.supportsInterface(0x24871b3d)`. |
| Second allowed call | **Call Types** - `0x00000003` (Transfervalue & Call) <br/> **Address** - `0xcafecafecafecafecafecafecafecafecafecafe` <br/> **Standard** - `0x24871b3d` (LSP0) <br/> **Function** - `0x44c028fe` (`execute(uint256,address,uint256,bytes)`) | - This allowed call permits the controller to use the function `execute(uint256,address,uint256,bytes)` in the contract deployed at address `0xcafecafecafecafecafecafecafecafecafecafe`. <br/> - When calling that function the operation type has to be `CALL`, you can send value as well. <br/> - The address `0xcafecafecafecafecafecafecafecafecafecafe` has to return true to `ERC165.supportsInterface(0x24871b3d)`. |

## Further Reading

- [The Bytecode episode #4 (Youtube) - overview of the Solidity code of the `LSP6KeyManagerCore.sol` by Jean Cavallera](https://www.youtube.com/watch?v=2Sm9LsCPjdE)

0 comments on commit 9df3007

Please sign in to comment.