Skip to content

Alien-Worlds/missions-api

Repository files navigation

missions-api

An event listener for contracts deployed on binance smart chain to store the events information in the database

Visual Source

Requirements

Running the service

For development purposes

  1. Modify config.yaml file with your needs:

    • Provide a database url where the information will be stored in the form as provided here

        db:
           url: "postgresql://[userspec@][hostspec][/dbname][?paramspec]"
    • Provide contract address instead of 0x0..0

        contract:
           address: "0x0000000000000000000000000000000000000000"
    • Provide block number to start with

        blockchain_info:
                   from_block_num: 8325019
    • If you are using local blockchain (e.g Ganache), provide other endpoint

        rpc:
           endpoint: "http://127.0.0.1:8545" # or localhost
  2. Open project using IDE (e.g GoLand from JetBrains), open IDE terminal, run

    go mod init
    go mod vendor
  3. At bsc-checker-events/assets/main.go run two migration related scripts:

    //go:generate packr2 clean
    //go:generate packr2
  4. Entry point is bsc-checker-events/main.go

  5. Modify run configuration as follows:

    • KV_VIPER_FILE=config.yaml (environment variable)
  6. Run service twice with the following command arguments:

    migrate up
    run service

For deployment purposes

  1. Navigate to the cloned repository

  2. Do the step 1 from development build, except modify config at configs/spaceship-staking.yaml, changing contract address and database url (for the contract deployed on the Binance Smart Chain leave the endpoint as it is

  3. Build container image:

    docker compose build
  4. Run using docker-compose

    docker-compose down -v
    docker-compose up -d

API

To change port, configure

listener:
  addr: :8888

where 8888 is a port to listen on.

Endpoints

/missions # get all missions
/missions/{mission-id} # get mission by it's id
/explorers/{explorer-address} # get missions joined by explorer address

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published