Git Product home page Git Product logo

near-contract-helper's Introduction

near-contract-helper

Microservice used to create NEAR accounts

Local Development

Requirements

Install latest Node.js LTS release

Install dependencies

yarn

Environment Variables

Create a .env file, copy in the default values from .env.sample. Read this file for information about how to change configuration settings to suit your needs.

By default, it assumes that you're running a local node and local network. To do this, use nearup or rainbow-bridge-cli

Now you can add an ACCOUNT_CREATOR_KEY to your .env. Running a local NEAR network created a ~/.near/localnet/node0/validator_key.json file for you. Copy the contents of this file and paste them as a single line, with NO whitespace, for the ACCOUNT_CREATOR_KEY value in your .env. For example:

ACCOUNT_CREATOR_KEY={"account_id":"node0","public_key":"...","secret_key":"..."}

Run server with local DynamoDB

yarn start

This starts a local DynamoDB instance on port 7877 which is used when NODE_ENV=development to facilitate local testing. This instance is persisted to a .db file at the project root.

Create account (works only on test networks)

curl -H "Content-Type: application/json" -XPOST http://0.0.0.0:3000/account --data '{"newAccountId": "nosuchuseryet", "newAccountPublicKey": "22skMptHjFWNyuEWY22ftn2AbLPSYpmYwGJRGwpNHbTV"}

Lookup account by public key

curl -XGET http://0.0.0.0:3000/publicKey/ed25519:EKveJ28ocxfHXQEfH42AowPL7HgXHkKp3kmMoSXNjiRF/accounts
curl -XGET https://helper.mainnet.near.org/publicKey/ed25519:EKveJ28ocxfHXQEfH42AowPL7HgXHkKp3kmMoSXNjiRF/accounts

Sample response

[
    "heyheyhey.near"
]

Running tests

Ensure NEAR localnet is running

As mentioned in the "Environment Variables" section above, make sure you are running a local blockchain

Run yarn test

This will run the tests using mocha. Assertions are written using chai with chai-as-promised for async assertions. Spies and fake timers provided with sinon.

near-contract-helper's People

Contributors

vgrichina avatar andy-haynes avatar maximushaximus avatar morgsmccauley avatar mattlockyer avatar dependabot-preview[bot] avatar chadoh avatar janedegtiareva avatar dependabot[bot] avatar esaminu avatar ilblackdragon avatar patrick1904 avatar bowenwang1996 avatar azban avatar chefsale avatar mhalambek avatar willemneal avatar ggoshanov avatar ddealmeida avatar htafolla 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.