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
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
.
cd tools/ethereum_private_network/
docker-compose up
./gradlew test
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.
-
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.
-
Subscribe to token transfer events of a specific contract address
POST /subscribe/{contractAddress}
-
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. -
Other APIs for wallet integration
GET /{contractAddress}/balanceOf/{userId}
: Get token balance of a userPOST /{contractAddress}/transferFrom
: Transfer a user's tokens to an addressGET /{contractAddress}/listtx/{userId}
: Returns a list of token transactions for a given user