LSP1 - Universal Receiver Delegate
To better understand this standard, it is well-advised first to check the origin standard LSP1-UniversalReceiver.
Once deployed, the code of a smart contract can not be changed. However, builders can decide how their smart contracts implement the
universalReceiver(...) function. This standard allows any external smart contract to change relations from the main contract to change function behavior.
Therefore, it is advised not to hardcode how the smart contract should handle and react to specific calls inside the
universalReceiver(...) function. Instead, it should delegate this functionality to another external contract. Developers could then customize such contracts to implement a specific logic that is changeable anytime via an upgrade.
What does this standard represent ?
This standard represents a smart contract delegated to the initial
It contains a single function named
universalReceiverDelegate(...) that takes the same parameters as the
universalReceiver(...) function with an additional one:
sender: the address that initially called the
How Delegation works
The address of the UniversalReceiverDelegate contract should be set as a value for the data key
LSP1UniversalReceiverDelegate, inside the ERC725Y Data key-value store of the implementation contract (contract implementing the
With such an implementation, the
universalReceiver(...) function can forward the call to its similar one called
This external contract will then implement the
universalReceiverDelegate(...) function. It is also recommended that this contract registers the LSP1UniversalReceiverDelegate interfaceId using ERC165.
There are several implementations of the standard. The LSP1UniversalReceiverDelegateUP contract is one of them and is used as a delegate to the
universalReceiver(...) function of UniversalProfile contract.
At the moment, this contract allows to:
- receive and send tokens & vaults
- register the data keys representing them according to LSP5-ReceivedAssets and LSP10-ReceivedVaults Standards.
Token transfer scenario
One of the possible scenarios is a token transfer between Alice and Bob. Alice wants to transfer a token owned by her Universal Profile to the Universal Profile of her friend Bob.
1. It calls the
transfer(...) function on the token contract through the KeyManager.
transfer(...) function on the token contract will directly trigger a hook that will call the
universalReceiver(...) function on both sender and recipient Universal Profiles.
3. 3. If the UniversalReceiverDelegate contract is set, it will be called by the
universalReceiver(...) function and will execute its custom logic.
4. The UniversalReceiverDelegate of Universal Profile allows the transfer and set LSP5-ReceivedAssets data keys on both Profiles through the KeyManager.