본문 바로가기
개발/블록체인

TRON 기반 개발 기초 정리(로컬 개발)

by 개발자종혁 2020. 3. 13.
728x90

TRON 특징

https://developers.tron.network/docs/getting-started

 

tron이 내세우는 장점?

  • 퍼포먼스가 높다(TPS)
  • 확장성이 좋다(scalability)
  • 사용성이 좋다
  • 낮은 비용
  • 유저 친화적
  • Unique DPOS(Delegated Proof of Stake) 지분 증명 방식

 

Installation 

 

TRONBOX (npm) https://github.com/TRON-US/tronbox

 

Wallet-cli  https://github.com/tronprotocol/wallet-cli

 

 

Tron quickstart docker

 

git clone https://github.com/tronprotocol/docker-tron-quickstart

 

Installation

 

 

Tron 요소 (Tronbox/ tron web)

 

  • Tronbox
    • solidity 이용(native)
  • Tronweb
    •  ethereum web3 같은 기능

 

TRONBOX

Requirements

  • Node.js 8.0 +
  • Windows, linux, or mac os x

설치

$user@foo: npm install -g tronbox

출처: <https://github.com/TRON-US/tronbox>

 

명령어

 

Customer Tron-Box Project 시작

$user@foo: tronbox init

 

TRONWEB

installation

 

$user@foo: npm install tronweb
$user@foo: cp node_modules/tronweb/dist/TronWeb.js ./js/tronweb.js

 

 

Quickstart

환경

  • 최신 버전 Docker
  • Node.JS Console

출처: <https://developers.tron.network/docs/quickstart>

 

 

Tron 도커 이미지 이용하여 로컬 개발

필요사항

- Docker 최신 버전

 

실행하기

1. 이미지 pull

$ docker pull trontools/quickstart
Using default tag: latest
latest: Pulling from trontools/quickstart
898c46f3b1a1: Already exists
63366dfa0a50: Already exists
041d4cd74a92: Already exists
6e1bee0f8701: Already exists
322c8a0afea7: Pulling fs layer
38a74c37415b: Pull complete
cfdf90134a15: Pull complete
30e0c7fcb571: Pull complete
1c64b4c06eff: Pull complete
afb5f973a9d0: Pull complete
cb6be1d1eec7: Pull complete
ed1ccf57687d: Pull complete
d5cc6cdb5604: Pull complete
344ad5531b2e: Pull complete
f155eef883c9: Pull complete
6442240ba058: Pull complete
e26dbba54a7b: Pull complete
491ad686b686: Pull complete
ff6c8b6f52e6: Pull complete
4fd06e21ac62: Pull complete
4f2699c933fe: Pull complete
a325c71caa8d: Pull complete
1b7a3abfa66b: Pull complete
5da9e66fd3b1: Pull complete
8a00707f63ef: Pull complete
1936802d326d: Pull complete
7d7201d3ec18: Pull complete
203bc1a30288: Pull complete
595bfdb7b7c8: Pull complete
Digest: sha256:1b504d89c494237344e14d23be2e8bd55f5f5bf33bd99c8073136e52eefe09b3
Status: Downloaded newer image for trontools/quickstart:latest
docker.io/trontools/quickstart:latest

 

 

2. 시작/ mock 계좌 생성

$ docker run -it \
  -p 9090:9090 \
  --rm \
  --name tron \
  trontools/quickstart

------------------------------

Tron Quickstart v2.1.0

….

HD Wallet

==================
Mnemonic:      invest beef option smooth brand quit pond average drum grape glide stuff   
Base HD Path:  m/44'/195'/0'/0/{account_index}

GET 200  - 24041.502 ms

 

체크

$user@foo: docker exec -it tron ps aux


USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0  20044  1900 pts/0    Ss+  01:42   0:00 bash ./quickstart v2.0.0
root        13  0.2  0.0  50148  1740 pts/0    Sl+  01:42   0:00 redis-server *:6379
root        15  0.0  0.0  20044    40 pts/0    S+   01:42   0:00 bash ./quickstart v2.0.0
root        16 11.5 19.2 5277964 393692 pts/0  Sl+  01:42   0:31 java -jar FullNode.jar -c fullnode.conf --witness
root        43  0.1  1.8 930932 37456 ?        Ssl  01:42   0:00 PM2 v3.3.1: God Daemon (/root/.pm2)
root        54  0.2  2.6 939316 54880 ?        Ssl  01:42   0:00 /tron/eventron/eventron
root        67  0.5  3.1 941540 64212 pts/0    Sl+  01:42   0:01 node /tron/app
root        72  412 32.0 5208448 655136 pts/0  Sl+  01:42  18:49 java -jar BlockParser.jar --Node-list 127.0.0.1 --intial-block 1 -end -1 --event-server http://127.0.0.1:8060 --secret-key TNSpckEZhGfZ4ryidHG2fYWMARLpZ6U139
root       261  0.0  0.1  20176  3748 pts/1    Ss   01:46   0:00 bash
root       289  0.0  0.1  36068  3168 pts/1    R+   01:47   0:00 ps aux

 

옵션

 

-e 플래그로 이용 가능

docker run -it \
  -p 9090:9090 \
  --rm \
  --name tron \
  -e "accounts=20" \
  trontools/quickstart

 

List of options:

  • accounts=12 sets the number of generated accounts
  • useDefaultPrivateKey=true tells Quickstart to use the default account as accounts[0]
  • mnemonic=wrong bit chicken kitchen rat uses a specified mnemonic
  • defaultBalance=100000 sets the initial balance for the generated accounts (in the example to 100,000 TRX)
  • seed=ushwe63hgeWUS sets the seed to be used to generate the mnemonic (if none is passed)
  • hdPath=m/44'/60'/0'/0 sets a custom bit39 hdPath
  • formatJson=true formats the output
  • preapprove=... pre approved proposals 

 

검색

 

Base58

$user@foo: curl http://127.0.0.1:9090/admin/accounts

 

hexstring

$user@foo: curl http://127.0.0.1:9090/admin/accounts?format=hex

 

Both format

$user@foo:curl http://127.0.0.1:9090/admin/accounts?format=all

 

출처: <https://developers.tron.network/docs/quickstart>

728x90

댓글