Skip to main content

LSP5Utils

Standard Specifications
Solidity implementation

LSP5 Utility library.

LSP5Utils is a library of functions that can be used to register and manage assets under an ERC725Y smart contract. Based on the LSP5 Received Assets standard.

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.

generateReceivedAssetKeys​

Warning

Returns empty arrays when encountering errors. Otherwise the arrays must have 3 data keys and 3 data values.

function generateReceivedAssetKeys(
address receiver,
address assetAddress,
bytes4 assetInterfaceId
) internal view returns (bytes32[] lsp5DataKeys, bytes[] lsp5DataValues);

Generate an array of data key/value pairs to be set on the receiver address after receiving assets.

Parameters​

NameTypeDescription
receiveraddressThe address receiving the asset and where the LSP5 data keys should be added.
assetAddressaddressThe address of the asset being received (e.g: an LSP7 or LSP8 token).
assetInterfaceIdbytes4The interfaceID of the asset being received.

Returns​

NameTypeDescription
lsp5DataKeysbytes32[]An array Data Keys used to update the [LSP-5-ReceivedAssets] data.
lsp5DataValuesbytes[]An array Data Values used to update the [LSP-5-ReceivedAssets] data.

generateSentAssetKeys​

Warning

Returns empty arrays when encountering errors. Otherwise the arrays must have at least 3 data keys and 3 data values.

function generateSentAssetKeys(
address sender,
address assetAddress
) internal view returns (bytes32[] lsp5DataKeys, bytes[] lsp5DataValues);

Generate an array of Data Key/Value pairs to be set on the sender address after sending assets.

Parameters​

NameTypeDescription
senderaddressThe address sending the asset and where the LSP5 data keys should be updated.
assetAddressaddressThe address of the asset that is being sent.

Returns​

NameTypeDescription
lsp5DataKeysbytes32[]An array Data Keys used to update the [LSP-5-ReceivedAssets] data.
lsp5DataValuesbytes[]An array Data Values used to update the [LSP-5-ReceivedAssets] data.

getLSP5ArrayLengthBytes​

function getLSP5ArrayLengthBytes(contract IERC725Y erc725YContract) internal view returns (bytes);

Get the raw bytes value stored under the _LSP5_RECEIVED_ASSETS_ARRAY_KEY.

Parameters​

NameTypeDescription
erc725YContractcontract IERC725YThe contract to query the ERC725Y storage from.

Returns​

NameTypeDescription
0bytesThe raw bytes value stored under this data key.