Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chain-end

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chain-end

Programmatic pre-compiled Truffle contract deployment

  • 0.8.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

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:

{
  "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

Keywords

FAQs

Package last updated on 28 Mar 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc