# The blob Contract

The blob contract is one of the core contracts on each IOTA Smart Contracts chain.

The function of the blob contract is to maintain an on-chain registry of blobs, a collections of arbitrary binary data. Smart contracts reference blobs via their hashes.

A blob is a collection of named pieces of arbitrary binary data:

<fieldName1> : <binaryChunk1><fieldName2> : <binaryChunk2>...<fieldNameN> : <binaryChunkN>

Here the fieldNameK is an arbitrary binary (a string) used as a name for the binary data binaryChunkK. Usually fieldNameK is not long. Its interpretation is use-case specific.

The binaryChunkK may be of arbitrary size (practical limits apply, of course).

The order of the field-chunk pairs is essential because the hash of the blob depends on it.

The hash of the blob is equal to the hash of concatenation of all pieces:

blobHash = hash( fieldName1 || binaryChunk1 || fieldName2 || binaryChunk2 || ... || fieldNameN || binaryChunkN)

There are two predefined field names which are interpreted by the VM while deploying smart contracts from binary:

• fieldname = "v" is interpreted as a VM type
• fieldname = "p" is interpreted as a smart contract program binary

If the field "v" is equal to the string "wasmtimevm", the binary chunk of "p" is interpreted as WebAssembly binary, loadable into the Wasmtime Wasm VM.

Another usecase for a _blob may be a full collection of self-described immutable data of a smart contract program:

"v" : VM type"p" : smart contract program binary"d" : data schema for data exchange between smart contract and outside sources and consumers"s" : program sources in .zip format

## Entry Points​

There is only one full entry point which allows us to submit a blob to the blob contract:

### storeBlob​

In the current implementation the data of the blob is passed as parameters to the call of the entry point. It may be practically impossible to submit very large blobs to the chain. In the future we plan to implement a special mechanism which allows for the nodes to download big data chunks as part of the committee consensus.

## Views​

### getBlobInfo​

Returns information about fields of the blob with specific hash and sizes of its data chunks:

<fieldName1>: <size of the dataChunk1>...<fieldNameN>: <size of the dataChunkN>

### getBlobField​

Returns the data of the specified blob field.

### listBlobs​

Returns a list of pairs blob hash: total size of chunks for all blobs in the registry.