Typescript-version of the incubed client/server
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode added License Oct 26, 2018
doc updated readme Oct 26, 2018
proxy added License Oct 26, 2018
src changed default to mainnet Oct 29, 2018
test added License Oct 26, 2018
.gitignore added logger May 9, 2018
.gitlab-ci.yml added Docker-image Oct 2, 2018
.npmignore changed default to mainnet Oct 29, 2018
.tslintignore added inital alpha-impl Mar 13, 2018
CHANGELOG Add CHANGELOG Aug 7, 2018
Dockerfile added License Oct 26, 2018
LICENSE fixed npm-release Oct 26, 2018
README.md more content in README Oct 29, 2018
package-lock.json updated readme Oct 26, 2018
package.json fixed npm-release Oct 26, 2018
tsconfig.json added proxy Oct 2, 2018
tslint.json added inital alpha-impl Mar 13, 2018

README.md

INCUBED

INCUBED = A trustless INcentivized remote Node Network = IN3

This is the Typescript-version of the incubed client.

Build Status

Getting started

npm install --save in3

In your code:

// import in3-Module
import In3Client from 'in3'
import * as web3 from 'web3'

// use the In3Client as Http-Provider
const web3 = new Web3(new In3Client({
    proof: true,
    signatureCount: 1,
    requestCount : 2,
    chainId: 'mainnet'
}))

// use the web3 
const block = await web.eth.getBlockByNumber('latest')
...

Docker

In order to start the incubed-client as a standalone client (allowing others none-js-application to connect to it), you can start the container as

docker run -d -p 8545:8545  slockit/in3:latest --chainId=kovan

The application would then accept the following arguments:

param description
--nodeLimit the limit of nodes to store in the client.
--keepIn3 if true, the in3-section of thr response will be kept. Otherwise it will be removed after validating the data. This is useful for debugging or if the proof should be used afterwards.
--format the format for sending the data to the client. Default is json, but using cbor means using only 30-40% of the payload since it is using binary encoding
--autoConfig if true the config will be adjusted depending on the request
--retryWithoutProof if true the request may be handled without proof in case of an error. (use with care!)
--includeCode if true, the request should include the codes of all accounts. otherwise only the codeHash is returned. In this case the client may ask by calling eth_getCode() afterwards
--maxCodeCache number of max bytes used to cache the code in memory
--maxBlockCache number of number of blocks cached in memory
--verifiedHashes if the client sends a array of blockhashes the server will not deliver any signatures or blockheaders for these blocks, but only return a string with a number. This is automaticly updated by the cache, but can be overriden per request.
--proof if true the nodes should send a proof of the response
--signatureCount number of signatures requested
--minDeposit min stake of the server. Only nodes owning at least this amount will be chosen.
--replaceLatestBlock if specified, the blocknumber latest will be replaced by blockNumber- specified value
--requestCount the number of request send when getting a first answer
--timeout specifies the number of milliseconds before the request times out. increasing may be helpful if the device uses a slow connection.
--chainId servers to filter for the given chain. The chain-id based on EIP-155.
--chainRegistry main chain-registry contract
--mainChain main chain-id, where the chain registry is running.
--autoUpdateList if true the nodelist will be automaticly updated if the lastBlock is newer
--cacheStorage a cache handler offering 2 functions ( setItem(string,string), getItem(string) )
--loggerUrl a url of RES-Endpoint, the client will log all errors to. The client will post to this endpoint JSON like { id?, level, message, meta? }

Documentation

The following docuemntations are available:

Chains

Currently incubed is deployed on the following chains:

Mainnet

Registry : 0xFdb0eA8AB08212A1fFfDB35aFacf37C3857083ca
ChainId : 0x1 (alias mainnet)
Status : https://in3.slock.it?n=mainnet
NodeList: https://in3.slock.it/mainnet/nd-3

Kovan

Registry : 0x27a37a1210df14f7e058393d026e2fb53b7cf8c1
ChainId : 0x2a (alias kovan)
Status : https://in3.slock.it?n=kovan
NodeList: https://in3.slock.it/kovan/nd-3

Tobalaba

Registry : 0x845E484b505443814B992Bf0319A5e8F5e407879
ChainId : 0x44d (alias tobalaba)
Status : https://in3.slock.it?n=tobalaba
NodeList: https://in3.slock.it/tobalaba/nd-3

Evan

Registry : 0x85613723dB1Bc29f332A37EeF10b61F8a4225c7e
ChainId : 0x4b1 (alias evan)
Status : https://in3.slock.it?n=evan
NodeList: https://in3.slock.it/evan/nd-3

IPFS

Registry : 0xf0fb87f4757c77ea3416afe87f36acaa0496c7e9
ChainId : 0x7d0 (alias ipfs)
Status : https://in3.slock.it?n=ipfs
NodeList: https://in3.slock.it/ipfs/nd-3

Registering a own in3-node

If you want to participate in this network and also register a node, you need to send a transaction to the registry-contract calling registerServer(string _url, uint _props).

ABI of the registry:

[{"constant":true,"inputs":[],"name":"totalServers","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_serverIndex","type":"uint256"},{"name":"_props","type":"uint256"}],"name":"updateServer","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_url","type":"string"},{"name":"_props","type":"uint256"}],"name":"registerServer","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"servers","outputs":[{"name":"url","type":"string"},{"name":"owner","type":"address"},{"name":"deposit","type":"uint256"},{"name":"props","type":"uint256"},{"name":"unregisterTime","type":"uint128"},{"name":"unregisterDeposit","type":"uint128"},{"name":"unregisterCaller","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_serverIndex","type":"uint256"}],"name":"cancelUnregisteringServer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_serverIndex","type":"uint256"},{"name":"_blockhash","type":"bytes32"},{"name":"_blocknumber","type":"uint256"},{"name":"_v","type":"uint8"},{"name":"_r","type":"bytes32"},{"name":"_s","type":"bytes32"}],"name":"convict","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_serverIndex","type":"uint256"}],"name":"calcUnregisterDeposit","outputs":[{"name":"","type":"uint128"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_serverIndex","type":"uint256"}],"name":"confirmUnregisteringServer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_serverIndex","type":"uint256"}],"name":"requestUnregisteringServer","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"url","type":"string"},{"indexed":false,"name":"props","type":"uint256"},{"indexed":false,"name":"owner","type":"address"},{"indexed":false,"name":"deposit","type":"uint256"}],"name":"LogServerRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"url","type":"string"},{"indexed":false,"name":"owner","type":"address"},{"indexed":false,"name":"caller","type":"address"}],"name":"LogServerUnregisterRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"url","type":"string"},{"indexed":false,"name":"owner","type":"address"}],"name":"LogServerUnregisterCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"url","type":"string"},{"indexed":false,"name":"owner","type":"address"}],"name":"LogServerConvicted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"url","type":"string"},{"indexed":false,"name":"owner","type":"address"}],"name":"LogServerRemoved","type":"event"}]

To run a incubed node, you simply use docker-compose:

version: '2'
services:
  incubed-server:
    image: slockit/in3-server:latest
    volumes:
    - $PWD/keys:/secure                                     # directory where the private key is stored 
    ports:
    - 8500:8500/tcp                                         # open the port 8500 to be accessed by public
    command:
    - --privateKey=/secure/myKey.json                       # internal path to the key
    - --privateKeyPassphrase=dummy                          # passphrase to unlock the key
    - --chain=0x2a                                          # chain (kovan)
    - --rpcUrl=http://incubed-parity:8545                   # url of the kovan-client
    - --registry=0x85613723dB1Bc29f332A37EeF10b61F8a4225c7e # url of the incubed-registry 
    - --autoRegistry-url=http://in3.server:8500             # check or register this node for this url
    - --autoRegistry-deposit=2                              # deposit to use when registering

  incubed-parity:
    image: slockit/parity-in3:v2.2                          # parity-image with the getProof-function implemented
    command:
    - --auto-update=none                                    # do not automaticly update the client
    - --pruning=archive 
    - --pruning-memory=30000                                # limit storage
    - --testnet                                             # kovan