tron-web 설치

트론 2018. 12. 17. 15:24

ubuntu-18.04.1-desktop-amd64.iso

버추얼박스는 5.1.38 r122592 버전이다.

 

 

최근 버추얼박스가 vmware보다 더 리소스를 적게 먹는다.

많이 성능이 좋아 졌다.

거의 무료가 유료를 앞질렀다고 보면 된다.

root@tkpark-VirtualBox:~# uname -a
Linux tkpark-VirtualBox 4.15.0-39-generic #42-Ubuntu SMP Tue Oct 23 15:48:01 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
root@tkpark-VirtualBox:~#
 

 

출처 : https://github.com/tronprotocol/tron-web

 

공식 사이트 대로 슬슬 삽질을 시작해 보자.

 npm install tronweb

git clone https://github.com/tronprotocol/tron-web.git
cd tron-web
yarn
yarn build -d
yarn example

 

 

yarn 버전이 너무 낮아서 안됨 몰라서 GURU개발자 에게 물어봄

root@tkpark-VirtualBox:~/tron-web# ls
dist           LICENSE       scripts  webpack.config.js
examples       package.json  src      yarn-error.log
karma.conf.js  README.md     test     yarn.lock
root@tkpark-VirtualBox:~/tron-web# yarn
00h00m00s 0/0: : ERROR: There are no scenarios; must have at least one.
root@tkpark-VirtualBox:~/tron-web# yarn --version
0.32
root@tkpark-VirtualBox:~/tron-web#
 

 

 

yarn 업데이트를 완료 하고

#curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

#echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

#sudo apt update
#sudo apt install yarn

 4줄이다.

 

root@tkpark-VirtualBox:~/tron-web# yarn --version
yarn install v1.12.3

위에 순서대로 yarn, build , example도 실행해 본다.

 

root@tkpark-VirtualBox:~/tron-web# yarn example
yarn run v1.12.3
$ node ./examples/server
Error: fullNode is not connected
Error: solidityNode is not connected
Error: eventServer is not connected

노드는 알아서 잘 적어 주면 된다.

 

vi /examples/server/index.js

const fullNode = 'https://api.shasta.trongrid.io';
const solidityNode = 'https://api.shasta.trongrid.io';
const eventServer = 'https://api.shasta.trongrid.io';
const privateKey = 'Tron링크 계좌 만들어서 PK입력'; 

 

node ./examples/server/ 실행결과

      "id": "1000009"
    },
    {
      "owner_address": "410c7c4f2e280aa73561efe5b92355cc12a150f566",
      "name": "CoconutToken",
      "abbr": "FTKN",
      "total_supply": 900000000,
      "frozen_supply": [
        {
          "frozen_amount": 5,
          "frozen_days": 1
        }
      ],
      "trx_num": 1,
      "num": 1,
      "start_time": 1544511604212,
      "end_time": 1547103604211,
      "description": "Useless utility token",
      "url": "https://google.com",
      "id": "1000002"
    }
  ]

 

root@tkpark-VirtualBox:~/tron-web# node ./examples/server/

 

 

 

 

 

 

 

참고 사이트

https://github.com/tronprotocol/Documentation/blob/master/TRX/Tron-http.md

 

명령어 하나 하나 실행해서 해당 명령어가 멀 뜻하는지 판단

curl -X POST  https://api.trongrid.io/walletsolidity/getaccount -d '{"address":

 "41E552F6487585C2B58BC2C9BB4492BC1F17132CD0"}'

root@tkpark-VirtualBox:~/tron-web# curl -X POST  https://api.trongrid.io/walletsolidity/getaccount -d '{"address": "41E552F6487585C2B58BC2C9BB4492BC1F17132CD0"}' | more
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
{"account_name": "636363797979636363","address": "41e552f6487585c2b58bc2c9bb4492
bc1f17132cd0","balance": 10085289,"asset": [{"key": "TRX","value": 1},{"key": "D
EX","value": 0},{"key": "Kitty","value": 0},{"key": "SEED","value": 0},{"key": "
WIN","value": 0},{"key": "Perogies","value": 0},{"key": "TRXTestCoin","value": 0
},{"key": "ofoBike","value": 7},{"key": "Skypeople","value": 0},{"key": "OnePiec
e","value": 0},{"key": "ZZZDOGETRXZZ","value": 0},{"key": "IGG","value": 0},{"ke
y": "Messenger","value": 0},{"key": "justinsuntron","value": 0},{"key": "Bitcoin
100 ","value": 0},{"key": "bittorrent","value": 0},{"key": "IPFS","value": 33},{"key
 

 

 

 

 

트론 개발자 웹사이트

https://www.trongrid.io/

 

oot@tkpark-VirtualBox:~# tronbox
Tronbox v2.2.3-prev.0 - a development framework for tronweb

Usage: tronbox <command> [options]

Commands:
  init     Initialize new and empty tronBox project
  compile  Compile contract source files
  migrate  Run migrations to deploy contracts
  deploy   (alias for migrate)
  build    Execute build pipeline (if configuration present)
  test     Run JavaScript and Solidity tests
  console  Run a console with contract abstractions and commands available
  create   Helper to create new contracts, migrations and tests
  watch    Watch filesystem for changes and rebuild the project automatically
  serve    Serve the build directory on localhost and watch for changes
  exec     Execute a JS module within this tronBox environment
  unbox    Download a tronbox Box, a pre-built tronbox project
  version  Show version number and exit

See more at http://tronboxframework.com/docs

 

응답 결과

curl -G https://api.trongrid.io/wallet/getnowblock 

 

1544596134000,
"fee_limit":6000000,
"timestamp":1544596079147
}
},
{
"ret":[
{
 "contractRet":"SUCCESS"
}
],
"signature":[
"4ba313dd2cd877286d2e2d6a5c987367f60db72d6061248c822959ee8b88980bf8eda99829de336b0f333621976f1f6c38c57babd040ca3a8caccfd91c8efa7500"
],
"txID":"402747a4056cf30e5a062da58ddcdfb2f76643de45ceedbb23a6c84f992f6105",
"raw_data":{
"contract":[
 {
  "parameter":{
   "value":{
    "data":"a3082be900000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001",
    "owner_address":"416b856cb82ad984b5ca5ab6d0a48c550574c4901d",
    "contract_address":"412ec5f63da00583085d4c2c5e8ec3c8d17bde5e28",
    "call_value":550000000
   },
   "type_url":"type.googleapis.com/protocol.TriggerSmartContract"
  },
  "type":"TriggerSmartContract"
 }
],
"ref_block_bytes":"5a0f",
"ref_block_hash":"bddd829263d1947e",
"expiration":1544596134000,
"fee_limit":6000000,
"timestamp":1544596078871
}
},
{
"ret":[
{
 "contractRet":"SUCCESS"
}
],
"signature":[
"9fa491d3b5eb10fa5c96969d0a223e0dcffc45ac71e50e30bca125396f9a8da5422940b0b1f6832436a4fc7286d5ffe1447381ab4616ef6d337dc3d91be41b6400"
],
"txID":"a098d414205db9c9a83daefc71f6a7bb24f7484210d1bd11d3a90dc5fd48af94",
"raw_data":{
"contract":[
 {
  "parameter":{
   "value":{
    "data":"a3082be900000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001",
    "owner_address":"4131e1ec8054b56a857e970656a4f16a95e3cfa4b7",
    "contract_address":"412ec5f63da00583085d4c2c5e8ec3c8d17bde5e28",
    "call_value":1200000000
   },
   "type_url":"type.googleapis.com/protocol.TriggerSmartContract"
  },
  "type":"TriggerSmartContract"
 }
],
"ref_block_bytes":"5a0f",
"ref_block_hash":"bddd829263d1947e",
"expiration":1544596134000,
"fee_limit":6000000,
"timestamp":1544596079403
}
}
]
}

 

 

 

 

 

 

 

 

 

 

 

'트론' 카테고리의 다른 글

tron-web 분해하기2(transactionBuilder.sendTrx)  (0) 2018.12.18
tron-web 분해하기1 (tronWeb.createAccount)  (0) 2018.12.17
tronbox 설치  (1) 2018.12.17
트론 shasta 테스트넷  (0) 2018.12.13
tron 파이썬 모듈  (0) 2018.12.13
블로그 이미지

iesay

,