Skip to content

Create a Box

To create a TronBox Box, you need:

  • A GitHub repository
  • A tronbox.json file, which configures how your Box is unboxed
  • A tronbox.js file, the TronBox configuration of the project being boxed

Both files belong in the top-level directory of your repo. With them in place, and your repo on GitHub, the unbox command will be: tronbox unbox {USER_NAME || ORG_NAME}/{REPO_NAME}

Unless a ref is given, TronBox unboxes from the master branch. If your repository uses main instead, users have to unbox it as tronbox unbox {USER_NAME || ORG_NAME}/{REPO_NAME}#main.

Configuration file

Every TronBox Box includes a tronbox.json configuration file with the following attributes: ignore and commands.

ignore (array)

An array of files or relative paths that TronBox ignores when unboxing, usually including readme.md or .gitignore. These files will not be copied from the Box's repository when you unbox.

JSON
json
{
  "ignore": ["README.md", ".gitignore"]
}

commands (object)

An object whose key-value pairs are a descriptor and console command respectively. Once your Box is successfully unboxed, the key-value pairs will be shown to users and can be seen as quick instructions.

The following example provides commands not only to compile, migrate, and test smart contracts but also for frontend development.

JSON
json
{
  "commands": {
    "Compile": "tronbox compile",
    "Migrate": "tronbox migrate",
    "Test contracts": "tronbox test",
    "Test dapp": "npm test",
    "Run dev server": "npm run start",
    "Build for production": "npm run build"
  }
}

Installing dependencies

After unboxing, TronBox looks for a package.json at the root of the unboxed project. If one is present, it automatically runs npm install --ignore-scripts to install the Box's dependencies.

Because the install uses --ignore-scripts, npm lifecycle scripts (preinstall, install, postinstall, and so on) are not run, so don't rely on them to finish setting up your Box. Earlier versions executed a post-unpack hook declared in tronbox.json; that hook is no longer run.