Skip to content

๐Ÿš€ Run Slangroom Your Way โ€‹

From terminals to browsersโ€”powerful, portable, and privacy-preserving execution

Slangroom adapts to your environment with multiple deployment options:

โŒจ๏ธ CLI โ€‹

Terminal whisperer? ๐Ÿฆœ Slangroom speaks your language!

๐Ÿง  Slangroom-exec โ€‹

Slangroom-exec is a simple utility that reads from STDIN the following content

  • conf
  • slangroom-contract
  • data
  • keys
  • extra
  • context

Each is separated by a newline and encoded in base64 (sounds tricky, but slexfe is here to help) and outputs the slangroom execution to STDOUT.

A simple example using mise to install slangroom-exec and slexfe is the following

bash
# โฌ‡๏ธ install slangroom-exec (this also install slexfe)
mise use aqua:dyne/slangroom-exec

# โšกrun it
cat <<EOF | slexfe | slangroom-exec
Prepare 'timestamp': fetch the local timestamp in seconds
Given I have a 'time' named 'timestamp'
Then print the string '๐Ÿ˜˜ Welcome to the Slangroom World ๐ŸŒˆ'
Then print the 'timestamp'
EOF

๐Ÿ“– Full documentation | ๐Ÿ” Back to top

๐Ÿ‘ฏ Twinroom โ€‹

Twinroom builds on slangroom-exec, letting you turn Slangroom contracts into CLI commands (and even more!). Not enough? It let you also:

  • run external slangroom contracts dynamically ๐Ÿงจ
  • Expose commands as HTTP API endpoints: daemon mode ๐Ÿ˜ˆ

Some twinroom examples:

bash
# โฌ‡๏ธ download the binary
wget https://github.com/forkbombeu/twinroom/releases/latest/download/twinroom -O ~/.local/bin/twinroom && chmod +x ~/.local/bin/twinroom

# ๐Ÿ“ƒ list embedded contracts (that now are commands!)
twinroom test --help
# โšก run an embedded contracts
twinroom test hello
# ๐Ÿงจ run an external contracts
cat << EOF > welcome.slang
Prepare 'timestamp': fetch the local timestamp in seconds
Given I have a 'time' named 'timestamp'
Then print the string '๐Ÿ˜˜ Welcome to the Slangroom World ๐ŸŒˆ'
Then print the 'timestamp'
EOF
twinroom $(pwd) welcome

๐Ÿ“– Full documentation | ๐Ÿ” Back to top

๐ŸŒ Web โ€‹

Like Bash, but cuter ๐Ÿ’… And serverless.

๐Ÿ› Online playgorund โ€‹

Test slangroom contracts instantly on the web playgorund

๐Ÿ” Back to top

๐Ÿงฉ Web component โ€‹

Dyne Components is a UI component library designed for Dyne.org hackers to easily implement web pages that adhere to Dyne.org's design principles. It offers a set of reusable, customizable web components, such as buttons and inputs, built with modern web standards. The library is optimized for seamless integration into web projects, promoting consistency and efficiency in web development.

html
<!doctype html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@dyne/components/dist/dyne-components/dyne-components.css" />
        <script type="module" src="https://cdn.jsdelivr.net/npm/@dyne/components/dist/dyne-components/dyne-components.esm.js"></script>
    </head>
    <body>
        <dyne-button emphasis="high">I'm useless but I love you ๐Ÿฅฐ</dyne-button>
    </body>
</html>

๐Ÿ“– Full documentation | ๐Ÿ” Back to top

๐Ÿ“œ Simple integration in html file โ€‹

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:

A minimal example is:

html
<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 = `
                    Prepare 'timestamp': fetch the local timestamp in seconds
                    Given I have a 'time' named 'timestamp'
                    Then print the string '๐Ÿ˜˜ Welcome to the Slangroom World in the Web ๐ŸŒˆ'
                    Then print the 'timestamp'
                    `;
                const res = document.getElementById('res');
                slangroom.execute(script)
                .then((r) => {
                    res.innerText = JSON.stringify(r.result);
                });
            });
        </script>
    </body>
</html>

๐Ÿ” Back to top

๐Ÿ“ก REST โ€‹

Your contracts, now RESTing comfortably in an endpoint near you. ๐Ÿ›

๐Ÿช„ Noห‘codeห‘room โ€‹

Noห‘codeห‘room lets you execute Slangroom smart contracts via RESTful API calls, turning natural language logic into live endpointsโ€”no traditional code needed. Its strength lies in flexible configuration: you can set it up using command-line options or environment variables, and control the behavior of each API endpoint through a simple metadata file.

First steps with ncr:

bash
# download the binary (only for linux at the moment)
wget https://github.com/forkbombeu/ncr/releases/latest/download/ncr -O ~/.local/bin/ncr && chmod +x ~/.local/bin/ncr

# checkout this repo
git clone https://github.com/forkbombeu/ncr

# run the server on port 3000 with the example folders
ncr -p 3000 -z ./ncr/tests/fixtures --public-directory ./ncr/public

๐Ÿ“– Full documentation | ๐Ÿ” Back to top

๐Ÿ˜ˆ Twinroom in daemon mode โ€‹

Twinroom builds on slangroom-exec, letting you turn Slangroom contracts into CLI commands or HTTP API endpoints.

bash
# โฌ‡๏ธ download the binary
wget https://github.com/forkbombeu/twinroom/releases/latest/download/twinroom -O ~/.local/bin/twinroom && chmod +x ~/.local/bin/twinroom

# ๐Ÿ˜ˆ start the daemon mode
twinroom --daemon
# visit http://localhost:3000/slang for the swagger documentation ot just test it
curl -X GET http://localhost:3000/test/hello

๐Ÿ“– Full documentation | ๐Ÿ” Back to top

๐Ÿฏ JS/TS โ€‹

Write your will in words, and watch JavaScript make it real. โœ

๐Ÿ“š Library โ€‹

js
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 })

๐Ÿ” Back to top