[한글설명有] Garnet Solution(Alpha Version) : BINDLABS’ first version of blockchain solution/ 무료 블록체인 솔루션

in #blockchain6 years ago (edited)

This version of solution provides cryptocurrency features only. JAVA developers can build their own cryptocurrency (private blockchain) main nodes and wallet clients with this library. Even if you are not a developer, you can set up your own main node servers using server jar file. You can change settings by editing config with text editor. 

In this post, we are going to explain how to use our solution as server, client and library. At this moment, we only provide alpha version of solution written in JAVA language. 


Server - This is runnable java jar file and config file. Put these files into server and run this on terminal

java -jar server.jar 

Client - This is runnable java jar file and config file. Put these files anywhere and run this on terminal

java -jar client.jar 

Library - This is java library file for developers. Put this file into java project’s library folder and set the build path. Specific example is at the bottom of this post.



Download Link – JAVA 

- Server : http://bindlabs.com/garnet/alpha/server.zip 

- Client : http://bindlabs.com/garnet/alpha/client.zip 

- Library : http://bindlabs.com/garnet/alpha/library.zip 

- Example : https://github.com/BINDLABS/GarnetCustonClientExample



Usage – server and client

The config file of server is

port="8146"
jsonport="8147"
signalingport="8888"
datapath="chaindata/server"
keypath="key/server"
genesis="BDCEB2GKA16GGA6LVJKN52UP3H73DKRE5BYT:10000000000000000;"
node="1.1.1.1:8146,1.1.1.2:8146"
  • port is the main port of the main node - communication between java applications
  • jsonport is the port for text formatted communication (incomplete yet)
  • signalingport is the AppRTC Signaling server port
  • datapath is the path where chaindata will be saved
  • keypath is the path where server client keypair will be saved
  • genesis is the content of genesis block
  • node is the main node servers

*server keypair will not be used on this Alpha version so it is safe to save them anywhere


genesis format is

{Wallet address}:{Amount of Coin on this wallet};

*Amount of Coin must not contain '.' This is in format of 'satoshi' of Bitcoin (*100000000)

If you want to allocate coins for more than 2 wallets, simply add above code at the end of the code like

{Wallet address 1}:{Amount of Coin on this wallet 1};{Wallet address 2}:{Amount of Coin on this wallet 2};


node format is

{Server IP}:{Port}

and multiple nodes with comma ',' like

{Server IP 1}:{Port 1},{Server IP 2}:{Port 2}


*It is completely fine to contain itself's IP and Port.


The config file of client is

datapath="chaindata/client"
keypath="key/client"
node="1.1.1.1:8146,1.1.1.2:8146"
  • datapath is the path where chaindata will be saved
  • keypath is the path where wallet keypair will be saved
  • node is the main node servers

*keypair contains your private key, thus it should be in safe directory

*If you deleted private key in the keypath, you cannot restore your wallet


description of node is on server's config


If you have any questions, please leave comment on this post or send us email : [email protected]



Example code – library (For JAVA Developers)

Source Code : https://github.com/BINDLABS/GarnetCustonClientExample
Usage of library is limited on Alpha version. We are working on this to provide various features in the future.

If you are building new project, Add library to your project and follow this instruction.

1.  Create node arraylist

ArrayList<Node> nodes = new ArrayList<Node>();

2. Add nodes that you have set on servers.

 nodes.add(new Node("127.0.0.1",8146));

3. Init Main_Client by

 Main_Client mc = new Main_Client("chaindata/client","clientkey",nodes,ll);

Main_Client({Data Path},{Key Path},{ArrayList<Node>},Listener);


Listener should be created before init process.

static OnLoadListener ll = new OnLoadListener() {

   @Override
   public void OnBalanceLoadListener(String balance){
       System.out.println("my balance : "+balance+"coin");
   }

   @Override
   public void OnReceiveListener(double amount){
       System.out.println("Received : "+amount+"coin");
   }

   @Override
   public void OnSuccessfullySendListener(double amount,String balance){     
       System.out.println("sent successfully");
   }

}; 

As you can see, the listener names imply the features.


Methods that you can use with the Main_Client

1. getting wallet address

mc.getWalletAddress();

2. getting amount of coin in my wallet

mc.getBalance();

3. getting amount of coin in a specific wallet

mc.getBalance(wallet);

4. sending coin

mc.send(wallet,amount); 

5. getting latest block

mc.getLastBlock();


This blockchain system does not have block interval, It creates block when someone makes transaction. Thus, you can build a blockchain that supports real-time transaction.
We use our own algorithm that makes this possible. The algorithm prohibits double spending and creating multiple chains when transactions made concurrently. If you find any problem or error, please contact us with specific information. Your contribution will be applied on the next version.


As we mentioned above, this version of library is not a proper version, we are working on it to provide more useful features.
Thank you.




이번 버전의 솔루션은 개발자 및 테스트를 위한 알파버전으로, 기존의 가상화폐 기능만을 구현할 수 있습니다. 솔루션은 서버버전, 클라이언트버전, 개발자 라이브러리 버전 으로 제공됩니다. 자바 개발자는 프라이빗 블록체인 메인노드 서버를 설정하고, 라이브러리를 활용하여 지갑과 같은 어플리케이션을 제작 할 수 있습니다. 개발자가 아닌경우, 클라우드 혹은 가상서버 호스팅을 받은곳에 서버버전을 올려서 개인 블록체인을 구축하고, 클라이언트 버전을 지갑처럼 사용할 수 있습니다. 서버와 클라이언트 세팅은 텍스트파일로 이루어져 보다 쉽게 설정할 수 있습니다.

이번 글에서는 서버버전과 클라이언트 버전의 세팅을 어떻게 하는지 간단하게 설명하고, 개발자가 라이브러리를 어떻게 사용할 수 있는지 간단한 예제를 통해 설명드리도록 하겠습니다.

서버버전 - 실행가능한 프로그램과 설정파일을 말합니다. 압축을풀어 나온 파일들을 한 폴더에 넣고 아래 코드를 통해 실행하실 수 있습니다.

java -jar server.jar 

클라이언트버전 - 실행가능한 프로그램과 설정파일을 말합니다. 압축을풀어 나온 파일들을 한 폴더에 넣고 아래 코드를 통해 실행하실 수 있습니다.

java -jar client.jar 

라이브러리버전 - JAVA프로젝트에 추가하여 사용할 수 있는 라이브러리 입니다. jar 파일을 프로젝트에 import 하시고 Build Path 설정까지 해주시면 사용 가능합니다. 자세한 사용 방법은 하단에 예시에서 다루도록 하겠습니다.



다운로드 링크 – JAVA 

- 서버 : http://bindlabs.com/garnet/alpha/server.zip 

- 클라이언트 : http://bindlabs.com/garnet/alpha/client.zip 

- 라이브러리 : http://bindlabs.com/garnet/alpha/library.zip 

- 예제 : https://github.com/BINDLABS/GarnetCustonClientExample



서버와 클라이언트 설정 및 설명

 서버버전의 설정파일 내용

port="8146"
jsonport="8147"
signalingport="8888"
datapath="chaindata/server"
keypath="key/server"
genesis="BDCEB2GKA16GGA6LVJKN52UP3H73DKRE5BYT:10000000000000000;"
node="1.1.1.1:8146,1.1.1.2:8146"
  • port 는 메인 노드의 포트번호입니다. - 자바 어플리케이션끼리의 통신에 사용됩니다.
  • jsonport 는 텍스트형태의 통신에 사용되는 포트번호입니다. (미완성)
  • signalingport AppRTC에 사용되는 시그널링 서버 포트번호 입니다.
  • datapath 는 블록체인 데이터가 저장될 디렉토리 입니다.
  • keypath 는 키페어가 저장될 디렉토리 입니다.
  • genesis 는 제네시스 블록에 작성될 내용입니다.
  • node 는 메인 노드 리스트로, 서로 연결할 서버들 입니다.

*알파버전에서는 서버 키페어가 사용되지 않으므로 디렉토리를 어디로 설정하더라도 무방합니다.


genesis 의 포맷은 다음과 같습니다.

{지갑주소}:{지갑에 할당할 코인수};

*코인수는 '.'을 포함하면 안됩니다. 비트코인에서 '사토시' 단위로 100000000을 곱한 값입니다.

만약 두개 이상의 지갑주소에 코인을 할당하려면, 같은 포맷으로 추가하면 됩니다.

{지갑주소 1}:{지갑에 할당할 코인수 1};{지갑주소 2}:{지갑에 할당할 코인수 2};


node 포맷은 다음과 같습니다.

{서버 IP}:{포트번호}

여러개의 노드는 쉼표(,)로 구분합니다.

{서버 IP 1}:{포트번호 1},{서버 IP 2}:{포트번호 2}


*프로그램을 실행 할 서버 본인의 정보가 같이 들어가도 문제 없습니다.


클라이언트버전의 설정파일 내용

datapath="chaindata/client"
keypath="key/client"
node="1.1.1.1:8146,1.1.1.2:8146"
  • datapath 는 블록체인 데이터가 저장될 디렉토리 입니다.
  • keypath 는 키페어가 저장될 디렉토리 입니다.
  • node 는 메인 노드 리스트로, 서로 연결할 서버들 입니다.

*키페어는 개인키를 포함하므로 비교적 안전한 곳에 저장해두시길 권장합니다.

*키페어 디렉토리에서 키파일이 지워진 경우 기존의 지갑을 복구할 수 없습니다.


node 의 포맷과 설명은 위 '서버버전' 설명 부분에서 참고하시길 바랍니다.


만약 문제나 질문이 있다면 이곳에 댓글을 남겨주시거나, 이메일을 보내주세요 : [email protected]



예제 소스코드 – 라이브러리(JAVA 개발자용)

소스코드 : https://github.com/BINDLABS/GarnetCustonClientExample
알파버전의 활용도는 한정적입니다. 더 많은 기능을 지원할 수 있도록 작업중이니, 다음버전에 더 많은 기능을 가져오도록 하겠습니다.

새로운 프로젝트를 생성하거나 기존의 프로젝트에 추가시, 라이브러리 파일을 import 하시고 아래 설명을 따라해 주세요.

1.  노드 ArrayList를 만듭니다.

ArrayList<Node> nodes = new ArrayList<Node>();

2. 서버주소와 포트번호를 가지고 노드를 추가합니다.(여러개의 노드가 있다면 랜덤으로 한곳에만 연결합니다)

 nodes.add(new Node("127.0.0.1",8146));

3. Main_Client를 Init 합니다.

 Main_Client mc = new Main_Client("chaindata/client","clientkey",nodes,ll);

Main_Client({데이터저장소},{키페어저장소},{ArrayList<Node>},리스너);


리스너는 Main_Client를 init 하기 전에 명시되어 있어야 합니다.

static OnLoadListener ll = new OnLoadListener() {

   @Override
   public void OnBalanceLoadListener(String balance){
       System.out.println("my balance : "+balance+"coin");
   }

   @Override
   public void OnReceiveListener(double amount){
       System.out.println("Received : "+amount+"coin");
   }

   @Override
   public void OnSuccessfullySendListener(double amount,String balance){     
       System.out.println("sent successfully");
   }

}; 

리스너의 이름이 각자의 기능을 암시하므로 자세한 설명은 넘어가겠습니다.
질문이 있다면 댓글로 남겨주시면 답글로 답변 드리겠습니다.


Main_Client로 사용 가능한 함수들

1. 내 지갑주소 가져오기

mc.getWalletAddress();

2. 내지갑에 있는 코인 확인

mc.getBalance();

3. 특정 지갑주소에 있는 코인 확인

mc.getBalance(wallet);

4. 코인 보내기

mc.send(wallet,amount); 

5. 최신 블록 정보 가져오기

mc.getLastBlock();


이 블록체인 시스템은 블록생성주기가 없습니다. 누군가가 코인을 발송할 때 새로운 블록이 생성됩니다. 따라서 실시간 코인 거래가 가능합니다.

이중지급과 동시 거래 발생을 방지하는 자체 알고리즘이 적용되어있습니다. 이 알고리즘은 알파버전에서 많은 테스트를 진행중이며, 문제가 확인되면 상황 설명과 함께 연락 부탁드립니다.


위에서 말씀드린대로, 이 버전은 개발을 위한 알파버전입니다. 실제 프로젝트에 사용되어도 당장에 큰 문제는 없지만 앞으로 발생할 문제에 관해서는 해당 버전에서 책임을 지지 않습니다. 앞으로 더 많은 기능과 보안 업데이트를 통해 발전된 솔루션을 제공해 드리도록 하겠습니다.
감사합니다.

Sort:  

Congratulations @bindlabs! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You got your First payout

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

Do you like SteemitBoard's project? Vote for its witness and get one more award!

Congratulations @bindlabs! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

SteemitBoard - Witness Update
SteemitBoard to support the german speaking community meetups
Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.29
TRX 0.11
JST 0.033
BTC 63901.15
ETH 3133.40
USDT 1.00
SBD 4.05