Skip to content

This repository contains the SF Oracle SDKs, which is a collection of software development kits (SDKs) for submitting price automatically to SF contract oracles on the Ether.

Notifications You must be signed in to change notification settings

stip-flip/oracle-sdks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SF Oracles

This repository contains the SF Oracle SDKs, which is a collection of software development kits (SDKs) for submitting price automatically to SF contract oracles on the Ether.

Installation

To use the SF Oracles SDKs in your Go project, you need to have Go installed on your machine. You can download and install Go from the official Go website.

To install the SDKs, you can either:

Build it from source

  1. Clone this repository to your local machine.
  2. Navigate to the root directory of the repository.
  3. Build the SDKs by running the following command:
go build

Install the Go SDK by running the following command:

go get -u github.com/stip-flip/oracle-sdks

Download the appropriate binary from the releases page

  1. Navigate to the releases page of this repository.
  2. Download the appropriate binary for your operating system.
  3. Extract the contents of the archive to a directory on your machine.

Use the docker image available on the docker hub

docker pull sotachi/sf-oracle

Usage

You have 2 possibility to run the sdk, either as a server or as a cron job.

1. As a server

Once the sdk is installed and ready to run, you need to set the following environment variables:

# The private key of the account that will be used to sign transactions
PRIVATE_KEY=your-private-key
# Cryptocompare API key
CC_API_KEY=your-api-key
# The contract oracle address that will be used to store crypto compare oracle prices
CC_ORACLE_ADDRESS=cc-oracle-address

POLL_INTERVAL=300s

CHAIN_ID=61

RPC_URL=https://etc.etcdesktop.com

This .env file hold important informations, ie the private key, make sure it is kept safe and not shared with anyone.

Note that in order to submit prices to an oracle, you need to stake a minimum amount in the contract first. Visit https://sf.exchange/oracle/deposit to stake the minimum amount.

You can then run this program as a standalone binary or as a docker container.

2. As a CRON job

Download the appropriate binary (cronv1.0.1) from the releases page or build it from source.

Create a .env file next to the cron binary file with the following content:

# The private key of the account that will be used to sign transactions
PRIVATE_KEY=your-private-key

CHAIN_ID=61

RPC_URL=https://etc.etcdesktop.com

This .env file hold important informations, ie the private key, make sure it is kept safe and not shared with anyone.

You can then automate the execution of the binary by using the daily_task bash script available in the repository.

Windows:

Download and place the daily_task.ps1 script in the same directory as the cron binary and the .env files.

Open Powersell and run the following command:

chmod +x ./daily_task.ps1
chmod +x ${CRON_BINARY}
./daily_task.ps1 ${CRON_BINARY}

Linux and MacOS:

Download and place the daily_task.sh script in the same directory as the cron binary and the .env files.

Open a terminal and run the following command:

 chmod +x ./daily_task.sh
 chmod +x ${CRON_BINARY}
./daily_task.sh ${CRON_BINARY}

This will wake your computer up from sleep and run the cron binary at 00:30 UTC every day.

MacOS will by default block the execution of the binary, you need to allow it in the security settings.

License

This project is licensed under the MIT License. See the LICENSE file for more information.

About

This repository contains the SF Oracle SDKs, which is a collection of software development kits (SDKs) for submitting price automatically to SF contract oracles on the Ether.

Resources

Stars

Watchers

Forks

Packages

No packages published