
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
Simple development framework for Tron SunNetwork TronBox is a fork of Truffle code
npm install -g sunbox
Initialize a Customer Sun-Box Project
sunbox init
Download a dApp, ex: metacoin-box
sunbox unbox metacoin
Contract Compiler
sunbox compile
Optionally, you can select:
--compile-all: Force compile all contracts.
--network save results to a specific host network
To use SunBox, your dApp has to have a file sunbox.js in the source root. This special files, tells SunBox how to connect to nodes and event server, and passes some special parameters, like the default private key. This is an example of sunbox.js:
module.exports = {
networks: {
development: {
// For trontools/quickstart docker image
privateKey: 'da146374a75310b9666e834ee4ad0866d6f4035967bfc76217c5a495fff9f0d0',
userFeePercentage: 30,
feeLimit: 100000000,
mainFullHost: 'https://api.trongrid.io',
sideFullHost: 'https://sun.tronex.io',
mainGateway: 'TWaPZru6PR5VjgT4sJrrZ481Zgp3iJ8Rfo',
sideGateway: 'TGKotco6YoULzbYisTBuP6DWXDjEgJSpYz',
chainId: '41E209E4DE650F0150788E8EC5CAFA240A23EB8EB7',
network_id: "*"
},
mainnet: {
// Don't put your private key here, pass it using an env variable, like:
// PK=da146374a75310b9666e834ee4ad0866d6f4035967bfc76217c5a495fff9f0d0 tronbox migrate --network mainnet
privateKey: process.env.PK,
userFeePercentage: 30,
feeLimit: 100000000,
mainFullHost: '',
sideFullHost: '',
mainGateway: '',
sideGateway: '',
chainId: '',
network_id: "*"
}
}
};
Notice that the example above uses Tron Quickstart >= 1.1.16, which exposes a mononode on port 9090.
sunbox migrate
This command will invoke all migration scripts within the migrations directory. If your previous migration was successful, sunbox migrate will invoke a newly created migration. If there is no new migration script, this command will have no operational effect. Instead, you can use the option --reset to restart the migration script.
sunbox migrate --reset
It is very important to set the deploying parameters for any contract. In TronBox 2.2.2+ you can do it modifying the file
migrations/2_deploy_contracts.js
and specifying the parameters you need like in the following example:
var ConvertLib = artifacts.require("./ConvertLib.sol");
var MetaCoin = artifacts.require("./MetaCoin.sol");
module.exports = function(deployer) {
deployer.deploy(ConvertLib);
deployer.link(ConvertLib, MetaCoin);
deployer.deploy(MetaCoin, 10000, {
fee_limit: 1.1e8,
userFeePercentage: 31,
originEnergyLimit: 1.1e8
});
};
This will use the default network to start a console. It will automatically connect to a TVM client. You can use --network to change this.
sunbox console
The console supports the sunbox command. For example, you can invoke migrate --reset in the console. The result is the same as invoking sunbox migrate --reset in the command.
All the compiled contracts can be used, just like in development & test, front-end code, or during script migration.
After each command, your contract will be re-loaded. After invoking the migrate --reset command, you can immediately use the new address and binary.
Every returned command's promise will automatically be logged. There is no need to use then(), which simplifies the command.
To carry out the test, run the following command:
tronbox test
You can also run the test for a specific file:
tronbox test ./path/to/test/file.js
Testing in TronBox is a bit different than in Truffle.
Let's say we want to test the contract Metacoin (from the Metacoin Box that you can download with tronbox unbox metacoin):
contract MetaCoin {
mapping (address => uint) balances;
event Transfer(address _from, address _to, uint256 _value);
event Log(string s);
constructor() public {
balances[tx.origin] = 10000;
}
function sendCoin(address receiver, uint amount) public returns(bool sufficient) {
if (balances[msg.sender] < amount) return false;
balances[msg.sender] -= amount;
balances[receiver] += amount;
emit Transfer(msg.sender, receiver, amount);
return true;
}
function getBalanceInEth(address addr) public view returns(uint){
return ConvertLib.convert(getBalance(addr),2);
}
function getBalance(address addr) public view returns(uint) {
return balances[addr];
}
}
Now, take a look at the first test in test/metacoin.js:
var MetaCoin = artifacts.require("./MetaCoin.sol");
contract('MetaCoin', function(accounts) {
it("should put 10000 MetaCoin in the first account", function() {
return MetaCoin.deployed().then(function(instance) {
return instance.call('getBalance',[accounts[0]]);
}).then(function(balance) {
assert.equal(balance.toNumber(), 10000, "10000 wasn't in the first account");
});
});
// ...
Starting from version 2.0.5, in TronBox artifacts () the following commands are equivalent:
instance.call('getBalance', accounts[0]);
instance.getBalance(accounts[0]);
instance.getBalance.call(accounts[0]);
and you can pass the address and amount for the method in both the following ways:
instance.sendCoin(address, amount, {from: account[1]});
and
instance.sendCoin([address, amount], {from: account[1]});
Fork this repo.
Clone your forked repo recursively, to include submodules, for example:
git clone --recurse-submodules -j8 git@github.com:sullof/tronbox.git
nvm install v8.16.0
nvm use v8.16.0
npm i -g lerna
lerna bootstrap
./tronbox.dev migrate --reset
TronBox does not supports all the Solidity compilers. Supported versions:
0.4.24
0.4.25
0.5.4
0.5.8
0.5.9
3.0.0
2.5.2
2.5.0
^0.5.4web3 and diff packages2.3.16
2.3.16
2.3.15
2.3.1
2.3.0
2.2.3
2.2.2
2.2.1
For more historic data, check the original repo at https://github.com/tronprotocol/tron-box
FAQs
SunBox - Simple development framework for Tron SunNetwork
The npm package sunbox receives a total of 14 weekly downloads. As such, sunbox popularity was classified as not popular.
We found that sunbox demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.