Giter Site home page Giter Site logo

sn0rp / finense Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 509 KB

RESTful API to aggregate ENS records and estimate net worth

License: GNU General Public License v3.0

JavaScript 99.70% Dockerfile 0.30%
ethereum ens ether eth api rest ethers ethers-js ethersjs express

finense's Introduction

FINENSE

finense logo

RESTful API to aggregate ENS records and estimate net worth

Workflow GitHub issues License badge
GitHub Stars GitHub Watchers

Table of Contents

About

Finense is an API which simplifies the process of evaluating one's cryptocurrency portfolio for ENS domain registrants. The original goal of this software was to evaluate a domain's "Net Worth" in USD; this goal has been satisfied with regard to major cryptocurrency assets. This software is not built to allow any modification of ENS or other blockchain data and only GET requests are supported. Functionality is delivered in the form of a self-hosted API. I do intend to utilize the lessons learned here within a more robust portfolio analysis application in the distant future, however I make no public commitment at this time.

This software was created to meet a personal need, although the utility is self-evident.

Setup

These directions assume the user will deploy on a Debian server with Docker. If you just want to run the software with Node, you can simply clone this repository, create the required environment variables (Step 4), and run npm run start. If you already have Docker and Screen installed, skip to Step 4.

  1. Deploy a new Debian server, if applicable.
  2. Uninstall outdated versions of Docker (this step taken from Docker documentation)
apt remove docker docker-engine docker.io containerd runc
  1. Install Docker, Git, Screen (this step taken from Docker documentation)
apt update

apt install ca-certificates curl gnupg lsb-release

curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null

apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin screen git
  1. Download and configure Finense
git clone https://github.com/snorper/finense

cd finense

cat >> ./.env<< EOF
INFURA_ID=     ***FILL THIS IN***
INFURA_SECRET= ***FILL THIS IN***
NOW_NODES=     ***FILL THIS IN***
PORT=5000
NODE_ENV="production"
EOF

Regarding the above environment variables:

  • INFURA_ID is your Infura Project ID.
  • INFURA_SECRET is your Infura Project Secret.
  • NOW_NODES is your NOWNodes API Key.
  • PORT is the port on which the API will listen (default 5000).

Undisclosed environment variables are to be supplied by the user in a local deployment. Replace ***FILL THIS IN*** with the relevant information, in quotes with no spaces.

  1. Run Finense
screen -S finense

docker compose up
  • To exit and leave finense running, press CTRL+A and then D.
  • To return after exiting, run screen -r finense.
  • To stop finense, run screen -X -S finense quit.

Usage

If you followed the suggested steps from Setup, the API is now accessible at localhost:5000. All endpoints and errors are fully documented at docs/index.md in this repository, linked here. As an example, sending a GET request or otherwise navigating to http://localhost:5000/domain/snorp.eth returns the following response:

{
    "domain": "snorp.eth",
    "avatar": "https://gateway.ipfs.io/ipfs/Qmbkc7q1MASig2BpizCXwR4tUUq4GG7ubQ15VucAf1B5pq/493.png",
    "net": "4726.272173353719",
    "assets": [
        {
            "name": "eth",
            "address": "0x0FA6273Ce887D26622698eAbc9311597fC66a351",
            "balance": "0.8440922705248084",
            "usd": "2338.1355893537193"
        },
        {
            "name": "btc",
            "address": "bc1q9x8660cp73x2v3lyvm6ua9gqwz6fy8gqhrsv06",
            "balance": "0.06419722",
            "usd": "2388.136584"
        },
        {
            "name": "ltc",
            "address": "ltc1qlf0s82v7ywvnf52c0jk9ejx6qfsragk58pgvmp",
            "balance": "0",
            "usd": "0"
        },
        {
            "name": "doge",
            "address": "D6LVbmQM3UQmvwFnWX8VKECJH7ySNnYzX9",
            "balance": "0",
            "usd": "0"
        }
    ]
}

Informational messages and errors are logged to finense.log in the project root directory. If you make regular use of this software, you may want to occasionally delete that file using cron or a similar tool.

Note that this API supports four assets: btc, ltc, eth, and doge. Support for additional assets would require additional upstream API dependencies, which explains why it is common to support just these four. I do not intend to integrate any additional APIs, but feedback is welcome.

Dependencies

Proper functionality is dependent upon other upstream APIs remaining accessible. If at any time these APIs cannot be reached, Finense is expected to return an "UpstreamError" with status code 502. Beyond this, all routes and underlying functions are tested. Errors should only be returned if the user supplies a dissallowed or misspelled request.

Roadmap

  • Determine best approach in detail
  • Create README.md skeleton
  • Communicate with ENS and relevant blockchain APIs to get necessary data
    • Connect to Ethereum & establish resolver for arbitrary domains
    • Resolve domain to list of coin types with address records
    • Filter a domain's coin types list for supported assets
    • Resolve each supported coin type to the given domain's matching address record
    • Get amount owned for each supported asset
    • Convert amounts owned to USD
    • Aggregate amounts owned for all supported assets to calculate net worth
  • API Development
    • Create API skeleton
    • Fill in API routes using ENS scripts
      • /:domain: provide net worth and asset breakdown
      • /:domain/address: provide only addresses, for all supported assets
      • /:domain/amount: provide only amounts owned for all supported assets
      • /:domain/:asset provide only (all) data for a specific asset
      • /:domain/:asset/address provide only address for a specific asset
      • /:domain/:asset/amount provide only amount owned for a specific asset
      • /:domain/:asset/fiat provide only value in USD of amount owned for a specific asset
      • /:domain/net provide only net worth
  • Testing
    • Affirm implementation of all necessary error handling
    • Implement proper logging
    • Implement all necessary tests
    • Automate testing with GitHub workflows
  • Implement Docker
  • Fully document API

License

All original software within this repository is licensed under the GPL-3.0 License.

finense's People

Contributors

sn0rp avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.