Skip to content

BOXFoundation/erc20-rest-service

 
 

Repository files navigation

Wallet RESTful APIs

This application provides a RESTful service for creating and managing ERC-20 tokens. It has been built using Spring Boot, and web3j.

It works with both Geth, Parity, and Quorum.

For Quorum, the RESTful semantics are identical, with the exception that if you wish to create a private transaction, you populate a HTTP header name privateFor with a comma-separated list of public keys

How to Run Unit Tests

Launch a MySQL instance

docker volume rm contentbox-mysql
docker run --name contentbox-mysql --mount source=contentbox-mysql,target=/var/lib/mysql -e MYSQL_USER=contentbox -e MYSQL_PASSWORD=ThePassw0rd -e MYSQL_DATABASE=wallet -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -p 3306:3306 -d mysql:5

The command above will launch a MySQL instance, create a table wallet, add a user contentbox and set its password automatically. Make sure the username and password are identical with src/main/resources/application.yml.

Create an Ethereum private network

cd tools/ethereum_private_network/
docker-compose up

Run all unit tests

./gradlew test

API References

All available application endpoints are documented using Swagger.

You can view the Swagger UI at http://localhost:8080/swagger-ui.html. From here you can perform all POST and GET requests easily to facilitate deployment of, transacting with, and querying state of ERC-20 tokens.

alt text

  1. Deploy our ERC-20 token contract

    POST /deploy

    {
      "decimalUnits": 0,
      "initialAmount": 1000,
      "tokenName": "BOX token",
      "tokenSymbol": "BOX"
    }
    

    Upon successful deployment, the contract address will be returned, which can be used to interact with the contract.

  2. Subscribe to token transfer events of a specific contract address POST /subscribe/{contractAddress}

  3. Get some initial coins for users GET /{userId}/address: Get user's address. Generate a few users and change their balances to positive in mysql directly so they can start transacting.

  4. Other APIs for wallet integration

  • GET /{contractAddress}/balanceOf/{userId}: Get token balance of a user
  • POST /{contractAddress}/transferFrom: Transfer a user's tokens to an address
  • GET /{contractAddress}/listtx/{userId}: Returns a list of token transactions for a given user

About

ERC-20 token standard RESTful service using Spring Boot and web3j

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 98.8%
  • Shell 1.2%