Skip to content
This repository has been archived by the owner on Jan 31, 2022. It is now read-only.

serge-medvedev/freeton-staking-manager

Repository files navigation

[REPO IS ARCHIVED] Maintained version lives here

FreeTON Staking Manager

What is it?

This product is a complete solution for a Free TON validator, which abstracts away all the complexity of dealing with validator node and the network while sending stakes, receiving rewards and coping with various kinds of hardware or network issues.

It supports both C++ (legacy) and Rust (modern) nodes, as well as both wallet-based and DePool-based staking.

Support the Project

You could help by:

  • submitting an issue

  • making a pull request

  • sending some TONs to 0:cba74138b0ac11873e1ec262a71a22c3352de44383877679d1c6bd5165b7b49e

    0:cba74138b0ac11873e1ec262a71a22c3352de44383877679d1c6bd5165b7b49e

Have it Up & Running

  • Refer to config.js.example to create the ./config.js file

  • In case of using 'legacy' mode, make sure you have the client private key and the server public keys, generated during validator engine initialization, stored in ./certs directory (must contain client, server.pub and liteserver.pub files).

  • Create ./docker-compose.yml using example below and deploy the service:

    version: "2.3"
    services:
      freeton-staking-manager:
        image: sergemedvedev/freeton-staking-manager
        volumes:
          - type: bind
            source: ./config.js
            target: /usr/src/app/config.js
            read_only: true
          - type: bind
            source: ./certs
            target: /usr/src/app/certs
            read_only: true
          - type: volume
            source: freeton-staking-manager-data
            target: /data/freeton-staking-manager
        ports:
          - "127.0.0.1:3000:3000"
        environment:
          DEBUG: "app,api,lib:*"
        restart: always
    
    volumes:
      freeton-staking-manager-data:

    If you want to expose API to the internet, generate a secret and activate token-based authentication by providing additional environment variables:

    $ openssl rand --hex 32
    ports:
      - "3000:3000"
    environment:
      FREETON_SM_ADMIN_NAME: <nice name>
      FREETON_SM_ADMIN_PASSWORD: <strong password>
      FREETON_SM_AUTH_SECRET: <secret generated via openssl>
    $ docker-compose up -d

API Reference

If you have authentication enabled, get your token first:

$ curl -s -H 'Content-Type: application/json' -d '{"name":"<nice name>","password":"<strong password>"}' <ip address or domain name>:3000/auth

For convenience, you might want to store the token in a file in the HTTP header form:

$ echo 'FREETON-SM-APIKEY: <token you received>' > token-header

Now curl can be called like that:

$ curl -H @token-header ...

POST /stake/:action

Tries to send/recover/resize a stake

:action "send", "recover" or "resize"

NOTE: only "send" (without "force") is usable in "depool" funding mode

Example:

$ curl -XPOST localhost:3000/stake/recover

Pass force query parameter to send a stake even if it's "already submitted":

$ curl -XPOST localhost:3000/stake/send?force=yes

Pass value query parameter to set the default stake size:

$ curl -XPOST localhost:3000/stake/resize?value=20000

POST /elections/:action

Allows to skip upcoming elections (no idea why one would need it)

:action "skip" or "participate"

Example:

$ curl -XPOST localhost:3000/elections/skip

GET /elections/history

Returns info (keys, stake, etc.) about elections the node participated in

Example:

$ curl -s localhost:3000/elections/history | jq '.'

PUT /ticktock

Invokes DePool's State Update method (ticktock)

Example:

$ curl -XPUT localhost:3000/ticktock

POST /validation/resume

Returns the node back to validation after it's re-sync'ed from scratch

NOTE: at the moment it's supported only by 'legacy' staking policy

Example:

$ curl -XPOST localhost:3000/validation/resume

GET /stats/:representation

Shows validator stats

:representation "json" or "influxdb"

Pass interval query parameter (in seconds) to change the time frame for blocks signatures counting (default: 60s)

Example:

$ curl localhost:3000/stats/json?interval=3600

TODO

  • Add multiple nodes management