Edit this page

Example for Consumer with Linux 64

Updated on 08-02-2018

Here is an example for Consumer, that uses Linux 64. Use Copy-Paste commands.

SONM MVP.RC1 workes in test mode on Rinkeby blockchain!

Preconditions: To start using SONM MVP.RC1 you need to have an account on Rinkeby blockchain. The keystore file to access your Rinkeby accout must be in UTC/JSON format. You SHOULD generate a NEW Ethereum key with SONM Wallet or CLI. Then you have to get test Ether on Rinkeby blockchain.

  1. To download SONM application (this example is for installation from binaries) open new terminal and use commands:
    cd ~/
    mkdir sonm && cd sonm
    wget https://github.com/sonm-io/core/releases/download/v0.3.2/sonm_v0.3.2_linux64.zip
    unzip sonm_v0.3.2_linux64.zip
  2. Put your keystore file to /home/< user >/keys/ directory.
  3. Set up Client node. Use commands:
cd ~/sonm/sonm_v0.3.2_linux64/node
nano node.yaml

Set ONLY the parameters "key_store:" and "pass_phrase:" in the node.yaml file:

# Local Node settings
node:
  # address to bind Node's gRPC endpoint
  # required
  listen_addr: "127.0.0.1:15030"

# Marketplace service settings
market:
  # marketplace gRPC endpoint
  # required
  endpoint: "[email protected]:15021"

# Logging settings.
log:
  # The desired logging level.
  # Allowed values in range of -1 (high verbosity) to 3 (most quiet)
  level: -1

# locator settings
locator:
  # Locator's gRPC endpoint for Eth to IP addr resolution
  endpoint: "[email protected]:15020"

# Settings for Ethereum keys
ethereum:
  # path to keystore
  key_store: "/home/< user >/keys"
  # passphrase for keystore
  pass_phrase: "< your passphrase >"

# Hub management settings.
# Set this if you have your own Hub and want to manage it.
hub:
  # endpoint is Hub's monitoring gRPC endpoint for client connections.
  endpoint: "127.0.0.1:15010"

metrics_listen_addr: "127.0.0.1:14003"
  1. Start Client node

    ./sonmnode_linux64 
  2. Set up SONM CLI. Open new terminal and use commands:

    cd ~/sonm/sonm_v0.3.0_linux64/cli
    nano cli.yaml

    Set the parameters "key_store:" and "pass_phrase:" in the cli.yaml file:

    # In what format CLI must show their output
    # can be "simple" for human-readable messages
    # and "json" for output in machine-readable JSON format
    output_format: "simple"
    ethereum:
    # path to keystore
    key_store: "/home/< user >/keys"
    # passphrase for keystore
    pass_phrase: "< your passphrase >"
  3. Move the cli.yaml file to new ~/.sonm/ directory:

    mkdir ~/.sonm
    mv cli.yaml ~/.sonm/
  4. Check CLI application by using login command. You should see your Ethereum address as an answer:

    ./sonmcli_linux64 login 

    Answer:

    Using /home/< user >/keys as KeyStore directory
    Keystore successfully opened
    Eth address: 0x02862A6...b0e3Be4ecf
  5. Get test Ether on Rinkeby blockchain.

  6. Get test tokens to your account using SONM Wallet or use CLI command "get":

    ./sonmcli_linux64 get

    10.Make allowance for SONM smart contract to be able to pay for the resourses (price is in SNM):

    ./sonmcli_linux64 approve 1000000000000000000000000000000
  7. Create a slot configuration file (bid_slot.yaml) to search for orders in the Marketplace and place it to /home/< user >/sonm/sonm_v0.3.0_linux64/cli/ directory.

Example:

duration: 1h

resources:
  cpu_cores: 1
  ram_bytes: 512mb
  gpu_count: NO_GPU
  storage: 1Gb

  network:
    in: 100Mb
    out: 100Mb
    type: INCOMING

  properties:
    foo: 1101
    cycles: 42

Notes:

  • "gpu_count:" determines count of GPU, and may have one of the values: NO_GPU, MULTIPLE_GPU.
  1. Search for BID or ASK orders matched to your slot.

    ./sonmcli_linux64 market search bid_slot.yaml
  2. Use your slot file (bid_slot.yaml) to buy resourses in the Marketplace. Place BID order to Marketplace (price is in SNM for 1 sec working time):

    ./sonmcli_linux64 market create 0.00002 bid_slot.yaml
  3. Check status of your BID orders:

    ./sonmcli_linux64 market processing
  4. Check your deals list to see your current deals:

    ./sonmcli_linux64 deals list

    View your deal ID in an answer, for example:

    ID:       122
    Price:    2020000000000000000
    Status:   ACCEPTED
    Buyer:    0x708dc812F...488e056fC18478B
    Supplier: 0x88057F142...05e8EFB9E45166Fe72
    Start at: 2017-12-25T19:46:22+03:00
    End at:   2017-12-25T21:46:22+03:00
  5. Prepare your task: choose task image you like to execute from whitelist and download its description: task.yaml file. Place it to /home/< user >/sonm/sonm_v0.3.0_linux64/cli/ directory.

Example eth-claymore.task.yaml, set environment variables "POOL:", "EMAIL:", your "ETH_ADDR:":

task:
  # Preferred miners.
  miners: []
  # docker image settings, required section
  container:
    # image name to start on miner, required param
    name: sonm/[email protected]:b5f9a9e47fa319607ed339789ef6692d4937ae5910b86e0ab929d035849e491e
    # env variables that will be passed to container on start
    env:
      POOL: < pool name >
      EMAIL: < your email >
      ETH_ADDR: < your ethaddress> 
  # container resources definition, required section
  resources:
      # number of CPU cores required by task, required param
      CPU: 1
      # amount of memory required by task, required param
      # You may use Kb, Mb and Gb suffixes
      RAM: 1024kb
      GPU: true
  1. After deal approved, ready to allocate task. Start task:

    ./sonmcli_linux64 tasks start < deal_id > task.yaml
  2. View task logs:

    ./sonmcli tasks logs <hub_addr> <task_id> 

    Also use help for "logs" command.

  3. After task execution stop the task:

    ./sonmcli_linux64 tasks stop <hub_addr> <task_id> 
  4. Get task result:

    ./sonmcli_linux64 tasks pull <deal_id> <task_id> 
  5. Close your deal:

    ./sonmcli deals finish <deal_id> 

    The END!