gm
gm

Subscribe to gm

Subscribe to gm
Share Dialog
Share Dialog
<100 subscribers
<100 subscribers
Learn the basics by setting up and interacting with the Ceramic CLI. This tutorial serves as a simple introduction to Ceramic concepts.
Want an even faster way to try Ceramic? Visit the Playground demo app to test the full stack of Ceramic components in the browser.
Install the CLIs¶
npm install --global @ceramicnetwork/cli @glazed/cli The Ceramic CLI is then accessible as ceramic and the Glaze CLI as glaze.
Run ceramic help and glaze help to list the available commands.
Start the Ceramic daemon¶ Run the daemon command of the Ceramic CLI to start a local Ceramic node:
ceramic daemon Visit the Ceramic CLI page for more informations about the Ceramic daemon.
Create a Ceramic account¶ Signing transactions to send on a Ceramic node requires a Ceramic account provided by a DID.
The Glaze CLI can be used to create a key DID, generating a 32-byte random seed:
glaze did:create The expected output will be similar to the following, with ... used as placeholder for brievety:
✔ Created DID did:key:z6Mk... with seed ab...f0 The seed can then be used when running other commands:
glaze [command] --key=ab...f0 DID_KEY=ab...f0 glaze [command] 4. Create a stream¶ Use the tile:create command to create a new stream. In the example below we create a stream that uses the TileDocument StreamType. Note that TileDocument is the only StreamType that can currently be created by the Ceramic CLI.
Command Output
glaze tile:create --key ab...f0 --content '{"Foo":"Bar"}'
More options 5. Query a stream¶ Use the tile:show command to query the current state of a stream. You will need to provide its StreamID.
Command Output
glaze tile:show kjzl6cwe1jw147ww5d8pswh1hjh686mut8v1br10dar8l9a3n1wf8z38l0bg8qa You should use your StreamID instead of the StreamID included here.
Use the stream:state command to query the entire state of a stream.
Command Output before anchor Output after anchor
glaze stream:state kjzl6cwe1jw147ww5d8pswh1hjh686mut8v1br10dar8l9a3n1wf8z38l0bg8qa You should use your StreamID instead of the StreamID included here.
Update a stream¶ Use the tile:update command to update a stream. Your DID must be the controller of the stream in order to update it. Note that TileDocument is the only StreamType that can currently be updated by the CLI.
Command Output
glaze tile:update kjzl6cwe1jw147ww5d8pswh1hjh686mut8v1br10dar8l9a3n1wf8z38l0bg8qa --key ab...f0 --content '{"Foo":"Baz"}' You should use your StreamID instead of the StreamID included here.
More options 7. Create a schema¶ TileDocuments can enforce that their contents adhere to a specified schema. The schemas themselves are TileDocuments where the content is a json-schema. For example we can create a schema that requires a TileDocument to have a title and message.
Command Output
glaze tile:create --key ab...f0 --content '{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Reward", "type": "object", "properties": { "title": {"type": "string"}, "message": {"type": "string"} }, "required": [ "message", "title" ] }'
Create a TileDocument stream that uses a schema¶ First, use the stream:commits command to list the commitIDs contained in the schema stream. When creating a TileDocument that uses this schema, we need to use a commitID instead of the StreamID to enforce that we are using a specific version of the schema since the schema stream is mutable and can be updated.
Command Output
glaze stream:commits kjzl6cwe1jw1472as4pj3b3ahqmkokbmwc7jchqcob6pcixcoo4kxq6ls8uuxgb You should use your StreamID for the stream containing the json-schema you want to enforce, instead of the StreamID included here.
If a stream contains multiple commits and you're not sure which one you want, use the tile:show command to show the content of the stream at the given commit.
Once you retrieve the desired commit, you can now create a TileDocument that is enforced to conform to this version of the schema. Use the tile:create command and pass the --metadata option along with your commitID.
Command Output
glaze tile:create --key ab...f0 --content '{ "title": "My first document with schema", "message": "Hello World" }' --metadata '{"schema":"k3y52l7qbv1frxu8co1hjrivem5cj2oiqtytlku3e4vjo92l67fkkvu6ywuzfxvy8"}' You should use your commitID instead of the commitID included here.
Query the stream you created¶ Use the stream:state command to query the state of the TileDocument we just created. We can see that the schema is set to the correct commitID.
Command Output
glaze stream:state kjzl6cwe1jw14b5sr79heovz7fziz4dxcn8upx3bcesriloqcui137k6rq6g2mn You should use your StreamID instead of the StreamID included here.
That's it!
Learn the basics by setting up and interacting with the Ceramic CLI. This tutorial serves as a simple introduction to Ceramic concepts.
Want an even faster way to try Ceramic? Visit the Playground demo app to test the full stack of Ceramic components in the browser.
Install the CLIs¶
npm install --global @ceramicnetwork/cli @glazed/cli The Ceramic CLI is then accessible as ceramic and the Glaze CLI as glaze.
Run ceramic help and glaze help to list the available commands.
Start the Ceramic daemon¶ Run the daemon command of the Ceramic CLI to start a local Ceramic node:
ceramic daemon Visit the Ceramic CLI page for more informations about the Ceramic daemon.
Create a Ceramic account¶ Signing transactions to send on a Ceramic node requires a Ceramic account provided by a DID.
The Glaze CLI can be used to create a key DID, generating a 32-byte random seed:
glaze did:create The expected output will be similar to the following, with ... used as placeholder for brievety:
✔ Created DID did:key:z6Mk... with seed ab...f0 The seed can then be used when running other commands:
glaze [command] --key=ab...f0 DID_KEY=ab...f0 glaze [command] 4. Create a stream¶ Use the tile:create command to create a new stream. In the example below we create a stream that uses the TileDocument StreamType. Note that TileDocument is the only StreamType that can currently be created by the Ceramic CLI.
Command Output
glaze tile:create --key ab...f0 --content '{"Foo":"Bar"}'
More options 5. Query a stream¶ Use the tile:show command to query the current state of a stream. You will need to provide its StreamID.
Command Output
glaze tile:show kjzl6cwe1jw147ww5d8pswh1hjh686mut8v1br10dar8l9a3n1wf8z38l0bg8qa You should use your StreamID instead of the StreamID included here.
Use the stream:state command to query the entire state of a stream.
Command Output before anchor Output after anchor
glaze stream:state kjzl6cwe1jw147ww5d8pswh1hjh686mut8v1br10dar8l9a3n1wf8z38l0bg8qa You should use your StreamID instead of the StreamID included here.
Update a stream¶ Use the tile:update command to update a stream. Your DID must be the controller of the stream in order to update it. Note that TileDocument is the only StreamType that can currently be updated by the CLI.
Command Output
glaze tile:update kjzl6cwe1jw147ww5d8pswh1hjh686mut8v1br10dar8l9a3n1wf8z38l0bg8qa --key ab...f0 --content '{"Foo":"Baz"}' You should use your StreamID instead of the StreamID included here.
More options 7. Create a schema¶ TileDocuments can enforce that their contents adhere to a specified schema. The schemas themselves are TileDocuments where the content is a json-schema. For example we can create a schema that requires a TileDocument to have a title and message.
Command Output
glaze tile:create --key ab...f0 --content '{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "Reward", "type": "object", "properties": { "title": {"type": "string"}, "message": {"type": "string"} }, "required": [ "message", "title" ] }'
Create a TileDocument stream that uses a schema¶ First, use the stream:commits command to list the commitIDs contained in the schema stream. When creating a TileDocument that uses this schema, we need to use a commitID instead of the StreamID to enforce that we are using a specific version of the schema since the schema stream is mutable and can be updated.
Command Output
glaze stream:commits kjzl6cwe1jw1472as4pj3b3ahqmkokbmwc7jchqcob6pcixcoo4kxq6ls8uuxgb You should use your StreamID for the stream containing the json-schema you want to enforce, instead of the StreamID included here.
If a stream contains multiple commits and you're not sure which one you want, use the tile:show command to show the content of the stream at the given commit.
Once you retrieve the desired commit, you can now create a TileDocument that is enforced to conform to this version of the schema. Use the tile:create command and pass the --metadata option along with your commitID.
Command Output
glaze tile:create --key ab...f0 --content '{ "title": "My first document with schema", "message": "Hello World" }' --metadata '{"schema":"k3y52l7qbv1frxu8co1hjrivem5cj2oiqtytlku3e4vjo92l67fkkvu6ywuzfxvy8"}' You should use your commitID instead of the commitID included here.
Query the stream you created¶ Use the stream:state command to query the state of the TileDocument we just created. We can see that the schema is set to the correct commitID.
Command Output
glaze stream:state kjzl6cwe1jw14b5sr79heovz7fziz4dxcn8upx3bcesriloqcui137k6rq6g2mn You should use your StreamID instead of the StreamID included here.
That's it!
No activity yet