truffle-plugin-dist
v0.1.0
Published
Truffle distribution plugin
Downloads
16
Readme
Truffle distribution plugin
Installation
$ npm i truffle-plugin-dist -D
Configuration
Activate plugin in truffle.js
module.exports = {
// ...
plugins: [
'truffle-plugin-dist',
],
}
Add main
and types
in package.json
{
"main": "./dist/index.js",
"types": "./dist/index.d.ts"
}
Define schema
schema in truffle.js
module.exports = {
// ...
schema: {
Example: {
abi: true,
addresses: true,
byteCodeHash: true,
},
},
};
Create distribution
$ truffle run dist
Usage
import {
ContractNames,
getContractAddress,
getContractAbiDefinition,
getContractByteCodeHash,
} from 'your-contracts-npm-package';
console.log(
'Example contract mainnet address:',
getContractAddress(ContractNames.Example, '1'),
);
console.log(
'Example contract kovan address:',
getContractAddress(ContractNames.Example, '42'),
);
console.log(
'Example contract abi definition:',
getContractAbiDefinition(ContractNames.Example),
);
console.log(
'Example contract byteCodeHash:',
getContractByteCodeHash(ContractNames.Example),
);
License
The MIT License