Skip to content

API Distribution

This distribution method is an application owned distribution method as opposed to an on-chain distribution. The API facilitates sFUEL distribution to users by exposing an API endpoint through a public or private endpoint.

The default infrastructure option showed in the documentation is public by default as well as very minimal. It is designed to be easily extended by projects with various middlewares, protections, etc.

Implementation Example

  1. Create project folder

    Open up your terminal and start by cloning the Github Repo

    In order to create a project using Node.js and NPM. You can verify that you have Node.js installed by running:

    Terminal window
    node -v

    You should see a number such as 18.12.0 OR a response saying that the command node is not recognized. If you see the former, continue, else head over to the Node.js website and install Node.js on your computer.

    Once you have Node installed, proceed to the project creation.

    Terminal window
    git clone -b starter-api-distribution-nodejs https://github.com/skalenetwork/recipes.git
  2. Install Dependencies

    Run the following in your terminal to install the project dependencies

    Terminal window
    npm install
  3. Add Environment Variables

    Run the following in your terminal

    Terminal window
    cp .env.example .env

    Add an Ethereum private key to your .env file and change the RPC to match your SKALE Chain. The default RPC_URL is set to the Chaos Testnet.

  4. Run the API

    To run the API locally and hot-reload when changes occur, run:

    Terminal window
    yarn dev

    To run the API without hot-reload, run:

    Terminal window
    yarn start