How to publish list of HeldCredentials to ceramic

Hey,
Im trying to publish a list of VerifiableCredentials to ceramic testnet. Im using ‘@datamodels/verifiable-credentia’ library.

This is my code

import { CeramicClient } from "@ceramicnetwork/http-client";
import { EthereumAuthProvider } from "@ceramicnetwork/blockchain-utils-linking";
import { DIDDataStore } from "@glazed/did-datastore";
import { DIDSession } from "@glazed/did-session";
import {
  HeldCredentials,
  VerifiableCredential,
} from "@datamodels/verifiable-credentials";

const ceramic = new CeramicClient("https://ceramic-clay.3boxlabs.com");

const aliases = {
  definitions: {
    VerifiableCredential:
      "kjzl6cwe1jw149dwrqgkmdhbxm52t5i0m37k5t7o9y2vf1tncss86iljsin8fpr",
    VlaimedCredentials:
      "kjzl6cwe1jw14bdckgezfuci7b5if7ussy4zmxj0q97c8jl3zvb172qz7h8jbqd",
    IssuedCredentials:
      "kjzl6cwe1jw149hainpftr2tssjnlf2ty154nc137ujqq329aydhsrp5252y0hx",
    HeldCredentials:
      "kjzl6cwe1jw14afevdrbxwgcw2aqk3nj0g47w8ermgde61o09o52bn6fkyq7k6i",
  },
  schemas: {
    verifiableCredential:
      "ceramic://k3y52l7qbv1frxo5510cruhkluijtav39g4vacian4lrh7bxs8vk0b2w7pjmilqtc",
    claimedCredentials:
      "ceramic://k3y52l7qbv1frxv8kiit856743dfzrrwsihrfuvdn3y3nvevv4o8zpfdyt0nfwhz4",
    heldCredentials:
      "ceramic://k3y52l7qbv1fryihueadzabto4qyfkfq11knx3szfrd6yz83c5bbzsuswfyxoqfpc",
    issuedCredentials:
      "ceramic://k3y52l7qbv1fryp7fle8dvb02bxwugsqhjz3edlzu8n33msm8w33613fdge24aby8",
  },
  tiles: {},
};

const datastore = new DIDDataStore({ ceramic, model: aliases });

When I try to upload a single VC it works fine, but I have no idea how to go about uploading HeldCredentials object.

const heldCredentials = {
      held: [JSON.stringify(vc)],
    } as HeldCredentials;
    //use the DIDDatastore to merge profile data to Ceramic
    await datastore.merge("HeldCredentials", heldCredentials);

When I try to run this code I get the following error: HTTP request to 'https://ceramic-clay.3boxlabs.com/api/v0/commits' failed with status '': {"error":"Validation Error: data/held/0 must NOT have more than 150 characters, data/held/0 must match pattern "^ceramic://.+(\?version=.+)?""}

Would really appreciate any help. Am kind of lost atm.

Thanks!

And if this doesnt work, is it possible to create a custom datamodel that is an array of verifiableCredentials and not just strings? Or is there a limit how much data can be stored in a single model?

cc @artur @paul, any idea? I’m not well-versed enough here to help :persevere:

This is a validation error so it looks like you’re misusing the schema, make sure the contents you set match the expected validation rules defined in datamodels/HeldCredentials.json at main · ceramicstudio/datamodels · GitHub