Issue creating MID stream using JS libraries

Hello everyone,

I’m trying to create model streams using the JS libraries directly and I’m facing some issues and it’s hard to debug since there doesn’t seem to be a lot of doc covering this.

Here is the process I followed so far:

I used the @ceramicnetwork/stream-model library to create a model which worked, the model is available here: https://cerscan.com/mainnet/stream/kjzl6hvfrbw6c7qqnhgjubuiwbg1965tm4zsw5p5jutpapxrpbux0qy6e3non81

I’m then trying to use the @ceramicnetwork/stream-model-instance library to create streams using this model but I constantly get a Error: undefined is not supported by the IPLD Data Model and cannot be encoded error which seems to be coming from the _signDagJWS function. Here is the code I’m using to create the stream:

let stream = await ModelInstanceDocument.create(
  this.ceramic,
  { asset: 'bitcoin', price: '36838', timestamp: 1699524618 },
  {
    model: "kjzl6hvfrbw6c7qqnhgjubuiwbg1965tm4zsw5p5jutpapxrpbux0qy6e3non81",
    controller: this.session.id
  }
);

Is there anything I’m doing wrong? cc @spencer

In the past I got this error when the stream content wasn’t valid vs the schema/model but everything seems fine in the example I shared.

I solved it by using StreamID.fromString("kjzl6hvfrbw6c77ypg2ug7kka2zorn82534vt1k1phjstjgpm1v77wg8caqet4w") instead of the model ID as a simple string.

1 Like

Thank you for sharing the solution here, @baptiste! :raised_hands:

1 Like