@windingtree/off-chain-accessor-in-memorydeprecated

In memory storage that can be used as an off-chain data accessor in @windingtree/wt-js-libs

Usage no npm install needed!

<script type="module">
  import windingtreeOffChainAccessorInMemory from 'https://cdn.skypack.dev/@windingtree/off-chain-accessor-in-memory';
</script>

README

Winding Tree Off Chain Data Accessor - In memory

Very simple in-memory key-value storage that can be used in Winding Tree wt-js-libs.

Installation

npm install @windingtree/off-chain-accessor-in-memory
# or
git clone https://github.com/windingtree/off-chain-accessor-in-memory
nvm install
npm install

Usage

import WTLibs from '@windingtree/wt-js-libs';
import InMemoryAccessor from '@windingtree/off-chain-accessor-in-memory';

const libs = WTLibs.createInstance({
  dataModelOptions: {
    provider: 'http://localhost:8545',
  },
  offChainDataOptions: {
    accessors: {
      json: {
        options: {
          // some: options
        }
        create: (options) => {
          return new InMemoryAccessor(options);
        },
      },
    },
  },
});
const index = await libs.getWTIndex('0x...');
const hotel = await index.getHotel('0x...');
// Accessing off-chain data - url is actually stored on chain
const hotelDescriptionUrl = await (await hotel.dataIndex).ref;
// This data is fetched from some off-chain storage
const hotelDescription = await (await hotel.dataIndex).contents.description;
const hotelName = await hotelDescription.contents.name;