Skip to main content

LSP4DigitalAssetMetadata

Standard Specifications
Solidity implementation

Implementation of a LSP4DigitalAssetMetadata contract that stores the Token-Metadata (LSP4TokenName and LSP4TokenSymbol) in its ERC725Y data store.

Standard Implementation of the LSP4 standard.

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.

getData​

References
function getData(bytes32 dataKey) external view returns (bytes dataValue);

Reading the ERC725Y storage for data key dataKey returned the following value: dataValue.

Get in the ERC725Y storage the bytes data stored at a specific data key dataKey.

Parameters​

NameTypeDescription
dataKeybytes32The data key for which to retrieve the value.

Returns​

NameTypeDescription
dataValuebytesThe bytes value stored under the specified data key.

getDataBatch​

References
function getDataBatch(
bytes32[] dataKeys
) external view returns (bytes[] dataValues);

Reading the ERC725Y storage for data keys dataKeys returned the following values: dataValues.

Get in the ERC725Y storage the bytes data stored at multiple data keys dataKeys.

Parameters​

NameTypeDescription
dataKeysbytes32[]The array of keys which values to retrieve

Returns​

NameTypeDescription
dataValuesbytes[]The array of data stored at multiple keys

owner​

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

Returns the address of the current owner.

Returns​

NameTypeDescription
0address-

renounceOwnership​

References
function renounceOwnership() external nonpayable;

Leaves the contract without owner. It will not be possible to call onlyOwner functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.


setData​

References
Warning

Note for developers: despite the fact that this function is set as payable, if the function is not intended to receive value (= native tokens), an additional check should be implemented to ensure that msg.value sent was equal to 0.

function setData(bytes32 dataKey, bytes dataValue) external payable;

Setting the following data key value pair in the ERC725Y storage. Data key: dataKey, data value: dataValue.

Sets a single bytes value dataValue in the ERC725Y storage for a specific data key dataKey. The function is marked as payable to enable flexibility on child contracts. For instance to implement a fee mechanism for setting specific data.

Requirements:

  • SHOULD only be callable by the owner.

Emitted events:

Parameters​

NameTypeDescription
dataKeybytes32The data key for which to set a new value.
dataValuebytesThe new bytes value to set.

setDataBatch​

References
Warning

Note for developers: despite the fact that this function is set as payable, if the function is not intended to receive value (= native tokens), an additional check should be implemented to ensure that msg.value sent was equal to 0.

function setDataBatch(bytes32[] dataKeys, bytes[] dataValues) external payable;

Setting the following data key value pairs in the ERC725Y storage. Data keys: dataKeys, data values: dataValues.

Batch data setting function that behaves the same as setData but allowing to set multiple data key/value pairs in the ERC725Y storage in the same transaction.

Requirements:

  • SHOULD only be callable by the owner of the contract.

Emitted events:

Parameters​

NameTypeDescription
dataKeysbytes32[]An array of data keys to set bytes values for.
dataValuesbytes[]An array of bytes values to set for each dataKeys.

supportsInterface​

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

See IERC165-supportsInterface.

Parameters​

NameTypeDescription
interfaceIdbytes4-

Returns​

NameTypeDescription
0bool-

transferOwnership​

References
function transferOwnership(address newOwner) external nonpayable;

Transfers ownership of the contract to a new account (newOwner). Can only be called by the current owner.

Parameters​

NameTypeDescription
newOwneraddress-

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.

_checkOwner​

function _checkOwner() internal view;

Throws if the sender is not the owner.


_setOwner​

function _setOwner(address newOwner) internal nonpayable;

Changes the owner if newOwner and oldOwner are different This pattern is useful in inheritance.


_getData​

function _getData(bytes32 dataKey) internal view returns (bytes dataValue);

Read the value stored under a specific dataKey inside the underlying ERC725Y storage, represented as a mapping of bytes32 data keys mapped to their bytes data values.

mapping(bytes32 => bytes) _store

Parameters​

NameTypeDescription
dataKeybytes32A bytes32 data key to read the associated bytes value from the store.

Returns​

NameTypeDescription
dataValuebytesThe bytes value associated with the given dataKey in the ERC725Y storage.

_setData​

function _setData(bytes32 dataKey, bytes dataValue) internal nonpayable;

The ERC725Y data keys LSP4TokenName and LSP4TokenSymbol cannot be changed via this function once the digital asset contract has been deployed.


Events​

DataChanged​

References
event DataChanged(bytes32 indexed dataKey, bytes dataValue);

The following data key/value pair has been changed in the ERC725Y storage: Data key: dataKey, data value: dataValue.

Emitted when data at a specific dataKey was changed to a new value dataValue.

Parameters​

NameTypeDescription
dataKey indexedbytes32The data key for which a bytes value is set.
dataValuebytesThe value to set for the given data key.

OwnershipTransferred​

References
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);

Parameters​

NameTypeDescription
previousOwner indexedaddress-
newOwner indexedaddress-

Errors​

ERC725Y_DataKeysValuesEmptyArray​

References
error ERC725Y_DataKeysValuesEmptyArray();

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


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.


ERC725Y_MsgValueDisallowed​

References
error ERC725Y_MsgValueDisallowed();

Reverts when sending value to the setData or setDataBatch function.


LSP4TokenNameNotEditable​

References
error LSP4TokenNameNotEditable();

Reverts when trying to edit the data key LSP4TokenName after the digital asset contract has been deployed / initialized. The LSP4TokenName data key is located inside the ERC725Y data key-value store of the digital asset contract. It can be set only once inside the constructor/initializer when the digital asset contract is being deployed / initialized.


LSP4TokenSymbolNotEditable​

References
error LSP4TokenSymbolNotEditable();

Reverts when trying to edit the data key LSP4TokenSymbol after the digital asset contract has been deployed / initialized. The LSP4TokenSymbol data key is located inside the ERC725Y data key-value store of the digital asset contract. It can be set only once inside the constructor/initializer when the digital asset contract is being deployed / initialized.


LSP4TokenTypeNotEditable​

References
error LSP4TokenTypeNotEditable();

Reverts when trying to edit the data key LSP4TokenType after the digital asset contract has been deployed / initialized. The LSP4TokenType data key is located inside the ERC725Y data key-value store of the digital asset contract. It can be set only once inside the constructor / initializer when the digital asset contract is being deployed / initialized.


OwnableCallerNotTheOwner​

References
error OwnableCallerNotTheOwner(address callerAddress);

Reverts when only the owner is allowed to call the function.

Parameters​

NameTypeDescription
callerAddressaddressThe address that tried to make the call.

OwnableCannotSetZeroAddressAsOwner​

References
error OwnableCannotSetZeroAddressAsOwner();

Reverts when trying to set address(0) as the contract owner when deploying the contract, initializing it or transferring ownership of the contract.