subspace / subspace.js

Client library for easy get/put storage interaction with Subspace Network blockchain
3 stars 107 forks source link

Update examples #21

Open isSerge opened 1 year ago

isSerge commented 1 year ago
caudurodev commented 1 year ago

Additionally, I have created a local node and farmer using docker-compose to avoid having to install Rust and tooling - if just working on the frontend. Here it is and can serve as a starting point for a more complete implemenation:

version: "3.7"
services:
  node:
    image: ghcr.io/subspace/node:gemini-1b-2022-aug-17
    volumes:
      - node-data:/var/subspace:rw
    ports:
      - "9944:9944"
      # - "0.0.0.0:9955:9955"
    restart: unless-stopped
    command:
      [
        "--dev",
        "--tmp",
        "--force-authoring",
        "--execution",
        "wasm",
        "--pruning",
        "1024",
        "--keep-blocks",
        "1024",
        "--port",
        "9955",
        # "--ws-external",
        "--unsafe-rpc-external",
        "--rpc-cors",
        "ws://localhost,http://localhost,ws://node,http://node,ws://farmer,http://farmer,all,127.0.0.1,localhost",
        "--rpc-methods",
        "safe",
        "--unsafe-ws-external",
        "--validator",
        "--name",
        "local-test-node"
      ]
    healthcheck:
      timeout: 5s
      interval: 30s
      retries: 5
  farmer:
    depends_on:
      node:
        condition: service_healthy
    image: ghcr.io/subspace/farmer:gemini-1b-2022-aug-17
    volumes:
      - farmer-data:/var/subspace:rw
    restart: unless-stopped
    ports:
      - "0.0.0.0:9955:9955"
    command:
      [
        "--base-path",
        "/var/subspace",
        "farm",
        "--node-rpc-url",
        "ws://node:9944",
        "--ws-server-listen-addr",
        "0.0.0.0:9955",
        "--reward-address",
        "sucg5EMF8iqASSdRQy55V32DWfHwZK65Eq1TzdexypyFetL5K",
        "--plot-size",
        "2G"
      ]
volumes:
  node-data:
  farmer-data:

Note: "--rpc-cors all" is currently blocking all connections instead of opening up all - so open origins need to be specified.

But I am not clear on how to interact with the local network once this is up and running via the polkadot{.js} extension as attempts to putObjects fail.

So I would suggest adding to your list: How to connect with a valid identity from web extension or hardcoded via subspace.js to local chain when it is up and running.

isSerge commented 1 year ago

@caudurodev I will definitely check, thanks

isSerge commented 1 year ago

@caudurodev I think the problem in your case is Farmer port is not exposed as described here in the comment. I will add a note on this in the readme