A tool for managing tokenscript projects
npm install @tokenscript/cliTokenScript CLI
=================
TokenScript CLI is tool for managing TokenScript projects.
The CLI currently includes commands for:
- Creating/initializing projects based on a set of inbuilt templates or contract ABIs
- Building the project into a TSML and validating the output
- Emulating a TokenScript in the browser with live reload
- Signing & validating TokenScripts for distribution
Note: ABI import support is experimental and only works for one template

* Installation & Usage
* Development
* Commands
sh-session
$ npm install -g @tokenscript/cli
$ tokenscript COMMAND
running command...
$ tokenscript (--version)
@tokenscript/cli/1.2.6 linux-x64 node-v18.18.2
$ tokenscript --help [COMMAND]
USAGE
$ tokenscript COMMAND
...
`
Creating a TokenScript project
`shell
$ tokenscript create my-project-dir
`When executing this command you will be asked a series of questions according to the template you selected.
It is recommended to use the Svelte or typescript template to benefit from type checking, including for Card SDK types.
Once the project is successfully initialized you can build or emulate the project:
`shell
$ cd my-project-dir
my-project-dir$ npm run build
`If all goes well you should see a file in
./out/tokenscript.tsml`shell
my-project-dir$ npm run emulate
`Your browser will open TokenScript viewer and load your project.
You can make changes to your project and the CLI will rebuild & reload as you code.
Development
The CLI is built using oclif.
Development dependencies
The TokenScript CLI requires libxml2js which in turn requires node-gyp to build.
This comes bundled with newer versions of npm but may need some dependencies installed depending on your operating system.
Please follow the guide at the node-gyp GIT repo to ensure that it's working.
Use locally
You can run the CLI from source in developer mode like this:
`sh-session
$ git clone https://github.com/TokenScript/tokenscript-cli.git
$ cd tokenscript-cli
$ npm i
$ ./bin/dev
`You can also install the package globally on your system like this:
`sh-session
$ npm run build
$ npm link
`Note: Rebuilding will update the global version
Framework requirements
TokenScript is compatible with almost any frontend framework. Currently only Svelte template is available but React is coming soon.
The only requirement is that the builder/bundler is capable of exporting to a deterministic set of files that can be referenced for inclusion within tokenscript.xml.
It is recommended to export as a single page application and rely on document.location.hash for routing.
Please get in touch with us if you need assistance creating your own templates.
Commands
* [tokenscript build [ENVIRONMENT]](#tokenscript-build-environment)
* tokenscript certificate COMMAND
* [tokenscript create [DIRECTORY]](#tokenscript-create-directory)
* [tokenscript emulate [ENVIRONMENT]](#tokenscript-emulate-environment)
* [tokenscript help [COMMANDS]](#tokenscript-help-commands)
* tokenscript plugins
* tokenscript plugins:install PLUGIN...
* tokenscript plugins:inspect PLUGIN...
* tokenscript plugins:install PLUGIN...
* tokenscript plugins:link PLUGIN
* tokenscript plugins:uninstall PLUGIN...
* tokenscript plugins:uninstall PLUGIN...
* tokenscript plugins:uninstall PLUGIN...
* tokenscript plugins update
* tokenscript refresh
* tokenscript sign
* tokenscript validatetokenscript build [ENVIRONMENT]Build the tokenscript project into a .tsml
`
USAGE
$ tokenscript build [ENVIRONMENT] [-t]ARGUMENTS
ENVIRONMENT [default: default] The environment configuration to use for the build
FLAGS
-t, --outputTemplate Output a .tsml template that can be used to serve TokenScripts on-the-fly for multiple contracts
DESCRIPTION
Build the tokenscript project into a .tsml
`_See code: src/commands/build.ts_
tokenscript certificate COMMANDCreate a certificate request or sign an existing request.
`
USAGE
$ tokenscript certificate COMMAND [-k ] [-m ] [-r ] [-r ] [-c ]ARGUMENTS
COMMAND (request|sign) Whether to create a signing 'request' or 'sign' an existing request
FLAGS
-c, --cn= The CN for the certificate, or issuer CN if signing
-k, --privateKeyFile= [default: ts-signing.key] Hex encoded private key filename (for creating CSR)
-m, --masterPrivateKeyFile= [default: ts-master.key] Hex encoded master private key filename (for signing CSR)
-r, --certFile= [default: ts-certificate.pem] Certificate PEM input or output filename
-r, --certRequestFile= [default: ts-certificate-request.pem] Certificate signing request PEM input or
output filename
DESCRIPTION
Create a certificate request or sign an existing request.
`_See code: src/commands/certificate.ts_
tokenscript create [DIRECTORY]Create a new TokenScript project
`
USAGE
$ tokenscript create [DIRECTORY] [-t emptySvelte|emptyReact|emptyTypescript|empty] [-h ]FLAGS
-h, --hardHat= Directory of HardHat project
-t, --template=
DESCRIPTION
Create a new TokenScript project
`_See code: src/commands/create.ts_
tokenscript emulate [ENVIRONMENT]Emulate the TokenScript in a browser
`
USAGE
$ tokenscript emulate [ENVIRONMENT] [-e ]ARGUMENTS
ENVIRONMENT [default: default] The environment configuration to use for the build
FLAGS
-e, --emulatorHost=
DESCRIPTION
Emulate the TokenScript in a browser
`_See code: src/commands/emulate.ts_
tokenscript help [COMMANDS]Display help for tokenscript.
`
USAGE
$ tokenscript help [COMMANDS] [-n]ARGUMENTS
COMMANDS Command to show help for.
FLAGS
-n, --nested-commands Include all nested commands in the output.
DESCRIPTION
Display help for tokenscript.
`_See code: @oclif/plugin-help_
tokenscript pluginsList installed plugins.
`
USAGE
$ tokenscript plugins [--core]FLAGS
--core Show core plugins.
DESCRIPTION
List installed plugins.
EXAMPLES
$ tokenscript plugins
`_See code: @oclif/plugin-plugins_
tokenscript plugins:install PLUGIN...Installs a plugin into the CLI.
`
USAGE
$ tokenscript plugins:install PLUGIN...ARGUMENTS
PLUGIN Plugin to install.
FLAGS
-f, --force Run yarn install with force flag.
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Installs a plugin into the CLI.
Can be installed from npm or a git url.
Installation of a user-installed plugin will override a core plugin.
e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
the CLI without the need to patch and update the whole CLI.
ALIASES
$ tokenscript plugins add
EXAMPLES
$ tokenscript plugins:install myplugin
$ tokenscript plugins:install https://github.com/someuser/someplugin
$ tokenscript plugins:install someuser/someplugin
`tokenscript plugins:inspect PLUGIN...Displays installation properties of a plugin.
`
USAGE
$ tokenscript plugins:inspect PLUGIN...ARGUMENTS
PLUGIN [default: .] Plugin to inspect.
FLAGS
-h, --help Show CLI help.
-v, --verbose
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
Displays installation properties of a plugin.
EXAMPLES
$ tokenscript plugins:inspect myplugin
`_See code: @oclif/plugin-plugins_
tokenscript plugins:install PLUGIN...Installs a plugin into the CLI.
`
USAGE
$ tokenscript plugins:install PLUGIN...ARGUMENTS
PLUGIN Plugin to install.
FLAGS
-f, --force Run yarn install with force flag.
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Installs a plugin into the CLI.
Can be installed from npm or a git url.
Installation of a user-installed plugin will override a core plugin.
e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
the CLI without the need to patch and update the whole CLI.
ALIASES
$ tokenscript plugins add
EXAMPLES
$ tokenscript plugins:install myplugin
$ tokenscript plugins:install https://github.com/someuser/someplugin
$ tokenscript plugins:install someuser/someplugin
`_See code: @oclif/plugin-plugins_
tokenscript plugins:link PLUGINLinks a plugin into the CLI for development.
`
USAGE
$ tokenscript plugins:link PLUGINARGUMENTS
PATH [default: .] path to plugin
FLAGS
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Links a plugin into the CLI for development.
Installation of a linked plugin will override a user-installed or core plugin.
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
command will override the user-installed or core plugin implementation. This is useful for development work.
EXAMPLES
$ tokenscript plugins:link myplugin
`_See code: @oclif/plugin-plugins_
tokenscript plugins:uninstall PLUGIN...Removes a plugin from the CLI.
`
USAGE
$ tokenscript plugins:uninstall PLUGIN...ARGUMENTS
PLUGIN plugin to uninstall
FLAGS
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Removes a plugin from the CLI.
ALIASES
$ tokenscript plugins unlink
$ tokenscript plugins remove
`tokenscript plugins:uninstall PLUGIN...Removes a plugin from the CLI.
`
USAGE
$ tokenscript plugins:uninstall PLUGIN...ARGUMENTS
PLUGIN plugin to uninstall
FLAGS
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Removes a plugin from the CLI.
ALIASES
$ tokenscript plugins unlink
$ tokenscript plugins remove
`_See code: @oclif/plugin-plugins_
tokenscript plugins:uninstall PLUGIN...Removes a plugin from the CLI.
`
USAGE
$ tokenscript plugins:uninstall PLUGIN...ARGUMENTS
PLUGIN plugin to uninstall
FLAGS
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Removes a plugin from the CLI.
ALIASES
$ tokenscript plugins unlink
$ tokenscript plugins remove
`tokenscript plugins updateUpdate installed plugins.
`
USAGE
$ tokenscript plugins update [-h] [-v]FLAGS
-h, --help Show CLI help.
-v, --verbose
DESCRIPTION
Update installed plugins.
`_See code: @oclif/plugin-plugins_
tokenscript refreshRefresh a HardHat project
`
USAGE
$ tokenscript refreshDESCRIPTION
Refresh a HardHat project
`_See code: src/commands/refresh.ts_
tokenscript signsign the built .tsml
`
USAGE
$ tokenscript sign [-v] [-k ] [-p ] [-r ]FLAGS
-k, --privateKeyFile= [default: ts-signing.key] Hex encoded private key file location
-p, --publicKeyFile= [default: ts-signing.pub] Hex encoded private key file location
-r, --certFile= [default: /home/michael/PhpstormProjects/tokenscript-cli/ts-certificate.pem] Certificate
PEM filename
-v, --verify Verify existing signed .tsml
DESCRIPTION
sign the built .tsml
`_See code: src/commands/sign.ts_
tokenscript validateValidate an existing .tsml
`
USAGE
$ tokenscript validateDESCRIPTION
Validate an existing .tsml
``_See code: src/commands/validate.ts_