rain.metadata

Specs

MetadataV1 spec - https://github.com/rainprotocol/specs/blob/main/metadata-v1.md

Contents

MetaBoard

Git Source

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

NameTypeDescription
subject_uint256
meta_bytes

Contents

IMetaBoardV1

Git Source

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

NameTypeDescription
subjectuint256As per IMetaV1 event.
metabytesAs per IMetaV1 event.

UnexpectedMetaHash

Git Source

Thrown when hashed metadata does NOT match the expected hash.

error UnexpectedMetaHash(bytes32 expectedHash, bytes32 actualHash);

Parameters

NameTypeDescription
expectedHashbytes32The hash expected by the IMetaV1 contract.
actualHashbytes32The hash of the metadata seen by the IMetaV1 contract.

NotRainMetaV1

Git Source

Thrown when some bytes are expected to be rain meta and are not.

error NotRainMetaV1(bytes unmeta);

Parameters

NameTypeDescription
unmetabytesthe bytes that are not meta.

IMetaV1

Git Source

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

NameTypeDescription
senderaddressThe msg.sender.
subjectuint256The 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.
metabytesRain metadata V1 compliant metadata bytes. https://github.com/rainprotocol/specs/blob/main/metadata-v1.md

Constants

Git Source

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

Git Source

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

NameTypeDescription
meta_bytesThe data that may be rain metadata.

Returns

NameTypeDescription
<none>boolTrue 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

NameTypeDescription
meta_bytesThe 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

NameTypeDescription
expectedHash_bytes32
meta_bytesThe metadata to check.