Skip to main content
Version: 0.3.x

Composites deployment

Valid composites can be deployed to any supporting Ceramic node, by ensuring the model streams described in the composite are available and indexed on the node. An admin DID is necessary to start indexing models on a Ceramic node.

Dependencies required

Make sure you have installed the packages imported in the code below before running the script.

import { CeramicClient } from '@ceramicnetwork/http-client'
import { readEncodedComposite } from '@composedb/devtools-node'
import { DID } from 'dids'
import { Ed25519Provider } from 'key-did-provider-ed25519'
import { getResolver } from 'key-did-resolver'
import { fromString } from 'uint8arrays/from-string'

// Hexadecimal-encoded private key for a DID having admin access to the target Ceramic node
// Replace the example key here by your admin private key
const privateKey = fromString('b0cb[...]515f', 'base16')

const did = new DID({
resolver: getResolver(),
provider: new Ed25519Provider(privateKey),
await did.authenticate()

// Replace by the URL of the Ceramic node you want to deploy the Models to
const ceramic = new CeramicClient('http://localhost:7007')
// An authenticated DID with admin access must be set on the Ceramic instance
ceramic.did = did

// Replace by the path to the local encoded composite file
const composite = await readEncodedComposite(ceramic, 'my-first-composite.json')

// Notify the Ceramic node to index the models present in the composite
await composite.startIndexingOn(ceramic)

More details: readEncodedComposite