chain-end v0.8.0
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
contractsobject, which contains the JSON (truffle compileoutput) of the default contracts - The
Deployerclass- Instantiate a deployer using
Deployer(web3Provider, accountAddress, gasLimit)- For use with MetaMask, use
Deployer(web3Provider, accountAddress)to let MetaMask handle transaction gas
- For use with MetaMask, use
- Add a contract type to deploy instances of it using
deployer.addContract(compiledJSON)compiledJSONmust be an undeployed, compiled Truffle artifact, i.e. the output oftruffle compile
- Deploy and access a deployed contract instance using
const instance = deployer.deploy(contractName, constructorParameters)- ContractName must be a key from
contractsor the name of a contract added usingaddContract
- ContractName must be a key from
- Consult
src/web3/deployer.jsfor additional methods you may want to use
- Instantiate a deployer using
- The
deployfunction, which exposes the internal API ofDeployerfor stateless deployment- Deploy directly using:
deploy(contractJSON, constructorParams, web3Provider, web3Account, gasLimit) gasLimitis optional
- Deploy directly using:
- The
getInstancefunction, which retrieves a deployed contract given its artifact, its deployed address, a provider, and (optionally) a sender account - The
callInstancefunction, 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
.solfiles insolidity/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 theopenzeppelin-contractsfolder (note the version inpackage.json)
- Place your target contracts directly under
- Do
yarn get-metadata, notice the files output insolidity/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
- Their Truffle artifacts will be in
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
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago