rain.metadata
Specs
MetadataV1 spec - https://github.com/rainprotocol/specs/blob/main/metadata-v1.md
Contents
MetaBoard
Inherits: IMetaBoardV1
Functions
emitMeta
Emit a single MetaV1 event. Typically this is sufficient for most use
cases as a single MetaV1 event can contain many metas as a single
cbor-seq. Metadata MUST match the metadata V1 specification for Rain
metadata or tooling MAY drop it. IMetaBoardV1 contracts MUST revert any
metadata that does not start with the Rain metadata magic number.
function emitMeta(uint256 subject_, bytes calldata meta_) public;
Parameters
| Name | Type | Description |
|---|---|---|
subject_ | uint256 | |
meta_ | bytes |
Contents
IMetaBoardV1
Inherits: IMetaV1
Defines a general purpose contract that anon may call to emit ANY metadata. Anons MAY send garbage and malicious metadata so it is up to tooling to discard any suspect data before use, and generally treat it all as untrusted.
Functions
emitMeta
Emit a single MetaV1 event. Typically this is sufficient for most use
cases as a single MetaV1 event can contain many metas as a single
cbor-seq. Metadata MUST match the metadata V1 specification for Rain
metadata or tooling MAY drop it. IMetaBoardV1 contracts MUST revert any
metadata that does not start with the Rain metadata magic number.
function emitMeta(uint256 subject, bytes calldata meta) external;
Parameters
| Name | Type | Description |
|---|---|---|
subject | uint256 | As per IMetaV1 event. |
meta | bytes | As per IMetaV1 event. |
UnexpectedMetaHash
Thrown when hashed metadata does NOT match the expected hash.
error UnexpectedMetaHash(bytes32 expectedHash, bytes32 actualHash);
Parameters
| Name | Type | Description |
|---|---|---|
expectedHash | bytes32 | The hash expected by the IMetaV1 contract. |
actualHash | bytes32 | The hash of the metadata seen by the IMetaV1 contract. |
NotRainMetaV1
Thrown when some bytes are expected to be rain meta and are not.
error NotRainMetaV1(bytes unmeta);
Parameters
| Name | Type | Description |
|---|---|---|
unmeta | bytes | the bytes that are not meta. |
IMetaV1
Events
MetaV1
An onchain wrapper to carry arbitrary Rain metadata. Assigns the sender to the metadata so that tooling can easily drop/ignore data from unknown sources. As metadata is about something, the subject MUST be provided.
event MetaV1(address sender, uint256 subject, bytes meta);
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | The msg.sender. |
subject | uint256 | The entity that the metadata is about. MAY be the address of the emitting contract (as uint256) OR anything else. The interpretation of the subject is context specific, so will often be a hash of some data/thing that this metadata is about. |
meta | bytes | Rain metadata V1 compliant metadata bytes. https://github.com/rainprotocol/specs/blob/main/metadata-v1.md |
Constants
META_MAGIC_NUMBER_V1
Randomly generated magic number with first bytes oned out. https://github.com/rainprotocol/specs/blob/main/metadata-v1.md
uint64 constant META_MAGIC_NUMBER_V1 = 0xff0a89c674ee7874;
Contents
LibMeta
Need a place to put data that can be handled offchain like ABIs that IS NOT etherscan.
Functions
isRainMetaV1
Returns true if the metadata bytes are prefixed by the Rain meta magic number. DOES NOT attempt to validate the body of the metadata as offchain tooling will be required for this.
function isRainMetaV1(bytes memory meta_) internal pure returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
meta_ | bytes | The data that may be rain metadata. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if meta_ is metadata, false otherwise. |
checkMetaUnhashed
Reverts if the provided meta_ is NOT metadata according to
isRainMetaV1.
function checkMetaUnhashed(bytes memory meta_) internal pure;
Parameters
| Name | Type | Description |
|---|---|---|
meta_ | bytes | The metadata bytes to check. |
checkMetaHashed
Reverts if the provided meta_ is NOT metadata according to
isRainMetaV1 OR it does not match the expected hash of its data.
function checkMetaHashed(bytes32 expectedHash_, bytes memory meta_) internal pure;
Parameters
| Name | Type | Description |
|---|---|---|
expectedHash_ | bytes32 | |
meta_ | bytes | The metadata to check. |