{"id":18966870,"url":"https://github.com/tronprotocol/sun-photon","last_synced_at":"2025-04-19T14:22:08.997Z","repository":{"id":36774709,"uuid":"230200875","full_name":"tronprotocol/sun-photon","owner":"tronprotocol","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-24T01:02:01.000Z","size":139,"stargazers_count":6,"open_issues_count":21,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-16T08:10:41.612Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tronprotocol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-26T05:30:32.000Z","updated_at":"2024-12-09T11:41:43.000Z","dependencies_parsed_at":"2023-02-13T07:20:33.297Z","dependency_job_id":null,"html_url":"https://github.com/tronprotocol/sun-photon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tronprotocol%2Fsun-photon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tronprotocol%2Fsun-photon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tronprotocol%2Fsun-photon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tronprotocol%2Fsun-photon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tronprotocol","download_url":"https://codeload.github.com/tronprotocol/sun-photon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249711167,"owners_count":21314179,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T14:38:49.985Z","updated_at":"2025-04-19T14:22:08.971Z","avatar_url":"https://github.com/tronprotocol.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sun-photon\r\n\r\n## Introduction\r\n\r\nsun-photon is a development framework for smart contract development on SUN Network (Layer 2 of TRON Network). Core functionality includes: \r\n\r\n* smart contract compiling\r\n* smart contract deployment\r\n* smart contract testing\r\n\r\n## Installation\r\n\r\nnpm install -g sun-photon\r\n\r\n## System requirement\r\n\r\n* NodeJS 8.0+\r\n* Windows, Linux, or Mac OS X\r\n\r\n## Initalize a project\r\n\r\nCreate project in an empty directory:\r\n\r\n```bash\r\nsun-photon init\r\n```\r\n\r\n* Shell\r\n\r\n```bash\r\n➜  new-project sun-photon init\r\nDownloading...\r\nUnpacking...\r\nSetting up...\r\nUnbox successful. Sweet!\r\n\r\nCommands:\r\n\r\n  Compile:        sun-photon compile\r\n  Migrate:        sun-photon migrate\r\n  Test contracts: sun-photon test\r\n```\r\n\r\n## Directory\r\n\r\n* ./contracts     smart contract files\r\n* ./migrations    smart contract migration scripts\r\n* ./test          smart contract tests\r\n\r\n## Commands\r\n\r\n```bash\r\n➜  new-project sun-photon --help\r\nsun-photon v0.2.1 - a development framework for sunweb\r\n\r\nUsage: sun-photon \u003ccommand\u003e [options]\r\n\r\nCommands\r\n  init     Initialize new and empty sun-photon project\r\n  compile  Compile contract source files\r\n  migrate  Run migrations to deploy contracts\r\n  deploy   (alias for migrate)\r\n  build    Execute build pipeline (if configuration present)\r\n  test     Run JavaScript and Solidity tests\r\n  console  Run a console with contract abstractions and commands available\r\n  create   Helper to create new contracts, migrations and tests\r\n  watch    Watch filesystem for changes and rebuild the project automatically\r\n  serve    Serve the build directory on localhost and watch for changes\r\n  exec     Execute a JS module within this sun-photon environment\r\n  unbox    Download a sun-photon Box, a pre-built sun-photon project\r\n  version  Show version number and exit\r\n\r\nSee more at https://developers.tron.network/docs/tron-box-user-guide\r\n```\r\n\r\n## Configuration files\r\n\r\nDefine settings in sun-photon.js. Use --network mainnet to set different network。\r\n\r\n* sun-photon.js\r\n\r\n```js\r\nmodule.exports = {\r\n  networks: {\r\n    dappchain: {\r\n      // Don't put your private key here:\r\n      privateKey: process.env.PRIVATE_KEY_DAPPCHAIN,\r\n\r\n      /* Create a .env file (it must be gitignored) containing something like\r\n       * export PRIVATE_KEY_DAPPCHAIN=4E7FECCB71207B867C495B51A9758B104B1D4422088A87F4978BE64636656243\r\n       * Then, run the migration with:\r\n       * source .env \u0026\u0026 npx sun-photon migrate --network dappchain\r\n       **/\r\n\r\n      userFeePercentage: 100,\r\n      feeLimit: 1e8,\r\n      mainFullHost: 'https://api.trongrid.io',\r\n      sideFullHost: 'https://sun.tronex.io',\r\n      mainGateway: 'TWaPZru6PR5VjgT4sJrrZ481Zgp3iJ8Rfo',\r\n      sideGateway: 'TGKotco6YoULzbYisTBuP6DWXDjEgJSpYz',\r\n      chainId: '41E209E4DE650F0150788E8EC5CAFA240A23EB8EB7',\r\n      network_id: '1'\r\n    },\r\n    testnet: {\r\n      privateKey: process.env.PRIVATE_KEY_TESTNET,\r\n      userFeePercentage: 50,\r\n      feeLimit: 1e8,\r\n      mainFullHost: 'https://testhttpapi.tronex.io',\r\n      sideFullHost: 'https://suntest.tronex.io',\r\n      mainGateway: 'TFLtPoEtVJBMcj6kZPrQrwEdM3W3shxsBU',\r\n      sideGateway: 'TRDepx5KoQ8oNbFVZ5sogwUxtdYmATDRgX',\r\n      chainId: '413AF23F37DA0D48234FDD43D89931E98E1144481B',\r\n      network_id: '2'\r\n    },\r\n    compilers: {\r\n      solc: {\r\n        version: '0.5.4'\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n## Contract compilation\r\n\r\nSet correct solc version in sun-photon.js and run command:\r\n\r\n```bash\r\nsun-photon compile\r\n```\r\n\r\n## Contract deployment\r\n\r\nCreate a .env file to import private key and run command:\r\n\r\n```bash\r\nsource .env \u0026\u0026 sun-photon migrate --network mainnet\r\n```\r\n\r\n## Contract testing\r\n\r\nTesting file should be in  ./test directory\r\nTest demo:\r\n\r\n* test.js\r\n\r\n```js\r\nvar Test = artifacts.require('./test.sol');\r\ncontract('Test', function(accounts) {\r\n  it('call method g', function() {\r\n    Test.deployed()\r\n      .then(function(instance) {\r\n        return instance.call('g');\r\n      })\r\n      .then(function(result) {\r\n        assert.equal('method g()', result, 'is not call method g');\r\n      });\r\n  });\r\n  it('call method f', function() {\r\n    Test.deployed()\r\n      .then(function(instance) {\r\n        return instance.call('f');\r\n      })\r\n      .then(function(result) {\r\n        assert.equal('method f()', result, 'is not call method f');\r\n      });\r\n  });\r\n});\r\n```\r\n\r\nRun below command, if you want to deploy test.sol to dappchain (spec. in sun-photon.js).\r\n\r\n```bash\r\nsource .env \u0026\u0026 sun-photon test ./test/test.js --network dappchain\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftronprotocol%2Fsun-photon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftronprotocol%2Fsun-photon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftronprotocol%2Fsun-photon/lists"}