tronbox 설치

트론 2018. 12. 17. 10:34

출처 : https://developers.tron.network/docs/tron-box-user-guide

동영상 보고 따라해보았는데  결과가 잘 안나온다.

테스트넷이든 메인넷이든 아직 안정화 될러면 시간이 조금 필요 한듯하다.

 

NPM tronbox 설치

npm install -g tronbox 

 

tutorial 디렉토리 생성

mkdir tutorial 

cd tutorial

 

sample coin 다운로드

 root@tkpark-VirtualBox:~/tuto# tronbox unbox metacoin
Downloading...
Unpacking...
Setting up...
Unbox successful. Sweet!

Commands:

  Compile:        tronbox compile
  Migrate:        npm run migrate
  Test contracts: tronbox test
  Run dev server: npm run dev
root@tkpark-VirtualBox:~/tuto#

 

contracts, migrations 파일 내용 확인

 

약간의 버그가 있어 보이지만,,, 파일 내용을 수정해도 development를 바라보는거

같아서  테스트 서버 shasta 내용을 development쪽으로 복사 해줘라,,,

tronbox.js 내용 편집  TronLink에서 테스트 서버 shasta 발급된 개인키 입력

 

   module.exports = {
  networks: {
    development: {
      // For trontools/quickstart docker image
      privateKey: 'shasta 발급된 개인키 ',
      consume_user_resource_percent: 30,
      fee_limit: 100000000,

      // Requires TronBox 2.1.9+ and Tron Quickstart 1.1.16+
      // fullHost: "http://127.0.0.1:9090",

      // The three settings below for TronBox < 2.1.9
      fullNode: "https://api.shasta.trongrid.io",
      solidityNode: "https://api.shasta.trongrid.io",
      eventServer: "https://api.shasta.trongrid.io",


      network_id: "2"
    }, 

 

tronbox-config.js  development테스트넷 입력

module.exports = {"development"};

 

compile  Compile contract source files

root@tkpark-VirtualBox:~/tuto# tronbox compile
Compiling ./contracts/ConvertLib.sol...
Compiling ./contracts/MetaCoin.sol...
Compiling ./contracts/Migrations.sol...

Compilation warnings encountered:

Warning: This is a pre-release compiler version, please do not use it in production.

Writing artifacts to ./build/contracts

 

 

migrate  Run migrations to deploy contracts

root@tkpark-VirtualBox:~/tuto# tronbox migrate --reset
Using network 'development'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
  Migrations:
    (base58) TKoohGjpDNLJKka47nFAbkLDBReRV3Vbev
    (hex) 416bea0f0a7b48200852e0a83342c87580d69dc042
Saving successful migration to network...
Saving artifacts...
Running migration: 2_deploy_contracts.js
  Deploying ConvertLib...
  ConvertLib:
    (base58) TTFLhejo2BabkmjLBAVSeCHs2WCde3iRyM
    (hex) 41bd8738a33c2e2739aaca24e96f1a7901f85fa038
  Linking ConvertLib to MetaCoin
  Deploying MetaCoin...
  MetaCoin:
    (base58) TRGeHatnpxB6g8GmAdDMgjyFzRQR9u7T8J
    (hex) 41a7d6109dc1284b5c20f041c35ab03729bd64def8
Saving successful migration to network...
Saving artifacts...
root@tkpark-VirtualBox:~/tuto#
 

 

test 디렉토리로 이동

oot@tkpark-VirtualBox:~/tuto# cd test
root@tkpark-VirtualBox:~/tuto/test# ls
helpers  metacoin.js
root@tkpark-VirtualBox:~/tuto/test# vi metacoin.js
 

 

 

metacoin.js 파일 편집  vi에서 set nu해서 31번째 줄에 추가 

     it("should put 10000 MetaCoin in the first account", async function () {
    const instance = await MetaCoin.deployed();
    console.log(instance.address);
    const balance = await instance.getBalance(accounts[0], {from: accounts[0]});
    assert.equal(balance, 10000, "10000 wasn't in the first account");
  });

  

 

 

tronbox test

root@tkpark-VirtualBox:~/tuto/test# tronbox test
Using network 'development'.

Deploying contracts to development network...

Warning: This version does not support tests written in Solidity.

Preparing Javascript tests (if any)...


  Contract: MetaCoin

YOUR ATTENTION, PLEASE.]
To test MetaCoin you should use Tron Quickstart (https://github.com/tronprotocol/docker-tron-quickstart) as your private network.
Alternatively, you must set your own accounts in the "before" statement in "test/metacoin.js".

      1) should verify that there are at least three available accounts
    ✓ should verify that the contract has been deployed by accounts[0] (482ms)
41f15ced9d571f1b43346c3e2bde233f797a948f5a
    ✓ should put 10000 MetaCoin in the first account (460ms)
Sleeping for 1 second... Slept.
    ✓ should call a function that depends on a linked library (1779ms)
    2) should send coins from account 0 to 1
    3) should send coins from account 1 to 2


  3 passing (3s)
  3 failing
 1) Contract: MetaCoin
       should verify that there are at least three available accounts:

      AssertionError: expected false to be true
      + expected - actual

      -false
      +true

      at Context.<anonymous> (metacoin.js:21:12)
      at TestRunner.startTest (/usr/local/lib/node_modules/tronbox/build/webpack:/packages/truffle-core/lib/testing/testrunner.js:106:1)
      at Context.<anonymous> (/usr/local/lib/node_modules/tronbox/build/webpack:/packages/truffle-core/lib/test.js:213:1)

  2) Contract: MetaCoin
       should send coins from account 0 to 1:

      accounts[1] does not exist. Use Tron Quickstart!
      + expected - actual

      -false
      +true

      at Context.<anonymous> (metacoin.js:46:12)
      at TestRunner.startTest (/usr/local/lib/node_modules/tronbox/build/webpack:/packages/truffle-core/lib/testing/testrunner.js:106:1)
      at Context.<anonymous> (/usr/local/lib/node_modules/tronbox/build/webpack:/packages/truffle-core/lib/test.js:213:1)

  3) Contract: MetaCoin
       should send coins from account 1 to 2:

      accounts[1] and/or accounts[2] do not exist. Use Tron Quickstart!
      + expected - actual

      -false
      +true

      at Context.<anonymous> (metacoin.js:61:12)
      at TestRunner.startTest (/usr/local/lib/node_modules/tronbox/build/webpack:/packages/truffle-core/lib/testing/testrunner.js:106:1)
      at Context.<anonymous> (/usr/local/lib/node_modules/tronbox/build/webpack:/packages/truffle-core/lib/test.js:213:1)

 

 

 

제대로 올라 간건지 모르겠다.

https://tronscan.org/#/tools/tron-convert-tool

빨간 부분을  아래 사이트에서 Ascii코드에 입력하고 인코딩 시켜 준다.

Base58_hexstring을 선택한다.

 

 

 

 

 

 

 

 

 

GET인자 바꾸어서 크롬에서 접속해보면 아무것도 없다 ㅋㅋ

 https://api.shasta.trongrid.io/event/contract/

sXHwS5pcWLYVdxtTES3gZXADuiwzhVob8JUfRQgLfyz6UQRAKM3EuHV1J

 

TronLink에서 테스트 TRX는 소모된거 같고,, 트렌젝션에 기록도 있다.

 

 

트론 shasta테스트넷  블록익스플러러가 덜 만들어서

제대로 올라간건지 아닌건지 ,,

 

아직 트론은 개발중인거 같다.

 

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

tron-web 분해하기1 (tronWeb.createAccount)  (0) 2018.12.17
tron-web 설치  (0) 2018.12.17
트론 shasta 테스트넷  (0) 2018.12.13
tron 파이썬 모듈  (0) 2018.12.13
트론 노드구축  (0) 2018.12.11
블로그 이미지

iesay

,