Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@golem-sdk/cli

Package Overview
Dependencies
Maintainers
0
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@golem-sdk/cli

CLI for Golem SDK

  • 2.11.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
40
decreased by-70.59%
Maintainers
0
Weekly downloads
 
Created
Source

Golem SDK CLI

Golem SDK CLI is a companion tool for the Golem SDK. It accelerates the creation and management of Golem JS projects.

Installing / Getting started

Golem SDK CLI is available as an NPM package.

Install using npm:

npm install -g @golem-sdk/cli

Install using yarn:

yarn global add @golem-sdk/cli

To check if the installation was successful, run:

golem-sdk --version

After installation, the CLI is ready to be used.

Developing

If you want to install from source code or you would like to develop Golem SDK CLI, you can clone the repository and install dependencies:

git clone git@github.com:golemfactory/golem-sdk-cli.git
cd golem-sdk-cli/
npm install

Building

To build the CLI, run:

npm run build

To make the CLI available in your system, run:

npm link

Now, the golem-sdk command should be available in your system.

Features

Golem SDK CLI is a companion tool for the Golem SDK. It is developed in parallel with the SDK, and new features are added as the SDK evolves or new use cases emerge

If you see a feature missing or a possible Golem SDK user experience improvement we could implement, please open an issue or a pull request.

Create a new Golem Application

The fastest way to get started with Golem Network is to use golem-sdk new to create a new application from a template.

golem-sdk new

You will be asked a series of questions about your application and the CLI will use your answers to generate a new Golem Application.

The first question will be the project name. The CLI will use it to create a new directory for your application in the current directory. You can use the --path option to override this behaviour.

Note: The command will abort if the directory already exists.

You can provide all the needed information from command line too. Type golem-sdk new --help to see the list of available options.

Golem Manifest

Golem Manifest is a JSON document that describes your Golem application. While it is not necessary for simple applications, you will need it if you want to access advanced features of the Golem SDK, like access to the Internet (outbound).

The golem-sdk CLI allows users to create and update the manifest file. By default, it assumes the manifest is available in a manifest.json file in the current folder. If you want to point to a different file, use the --manifest (or -m) option.

Creating a Golem Manifest

To create a new Golem Manifest with the golem-sdk CLI, run:

golem-sdk manifest create <image> [--image-hash hash]

The image argument should identify the GVMI image used by your application. The tools accept a few formats which are explained in the table below. You can learn more about Golem images here.

If you have a package.json file in your project, the tool will use the name, version, and description fields from the file to fill in the fields in the manifest. Otherwise, you will need to provide them manually.

Image

The manifest needs to contain the image URL pointing to the GVMI download location and its hash to validate its integrity. To facilitate the process of creating a manifest, golem-sdk accepts multiple forms of image argument, where some of them will automatically resolve the URL and/or hash. Please consult the table below for more details:

Argument formatExampleIs --image-hash required?Notes
Image taggolem/node:latestNo, it will be automatically resolved.Image hash is fetched from [https://registry.golem.network]. It is the recommended method.
Image hash3d6c48bb4c192708168d53cee4f36876b263b7745c3a3c239c6749cdNo, it is resolved from the image argument.Image URL will point to [https://registry.golem.network]
URL to registry.golem.networkhttps://registry.golem.network/v1/image/download?tag=golem-examples/blender:2.80&https=trueNo, it is automatically resolved.
URL to arbitrary download locationhttps://example.com/my-imageYes, image-hash is required.Image is calculated by the gvmkit-build conversion tool.

If the hash is not provided or resolved, you will get a warning that the manifest will not be usable until you provide it manually.

Adding outbound URLs

For your application to access the Internet from the Golem network, the manifest must include the outbound URLs the application will be using.

The default set of URLs that providers may allow your application to use is available (here). Note providers can modify the content of the list.

Example: Simple use

This command will update the manifest file with the provided URL:

golem-sdk manifest net add-outbound https://golem.network

You can use this command multiple times to add additional URLs to the manifest or pass many URLs in a single run:

Example: Multiple URLs

This command will update the manifest file with all the URLs provided.

golem-sdk manifest net add-outbound https://golem.network https://github.com https://example.com

Signing the manifest

If the provider has set up an audited-payload rule for URLs not on the whitelist, you can gain access to these URLs. However, they must be declared in the manifest, and the manifest is signed by the key linked with the certificate accepted by the provider.

To sign the manifest, run:

golem-sdk manifest sign -k <private-key>

If your private key is encrypted, you will need to provide the correct passphrase (-p or --passphrase option). This command will produce a signature file (by default manifest.sig) that you will need to use in your application.

Verifying the signature

You can verify the manifest signature with your certificate using the following command:

golem-sdk manifest verify

By default, it will use manifest.pem as the certificate file and manifest.sig as the signature file. You can change that by using the --certificate-file and --signature-file options.

On success, it will print the following message:

Manifest matches signature.

It is important to use this command to make sure the key you are using is compatible with your certificate.

Run-on-golem

The run-on-golem command allows you to run an image on the Golem Network without the need to create a full Golem application. Now you can test, debug and validate images without having to writing a single line of code.

By default, run-on-golem will try to use your manifest file from the current directory. You can override this behaviour by using the --manifest option or by providing the --image option.

Example:

golem-sdk run-on-golem --image=golem/node:20-alpine

Once you run the command, the CLI will deploy the image to one of the providers and you will be presented with an interactive shell. You can type ? in order to get a list of all available commands.

Within the shell, you can quickly test your application by running commands on the image, as well as uploading and downloading files.

You can run commands without an interactive shell ether by passing the commands you want to run using the --execute option or using a batch file:

Examples:

golem-sdk run-on-golem --execute "upload localfile.txt /golem/input; run 'ls /golem/input'"
golem-sdk run-on-golem batchfile.txt

Contributing

If you'd like to contribute to the project, you can fork the repository and create a Pull Request. Code contributions are warmly welcomed.

Please make sure the code follows the coding style as configured in .eslintrc and .prettierrc.

The Pull Request should describe what changes you've made, what's the purpose of them and how to use them.

Licensing

The code in this project is licensed under the GPL-3 license.

See LICENSE for more information.

Keywords

FAQs

Package last updated on 05 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc