# chain-end

> Programmatic pre-compiled Truffle contract deployment

Latest version **0.8.0** (published 2020-03-28) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install chain-end
pnpm add chain-end
yarn add chain-end
bun add chain-end
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.8.0 |
| Published | 2020-03-28 |
| First published | 2018-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Erik Marks |
| Maintainers | rekmarks |
| Keywords | Ethereum, smart contracts, Truffle, Solidity |

## Links

- npm: https://www.npmjs.com/package/chain-end
- Repository: https://github.com/rekmarks/chain-end
- Homepage: https://github.com/rekmarks/chain-end#readme
- Issues: https://github.com/rekmarks/chain-end/issues
- npm.io page: https://npm.io/package/chain-end

## Dependencies (1)

- [@truffle/contract](https://npm.io/package/@truffle/contract.md) ^4.1.14

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.8.0 (latest) — 2020-03-28
- 0.7.1 — 2019-05-15
- 0.7.0 — 2019-02-15
- 0.6.5 — 2019-02-15
- 0.6.4 — 2019-02-15
- 0.6.3 — 2019-02-09
- 0.6.2 — 2019-01-18
- 0.5.4 — 2018-08-31
- 0.5.3 — 2018-08-31
- 0.5.2 — 2018-08-30
- 0.5.1 — 2018-08-13
- 0.5.0 — 2018-08-06
- 0.4.0 — 2018-08-03
- 0.3.0 — 2018-07-26
- 0.2.1 — 2018-07-20
- … 4 more at https://npm.io/package/chain-end/versions

## README

# ChainEnd

For programmatically deploying an arbitrary number of pre-compiled Solidity smart contracts.

You can also clone the repo to access a clunky command line utility for, given `.sol` source files, finding dependencies of smart contracts and joining them into a single source file for easy Etherscan verification.

## Usage

Install using `npm install chain-end`. Command line utilities require Python.

## Smart Contract Deployment

The imported package contains the following relevant properties:

- The `contracts` object, which contains the JSON (`truffle compile` output) of the default contracts
- The `Deployer` class
  - Instantiate a deployer using `Deployer(web3Provider, accountAddress, gasLimit)`
    - For use with MetaMask, use `Deployer(web3Provider, accountAddress)` to let MetaMask handle transaction gas
  - Add a contract type to deploy instances of it using `deployer.addContract(compiledJSON)`
    - `compiledJSON` must be an undeployed, compiled Truffle artifact, i.e. the output of `truffle compile`
  - Deploy and access a deployed contract instance using `const instance = deployer.deploy(contractName, constructorParameters)`
    - ContractName must be a key from `contracts` or the name of a contract added using `addContract`
  - Consult `src/web3/deployer.js` for additional methods you may want to use
- The `deploy` function, which exposes the internal API of `Deployer` for stateless deployment
  - Deploy directly using: `deploy(contractJSON, constructorParams, web3Provider, web3Account, gasLimit)`
  - `gasLimit` is optional
- The `getInstance` function, which retrieves a deployed contract given its artifact, its deployed address, a provider, and (optionally) a sender account
- The `callInstance` function, which calls a specified function from a given TruffleContract instance and returns the result

## Command Line Utility

_Note:_ GitHub repository only, also literally the hackiest thing you've ever seen.

All scripts must be run from the `chain-end` project root directory.

- `yarn cli-setup`
- Place your `.sol` files in `solidity/source_files/raw`
  - Place your target contracts directly under `raw/`
  - Place your dependencies in some folder, e.g. `raw/dependencies`
  - `raw/` will contain all OpenZeppelin contracts in the `openzeppelin-contracts` folder (note the version in `package.json`)
- Do `yarn get-metadata`, notice the files output in `solidity/metadata`
- Do `yarn join-source-files -- solidity/metadata/metadataFile solidity/metadata/filepathsFile`
  - Both arguments are simply the files output by the previous script
- Do `yarn solcompile`
- Your contracts will now be available through the package in `module.exports.contracts`
  - Their Truffle artifacts will be in `solidity/compiled`
  - Their joined source files in `solidity/source_files/complete`

### Metadata

If the metadata interests you, here is a partial example output:

```json
{
  "Address": {
    "compiler": "^0.5.0",
    "dependencies": [],
    "name": "Address",
    "type": "library"
  },
  "AllowanceCrowdsale": {
    "compiler": "^0.5.0",
    "dependencies": [
      "Crowdsale",
      "IERC20",
      "Math",
      "SafeERC20",
      "SafeMath"
    ],
    "name": "AllowanceCrowdsale",
    "type": "contract"
  },
  ...
}
```

## License

MIT

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