LSP4Compatibility
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
- Specification details: LSP-4-DigitalAssetMetadata
- Solidity implementation:
LSP4Compatibility.sol
- Function signature:
getData(bytes32)
- Function selector:
0x54f6127f
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
Name | Type | Description |
---|---|---|
dataKey | bytes32 | The data key for which to retrieve the value. |
Returns
Name | Type | Description |
---|---|---|
dataValue | bytes | The bytes value stored under the specified data key. |
getDataBatch
- Specification details: LSP-4-DigitalAssetMetadata
- Solidity implementation:
LSP4Compatibility.sol
- Function signature:
getDataBatch(bytes32[])
- Function selector:
0xdedff9c6
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
Name | Type | Description |
---|---|---|
dataKeys | bytes32[] | The array of keys which values to retrieve |
Returns
Name | Type | Description |
---|---|---|
dataValues | bytes[] | The array of data stored at multiple keys |
name
- Specification details: LSP-4-DigitalAssetMetadata
- Solidity implementation:
LSP4Compatibility.sol
- Function signature:
name()
- Function selector:
0x06fdde03
function name() external view returns (string);
Returns the name of the token.
Returns
Name | Type | Description |
---|---|---|
0 | string | The name of the token |
owner
- Specification details: LSP-4-DigitalAssetMetadata
- Solidity implementation:
LSP4Compatibility.sol
- Function signature:
owner()
- Function selector:
0x8da5cb5b
function owner() external view returns (address);
Returns the address of the current owner.
Returns
Name | Type | Description |
---|---|---|
0 | address | - |
renounceOwnership
- Specification details: LSP-4-DigitalAssetMetadata
- Solidity implementation:
LSP4Compatibility.sol
- Function signature:
renounceOwnership()
- Function selector:
0x715018a6
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
- Specification details: LSP-4-DigitalAssetMetadata
- Solidity implementation:
LSP4Compatibility.sol
- Function signature:
setData(bytes32,bytes)
- Function selector:
0x7f23690c
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:
DataChanged
event.
Parameters
Name | Type | Description |
---|---|---|
dataKey | bytes32 | The data key for which to set a new value. |
dataValue | bytes | The new bytes value to set. |
setDataBatch
- Specification details: LSP-4-DigitalAssetMetadata
- Solidity implementation:
LSP4Compatibility.sol
- Function signature:
setDataBatch(bytes32[],bytes[])
- Function selector:
0x97902421
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:
DataChanged
event for each data key/value pair set.
Parameters
Name | Type | Description |
---|---|---|
dataKeys | bytes32[] | An array of data keys to set bytes values for. |
dataValues | bytes[] | An array of bytes values to set for each dataKeys . |
supportsInterface
- Specification details: LSP-4-DigitalAssetMetadata
- Solidity implementation:
LSP4Compatibility.sol
- Function signature:
supportsInterface(bytes4)
- Function selector:
0x01ffc9a7
function supportsInterface(bytes4 interfaceId) external view returns (bool);
See IERC165-supportsInterface
.
Parameters
Name | Type | Description |
---|---|---|
interfaceId | bytes4 | - |
Returns
Name | Type | Description |
---|---|---|
0 | bool | - |
symbol
- Specification details: LSP-4-DigitalAssetMetadata
- Solidity implementation:
LSP4Compatibility.sol
- Function signature:
symbol()
- Function selector:
0x95d89b41
function symbol() external view returns (string);
Returns the symbol of the token, usually a shorter version of the name.
Returns
Name | Type | Description |
---|---|---|
0 | string | The symbol of the token |
transferOwnership
- Specification details: LSP-4-DigitalAssetMetadata
- Solidity implementation:
LSP4Compatibility.sol
- Function signature:
transferOwnership(address)
- Function selector:
0xf2fde38b
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
Name | Type | Description |
---|---|---|
newOwner | address | - |
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
Name | Type | Description |
---|---|---|
dataKey | bytes32 | A bytes32 data key to read the associated bytes value from the store. |
Returns
Name | Type | Description |
---|---|---|
dataValue | bytes | The 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 successfulsetData
call.
Parameters
Name | Type | Description |
---|---|---|
dataKey | bytes32 | A bytes32 data key to write the associated bytes value to the store. |
dataValue | bytes | The bytes value to associate with the given dataKey in the ERC725Y storage. |
Events
DataChanged
- Specification details: LSP-4-DigitalAssetMetadata
- Solidity implementation:
LSP4Compatibility.sol
- Event signature:
DataChanged(bytes32,bytes)
- Event topic hash:
0xece574603820d07bc9b91f2a932baadf4628aabcb8afba49776529c14a6104b2
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
Name | Type | Description |
---|---|---|
dataKey indexed | bytes32 | The data key for which a bytes value is set. |
dataValue | bytes | The value to set for the given data key. |
OwnershipTransferred
- 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
Name | Type | Description |
---|---|---|
previousOwner indexed | address | - |
newOwner indexed | address | - |
Errors
ERC725Y_DataKeysValuesEmptyArray
- Specification details: LSP-4-DigitalAssetMetadata
- Solidity implementation:
LSP4Compatibility.sol
- Error signature:
ERC725Y_DataKeysValuesEmptyArray()
- Error hash:
0x97da5f95
error ERC725Y_DataKeysValuesEmptyArray();
Reverts when one of the array parameter provided to setDataBatch
function is an empty array.
ERC725Y_DataKeysValuesLengthMismatch
- Specification details: LSP-4-DigitalAssetMetadata
- Solidity implementation:
LSP4Compatibility.sol
- Error signature:
ERC725Y_DataKeysValuesLengthMismatch()
- Error hash:
0x3bcc8979
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
- Specification details: LSP-4-DigitalAssetMetadata
- Solidity implementation:
LSP4Compatibility.sol
- Error signature:
ERC725Y_MsgValueDisallowed()
- Error hash:
0xf36ba737
error ERC725Y_MsgValueDisallowed();
Reverts when sending value to the setData
or setDataBatch
function.