Skip to main content

PeaqStorage

The Storage pallet is a decentralized storage system for the peaq network. It allows users to store data on the blockchain, and to access that data securely.

NOTE

Storage pallet is mainly for storing an item eg. CID (content Identifier) along with the type of that item.

TIP

Technically, we are storing key-value pairs in the chain storage with the key being the user public key + type of item we are storing and the value is the item.

Functions

  • addItem(itemType, item): Add an item type with any item.

peaq-storage-addItem

  • getItem(itemType): Read the item with the item's type. A user can only access those items which were added by user himself.

peaq-storage-getItem

  • updateItem(itemType, item): Update an item. Only the item itself can be updated, but not the item type (the item type is attached to the user's public key and acts as part of the item ID)

peaq-storage-updateItem

Code examples


// Store data on the blockchain.
let data = "This is some data.";
storeData(data);

// Get data from the blockchain.
let data = getData();
console.log(data);