stanislaw-glogowski / truffle-plugin-dist

Truffle distribution plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Truffle distribution plugin

NPM version

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

About

Truffle distribution plugin

License:MIT License


Languages

Language:JavaScript 100.0%