Skip to main content

LSP4Compatibility

Standard Specifications
Solidity implementation

LSP4Compatibility

LSP4 extension, for compatibility with clients & tools that expect ERC20/721.

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

name

References
function name() external view returns (string);

Returns the name of the token.

Returns

NameTypeDescription
0stringThe name of the token

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-

symbol

References
function symbol() external view returns (string);

Returns the symbol of the token, usually a shorter version of the name.

Returns

NameTypeDescription
0stringThe symbol of the token

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;

Write a dataValue to the underlying ERC725Y storage, represented as a mapping of bytes32 data keys mapped to their bytes data values.

mapping(bytes32 => bytes) _store

Emitted events:

  • DataChanged event emitted after a successful setData call.

Parameters

NameTypeDescription
dataKeybytes32A bytes32 data key to write the associated bytes value to the store.
dataValuebytesThe bytes value to associate with the given dataKey in the ERC725Y storage.

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
  • Specification details: LSP-4-DigitalAssetMetadata
  • Solidity implementation: LSP4Compatibility.sol
  • Event signature: OwnershipTransferred(address,address)
  • Event topic hash: 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0
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.