Edit this page

Example for Consumer with Windows

Updated on 08-02-2018

Here is an example for Consumer, that uses Windows 32/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. Download SONM CLI and Node application (sonm_v0.3.2_windows.zip) for Windows: binaries for current release. Save files in /home/< user >/runsonm/ directory.
  2. Put your keystore file to /home/< user >/runsonm/keys/ directory.
  3. Set up Client node. Create new node.yaml file in /home/< user >/runsonm/ with the following information.

Set ONLY the parameters "key_store:" and "pass_phrase:":

# 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 >/runsonm/keys"
  # passphrase for keystore
  pass_phrase: "< your passphrase >"

metrics_listen_addr: "127.0.0.1:14003"
  1. Start Client node. Open new terminal with Windows PowerShell or another cmd and execute:
    .\sonmnode_win32.exe 
  2. Set up SONM CLI. Create new /home/< user >/.sonm/ directory. Create new cli.yaml file in /home/< user >/.sonm/ with the following information.

Set ONLY the parameters "key_store:" and "pass_phrase:":

# 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 >/runsonm/keys"
  # passphrase for keystore
  pass_phrase: "< your passphrase >"
  1. Check CLI application by using login command. Open new terminal with Windows PowerShell or another cmd and execute:
    .\sonmcli_win32.exe login 

    You should see your Ethereum address as an answer. For example:

    Using /home/< user >/keys as KeyStore directory
    Keystore successfully opened
    Eth address: 0x02862A6...b0e3Be4ecf
  2. Get test Ether on Rinkeby blockchain.
  3. Get test tokens to your account using SONM Wallet or use CLI command "get":
    .\sonmcli_win32.exe get

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

    .\sonmcli_win32.exe approve 1000000000000000000000000000000
  4. Create a slot configuration file (bid_slot.yaml) to search for orders in the Marketplace and place it to /home/< user >/runsonm/ 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
  1. Search for BID or ASK orders matched to your slot.

    .\sonmcli_win32.exe market search bid_slot.yaml
  2. Place BID order to Marketplace based on slot file with price (price in SNM for 1 sec working time):

    .\sonmcli_win32.exe market create 0.0003 bid_slot.yaml
  3. Check status of your BID orders:

    .\sonmcli_win32.exe market processing
  4. Check your deals list to see your current deals:

    .\sonmcli_win32.exe 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 >/runsonm/ 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_win32.exe tasks start < deal_id > task.yaml
  2. View task logs:

    .\sonmcli_win32.exe tasks logs <hub_addr> <task_id> 

    Also use help for "logs" command.

  3. After task execution stop the task:

    .\sonmcli_win32.exe tasks stop <hub_addr> <task_id> 
  4. Get task result:

    .\sonmcli_win32.exe tasks pull <deal_id> <task_id> 
  5. Close your deal:

    .\sonmcli_win32.exe sonmcli deals finish <deal_id> 

    The END!