Slangroom is a plugin system to enhance the domain-specific Zencode language, allowing to define custom operations to new sentences and making it easy to execute fast cryptographic operations on any data structure.
Zencode has a no-code approach. It is a domain-specific language (DSL) similar to human language. One can process large data structures through complex cryptographic and logical transformations.
Zencode helps developers to empower people who know what to do with data: one can write and review business logic and data-sensitive operations without learning to code.
Start by reading the full documentation.
To use slangroom in your project you must install the @slangroom/core
package and then all the plugins that you like:
pnpm add @slangroom/core
# and then install the plugin that you need, here we install all of them
pnpm add @slangroom/db @slangroom/ethereum @slangroom/fs @slangroom/git @slangroom/helpers @slangroom/http @slangroom/json-schema @slangroom/oauth @slangroom/pocketbase @slangroom/qrcode @slangroom/rdf @slangroom/redis @slangroom/shell @slangroom/timestamp @slangroom/wallet @slangroom/zencode
After having installed the core plugin along with the other plugins that you need (here wew continuer with all the plugins) you can use it in your code in the following way:
import { Slangroom } from '@slangroom/core';
import { db } from '@slangroom/db';
import { ethereum } from '@slangroom/ethereum';
import { fs } from '@slangroom/fs';
import { git } from '@slangroom/git';
import { helpers } from '@slangroom/helpers';
import { http } from '@slangroom/http';
import { JSONSchema } from '@slangroom/json-schema';
import { oauth } from '@slangroom/oauth';
import { pocketbase } from '@slangroom/pocketbase';
import { qrcode } from '@slangroom/qrcode';
import { rdf } from '@slangroom/rdf';
import { redis } from '@slangroom/redis';
import { shell } from '@slangroom/shell';
import { timestamp } from '@slangroom/timestamp';
import { wallet } from '@slangroom/wallet';
import { zencode } from '@slangroom/zencode';
const SLANGROOM_PLUGINS = [
db,
ethereum,
fs,
git,
helpers,
http,
JSONSchema,
oauth,
pocketbase,
qrcode,
rdf,
redis,
shell,
timestamp,
wallet,
zencode
];
const slang = new Slangroom(SLANGROOM_PLUGINS);
// slangroom contract that you want to run
// here we simply take the timestamp in seconds
const script = `Rule unknown ignore
Given I fetch the local timestamp in seconds and output into 'timestamp'
Given I have a 'time' named 'timestamp'
Then print the 'timestamp'
`;
const data = {};
const keys = {};
const res = await slangroom.execute(script, { data, keys })
If you do not wwant to integrate slangroom in your code but wwant to use it, you can simply use:
- ncr: No code REST API server based on slangroom
- slangroom-exec: CLI tool to run slangroom contracts (offers also go bindings)
- twinroom: Create your own CLI tool that under the hoods run slangroom contracts.
Slangroom can also be directly used in the browser thorugh the plugin @slangroom/browser. This plugin at the moment contains only a subsets of plugin that are:
- @slangroom/helpers
- @slangroom/http
- @slangroom/json-schema
- @slangroom/location
- @slangroom/pocketbase
- @slangroom/qrcode
- @slangroom/timestamp
A minimal example is:
<html>
<head>
<script type="module" id="slangroom-loader" src="https://cdn.jsdelivr.net/npm/@slangroom/browser"></script>
</head>
<body>
<div id="res"></div>
<script>
document.getElementById('slangroom-loader').addEventListener('load', () => {
const script = `
Rule unknown ignore
Given I fetch the local timestamp in seconds and output into 'timestamp'
Given I have a 'time' named 'timestamp'
Then print the 'timestamp'
`;
const res = document.getElementById('res');
slangroom.execute(script, {
data: {
foo: 'bar',
did_url: 'https://did.dyne.org/dids/did:dyne:sandbox.test:pEn78CGNEKvMR7DJQ1yvUVUpAHKzsBz45mQw3zD2js9',
},
})
.then((r) => {
res.innerText = JSON.stringify(r.result);
});
});
</script>
</body>
</html>
To build slangroom locally you need:
pnpm@9
node@^20.10.0
ornode@22
both of this dependencies can be install with mise by simply running mise install
in the root of this repository. So the steps to build slangroom are:
# clone it
git clone https://github.com/dyne/slangroom
cd slangroom
# if you want to handle node and pnpm deps with mise now run: mise install
# install slangroom dependencies
pnpm i
# build slangroom
pnpm build
In order to test slangroom you will need to:
- have a redis server running on your machine, it usually can be started with:
This is needed to test the redis plugin.
sudo systemctl start redis.service
- start a local pocketbase instance:
This is needed to test the pocketbase plugin.
./slangroom/pkg/pocketbase/test/pocketbase serve
- start oauth microservices:
This is needed to test the oauth plugin.
./slangroom/pkg/oauth/test/start_microservices.sh setup
After that the above services are started the tests can be launched with
# install dependencies
pnpm i
# build and run tests
pnpm t
If you want to test only a particular plugin you can do it with
# install dependencies
pnpm i
# build
pnpm build
# test (subistitute timestamp with the plugin you want to test)
pnpm -F @slangroom/timestamp exec ava --verbose build/esm/test
To write new plugins and other technical documentation head your browser to https://dyne.org/slangroom/
Availabe bugs are reported via GitHub issues.
Copyleft ๐ฏ 2023โ2025 by Dyne.org foundation, Amsterdam.
The grammar package has been created starting from CodeMirror 6 language package template.
Please first take a look at the Dyne.org - Contributor License Agreement then
- ๐ FORK IT
- Create your feature branch
git checkout -b feature/branch
- Commit your changes
git commit -am 'Add some fooBar'
- Push to the branch
git push origin feature/branch
- Create a new Pull Request
gh pr create -f
- ๐ Thank you
Slangroom - the missing plugin system for Zencode
Copyleft ๐ฏ 2023-2025 Dyne.org foundation, Amsterdam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.