Git Product home page Git Product logo

vechain-rest-api's Introduction

Vechain Sample REST API

This is a very simple service exposing check balance and send tokens methods.

This is some simple PoC, to run it fast locally and check libraries, first you have to clone this repository

https://github.com/czareko/vechain-localstack

Next run local development stack.

What needs to be improved in this sample project:

  • Validations
  • Security
  • Unit and integration tests
  • Code static analysis
  • Some libraries should be updated

Command line methods

Typescript compilation command:

npm run compile-typescript

Run command:

npm run start

Run as a Docker image

This is the next step to build more complicated local environment

First build a docker image

docker build -t vechain-service .

Next run the image

docker run -it -p 8080:8080 --network="host" vechain-service

This machine needs to connect with other services from the local stack, so we have to open it for localhost.

Exposed services

Simple balance check without address exception handling

GET: http://localhost:8080/balance/0xa40F151a783302513402342a5Df82F1aD59978b6

Send tokens method

POST: http://localhost:8080/sendTokens

{
	"fromPublicKey": "0x9d92bAE571D3Ba1b869c5102c0D28136b910A760",
	"fromPrivateKey": "075c841cc3aedbb65fbfdbfc577c0b776111d0cd10841d96eb8def988282ed6c",
	"toPublicKey": "0xa40F151a783302513402342a5Df82F1aD59978b6",
	"amount": "1"
}

I hope I don't have to tell you that you have to be crazy to expose your real private key. In this request you can see test accounts, and account "from" was loaded with 500 tokens.

Useful links

To generate your own address you can go here:

https://laalaguer.github.io/VeChain-Address/

To get test tokens you can go here:

https://faucet.vecha.in/

To check transactions or address balance you can go here:

https://insight.vecha.in/#/test/

vechain-rest-api's People

Contributors

czareko avatar

Watchers

James Cloos 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.