# sun-photon

> Sun-Photon - Simple development framework for Tron SunNetwork

Latest version **0.0.2** (published 2019-12-26) · 0 weekly downloads

## Install

```sh
npm install sun-photon
pnpm add sun-photon
yarn add sun-photon
bun add sun-photon
```

Provides the command `sun-photon`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2019-12-26 |
| First published | 2019-12-26 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 43 |
| Unpacked size | 180.2 KB |
| Known vulnerabilities | 0 (+30 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 6 |
| Author | tron.network |
| Maintainers | llwslc |

## Links

- npm: https://www.npmjs.com/package/sun-photon
- Repository: https://github.com/tronprotocol/sun-photon
- Homepage: https://github.com/tronprotocol/sun-photon/
- Issues: https://github.com/tronprotocol/sun-photon/issues
- npm.io page: https://npm.io/package/sun-photon

## Dependencies (43)

- [cpr](https://npm.io/package/cpr.md) ^0.4.3
- [del](https://npm.io/package/del.md) ^2.2.0
- [chai](https://npm.io/package/chai.md) 4.1.2
- [diff](https://npm.io/package/diff.md) >=3.5.0
- [solc](https://npm.io/package/solc.md) 0.5.9
- [temp](https://npm.io/package/temp.md) ^0.8.3
- [async](https://npm.io/package/async.md) 2.6.1
- [axios](https://npm.io/package/axios.md) ^0.18.0
- [chalk](https://npm.io/package/chalk.md) ^2.4.1
- [debug](https://npm.io/package/debug.md) ^3.1.0
- [ethpm](https://npm.io/package/ethpm.md) 0.0.16
- [mocha](https://npm.io/package/mocha.md) 5.2.0
- [yargs](https://npm.io/package/yargs.md) ^8.0.2
- [colors](https://npm.io/package/colors.md) ^1.1.2
- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [semver](https://npm.io/package/semver.md) ^6.1.1
- [sunweb](https://npm.io/package/sunweb.md) ^1.1.0
- [find-up](https://npm.io/package/find-up.md) ^4.1.0
- [homedir](https://npm.io/package/homedir.md) ^0.6.0
- [tronweb](https://npm.io/package/tronweb.md) ^2.7.2
- [chokidar](https://npm.io/package/chokidar.md) ^1.4.2
- [fs-extra](https://npm.io/package/fs-extra.md) ^8.1.0
- [graphlib](https://npm.io/package/graphlib.md) ^2.1.7
- [node-dir](https://npm.io/package/node-dir.md) 0.1.17
- [ethjs-abi](https://npm.io/package/ethjs-abi.md) 0.1.8
- [safe-eval](https://npm.io/package/safe-eval.md) ^0.4.1
- [web3-mock](https://npm.io/package/web3-mock.md) 1.0.1
- [node-emoji](https://npm.io/package/node-emoji.md) ^1.8.1
- [spawn-args](https://npm.io/package/spawn-args.md) ^0.1.0
- [superagent](https://npm.io/package/superagent.md) ^5.1.0
- [bignumber.js](https://npm.io/package/bignumber.js.md) ^7.2.1
- [finalhandler](https://npm.io/package/finalhandler.md) ^1.1.2
- [serve-static](https://npm.io/package/serve-static.md) ^1.10.0
- [truffle-init](https://npm.io/package/truffle-init.md) ^1.0.7
- [@truffle/error](https://npm.io/package/@truffle/error.md) 0.0.7
- [ethpm-registry](https://npm.io/package/ethpm-registry.md) 0.1.0-next.3
- [@truffle/expect](https://npm.io/package/@truffle/expect.md) 0.0.11
- [@truffle/require](https://npm.io/package/@truffle/require.md) ^2.0.24
- [original-require](https://npm.io/package/original-require.md) 1.0.1
- [source-map-support](https://npm.io/package/source-map-support.md) ^0.5.3
- [@truffle/solidity-utils](https://npm.io/package/@truffle/solidity-utils.md) ^1.2.5
- [@truffle/contract-sources](https://npm.io/package/@truffle/contract-sources.md) ^0.1.6

## Recent versions

- 0.0.2 (latest) — 2019-12-26

## README

# sun-photon

## Introduction

sun-photon is a development framework for smart contract development on SUN Network (Layer 2 of TRON Network). Core functionality includes: 

* smart contract compiling
* smart contract deployment
* smart contract testing

## Installation

npm install -g sun-photon

## System requirement

* NodeJS 8.0+
* Windows, Linux, or Mac OS X

## Initalize a project

Create project in an empty directory:

```bash
sun-photon init
```

* Shell

```bash
➜  new-project sun-photon init
Downloading...
Unpacking...
Setting up...
Unbox successful. Sweet!

Commands:

  Compile:        sun-photon compile
  Migrate:        sun-photon migrate
  Test contracts: sun-photon test
```

## Directory

* ./contracts     smart contract files
* ./migrations    smart contract migration scripts
* ./test          smart contract tests

## Commands

```bash
➜  new-project sun-photon --help
sun-photon v0.2.1 - a development framework for sunweb

Usage: sun-photon <command> [options]

Commands
  init     Initialize new and empty sun-photon 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 sun-photon environment
  unbox    Download a sun-photon Box, a pre-built sun-photon project
  version  Show version number and exit

See more at https://developers.tron.network/docs/tron-box-user-guide
```

## Configuration files

Define settings in sun-photon.js. Use --network mainnet to set different network。

* sun-photon.js

```js
module.exports = {
  networks: {
    dappchain: {
      // Don't put your private key here:
      privateKey: process.env.PRIVATE_KEY_DAPPCHAIN,

      /* Create a .env file (it must be gitignored) containing something like
       * export PRIVATE_KEY_DAPPCHAIN=4E7FECCB71207B867C495B51A9758B104B1D4422088A87F4978BE64636656243
       * Then, run the migration with:
       * source .env && npx sun-photon migrate --network dappchain
       **/

      userFeePercentage: 100,
      feeLimit: 1e8,
      mainFullHost: 'https://api.trongrid.io',
      sideFullHost: 'https://sun.tronex.io',
      mainGateway: 'TWaPZru6PR5VjgT4sJrrZ481Zgp3iJ8Rfo',
      sideGateway: 'TGKotco6YoULzbYisTBuP6DWXDjEgJSpYz',
      chainId: '41E209E4DE650F0150788E8EC5CAFA240A23EB8EB7',
      network_id: '1'
    },
    testnet: {
      privateKey: process.env.PRIVATE_KEY_TESTNET,
      userFeePercentage: 50,
      feeLimit: 1e8,
      mainFullHost: 'https://testhttpapi.tronex.io',
      sideFullHost: 'https://suntest.tronex.io',
      mainGateway: 'TFLtPoEtVJBMcj6kZPrQrwEdM3W3shxsBU',
      sideGateway: 'TRDepx5KoQ8oNbFVZ5sogwUxtdYmATDRgX',
      chainId: '413AF23F37DA0D48234FDD43D89931E98E1144481B',
      network_id: '2'
    },
    compilers: {
      solc: {
        version: '0.5.4'
      }
    }
  }
}
```

## Contract compilation

Set correct solc version in sun-photon.js and run command:

```bash
sun-photon compile
```

## Contract deployment

Create a .env file to import private key and run command:

```bash
source .env && sun-photon migrate --network mainnet
```

## Contract testing

Testing file should be in  ./test directory
Test demo:

* test.js

```js
var Test = artifacts.require('./test.sol');
contract('Test', function(accounts) {
  it('call method g', function() {
    Test.deployed()
      .then(function(instance) {
        return instance.call('g');
      })
      .then(function(result) {
        assert.equal('method g()', result, 'is not call method g');
      });
  });
  it('call method f', function() {
    Test.deployed()
      .then(function(instance) {
        return instance.call('f');
      })
      .then(function(result) {
        assert.equal('method f()', result, 'is not call method f');
      });
  });
});
```

Run below command, if you want to deploy test.sol to dappchain (spec. in sun-photon.js).

```bash
source .env && sun-photon test ./test/test.js --network dappchain
```

---
_Source: https://npm.io/package/sun-photon · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
