Skip to content

Commit 70fc883

Browse files
committed
Initialization & MVP
0 parents  commit 70fc883

37 files changed

+30973
-0
lines changed

.gitignore

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Dependencies
2+
/node_modules
3+
4+
# Production
5+
/build
6+
7+
# Generated files
8+
.docusaurus
9+
.cache-loader
10+
11+
# Misc
12+
.DS_Store
13+
.env.local
14+
.env.development.local
15+
.env.test.local
16+
.env.production.local
17+
18+
npm-debug.log*
19+
yarn-debug.log*
20+
yarn-error.log*

README.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Website
2+
3+
This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator.
4+
5+
### Installation
6+
7+
```
8+
$ npm i
9+
```
10+
11+
### Local Development
12+
13+
```
14+
$ npm run start
15+
```
16+
17+
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
18+
19+
### Build
20+
21+
```
22+
$ npm run build
23+
```
24+
25+
This command generates static content into the `build` directory and can be served using any static contents hosting service.
26+
27+
### Deployment
28+
29+
Using SSH:
30+
31+
```
32+
$ USE_SSH=true npm run deploy
33+
```
34+
35+
Not using SSH:
36+
37+
```
38+
$ GIT_USER=<Your GitHub username> npm run deploy
39+
```
40+
41+
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.

babel.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
3+
};

docs/Getting Started/_category_.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"label": "Getting Started",
3+
"position": 3
4+
}
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
### 🐧 Linux Installation
2+
3+
1. Download the executables for your operating system from the [Releases](https://github.com/subspace/subspace/releases) tab.
4+
2. Open your favourite terminal, and change to the Downloads directory using `cd Downloads`
5+
3. Make the farmer & node executable `chmod +x $(farmer-name)` & `chmod +X $(node-name)`
6+
4. We will then start the node using the following command
7+
8+
> *Note, when attempting to run this command you may be prompted:* Click on `cancel` instead of moving it to trash.
9+
To allow execution, go to `System Preferences -> Security & Privacy -> General`, and click on `allow`.
10+
After this, simply repeat the step you prompted for (step 4 or 6). This time, click the `Open` button when prompted.
11+
12+
```
13+
# Replace `NODE_FILE_NAME` with the name of the node file you downloaded from releases.
14+
# Replace `INSERT_YOUR_ID` with a nickname you choose
15+
./NODE_FILE_NAME \
16+
--chain testnet \
17+
--wasm-execution compiled \
18+
--execution wasm \
19+
--bootnodes "/dns/farm-rpc.subspace.network/tcp/30333/p2p/12D3KooWPjMZuSYj35ehced2MTJFf95upwpHKgKUrFRfHwohzJXr" \
20+
--rpc-cors all \
21+
--rpc-methods unsafe \
22+
--ws-external \
23+
--validator \
24+
--telemetry-url "wss://telemetry.polkadot.io/submit/ 1" \
25+
--name INSERT_YOUR_ID
26+
```
27+
5. You should see something similar as the output in the terminal.
28+
```
29+
2022-02-03 10:52:23 Subspace
30+
2022-02-03 10:52:23 ✌️ version 0.1.0-35cf6f5-x86_64-macos
31+
2022-02-03 10:52:23 ❤️ by Subspace Labs <https://subspace.network>, 2021-2022
32+
2022-02-03 10:52:23 📋 Chain specification: Subspace testnet
33+
2022-02-03 10:52:23 🏷 Node name: YOUR_FANCY_NAME
34+
2022-02-03 10:52:23 👤 Role: AUTHORITY
35+
2022-02-03 10:52:23 💾 Database: RocksDb at /Users/X/Library/Application Support/subspace-node-x86_64-macos-11-snapshot-2022-jan-05/chains/subspace_test/db/full
36+
2022-02-03 10:52:23 ⛓ Native runtime: subspace-100 (subspace-1.tx1.au1)
37+
2022-02-03 10:52:23 🔨 Initializing Genesis block/state (state: 0x22a5…17ea, header-hash: 0x6ada…0d38)
38+
2022-02-03 10:52:24 ⏱ Loaded block-time = 1s from block 0x6ada0792ea62bf3501abc87d92e1ce0e78ddefba66f02973de54144d12ed0d38
39+
2022-02-03 10:52:24 Starting archiving from genesis
40+
2022-02-03 10:52:24 Archiving already produced blocks 0..=0
41+
2022-02-03 10:52:24 🏷 Local node identity is: 12D3KooWBgKtea7MVvraeNyxdPF935pToq1x9VjR1rDeNH1qecXu
42+
2022-02-03 10:52:24 🧑‍🌾 Starting Subspace Authorship worker
43+
2022-02-03 10:52:24 📦 Highest known block at #0
44+
2022-02-03 10:52:24 〽️ Prometheus exporter started at 127.0.0.1:9615
45+
2022-02-03 10:52:24 Listening for new connections on 0.0.0.0:9944.
46+
2022-02-03 10:52:26 🔍 Discovered new external address for our node: /ip4/176.233.17.199/tcp/30333/p2p/12D3KooWBgKtea7MVvraeNyxdPF935pToq1x9VjR1rDeNH1qecXu
47+
2022-02-03 10:52:29 ⚙️ Syncing, target=#215883 (2 peers), best: #55 (0xafc7…bccf), finalized #0 (0x6ada…0d38), ⬇ 850.1kiB/s ⬆ 1.5kiB/s
48+
```
49+
7. We will then open another terminal, change to the downloads directory, then start the farmer node with the following command:
50+
```
51+
# Replace `FARMER_FILE_NAME` with the name of the node file you downloaded from releases.
52+
./FARMER_FILE_NAME farm
53+
```
54+
7. It may prompt again in here. Refer to the note on step 4.
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
### 🍎 macOS Installation
2+
3+
1. Download the executables for your operating system from the [Releases](https://github.com/subspace/subspace/releases) tab.
4+
2. Open your favourite terminal, and change to the Downloads directory using `cd Downloads`
5+
3. Make the farmer & node executable `chmod +x $(farmer-name)` & `chmod +X $(node-name)`
6+
4. We will then start the node using the following command
7+
8+
> *Note, when attempting to run this command you may be prompted:* Click on `cancel` instead of moving it to trash.
9+
To allow execution, go to `System Preferences -> Security & Privacy -> General`, and click on `allow`.
10+
After this, simply repeat the step you prompted for (step 4 or 6). This time, click the `Open` button when prompted.
11+
12+
```
13+
# Replace `NODE_FILE_NAME` with the name of the node file you downloaded from releases.
14+
# Replace `INSERT_YOUR_ID` with a nickname you choose
15+
./NODE_FILE_NAME \
16+
--chain testnet \
17+
--wasm-execution compiled \
18+
--execution wasm \
19+
--bootnodes "/dns/farm-rpc.subspace.network/tcp/30333/p2p/12D3KooWPjMZuSYj35ehced2MTJFf95upwpHKgKUrFRfHwohzJXr" \
20+
--rpc-cors all \
21+
--rpc-methods unsafe \
22+
--ws-external \
23+
--validator \
24+
--telemetry-url "wss://telemetry.polkadot.io/submit/ 1" \
25+
--name INSERT_YOUR_ID
26+
```
27+
5. You should see something similar as the output in the terminal.
28+
```
29+
2022-02-03 10:52:23 Subspace
30+
2022-02-03 10:52:23 ✌️ version 0.1.0-35cf6f5-x86_64-macos
31+
2022-02-03 10:52:23 ❤️ by Subspace Labs <https://subspace.network>, 2021-2022
32+
2022-02-03 10:52:23 📋 Chain specification: Subspace testnet
33+
2022-02-03 10:52:23 🏷 Node name: YOUR_FANCY_NAME
34+
2022-02-03 10:52:23 👤 Role: AUTHORITY
35+
2022-02-03 10:52:23 💾 Database: RocksDb at /Users/X/Library/Application Support/subspace-node-x86_64-macos-11-snapshot-2022-jan-05/chains/subspace_test/db/full
36+
2022-02-03 10:52:23 ⛓ Native runtime: subspace-100 (subspace-1.tx1.au1)
37+
2022-02-03 10:52:23 🔨 Initializing Genesis block/state (state: 0x22a5…17ea, header-hash: 0x6ada…0d38)
38+
2022-02-03 10:52:24 ⏱ Loaded block-time = 1s from block 0x6ada0792ea62bf3501abc87d92e1ce0e78ddefba66f02973de54144d12ed0d38
39+
2022-02-03 10:52:24 Starting archiving from genesis
40+
2022-02-03 10:52:24 Archiving already produced blocks 0..=0
41+
2022-02-03 10:52:24 🏷 Local node identity is: 12D3KooWBgKtea7MVvraeNyxdPF935pToq1x9VjR1rDeNH1qecXu
42+
2022-02-03 10:52:24 🧑‍🌾 Starting Subspace Authorship worker
43+
2022-02-03 10:52:24 📦 Highest known block at #0
44+
2022-02-03 10:52:24 〽️ Prometheus exporter started at 127.0.0.1:9615
45+
2022-02-03 10:52:24 Listening for new connections on 0.0.0.0:9944.
46+
2022-02-03 10:52:26 🔍 Discovered new external address for our node: /ip4/176.233.17.199/tcp/30333/p2p/12D3KooWBgKtea7MVvraeNyxdPF935pToq1x9VjR1rDeNH1qecXu
47+
2022-02-03 10:52:29 ⚙️ Syncing, target=#215883 (2 peers), best: #55 (0xafc7…bccf), finalized #0 (0x6ada…0d38), ⬇ 850.1kiB/s ⬆ 1.5kiB/s
48+
```
49+
7. We will then open another terminal, change to the downloads directory, then start the farmer node with the following command:
50+
```
51+
# Replace `FARMERS_FILE_NAME` with the name of the node file you downloaded from releases.
52+
./FARMER_FILE_NAME farm
53+
```
54+
7. It may prompt again in here. Refer to the note on step 4.
+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
### 🖼️ Windows Installation
2+
3+
1. Download the executables for your operating system from the [Releases](https://github.com/subspace/subspace/releases) tab.
4+
2. Open `Powershell`, we do not recoomend using Command Prompt as it's syntax is slightly different.
5+
3. In the terminal we will change to the Downloads directory using this command `cd Downloads`
6+
4. We will then start the node using the following command
7+
8+
```
9+
# Replace `NODE_FILE_NAME` with the name of the node file you downloaded from releases.
10+
# Replace `INSERT_YOUR_ID` with a nickname you choose
11+
.\NODE_FILE_NAME.exe `
12+
--chain testnet `
13+
--wasm-execution compiled `
14+
--execution wasm `
15+
--bootnodes "/dns/farm-rpc.subspace.network/tcp/30333/p2p/12D3KooWPjMZuSYj35ehced2MTJFf95upwpHKgKUrFRfHwohzJXr" `
16+
--rpc-cors all `
17+
--rpc-methods unsafe `
18+
--ws-external `
19+
--validator `
20+
--telemetry-url "wss://telemetry.polkadot.io/submit/ 1" `
21+
--name INSERT_YOUR_ID
22+
```
23+
5. You should see something similar as the output in the terminal.
24+
```
25+
2022-02-03 10:52:23 Subspace
26+
2022-02-03 10:52:23 ✌️ version 0.1.0-35cf6f5-x86_64-macos
27+
2022-02-03 10:52:23 ❤️ by Subspace Labs <https://subspace.network>, 2021-2022
28+
2022-02-03 10:52:23 📋 Chain specification: Subspace testnet
29+
2022-02-03 10:52:23 🏷 Node name: YOUR_FANCY_NAME
30+
2022-02-03 10:52:23 👤 Role: AUTHORITY
31+
2022-02-03 10:52:23 💾 Database: RocksDb at /Users/X/Library/Application Support/subspace-node-x86_64-macos-11-snapshot-2022-jan-05/chains/subspace_test/db/full
32+
2022-02-03 10:52:23 ⛓ Native runtime: subspace-100 (subspace-1.tx1.au1)
33+
2022-02-03 10:52:23 🔨 Initializing Genesis block/state (state: 0x22a5…17ea, header-hash: 0x6ada…0d38)
34+
2022-02-03 10:52:24 ⏱ Loaded block-time = 1s from block 0x6ada0792ea62bf3501abc87d92e1ce0e78ddefba66f02973de54144d12ed0d38
35+
2022-02-03 10:52:24 Starting archiving from genesis
36+
2022-02-03 10:52:24 Archiving already produced blocks 0..=0
37+
2022-02-03 10:52:24 🏷 Local node identity is: 12D3KooWBgKtea7MVvraeNyxdPF935pToq1x9VjR1rDeNH1qecXu
38+
2022-02-03 10:52:24 🧑‍🌾 Starting Subspace Authorship worker
39+
2022-02-03 10:52:24 📦 Highest known block at #0
40+
2022-02-03 10:52:24 〽️ Prometheus exporter started at 127.0.0.1:9615
41+
2022-02-03 10:52:24 Listening for new connections on 0.0.0.0:9944.
42+
2022-02-03 10:52:26 🔍 Discovered new external address for our node: /ip4/176.233.17.199/tcp/30333/p2p/12D3KooWBgKtea7MVvraeNyxdPF935pToq1x9VjR1rDeNH1qecXu
43+
2022-02-03 10:52:29 ⚙️ Syncing, target=#215883 (2 peers), best: #55 (0xafc7…bccf), finalized #0 (0x6ada…0d38), ⬇ 850.1kiB/s ⬆ 1.5kiB/s
44+
```
45+
6. After running this command, Windows may ask you for permissions related to firewall, select `allow` in this case.
46+
7. We will then open another terminal, change to the downloads directory, then start the farmer node with the following command:
47+
```
48+
.\FARMER_FILE_NAME.exe farm
49+
```

docs/Getting Started/developing.md

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
sidebar_position: 3
3+
tags:
4+
- Development
5+
- Subspace.js
6+
- Node
7+
- Getting Started
8+
---
9+
10+
# Getting Started Developing
11+
12+
# [@subspace/subspace](https://github.com/subspace/subspace.js)
13+
14+
This JavaScript library provides a simple API to submit and retrieve user data to the [Subspace network](https://subspace.network/). The project is in active development with a [live test network](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Ftest-rpc.subspace.network#/explorer) designed to provide scalable and distributed archival storage.
15+
16+
# Storage API.
17+
18+
The Storage API exposes a Subspace node feature called [pallet-object-store](https://github.com/subspace/subspace/tree/main/crates/pallet-object-store) that implements RPC methods to store an **Object** from user-provided data. The user can send a simple text or even a file; the `pallet-object-store` receives an **Object** to store and generate an **objectId**.
19+
20+
- `put`: Receive a signed transaction containing an **Object** to store. It emit a `DataSubmitted Event` with an **objectId** to get the **Object** from the network.
21+
22+
- `findObject`: Receives an **objectId** to find the related **Object** stored, if it exists this method will return the **Object** data.
23+
24+
To expose these methods, this library implements two main classes:
25+
26+
- **Identity**: Class to load a **keyPair** from different sources. An instance of this class is required to create a **SubspaceClient**.
27+
28+
- `fromWeb3`: Load **keyPair** from `web3Accounts` using `@polkadot/extension-dapp`.
29+
30+
- `fromUri`: Load **keyPair** from a secret URI, Example: `//Alice///password` or a `mnemonic phrase`.
31+
32+
- **SubspaceClient**: Class that loads an **Identity** instance and creates providers to interact with the network.
33+
34+
- `connect`: Create an `ApiPromise` and `WsProvider`, returning a **SubspaceClient** instance ready to call:
35+
36+
- `putObject`: Receives an **Object** as Uint8Array, it create and submit a signed `put` transaction and return an **objectId**.
37+
38+
- `getObject`: Receives an **objectId** calling `findObject` to return the **Object** as Uint8Array.
39+
40+
# Run this project.
41+
42+
Clone this repository:
43+
44+
- `git clone https://github.com/subspace/subspace.js.git`
45+
46+
Install dependencies
47+
48+
- `npm ci`
49+
50+
Build the library.
51+
52+
- `npm run build`
53+
54+
## Usage
55+
56+
```javascript
57+
// Import the library.
58+
import { SubspaceClient, Identity } from "@subspace/subspace";
59+
60+
// Generate an Identity from node.js
61+
const identity = await Identity.fromUri(mnemonic);
62+
// Generate an Identity from broser using web3Account (injected by extension)
63+
const identity = await Identity.fromWeb3();
64+
65+
// Generate a SubspaceClient and connect to node and farmer rpc endpoints.
66+
const subspaceClient = await SubspaceClient.connect(
67+
identity,
68+
NODE_WS_PROVIDER,
69+
FARMER_WS_PROVIDER
70+
);
71+
72+
// Put the file as (Uint8Array) in to the objectStore and return the objectId
73+
const objectId: string = await subspaceClient.putObject(objectData);
74+
75+
// Using the objectId get the file as (Uint8Array) from the objectStore.
76+
const object: Uint8Array = await subspaceClient.getObject(objectId);
77+
```
78+
79+
## Run the examples.
80+
81+
- Check the examples folder for node.js and browser.
82+
83+
- [node.js](https://github.com/subspace/subspace.js/tree/master/examples).
84+
- [dapp](https://github.com/subspace/subspace.js/tree/master/examples).
85+
- [html](https://github.com/subspace/subspace.js/tree/master/examples).
86+
87+
## Running a local network
88+
89+
You can check the [Subspace repository](https://github.com/subspace/subspace) to learn how configure and run your local network.

0 commit comments

Comments
 (0)