cudos-tool
TypeScript icon, indicating that this package has built-in type declarations

4.0.0 • Public • Published

Cudo Compute PoC

Contract

Building & deploying

Deploying the contract requires first setting up the CLI tool.

Create a wallet called admin on testnet

$ cudos-tool wallet generate admin -n testnet

Now you can build and deploy

$ sh scripts/deploy-contracts.sh

CLI tool

Install

To install from NPM

$ npm install -g cudos-tool
$ cudos-tool ...

To install as a package from source

$ npm run build
$ npm pack
$ npm install -g cudos-tool-*.tgz
$ cudos-tool ...

To use from source without installing

$ npm run build
$ ./bin/cudos-tool.js ...

Adding wallets

To add a new wallet

$ cudos-tool wallet generate <name>

This will generate a wallet and show you the address and mnemonic.

To import an existing wallet

$ cudos-tool wallet import <name> <mnemonic...>

This will recreate the wallet from the mnemonic and show you the address.

Creating VMs

You will need enough funds in your wallet to pay for the VM and running the contracts. The VMs are currently cheap. Running the contracts costs around 0.6cudo each time.

To create a VM, e.g. a small VM for 1 hour:

$ cudos-tool machine add small 1h "ssh-ed25519 AAA..." --wait

To destroy it when you are done, either wait for the time to run out or remove it using the returned from machine add

$ cudos-tool machine rm <id>

Running the provider

The provider requires a GCP service account key able to manage VMs. It must be in a file called google_service_account.json, which cudos-tool will search for in the current directory and upwards.

To run as a provider, your wallet needs to be on the allowed_providers of the contract's configuration.

Notes

Contracts

The cudos-tool tool can be used as a general contract deployment and interaction tool.

The contract named machine is used by the machine commands. cudos-tool does not enforce it, but the contract named machine should usually be the contract in contracts/machine, or one with the same API interface.

Sizes

As of right now, the sizes available are small, medium, and large.

You can view the actual sizes configured using the config command:

$ cudos-tool machine config

If you control a wallet on the config's admin list, you can take that config and modify it

$ cudos-tool machine config <config filename>

Amounts and durations

Some commands accepts an amount in cudos, or a duration. Cudo amounts are simply converted directly to acudos, and durations are converted to acudos via the currently configured rate.

format unit in cudos
NNNs seconds config rate
NNNm minutes 60 * config rate
NNNh hours 3,600 * config rate
NNNd days 43,200 * config rate
NNNy years 15,768,000 * config rate
NNNacudos attocudos 1e-18 cudos
NNNfcudos femtocudos 1e-16 cudos
NNNpcudos picocudos 1e-12 cudos
NNNncudos nanocudos 1e-9 cudos
NNNucudos microcudos 1e-6 cudos
NNNmcudos millicudos 1e-3 cudos
NNNcudos cudos 1 cudo exactly
NNNkcudos kilocudos 1e+3 cudos

TODO

  • A web-based UI for the requester

  • Run the executor on the cloud

  • Run the executor on cloud compute resources provisioned by this system :)

CLI Tool Help

cudos-tool

Usage: cudos-tool [options] [command]

Options:
  -n, --network <name>  Network name
  -w, --wallet <name>   Wallet name
  -h, --help            display help for command

Commands:
  init                  Initialize cudos-tool
  network|net           Manage networks
  wallet                Manage wallets
  contract              Manage contracts
  machine               Machine commands
  help [command]        display help for command

cudos-tool init

Usage: cudos-tool init [options]

Initialize cudos-tool

Options:
  -h, --help  display help for command

cudos-tool network

Usage: cudos-tool network|net [options] [command]

Manage networks

Options:
  -h, --help          display help for command

Commands:
  list|ls             List networks
  default|def <name>  Set default
  help [command]      display help for command

cudos-tool wallet

Usage: cudos-tool wallet [options] [command]

Manage wallets

Options:
  -h, --help                   display help for command

Commands:
  list [options]               List wallets
  generate <name>              Generate wallet
  import <name> <mnemonic...>  Import existing wallet
  rm <name>                    Forget a wallet
  default [name]               Show or set current wallet
  check|show [name]            Check wallet balance
  send [options] <amount>      Send tokens
  help [command]               display help for command

cudos-tool contract

Usage: cudos-tool contract [options] [command]

Manage contracts

Options:
  -h, --help                          display help for command

Commands:
  list [options]                      List known contracts
  unregister <name>                   Unregister existing contract
  register [options] <name>           Register existing contract
  deploy [options] <name> <file>      Deploy a contract
  query <name> <query>                Query a contract
  query-raw <name> <key>              Raw-query a contract
  execute [options] <name> <execute>  Execute a contract
  help [command]                      display help for command

cudos-tool machine

Usage: cudos-tool machine [options] [command]

Machine commands

Options:
  -h, --help                              display help for command

Commands:
  config [config]                         View or set contract configuration
  list                                    List machines
  add [options] [size] [coins] [ssh-key]  Add a machine request
  get <id>                                Show information about machine ID
  rm <id...>                              Remove machine ID
  earnings                                Show earnings
  collect                                 Collect earnings
  one                                     Process a single operation
  run                                     Start processing machine operations
  help [command]                          display help for command

Readme

Keywords

none

Package Sidebar

Install

npm i cudos-tool

Weekly Downloads

1

Version

4.0.0

License

ISC

Unpacked Size

88.3 MB

Total Files

5

Last publish

Collaborators

  • nbaum