Giter Club home page Giter Club logo

tronbox's Introduction

TronBox

TronBox

TronBox is a tool for developing, testing, and deploying smart contracts. It is designed for blockchains using the TRON Virtual Machine (TVM).

  • Built-in smart contract compilation, linking, deployment, and binary management.
  • External script runner that executes scripts within a TronBox environment.
  • Interactive console for direct contract communication.
  • Automated contract testing for rapid development.
  • Scriptable, extensible deployment & migrations framework.
  • Network management for deploying to any number of public & private networks.

TronBox is a fork of Truffle.

Quick Start

Install

Before you can use TronBox, install it using the npm command. For details, see Install TronBox.

$ npm install -g tronbox

Note: To verify the PGP signature, see here.

Create a default Tron-Box Project

You can create a bare project without smart contracts, run:

$ tronbox init

Once this operation is completed, you'll now have a project structure with the following items:

contracts/: Directory for Solidity contracts
migrations/: Directory for scriptable deployment files
test/: Directory for test files for testing your application and contracts
tronbox.js: TronBox configuration file

For those getting started, you can use TronBox Boxes, which offers example applications and project templates. For details, see Create a TronBox Project.

Compile

If you want to only compile, run:

$ tronbox compile

To compile all contracts, use the --compile-all option.
Specify a network using the --network option. Network name must exist in the configuration. For details, see Compile a Project.

Migrate

To deploy our smart contracts, you need to connect to a blockchain. Use the TronBox Runtime Environment to create and interact with the blockchain. For details, see Contract Deployment (Migrations).

To run your migrations, run the following:

$ tronbox migrate

Test

To run all tests, run:

$ tronbox test

Alternatively, you can specify a path to a specific file you want to run: tronbox test ./path/to/test/file.js. For details, see Test Your Contracts.

Interact with the contract

To interact with the contract, run:

$ tronbox console

You will see the following prompt:

$ tronbox(development)>

The name in the parentheses of the prompt tronbox(development)> is the network that is currently connected to. For details, see Interact with a Contract.

Integrity Check

  • The package files will be signed using a GPG key pair, and the correctness of the signature will be verified using the following public key:
    pub: 82C1 BB84 1BFA FD01 9CA6  1ACB E98F C329 87F3 BF76
    uid: [email protected]
    

Development

To dive deeper into advanced topics of the TronBox project lifecycle, please see the Official TronBox Documentation for guides, tips, and examples.

To contribute, see CONTRIUTING.MD.

tronbox's People

Contributors

bluehoopor avatar darcac avatar dependabot[bot] avatar dinhha avatar folowing avatar jz2120100058 avatar kangjiancheng avatar kjc233 avatar kookiekrak avatar llwslc avatar shenyongri110 avatar start940315 avatar sullof avatar tycm4109 avatar ujwalbattar avatar unforgivenzzz avatar unicornonea avatar zhaohong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tronbox's Issues

Failed to get bytes length on shasta

I used Tronbox first to test my smart contract and everything is okay
version:Tronbox v2.7.20
Solidity version: I'm using 0.5.15
My function is like

function reward(address winner, bytes calldata userStep) external {
uint n = userStep.length;
...
}

After deploying to shasta, I just can't get the length of bytes calldata userStep, it's always 0!
but tronbox test is OK

Cannot install tronbox

Hi, I am trying to install tronbox on my machine and things are not doing so good for me.

I have a fresh install of MacOS

System Software Overview:

  System Version:	macOS 10.15.1 (19B88)
  Kernel Version:	Darwin 19.0.0
  Boot Volume:	Macintosh HD
  Boot Mode:	Normal

And node things:

zeus:~ vladar$ npm -v
6.12.1
zeus:~ vladar$ node -v
v13.1.0
zeus:~ vladar$ node-gyp -v
v6.0.1

But when I try to install tronbox it fails for some reason. This looks like some permission failure but I am really unaware what could it be? Did you guys see something like it before?

Full error log:

zeus:~ vladar$ sudo npm install -g tronbox

npm WARN deprecated [email protected]: One of your dependencies needs to upgrade to fsevents v2: 1) Proper nodejs v10+ support 2) No more fetching binaries from AWS, smaller package size
npm WARN deprecated [email protected]: use String.prototype.padStart()
npm WARN deprecated [email protected]: WARNING: This package has been renamed to @truffle/contract.
npm WARN deprecated [email protected]: WARNING: This package has been renamed to @truffle/contract-schema.
npm WARN deprecated [email protected]: WARNING: This package has been renamed to @truffle/interface-adapter.
npm WARN deprecated [email protected]: WARNING: This package has been renamed to @truffle/blockchain-utils.
npm WARN deprecated [email protected]: WARNING: This package has been renamed to @truffle/error.
npm WARN deprecated [email protected]: core-js@<3.0 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated [email protected]: WARNING: This package has been renamed to @truffle/config.
npm WARN deprecated [email protected]: WARNING: This package has been renamed to @truffle/provider.
/usr/local/bin/tronbox -> /usr/local/lib/node_modules/tronbox/build/tronbox.js

> [email protected] install /usr/local/lib/node_modules/tronbox/node_modules/fsevents
> node install

node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v79 ABI, unknown) (falling back to source compile with node-gyp) 
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/usr/local/lib/node_modules/tronbox/node_modules/fsevents/lib' 
gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/Users/vladar/Library/Caches/node-gyp/13.1.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/tronbox/node_modules/fsevents/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/tronbox/node_modules/fsevents/.node-gyp'
gyp ERR! System Darwin 19.0.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/local/lib/node_modules/tronbox/node_modules/fsevents/lib/binding/Release/node-v79-darwin-x64/fse.node" "--module_name=fse" "--module_path=/usr/local/lib/node_modules/tronbox/node_modules/fsevents/lib/binding/Release/node-v79-darwin-x64" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v79"
gyp ERR! cwd /usr/local/lib/node_modules/tronbox/node_modules/fsevents
gyp ERR! node -v v13.1.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/tronbox/node_modules/fsevents/lib/binding/Release/node-v79-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/tronbox/node_modules/fsevents/lib/binding/Release/node-v79-darwin-x64 --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v79' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/tronbox/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1028:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
node-pre-gyp ERR! System Darwin 19.0.0
node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/tronbox/node_modules/fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/tronbox/node_modules/fsevents
node-pre-gyp ERR! node -v v13.1.0
node-pre-gyp ERR! node-pre-gyp -v v0.12.0
node-pre-gyp ERR! not ok 
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/tronbox/node_modules/fsevents/lib/binding/Release/node-v79-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/tronbox/node_modules/fsevents/lib/binding/Release/node-v79-darwin-x64 --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v79' (1)

> [email protected] install /usr/local/lib/node_modules/tronbox/node_modules/keccak
> npm run rebuild || echo "Keccak bindings compilation fail. Pure JS implementation will be used."


> [email protected] rebuild /usr/local/lib/node_modules/tronbox/node_modules/keccak
> node-gyp rebuild

gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/Users/vladar/Library/Caches/node-gyp/13.1.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/tronbox/node_modules/keccak/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/tronbox/node_modules/keccak/.node-gyp'
gyp ERR! System Darwin 19.0.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/tronbox/node_modules/keccak
gyp ERR! node -v v13.1.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Keccak bindings compilation fail. Pure JS implementation will be used.

> [email protected] install /usr/local/lib/node_modules/tronbox/node_modules/secp256k1
> npm run rebuild || echo "Secp256k1 bindings compilation fail. Pure JS implementation will be used."


> [email protected] rebuild /usr/local/lib/node_modules/tronbox/node_modules/secp256k1
> node-gyp rebuild

gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/Users/vladar/Library/Caches/node-gyp/13.1.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/tronbox/node_modules/secp256k1/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/tronbox/node_modules/secp256k1/.node-gyp'
gyp ERR! System Darwin 19.0.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/tronbox/node_modules/secp256k1
gyp ERR! node -v v13.1.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Secp256k1 bindings compilation fail. Pure JS implementation will be used.

> [email protected] install /usr/local/lib/node_modules/tronbox/node_modules/sha3
> node-gyp rebuild

gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/Users/vladar/Library/Caches/node-gyp/13.1.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/tronbox/node_modules/sha3/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/tronbox/node_modules/sha3/.node-gyp'
gyp ERR! System Darwin 19.0.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/tronbox/node_modules/sha3
gyp ERR! node -v v13.1.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/tronbox/node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node install`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/vladar/.npm/_logs/2019-11-18T15_03_31_416Z-debug.log

UPDATE 1

I managed to pass this by manually fixing privileges for /usr/local/lib/node_modules/ folder. Not sure why is this being installed as a user nobody but ok. Next error i got was that options.uid should be of type int32. This is a super weird message I have never previously seen.

npm ERR! code ERR_INVALID_ARG_TYPE
npm ERR! The "options.uid" property must be of type int32. Received type number

UPDATE 2

I can confirm that this issue happens with LTS Node as well

zeus:~ vladar$ node -v
v12.13.0
zeus:~ vladar$ npm -v
6.12.0

Error on passing BigNumber to tronWeb.utils.abi.encodeParams

Code in question:

var sig = await tronWeb.trx.signMessage(tronWeb.sha3("TestSeed"));
var commit = tronWeb.utils.abi.encodeParams(['uint256'], [tronWeb.toBigNumber(sig)]);

The error also happens if i do:

tronWeb.utils.abi.encodeParams(['uint256'], [sig]);

Error:
image

How to set callValue or msg.value from migrations.js

I am learning solidity smart contract. I am using tronbox as my development framework. While deploying contract, I need to send some trx to contract address. So that It will be available in msg.value. For example this is my constructor function,

constructor() public payable {
    require(msg.value == 2 trx, "2 trx initial funding required");
}

How to send 2 trx, while deploying contract in migration file. For example this is my migration file,

var SimpleBank = artifacts.require("./Simple.sol");
var Migrations = artifacts.require("./Migrations.sol");

module.exports = function(deployer) {
  deployer.deploy(Simple);
  deployer.deploy(Migrations);
};

tronbox compile with windows

The error is

Error: Error parsing C:/dev/temp/contracts/Migrations.sol: Command failed: tronbox --download-compiler 0.6.0
    at checkExecSyncError (child_process.js:575:11)
    at execSync (child_process.js:612:13)
    at getWrapper (C:\Users\***\AppData\Roaming\npm\node_modules\tronbox\build\components\TronSolc.js:1:1717)
    at Object.parseImports (C:\Users\***\AppData\Roaming\npm\node_modules\tronbox\build\components\Compile\parser.js:1:2345)
    at C:\Users\***\AppData\Roaming\npm\node_modules\tronbox\build\components\Compile\profiler.js:1:4981
    at C:\Users\***\AppData\Roaming\npm\node_modules\tronbox\build\components\Resolver\index.js:1:1727
    at C:\Users\***\AppData\Roaming\npm\node_modules\tronbox\node_modules\async\internal\onlyOnce.js:12:16
    at next (C:\Users\***\AppData\Roaming\npm\node_modules\tronbox\node_modules\async\whilst.js:68:18)
    at C:\Users\***\AppData\Roaming\npm\node_modules\tronbox\build\components\Resolver\index.js:1:1495
    at C:\Users\***\AppData\Roaming\npm\node_modules\tronbox\build\components\Resolver\fs.js:1:1685

Config:

  networks: {
    mainnet: {
      // Don't put your private key here:
      privateKey: process.env.PRIVATE_KEY_MAINNET,
      /*
Create a .env file (it must be gitignored) containing something like

  export PRIVATE_KEY_MAINNET=4E7FECCB71207B867C495B51A9758B104B1D4422088A87F4978BE64636656243

Then, run the migration with:

  source .env && tronbox migrate --network mainnet

*/
      userFeePercentage: 100,
      feeLimit: 1e8,
      fullHost: 'https://api.trongrid.io',
      network_id: '1'
    },
    shasta: {
      privateKey: process.env.PRIVATE_KEY_SHASTA,
      userFeePercentage: 50,
      feeLimit: 1e8,
      fullHost: 'https://api.shasta.trongrid.io',
      network_id: '2'
    },
    nile: {
      privateKey: process.env.PRIVATE_KEY_NILE,
      userFeePercentage: 100,
      feeLimit: 1e8,
      fullHost: 'https://api.nileex.io',
      network_id: '3'
    },
    development: {
      // For trontools/quickstart docker image
      privateKey: 'da146374a75310b9666e834ee4ad0866d6f4035967bfc76217c5a495fff9f0d0',
      userFeePercentage: 0,
      feeLimit: 1e8,
      fullHost: 'http://127.0.0.1:' + port,
      network_id: '9'
    },
    compilers: {
      solc: {
        version: '0.6.0'
      }
    }
  }
}

Windows error:
Microsoft JScript compilation error

Any idea?

ERROR: OTHER_ERROR (other error : The key argument cannot be null) while broadcasting the transaction to create the contract Migrations

$ tronbox migrate --network development
Using network 'development'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
ERROR: OTHER_ERROR (other error : The key argument cannot be null) while broadcasting the transaction to create the contract Migrations
module.exports = {
  networks: {
    development: {
      privateKey
        process.env.PRIVATE_KEY,
      userFeePercentage: 30,
      feeLimit: 1e8,
      fullHost: "http://localhost:16667",
      network_id: "*",
    },
    compilers: {
      solc: {
        version: "0.5.10",
      },
    },
  },
};

Do you know what is causing this error?

Failed to compile solidity 0.6.0 special syntax

version:Tronbox v2.7.18-beta.1
Project:tronbox unbox metacoin
ERROR : tronbox compile --all
Compile solidity 0.6.0 special syntax, use tronbox test command to get the following error!!
but tronbox compile --all is OK
image

Tronbox 'test' command deploy migrations only once.

tronbox test

Tronbox test command must re-deploy all of migrations at the beginning of every test file to ensure you have a fresh set of contracts to test against. But the migrations are deployed only once.
contract() function in test does not work properly...

Tronbox v2.7.4
Solidity v0.5.8 (tron-solc)

Allow test_dictionary to be modified via configuration

At the moment i have a project setup with my tests being in folder:
"/tests/contracts/XXXContractTest.js"

However i have to run all the tests file by file cause tronbox test does not support wildcards like: "tronbox test /test/contracts/*.js"

Either make wildcard + folder support for the tronbox test argument, or allow to set the below configuration via tronbox-config.js.

https://github.com/TRON-US/tronbox/blob/8d9860e28bce460cdfebb2a3df3d6048c2c9ab50/src/components/Config.js#L94

Can't link library

Any library will lead to
ERROR: TypeError: Cannot read property 'forEach' of undefined

Example code:

 await deployer.deploy(SafeMath);
 await deployer.link(SafeMath, Presale);
 await deployer.deploy(Presale);

PayloadTooLargeError: request entity too large on Migration to devnet

Hi. I have this error POST 413 1049 - 0.834 ms

PayloadTooLargeError: request entity too large
at readStream (/tron/app/node_modules/raw-body/index.js:155:17)
at getRawBody (/tron/app/node_modules/raw-body/index.js:108:12)
at read (/tron/app/node_modules/body-parser/lib/read.js:77:3)
at jsonParser (/tron/app/node_modules/body-parser/lib/types/json.js:135:5)
at Layer.handle [as handle_request] (/tron/app/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/tron/app/node_modules/express/lib/router/index.js:317:13)
at /tron/app/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/tron/app/node_modules/express/lib/router/index.js:335:12)
at next (/tron/app/node_modules/express/lib/router/index.js:275:10)
at logger (/tron/app/node_modules/morgan/index.js:144:5)

Deployed only two contracts

root@user:~/Desktop/chbets_contracts$ tronbox migrate --reset --network development --limit 100
// pk
Using network 'development'.

Running migration: 1_initial_migration.js
Replacing Migrations...
Migrations:
(base58) TPY9bGPSj2xZ3drsWHCg9u9FWJr4SJvyye
(hex) 4194d483e5535e487a7348f18699918b6111316b61
Saving successful migration to network...
Saving artifacts...
Running migration: 2_deploy_contracts.js
Replacing Affiliates...
Affiliates:
(base58) TMzWaw5WSbqokxsbs3mWF2oKeaZFWpCkC4
(hex) 4183e09a918035624e0b05e322ec50d4cd419f03ce
Saving successful migration to network...
Saving artifacts...
Running migration: 3_deploy_contracts.js
Running step...
Deploying SafeMath...
SafeMath:
(base58) TN8E32RjP3dsNLB167eUTWLM1ow6B1tR63
(hex) 4185561dba165a6af2bdd6d8ca5d2fb53a17288001
Linking SafeMath to Test
Deploying Test...

// failed here

Can you fix it or give me the way to solve it manually.
System Nodejs v.8.16, Ubuntu16.04

PS. Not compiled on W10 and Mac.

Cannot deploy the library in migrations

Hi, I'm trying to deploy contracts by tronbox migrate and got error.

I have my library for instance:

pragma solidity ^0.5.14;

library SolRsaVerify {

    function memcpy(uint _dest, uint _src, uint _len) pure internal {
        // Copy word-length chunks while possible
        for (; _len >= 32; _len -= 32) {
            assembly {
                mstore(_dest, mload(_src))
            }
            _dest += 32;
            _src += 32;
        }

        // Copy remaining bytes
        uint mask = 256 ** (32 - _len) - 1;
        assembly {
            let srcpart := and(mload(_src), not(mask))
            let destpart := and(mload(_dest), mask)
            mstore(_dest, or(destpart, srcpart))
        }
    }

}

Error:

Deploying SolRsaVerify...

ERROR: TypeError: Cannot read property 'forEach' of undefined

I managed to pass this by manually add this function to my library. Not sure why this can fix the error

function convert() public pure returns (uint) { return 0; }

Linux install tronbox failed

npm install -g tronbox
got error:

npm WARN deprecated [email protected]: use String.prototype.padStart()
npm WARN deprecated [email protected]: WARNING: This package has been renamed to @truffle/contract.
npm WARN deprecated [email protected]: WARNING: This package has been renamed to @truffle/error.
npm WARN deprecated [email protected]: WARNING: This package has been renamed to @truffle/blockchain-utils.
npm WARN deprecated [email protected]: WARNING: This package has been renamed to @truffle/contract-schema.
npm WARN deprecated [email protected]: WARNING: This package has been renamed to @truffle/interface-adapter.
npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
/usr/local/node-v6/bin/tronbox -> /usr/local/node-v6/lib/node_modules/tronbox/build/tronbox.js

[email protected] install /usr/local/node-v6/lib/node_modules/tronbox/node_modules/keccak
npm run rebuild || echo "Keccak bindings compilation fail. Pure JS implementation will be used."

[email protected] rebuild /usr/local/node-v6/lib/node_modules/tronbox/node_modules/keccak
node-gyp rebuild

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/6.10.3"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/node-v6/lib/node_modules/tronbox/node_modules/keccak/.node-gyp"
make: Entering directory /usr/local/node-v6/lib/node_modules/tronbox/node_modules/keccak/build' CXX(target) Release/obj.target/keccak/src/addon.o make: g++: Command not found make: *** [Release/obj.target/keccak/src/addon.o] Error 127 make: Leaving directory /usr/local/node-v6/lib/node_modules/tronbox/node_modules/keccak/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/node-v6/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 3.10.0-514.26.2.el7.x86_64
gyp ERR! command "/usr/local/node-v6/bin/node" "/usr/local/node-v6/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/node-v6/lib/node_modules/tronbox/node_modules/keccak
gyp ERR! node -v v6.10.3
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok

npm ERR! Linux 3.10.0-514.26.2.el7.x86_64
npm ERR! argv "/usr/local/node-v6/bin/node" "/usr/local/node-v6/bin/npm" "run" "rebuild"
npm ERR! node v6.10.3
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] rebuild: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] rebuild script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the keccak package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs keccak
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls keccak
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /usr/local/node-v6/lib/node_modules/tronbox/node_modules/keccak/npm-debug.log
Keccak bindings compilation fail. Pure JS implementation will be used.

[email protected] install /usr/local/node-v6/lib/node_modules/tronbox/node_modules/websocket
(node-gyp rebuild 2> builderror.log) || (exit 0)

make: Entering directory /usr/local/node-v6/lib/node_modules/tronbox/node_modules/websocket/build' CXX(target) Release/obj.target/bufferutil/src/bufferutil.o make: Leaving directory /usr/local/node-v6/lib/node_modules/tronbox/node_modules/websocket/build'

[email protected] postinstall /usr/local/node-v6/lib/node_modules/tronbox/node_modules/core-js
node -e "try{require('./postinstall')}catch(e){}"

and tronbox compile got error too

error:
usr/local/node-v6/lib/node_modules/tronbox/node_modules/find-up/index.js:8
module.exports = async (name, options = {}) => {
^
SyntaxError: Unexpected token (
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (/usr/local/node-v6/lib/node_modules/tronbox/build/components/Config.js:1:245)
[root@VM_175_27_centos TronJoke]# npm start run

[email protected] start /home/gitdapp/TronJoke
react-scripts start "run"

sh: react-scripts: command not found

npm ERR! Linux 3.10.0-514.26.2.el7.x86_64
npm ERR! argv "/usr/local/node-v6/bin/node" "/usr/local/node-v6/bin/npm" "start" "run"
npm ERR! node v6.10.3
npm ERR! npm v3.10.10
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] start: react-scripts start "run"
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] start script 'react-scripts start "run"'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the tron-messageboard package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! react-scripts start "run"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs tron-messageboard
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls tron-messageboard
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! Please include the following file with any support request:

how too fix that?

thanks a lot

Cannot use all accounts in migrations

module.exports = function(deployer, network, accounts) {
  console.log("accounts: ", accounts);
  deployer.deploy(Migrations);
  deployer.deploy(Contract1, accounts[0], accounts[0]);
};

accounts only returns the very first account and not the entire array and accounts[0] returns the first character

Invalid operation code: opCode[47]

I'm not sure whether this problem should be reported here or in docker-tron-quickstart but the latter seems abandoned.

Problem

Accessing contract's balance by address(this).balance results in error class org.tron.common.runtime.vm.program.Program$IllegalOperationException : Invalid operation code: opCode[47]; when testing contracts with Tron Quickstart Docker image. On Shasta, it works well.

Judging by the opcode, it's SELFBALANCE.

Workaround

As a workaround, it's possible to do something like this

address self = address(this);
uint256 balance = self.balance;

Although this solves the problem with my own code, it's still a problem with third-party libraries like OpenZeppelin.

Diagnostic info

TronBox v2.7.22, Solidity 0.6.12 or 0.7.6, Tron Quickstart v2.0.17

Use another account for calls in a test

Hi,

How can I change a sender of contract call in my tests?

Like from: field in Truffle.

await contract.someMethod(arg1, arg2, {
  from: myAccount,
});

There's a method tronWeb.setAddress(). Looks like it should change the sender, but it doesn't do that in my tests.

Thank you!

solidity 0.6.2 or newer

Are there plans on adding solidity 0.6.2 or newer compilers? Would that be hard to do?
Asking because openzeppelin requires 0.6.2 for most of its functionality, and 0.6.9 or newer for some.

Test suite requires solc 0.5.4 or earlier

When creating contracts with tronbox v2.7.10 tronbox test does not run unless the solc declaration is 0.5.4 or earlier. However, tronbox compile command works O.K.

My contract begins with pragma solidity ^0.5.8; and my tronbox.js includes compilers: { solc: { version: '0.5.8' } }

The error message is

Error parsing [...]/contracts/Agile.sol: ParsedContract.sol:2:1:
ParserError: Source file requires different compiler version (current compiler is 0.5.4+commit.7b0de266.mod.Emscripten.clang)

When those values are changed to 0.5.4 the response is

6 passing (9s)

Cannot find module solc\soljson

I installed TronBox on my windows system using
npm install -g tronbox

Project was init successfully using
tronbox init

But the compile commands like these are failing

tronbox compile
tronbox migrate

This is the error I'm getting:

Capture

No documentation in unit tests to check how/why contract is reverting

Looking at the contract i am using, i know why the contract is reverting. However i do not know how to decode the transaction data to show the error condition message.

.e.g. if constraint below is broken the transaction revert message should be "maxProfit limit violation":

    // Enforce max profit limit.
    require (possibleWinAmount <= amount + maxProfit, "maxProfit limit violation.");

require() uses the 0xfd opcode to cause an error condition however i do not know how to grab this from the transaction data returned here:

{"ret":[{"contractRet":"REVERT"}],"signature":["25331b6168f677d4010a095b17f9401f8d844a21ab2b8bc1a1671ea09ac1cef0be9750f55fcc21289bca3edab48398432ca758ddc5848867cc4f5a0772594aa600"],"txID":"531667a2a814b38728716582970c18b18eaa7fce8a886f181203882e33ff68c9","raw_data":{"contract":[{"parameter":{"value":{"data":"5524e97a0000000000000000000000000000000000000000000000000000000000005f010000000000000000000000000000000000000000000000000000000000000063ea9e535d40885a976130b8c97048fb9f779d2d566fbe7d25f39ec55037535d291a8199f34f6e60b472542e9740b341de9277c54791b5f0018dba3500a007570b3713a404ba2df62572fe2e6a7c5a808fdbf06e1fb6ac0a87a3bee4f3cd32700b","owner_address":"41edfd69fbd9e0efcc26a4fceec0b17f8ae088a8e2","contract_address":"41dc2517097e9dbafb54457ca09bb542d429bc00b1","call_value":100000000},"type_url":"type.googleapis.com/protocol.TriggerSmartContract"},"type":"TriggerSmartContract"}],"ref_block_bytes":"000a","ref_block_hash":"eb361056e83d9096","expiration":1585080720000,"fee_limit":1000000000,"timestamp":1585080661608},"raw_data_hex":"0a02000a2208eb361056e83d90964080b5b1f1902e5a9502081f1290020a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412da010a1541edfd69fbd9e0efcc26a4fceec0b17f8ae088a8e2121541dc2517097e9dbafb54457ca09bb542d429bc00b11880c2d72f22a4015524e97a0000000000000000000000000000000000000000000000000000000000005f010000000000000000000000000000000000000000000000000000000000000063ea9e535d40885a976130b8c97048fb9f779d2d566fbe7d25f39ec55037535d291a8199f34f6e60b472542e9740b341de9277c54791b5f0018dba3500a007570b3713a404ba2df62572fe2e6a7c5a808fdbf06e1fb6ac0a87a3bee4f3cd32700b70e8ecadf1902e90018094ebdc03"}

Privatenet issue: ERROR: Contract Migrations has not been deployed on the network.

$ npx tronbox migrate --reset --network development
Using network 'development'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
ERROR: Contract Migrations has not been deployed on the network.
For more details, check the transaction at:
http://127.0.0.1:16667/wallet/gettransactionbyid?value=00db9c969e45c79cfecc854dff4a18cec59a643c887716c4b7fd1d51d89db4c5
If the transaction above is empty, most likely, your address had no bandwidth/energy to deploy the contract.

Here's my tronbox.js:

const port = process.env.HOST_PORT || 16667;

module.exports = {
  networks: {
    development: {
      privateKey:
        "da146374a75310b9666e834ee4ad0866d6f4035967bfc76217c5a495fff9f0d0",
      userFeePercentage: 30,
      feeLimit: 1e8,
      fullHost: `http://127.0.0.1:${port}`,
      network_id: "*",
    },
    compilers: {
      solc: {
        version: "0.5.10",
      },
    },
  },
};
curl "http://127.0.0.1:16667/wallet/gettransactionbyid?value=00db9c969e45c79cfecc854dff4a18cec59a643c887716c4b7fd1d51d89db4c5" | jq

{
  "signature": [
    "8e758b07051c2137a312b453dfe1db071056b1f09ad8bf6071e436490c898ebc90c7a825b28d0ed5440f50fd3296419253e875f72b0e7534ca1bc94d433176f601"
  ],
  "txID": "00db9c969e45c79cfecc854dff4a18cec59a643c887716c4b7fd1d51d89db4c5",
  "contract_address": "41676a5d831c114a35df9b7d14be15ebc11953d9e9",
  "raw_data": {
    "contract": [
      {
        "parameter": {
          "value": {
            "owner_address": "41928c9af0651632157ef27a2cf17ca72c575a4d21",
            "new_contract": {
              "bytecode": "608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506101b58061007a6000396000f3fe608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b506004361061005b5760003560e01c8063445df0ac146100605780638da5cb5b1461007e578063fdacd576146100c8575b600080fd5b6100686100f6565b6040518082815260200191505060405180910390f35b6100866100fc565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100f4600480360360208110156100de57600080fd5b8101908080359060200190929190505050610121565b005b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561017e57806001819055505b5056fea26474726f6e582012a3220f528ae24412fabc04f872f7a4b81468a36af489964489005dee5cdcd964736f6c634300050a0031",
              "consume_user_resource_percent": 30,
              "name": "Migrations",
              "origin_address": "41928c9af0651632157ef27a2cf17ca72c575a4d21",
              "abi": {
                "entrys": [
                  {
                    "outputs": [
                      {
                        "type": "uint256"
                      }
                    ],
                    "constant": true,
                    "name": "last_completed_migration",
                    "stateMutability": "View",
                    "type": "Function"
                  },
                  {
                    "outputs": [
                      {
                        "type": "address"
                      }
                    ],
                    "constant": true,
                    "name": "owner",
                    "stateMutability": "View",
                    "type": "Function"
                  },
                  {
                    "stateMutability": "Nonpayable",
                    "type": "Constructor"
                  },
                  {
                    "inputs": [
                      {
                        "name": "completed",
                        "type": "uint256"
                      }
                    ],
                    "name": "setCompleted",
                    "stateMutability": "Nonpayable",
                    "type": "Function"
                  }
                ]
              },
              "origin_energy_limit": 10000000
            }
          },
          "type_url": "type.googleapis.com/protocol.CreateSmartContract"
        },
        "type": "CreateSmartContract"
      }
    ],
    "ref_block_bytes": "0000",
    "ref_block_hash": "fb81c56753c14d88",
    "expiration": 60000,
    "fee_limit": 100000000,
    "timestamp": 1593705836636
  },
  "raw_data_hex": "0a0200002208fb81c56753c14d8840e0d4035aa906081e12a4060a30747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e437265617465536d617274436f6e747261637412ef050a1541928c9af0651632157ef27a2cf17ca72c575a4d2112d5050a1541928c9af0651632157ef27a2cf17ca72c575a4d211a770a2b10011a186c6173745f636f6d706c657465645f6d6967726174696f6e2a091a0775696e74323536300240020a1810011a056f776e65722a091a0761646472657373300240020a04300140030a281a0c736574436f6d706c6574656422141209636f6d706c657465641a0775696e743235363002400322af04608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506101b58061007a6000396000f3fe608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b506004361061005b5760003560e01c8063445df0ac146100605780638da5cb5b1461007e578063fdacd576146100c8575b600080fd5b6100686100f6565b6040518082815260200191505060405180910390f35b6100866100fc565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100f4600480360360208110156100de57600080fd5b8101908080359060200190929190505050610121565b005b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561017e57806001819055505b5056fea26474726f6e582012a3220f528ae24412fabc04f872f7a4b81468a36af489964489005dee5cdcd964736f6c634300050a0031301e3a0a4d6967726174696f6e734080ade20470dce09482b12e900180c2d72f"
}

tron.log
============ Peer stats: all 0, active 0, passive 0


12:03:07.366 INFO  [qtp14295722-28] [DB](Manager.java:1601) headNumber:0
12:03:07.367 INFO  [qtp14295722-28] [DB](Manager.java:1602) syncBeginNumber:0
12:03:07.367 INFO  [qtp14295722-28] [DB](Manager.java:1605) solidBlockNumber:0
12:03:07.368 INFO  [qtp14295722-51] [DB](Manager.java:1601) headNumber:0
12:03:07.368 INFO  [qtp14295722-51] [DB](Manager.java:1602) syncBeginNumber:0
12:03:07.368 INFO  [qtp14295722-51] [DB](Manager.java:1605) solidBlockNumber:0
12:03:07.551 INFO  [qtp14295722-51] [VM](VM.java:1445) VM halted: [Invalid operation code: opCode[d3];]
12:03:07.551 INFO  [qtp14295722-51] [VM](VMActuator.java:262) runtime result is :Invalid operation code: opCode[d3];
12:03:07.561 INFO  [qtp14295722-51] [o.t.c.Wallet](Wallet.java:518) Broadcast transaction dd062aa1f1ae558cdf64e57e5e8ee26f6d433aea860730a3907996bc867abaae successfully.
12:03:07.617 ERROR [qtp14295722-23] [o.t.c.Wallet](Wallet.java:2397) Get contract failed, the account does not exist or the account does not have a code hash!
12:03:08.127 ERROR [qtp14295722-29] [o.t.c.Wallet](Wallet.java:2397) Get contract failed, the account does not exist or the account does not have a code hash!
12:03:08.631 ERROR [qtp14295722-27] [o.t.c.Wallet](Wallet.java:2397) Get contract failed, the account does not exist or the account does not have a code hash!
12:03:09.142 ERROR [qtp14295722-51] [o.t.c.Wallet](Wallet.java:2397) Get contract failed, the account does not exist or the account does not have a code hash!
12:03:09.654 ERROR [qtp14295722-23] [o.t.c.Wallet](Wallet.java:2397) Get contract failed, the account does not exist or the account does not have a code hash!
12:03:10.162 ERROR [qtp14295722-29] [o.t.c.Wallet](Wallet.java:2397) Get contract failed, the account does not exist or the account does not have a code hash!
12:03:10.672 ERROR [qtp14295722-27] [o.t.c.Wallet](Wallet.java:2397) Get contract failed, the account does not exist or the account does not have a code hash!
12:03:11.181 ERROR [qtp14295722-51] [o.t.c.Wallet](Wallet.java:2397) Get contract failed, the account does not exist or the account does not have a code hash!
12:03:11.691 ERROR [qtp14295722-23] [o.t.c.Wallet](Wallet.java:2397) Get contract failed, the account does not exist or the account does not have a code hash!
12:03:12.196 ERROR [qtp14295722-29] [o.t.c.Wallet](Wallet.java:2397) Get contract failed, the account does not exist or the account does not have a code hash!
12:03:14.172 INFO  [pool-26-thread-1] [net](SyncPool.java:121)

My private net node is running with the unmodified configuration file: https://github.com/tronprotocol/tron-deployment/blob/master/private_net_config.conf

Any idea what is causing the issue?

Cannot specify other compiler versions ?

SyntaxError:

Source file requires different compiler version (current compiler is 0.4.24-develop.2018.8.28+commit.3ba0cdec.mod.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version

pragma solidity ^0.4.25;
^----------------------^
Compilation failed. See above.

block.timestamp - now is wrong

When a contract is deploying block.timestamp (alias of) now is 0. But when call some method it becomes the right value in second in Unix time. To properly test time-based code it needs to be consistent: always at 0 when deploying and after when query or always real Unix time, not a mixin.

Sending TRX to payable function not working

I have a payable function defined here:

  function placeBet(uint256 amount) external payable returns (address) {
    // make sure the amount we want to send is the amount we actually sent
    require(amount == msg.value);
    currentPot += amount;
    currentLeader = msg.sender;
    // return the current leader
    return currentLeader;
  }

In my tronbox tests I call it like this:

  await game.placeBet(300000000, {from: accounts[1], callValue: 300000000})
  let leader2 = await game.currentLeader()

  // ensure the lead changed
  assert(leader1 != leader2, "Bet was insufficient to update leader")

The assert is passing and I checked manually currentLeader data is being updated. However, when I look at the balance of the contract with tronbox await tronWeb.trx.getBalance(contract) it returns 0 and when using http://127.0.0.1:9090/admin/accounts (from tronquickstart) barely any TRX (less than 1) is being taken from accounts[1].

Why is data changing but no TRX being sent?

how to check revert tx in js tests?

Hello, I need to check transaction revert in tests(1), and i wont get return value if transaction complete(for not view function)(2)

But i not found solutions for tronbox

function check() public returns(uint256){ require(false); return 1; }

function check2() public returns(uint256){ return 1; }

tronbox init windows error.

bash error.

tronbox init
Downloading...
Unpacking...
Setting up...
Error: Command failed: bash post-unpack.sh && rm post-unpack.sh && npm install
'bash'��(��) ���� �Ǵ� �ܺ� ����, ������ �� �ִ� ���α׷�, �Ǵ�
��ġ ������ �ƴմϴ�.

    at ChildProcess.exithandler (child_process.js:294:12)
    at ChildProcess.emit (events.js:189:13)
    at maybeClose (internal/child_process.js:970:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)

Test command is not taking the solc version from tronbox.js

Problem:

If the contracts use solidity version higher than 0.5.4 the test command gives:
ParserError: Source file requires different compiler version (current compiler is 0.5.4+commit.7b0de266.mod.Emscripten.clang)

However the compile command works properly.

Sample code:

pragma solidity ^0.6.0;

abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

How it should work

The test command must take the solc version from the tronbox.js

compilers: {
      solc: {
          version: ">=0.6.0", 
      },
  },

Cause of the problem

After investigating it seems that the test command first parses the contracts (Compile/parser.js) next compiles (Compile/index.js).
During parsing the options object is not passed so settings for the solc verision are not available in the TronSolc.js, thus using the default version 0.5.4. In the second (compile) step they are available and it works properly.

Duplicate

This one is describing the same problem but without proper resolution:
#53

Error: Error parsing D:/.../ConvertLib.sol

: Cannot find module 'C:\Users\Device-4.tronbox\solc\soljson_v0.5.4.js'
Require stack:

  • C:\Users\Device-4\AppData\Roaming\npm\node_modules\tronbox\build\components\TronSolc.js
  • C:\Users\Device-4\AppData\Roaming\npm\node_modules\tronbox\build\lib\commands\version.js
  • C:\Users\Device-4\AppData\Roaming\npm\node_modules\tronbox\build\lib\commands\index.js
  • C:\Users\Device-4\AppData\Roaming\npm\node_modules\tronbox\build\index.js
  • C:\Users\Device-4\AppData\Roaming\npm\node_modules\tronbox\build\tronbox.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
    at Function.Module._load (internal/modules/cjs/loader.js:690:27)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at getWrapper (C:\Users\Device-4\AppData\Roaming\npm\node_modules\tronbox\build\components\TronSolc.js:1:2377)
    at Object.parseImports (C:\Users\Device-4\AppData\Roaming\npm\node_modules\tronbox\build\components\Compile\parser.js:1:2359)
    at C:\Users\Device-4\AppData\Roaming\npm\node_modules\tronbox\build\components\Compile\profiler.js:1:4981
    at C:\Users\Device-4\AppData\Roaming\npm\node_modules\tronbox\build\components\Resolver\index.js:1:1727
    at C:\Users\Device-4\AppData\Roaming\npm\node_modules\tronbox\node_modules\async\internal\onlyOnce.js:12:16
    at next (C:\Users\Device-4\AppData\Roaming\npm\node_modules\tronbox\node_modules\async\whilst.js:68:18)

am i missing something? i'm pretty sure follow the order

Deploy with trc10 token address

A contract with a constructor like constructor(trcToken _tokenId) cannot be deployed in a migration with an integer value as such await deployer.deploy(ContractArtifact, 1000001).

Error reported is ERROR: invalid type (arg="type", value="trcToken", version=4.0.48). Please advise.

tronbox console | accounts and contract address details | connected with docker run -it -p 9090:9090 --rm --name tron trontools/quickstart

1. How to get accounts in tronbox console

truffle console
truffle(development)> accounts
[ '0xd905A5eee0cA8E089E58B9b1192FBdd05dB45b10',
  '0x2b9e76dD2CC9d566d43EB7668AcD5eCDa6f38F2C',
  '0xEcd469B022caD7A683E0BB439BA3AEa0b4F55469',
  '0xF7Dc20DFF665f7d4E7515111B4Fae3843479B9a6',
  '0xd3bd1Cd6D6B7E32c10B760e754A89Cf546BB172e',
  '0xef230314ddDE21d52182eBA459639268a86d1b61',
  '0x2623e3C37cb6C7115284Ef1F13547E8085086EB3',
  '0x834c6FD5bCfbc4fe0C41748C518B08Ee04496F96',
  '0x7f73aFe4ddbba03A91139741C05Eb2F96448c321',
  '0xD807Fd7Bb238113D15C573841ECeffe619CC6574' ]

How to get the same in tronbox console. I am getting accounts is not defined error in tronbox console.

 tronbox console
tronbox(development)> accounts
ReferenceError: accounts is not defined

2. How to get contract address in tronbox console
I can get the contract address in truffle like the following,

truffle(development)> let instance = await Sample.deployed()
truffle(development)> instance.address
'0x7C4c67EddDd8eDe8c3c8548195DA16885A75eEc5'

But the same is not working in tronbox.

tronbox(development)> let instance = await Sample.deployed()
SyntaxError: await is only valid in async function
    at REPLServer.Interface._onLine (readline.js:280:10)
    at REPLServer.emit (events.js:211:7)
    at emitOne (events.js:116:13)
    at REPLServer.onLine (repl.js:468:10)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at bound (domain.js:301:14)
    at ReplManager.interpret (/home/css/.nvm/versions/node/v8.16.2/lib/node_modules/tronbox/build/lib/repl.js:1:1807)
    at Console.interpret (/home/css/.nvm/versions/node/v8.16.2/lib/node_modules/tronbox/build/lib/console.js:1:3182)
    at Object.runInContext (vm.js:119:10)
    at createScript (vm.js:80:10)
tronbox(development)> let instance =  Sample.deployed()
TypeError: Cannot read property 'match' of undefined
    at REPLServer.onLine (repl.js:468:10)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at bound (domain.js:301:14)
    at ReplManager.interpret (/home/css/.nvm/versions/node/v8.16.2/lib/node_modules/tronbox/build/lib/repl.js:1:1807)
    at Console.interpret (/home/css/.nvm/versions/node/v8.16.2/lib/node_modules/tronbox/build/lib/console.js:1:2864)
    at Command.getCommand (/home/css/.nvm/versions/node/v8.16.2/lib/node_modules/tronbox/build/lib/command.js:1:376)
    at Object.Yargs.self.parse (/home/css/.nvm/versions/node/v8.16.2/lib/node_modules/tronbox/node_modules/yargs/yargs.js:532:23)
    at Object.Yargs.self._parseArgs (/home/css/.nvm/versions/node/v8.16.2/lib/node_modules/tronbox/node_modules/yargs/yargs.js:938:27)
    at Function.Parser.detailed (/home/css/.nvm/versions/node/v8.16.2/lib/node_modules/tronbox/node_modules/yargs/node_modules/yargs-parser/index.js:761:10)
    at parse (/home/css/.nvm/versions/node/v8.16.2/lib/node_modules/tronbox/node_modules/yargs/node_modules/yargs-parser/index.js:125:13)

How to call a contract method with a struct parameter

I have the solidity method:

struct TestS {
    uint a;
    uint b;
}
...
function test(TestS memory s) external {
}

I tried to call it with the following code:

await contract.test({a: 1, b: 2});

But I get an error: Uncaught Error: Invalid argument count provided

How to call such a method correctly?

Thank you!

TronBox v2.7.9 Error Cannot find Module '.'

When you install [email protected] and hit tronbox command in your cli it will give you this error

internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module '.'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/home/rails/.nvm/versions/node/v10.15.1/lib/node_modules/tronbox/build/tronbox.js:2:1)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)

payable address is broken in tronbox 2.5.1

example:

function testSend(address payable to) public payable {
        to.transfer(msg.value);
    }

error:

Error parsing /home/herpderp123.sol: ParsedContract.sol:62:31: P
    function testSend(address payable to) public payable {                                                
                              ^-----^                                                                     

compile contracts with bytecode "0x"

Bug report!

Machine node12, solc0.5.10, ubuntu19/windows10, tronbox2.7.12

When I compile the code i get in build .json this result for bytecode

  "bytecode": "0x",
  "deployedBytecode": "0x",
  "sourceMap": "",
  "deployedSourceMap": "",

My contract

pragma solidity ^0.5.8;

import "../../../contracts/tokens/trc20/TRC20.sol";
import "../../../contracts/tokens/trc20/TRC20Mintable.sol";
import "../../../contracts/tokens/trc20/TRC20Detailed.sol";
import "../../../contracts/tokens/trc20/TRC20Freezable.sol";

/**
* @title Token contract for deploy
*/
contract Token is TRC20Detailed, TRC20Mintable, TRC20Freezable {}

Error on migration:

$ tronbox migrate
Using network 'development'.

Running migration: 3_deploy_token.js
  Deploying Token...
ERROR: Invalid bytecode provided

Migration error: no such file or directory

I have set a directory for my project contract and json in tronbox.js

     contracts_directory: './src/contracts',
     contracts_build_directory: './src/abis',

I can compile without issues and the files are placed in the right directories.

However when I want to run a migration with this command

source .env && tronbox migrate --network shasta

I get the following error;

Using network 'shasta'.

Running migration: 1_initial_migration.js
internal/fs/utils.js:308
    throw err;
    ^

Error: ENOENT: no such file or directory, scandir './src/abis'
    at Object.readdirSync (fs.js:1021:3)
    at FS.getContractName (/home/idecentralize/.nvm/versions/node/v14.14.0/lib/node_modules/tronbox/build/components/Resolver/fs.js:1:904)
    at FS.require (/home/idecentralize/.nvm/versions/node/v14.14.0/lib/node_modules/tronbox/build/components/Resolver/fs.js:1:440)
    at Resolver.require (/home/idecentralize/.nvm/versions/node/v14.14.0/lib/node_modules/tronbox/build/components/Resolver/index.js:1:740)
    at Object.require (/home/idecentralize/.nvm/versions/node/v14.14.0/lib/node_modules/tronbox/build/components/Migrate/index.js:1:5238)
    at ResolverIntercept.require (/home/idecentralize/.nvm/versions/node/v14.14.0/lib/node_modules/tronbox/build/components/Migrate/resolverintercept.js:1:278)
    at /mnt/d/Code/tronx/migrations/1_initial_migration.js:1:28
    at Script.runInContext (vm.js:142:18)
    at Script.runInNewContext (vm.js:147:17)
    at Object.file (/home/idecentralize/.nvm/versions/node/v14.14.0/lib/node_modules/tronbox/build/components/Require.js:1:1438)

How can I resolve this. All the files are in the right place.

tronbox would not start because fullHost not defined

The problem is that fresh version of tronbox not starting. The error is

Using network 'shasta'.
(node:14331) UnhandledPromiseRejectionWarning: Error: Invalid URL provided to HttpProvider
    at new e (/usr/local/lib/node_modules/tronbox/build/webpack:/packages/tronwrap/tronweb/dist/TronWeb.node.js:1:16497)
    at Object.create (/usr/local/lib/node_modules/tronbox/build/webpack:/packages/truffle-provider/index.js:70:1)
    at Config.get [as provider] (/usr/local/lib/node_modules/tronbox/build/webpack:/packages/truffle-config/index.js:278:1)
    at provision (/usr/local/lib/node_modules/tronbox/build/webpack:/packages/truffle-provisioner/index.js:4:1)
    at Resolver.require (/usr/local/lib/node_modules/tronbox/build/webpack:/packages/truffle-resolver/index.js:34:1)
    at Object.lastCompletedMigration (/usr/local/lib/node_modules/tronbox/build/webpack:/packages/truffle-migrate/index.js:266:1)
    at Object.needsMigrating (/usr/local/lib/node_modules/tronbox/build/webpack:/packages/truffle-migrate/index.js:295:1)
    at runMigrations (/usr/local/lib/node_modules/tronbox/build/webpack:/packages/truffle-core/lib/commands/migrate.js:94:1)
    at /usr/local/lib/node_modules/tronbox/build/webpack:/packages/truffle-core/lib/commands/migrate.js:125:1
    at /usr/local/lib/node_modules/tronbox/build/webpack:/packages/truffle-core/lib/environment.js:65:1
    at cb (/usr/local/lib/node_modules/tronbox/build/webpack:/packages/tronwrap/index.js:146:1)
    at axios.get.then.catch.err (/usr/local/lib/node_modules/tronbox/build/webpack:/packages/tronwrap/index.js:174:1)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Config:

module.exports = {
 networks: {
    shasta: {
      privateKey: process.env.SHASTA,
      userFeePercentage: 30, // or consume_user_resource_percent
      feeLimit: 100000000, // or fee_limit
      originEnergyLimit: 1e8, // or origin_energy_limit
      callValue: 0, // or call_value
      fullNode: "https://api.shasta.trongrid.io",
      fullHost: "https://api.shasta.trongrid.io",
      solidityNode: "https://api.shasta.trongrid.io",
      eventServer: "https://api.shasta.trongrid.io",
      network_id: "*"
    },
    mainnet: {
      privateKey: process.env.MAINNET,
      userFeePercentage: 30,
      feeLimit: 100000000,
      fullNode: "https://api.trongrid.io",
      fullHost: "https://api.trongrid.io",
      solidityNode: "https://api.trongrid.io",
      eventServer: "https://api.trongrid.io",
      network_id: "*"
    }
  }
};

AS you can see there IS fullHost parameter in config but it s unused.

A temporary workaround is to replace fullHost with fullNode
https://github.com/TRON-US/tronbox/blob/7b764c81deb3997e4c6b00b9d70429d03232a104/packages/truffle-provider/index.js#L70

payable address is broken in tronbox 2.5.2

Trying to compile my project using command source ./.env && tronbox compile --compile-all --reset and getting

Error parsing C:\dev\..\smart-contract\contracts\MyContract.sol: ParsedContract.sol:57:49: ParserError: Expected ')' but got 'payable'
    mapping(string => address payable) private membersAccounts;

The top line of my contract is pragma solidity ^0.5.4;
My tronbox.js file contains:

    compilers: {
      solc: {
         version: '0.5.4'
      }
    }

And my tronbox version is 2.5.2

@sullof

can't use all the accounts as owner in tronbox test

I was writing test cases for my contract.
and I needed to switch the owner account to access the contract functions.

tronbox only picks the first account (accounts[0]) as the owner.
I don't see any way to switch the owner's account other than changing the private key in tronbox config file.
(sending { from: address } with a transaction is not working (it worked with truffle))

Can't Compile Solidity ^0.5.4

When I try to compile the contract it uses compiler 0.4.25
Tronbox v2.5.2

This is what I get when I try to run tronbox migrate:

tronbox migrate --reset
SyntaxError: Source file requires different compiler version 
(current compiler is 0.4.25+commit.69a1e720.Emscripten.clang - note that 
nightly builds are considered to be strictly less than the released version
pragma solidity ^0.5.4;
^---------------------^
ParserError: Source file requires different compiler version 
(current compiler is 0.5.4+commit.7b0de266.mod.Emscripten.clang)

Even if I try to use pragma solidity >=0.4.23 <0.6.0; in the compiled json file of the contract I get this:

  "compiler": {
    "name": "solc",
    "version": "0.4.25+commit.69a1e720.Emscripten.clang"
  },

Might be related to #15

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.