The main goal of SkinCoin payment service is to simplify an integration third party applications with Ethereum network. The service provides an API to make payouts and accept payments in SKINs and ETHER. All API requests are idempotent, i.e. the result of a successful performed request is independent of the number of times it is executed
All you need to install SkinCoin service is docker and docker-compose tools (see 'Install docker and docker-compose' topic).
If you decided to build application from source code you also need to install:
To install the latest version of the docker do the following:
# curl -fsSL https://get.docker.com/ | sh
# curl -fsSL https://get.docker.com/gpg | apt-key add -
To install docker-compose do the following:
# curl -L https://github.com/docker/compose/releases/download/1.14.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
# chmod +x /usr/local/bin/docker-compose
There are two types of the installation:
- From pre-build binaries. This is the most fast way to run up application. Pre-build binaries was packed as docker images. You may find them here
- From source code. This requires to install JDK8 and 'maven' to compile source code.
The SkinCoin payment service ships with default configuration. You may find it in file config.sh in the root dir. To make you application more secure in production you should change the default configuration values. Let's describe the configurable parameters:
- MySql
- MYSQL_ROOT_PASSWORD - MySql 'root' password. Default value is 'root'
- MYSQL_USER - SkinCoin payment service database user name. Default value is 'dbuser'
- MYSQL_PASSWORD - SkinCoin payment service database user password. Default value is 'dbpass'
- MYSQL_DATABASE - SkinCoin payment service database name. Default value is 'payment_service'
- MYSQL_DATA_DIR - MySql database files location. Default value '/mnt/skincoin/mysql'
- Geth
- GETH_DATA_DIR - Geth data files location. Default '/mnt/skincoin/geth'
- ETHEREUM_NETWORK - Ethereum network. Possible values are: "live"(MAIN_NET), "private"(PRIVATE_NET) and "test"(TEST_NET). Default value is 'live'
- Skincoin Payment Service
- SERVICE_PORT - Service port. Default value is '8189'
- SERVICE_LOG_DIR - Service log dir. Default value '/mnt/skincoin/logs'
- SKINCOIN_ADDRESS - SkinCoin token deployed address. Default value is '0x2bdc0d42996017fce214b21607a515da41a9e0c5' (for production only).
- Admin UI
- ADMIN_NAME - Admin name. Default value is 'admin'
- ADMIN_PASSWORD - Admin password. Default value is 'admin'
- JWT_SECRET_KEY - Any random string. Uses to signing JWT token. Defauls value is 'secretKey'
NOTE Skip this topic in case of installation for the testing environment. Make sure that you've done configuration in config.sh file.
To install from pre-build binaries do the following:
- Generate configuration files and build docker images:
$ ./1_generate_config.sh
$ ./2_build_images.sh
- Start SkinCoin payment service:
$ docker-compose up -d
NOTE Skip this topic in case of installation for the production environment.
Installation for testing environment includes an additional step to deploy SkinCoin smart contract to Ethereum private network. So the steps will be as described below:
-
Set 'ETHEREUM_NETWORK=private' in config.sh
-
Generate configuration files and build docker images:
$ ./1_generate_config.sh
$ ./2_build_images.sh
- Start Geth service only:
$ docker-compose up -d geth
- Connect to the Geth docker container and deploy SkinCoin smart contract:
$ docker exec -it skincoinpaymentservice_geth_1 sh
# ./deploy.sh
where 'skincoinpaymentservice_geth_1' is a name automatically generated by docker-compose utility.
- Wait for deploy contract completion and exit from the Get docker container:
# exit
NOTE Be shure that you leave the Geth container
-
In the Geth data directory (see 'GETH_DATA_DIR' in config.sh) on your local host will be created 2 files:
- Payout.address - File contains a payout address. Use this address when you'll be register a new application (see "Register a new application"). Payout password is '123'
- Skincoin.address - File contains a SkinCoin contract deployed address.
-
Change the value of 'SKINCOIN_ADDRESS' variable in config.sh) on address from the 'Skincoin.address' file.
-
Generate configuration files and build docker images (one more time to apply our changes):
$ ./1_generate_config.sh
$ ./2_build_images.sh
- Start SkinCoin payment service:
$ docker-compose up -d
Make sure there are no errors in log file. See SERVICE_LOG_DIR for log location
One instance of the service can serve several third party applications. For this purpose "applications" are implemented. Your should register your application in order to use the API. Every new application has the following properties:
- App ID - An unique application ID
- Name - Application name
- API Key - Secure key to access to the API
- Payout address - Payout address in Ethereum networt. All payouts will be made from this address. Make sure there is enought money on it
- Payout password - Password from the payout address.
- Auth secret - A secret token to secure the callback notifications
- Callback URL - Callback REST interface to accept notification from the service
- Enable callback - Enable or disable notifications via REST interface.
To register a new application do the following:
- Go to Admin UI http://localhost:<SERVICE_PORT>
- Enter credentials as was specified in configuration (see <ADMIN_NAME> and <ADMIN_PASSWORD> ). Press "Login"
- Press "New" button, fill the form.
- Press "Save" button. The new application will be appeared in table.
Now you can try to use API as described here: API