Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

truffle-declarative

2.0.4 • Public • Published

truffle-declarative

Run complex playbooks of blockchain scripts using simple declarative syntax

Command Line

 
./node_modules/.bin/truffle-play
 

Programmatic

 
const TruffleDeclarative = require('truffle-declarative');
const run = new TruffleDeclarative({
  output: 'results.yml',
  networkName: 'development',
  dryRun: true
});
 
const results = await run([{
  description: 'Deploy a new version of SafeMathLib',
  contract: 'SafeMathLib',
  run: 'new',
  inputs: [{
    from: '0x1f9c410d5562bb6590b8f891f2e26311f9a6ef8c',
    gasPrice: 11e9,
  }],
  outputs: {
    'address': 'safeMathLib'
  }
}, {
  description: 'Link IDRP to new SafeMathLib',
  contract: 'IDRP',
  run: 'link',
  inputs: ['$contracts.SafeMathLib', {
    from: '0x1f9c410d5562bb6590b8f891f2e26311f9a6ef8c',
  }],
  outputs: {
    'address': 'idrp'
  }
}, {
  description: 'Deploy new CouponStorage',
  contract: 'CouponStorage',
  run: 'new',
  inputs: [{    
    safeMathLib: '$outputs.safeMathLib',
    stableCoin: '$outputs.idrp',
    initialSupply: 1e30,
  }, {
    from: '0x1f9c410d5562bb6590b8f891f2e26311f9a6ef8c',
  }],
  outputs: {
    'address': 'couponStorage'
  }
}, {
  description: 'Check CouponStorage balance for wallet #1.',
  contract: 'CouponStorage',
  at: '$outputs.couponStorage',
  run: 'balanceOf',
  inputs: ['0x1f9c410d5562bb6590b8f891f2e26311f9a6ef8c'],
  outputs: 'balanceOfWallet1'
}]);

special

Run special utils, such as truffle-object-mapper:

 
const TruffleDeclarative = require('truffle-declarative');
const run = new TruffleDeclarative({
  map: path.join(__dirname, 'map.js'),
});
 
const results = await run([{
  description: 'Dump the current contract',
  contract: 'CouponStorage',
  at: '0x1f9c410d5562bb6590b8f891f2e26311f9a6ef8c',
  run: 'util.map'
}]);
 

Install

npm i truffle-declarative

DownloadsWeekly Downloads

1

Version

2.0.4

License

MIT

Unpacked Size

63.4 kB

Total Files

26

Last publish

Collaborators

  • avatar