Code Monkey home page Code Monkey logo

mina-geoip-oracle's Introduction

A GeoIP Oracle for Mina zkApps

This oracle takes an IP address and returns the address's country code, along with a signature for Mina zkApps. (The country lookup uses ip-api.com, but there are many other Geo IP lookups available with different pricing schemes.)

Local Setup

Run the key generator script below to create a private/public key pair.

npm run keygen

Create a .env file with a PRIVATE_KEY= entry for the private key.

Start the server locally with

npm run dev

Once the server has started, you can check out the API using http://localhost:3000/ip/[IP-address], replacing [IP-address] with some IP address.

Run unit tests

npm run test

Deployment

The API is just a NodeJS + ExpressJS server. For convenience, you can deploy it on Digital Ocean using this link: Deploy to DO

During deployment, make sure you properly set the environment variable PRIVATE_KEY in the hosting environment (i.e. Digital Ocean). For security, this production private key should be different from what's used locally and not be shared among developers.

An example call could be found at https://mina-geoip-oracle-9mbb8.ondigitalocean.app/ip/24.48.0.1.

mina-geoip-oracle's People

Contributors

chucklam avatar

Watchers

 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.