{"id":18189691,"url":"https://github.com/wanseob/npm-truffle-box","last_synced_at":"2026-05-10T02:50:35.157Z","repository":{"id":57146583,"uuid":"172938173","full_name":"wanseob/npm-truffle-box","owner":"wanseob","description":"Truffle box to make your smart contracts as an npm library exporting them to truffle-contract objects","archived":false,"fork":false,"pushed_at":"2019-03-19T17:53:32.000Z","size":103,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T05:04:30.130Z","etag":null,"topics":["library","npm","solidity","truffle","truffle-contract"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wanseob.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-02-27T15:13:20.000Z","updated_at":"2019-03-19T17:53:34.000Z","dependencies_parsed_at":"2022-09-05T15:50:33.265Z","dependency_job_id":null,"html_url":"https://github.com/wanseob/npm-truffle-box","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/wanseob%2Fnpm-truffle-box","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanseob%2Fnpm-truffle-box/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanseob%2Fnpm-truffle-box/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanseob%2Fnpm-truffle-box/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wanseob","download_url":"https://codeload.github.com/wanseob/npm-truffle-box/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247675626,"owners_count":20977376,"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":["library","npm","solidity","truffle","truffle-contract"],"created_at":"2024-11-03T04:03:47.745Z","updated_at":"2026-05-10T02:50:33.635Z","avatar_url":"https://github.com/wanseob.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# npm Truffle box\n\nThis is a boilerplate code to make your smart contract as an [npm](https://npmjs.com) library using [`truffle-plugin-modularizer`](https://github.com/wanseob/truffle-plugin-modularizer) . It exports the json files in `build/contracts/` and creates `src/index.js`. Then you will be able to use your contracts as an instance of [`truffle-contract`](https://github.com/trufflesuite/truffle/tree/develop/packages/truffle-contract). Finally, publish them onto the npm repository, and import into your applications. \n\nSee [this](https://github.com/wanseob/truffle-plugin-modularizer) to get more detail how `truffle-plugin-modularize` works.\n\n\n\n# Usage\n\n### Contract side\n\n1. Create a directory to start your project\n\t```bash\n\tmkdir YourProject\n\tcd YourProject\n\t```\n\t\n2. Unbox `npm-truffle-box`\n\t```bash\n\tnpx truffle unbox wanseob/npm-truffle-box\n\t```\n\t\n3. Develop and test\n\t```bash\n\tnpm run test\n\t```\n\t\n4. Configure your truffle-config.json\n\t```javascript\n    // truffle-config.js\n    module.exports = {\n      ...,\n      plugins: [\n        'truffle-plugin-modularizer'\n      ],\n      modularizer: {\n        // output: 'src/index.js',\n        // target: 'build/contracts'\n        // includeOnly: [],\n        // networks: []\n      },\n    }\n   ```\n   \n5. Modularize your smart contract as a node module. The following command will automatically generate the `src/index.js` file which contains your smart contracts as `truffle-contract` instances\n\t```javascript\n\tnpm run modularize\n\t```\n\n6. Configure your package.json\n\t```javascript\n\t//package.json\n\t{\n        \"name\": \"Your project name\",\n        ...,\n        \"main\": \"src/index.js\",\n        ...\n\t}\n\t```\n\t\n7. \tDeploy to npm\n\t```bash\n\tnpm publish\n\t```\n\n### Application side\n\n1. install your module\n\t```bash\n\t$ cd /your/react/app/path\n\t$ npm install --save \"your-project-name\"\n\t```\n\n2. Import contracts into your front-end application and init with web3 provider\n\n\t```javascript\n    import { SampleContract } from 'your-project-name'\n\n    web3 = window.web3\n    \n    SampleContract(web3).deployed().then(\n        async instance =\u003e {\n          await instance.add(10)\n          await instance.add(20)\n          await instance.add(30)\n          let values = await instance.getValues()\n          console.log(\"Values: \", values)\n        }\n    )\n   ```\n\n\n\n# Scripts\n\n- `npm run testContracts`: It runs test cases in `test/` directory for your smart contracts. This uses `truffle test` command.\n- `npm run testModule`: It runs test cases in `moduleTest/` to check the modularized output. It modularizes your contracts and create a temporal output file `build/index.tmp.js`. You should write Mocha test cases importing your smart contract from the temporal output file.\n- `npm run test`: It tests both the contracts and the modularized output.\n- `npm run standard`: It follows JS standard style.\n- `npm run ethlint`: Lint your smart contracts.\n\nIf you don't prefer standard style and ethlint, remove \"pre-commit\" property from the `package.json` .\n\n\n# License\n\n[Apache-2.0](LICENSE)\n\n# Contributors\n\n[@wanseob](https://github.com/wanseob) [@gurrpi](https://github.com/gurrpi) [@jacobcreech](https://github.com/jacobcreech)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwanseob%2Fnpm-truffle-box","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwanseob%2Fnpm-truffle-box","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwanseob%2Fnpm-truffle-box/lists"}