Convert a Solidity JSON ABI definition to yargs validation
MIT License
Add hearty bash commands to contracts what be stowed in ye's truffle project:
truffle-contract USDC.balanceOf \
--at 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 \
--address 0xdfcb116732ebc9ae2c8939b053363bcf48a37a99 \
--network mainnet
npm install -g truffle-yargs
truffle-contract --dir path-to-your/truffle-project
npm install --save truffle-yargs
Roll your own CLI within your own truffle project.
For example, create a cli.js
with your truffle project:
#!/usr/bin/env node
const path = require('path');
const yargs = require('yargs');
const truffleYargs = require('truffle-yargs')(yargs);
// by default, this will scan truffle default contracts location
truffleYargs()
.demandCommand(1, 'Specify at least one command to run.')
.strict()
.help()
.argv;
Run the methods as commands with the same validation and parsing:
const yargs = require('yargs');
const truffleYargs = require('truffle-yargs')(yargs);
try {
truffleYargs()
.contract('Token', '0x468d834b0FAc4B9D8B2E90bE1cE35A891Ff96Ae9')
.balanceOf({
owner: '0x4a378afbc608073d4520c91d70d06cb79a0a31c5',
})
.then(balance => {
console.log('Balance is:', balance);
}, err => {
console.error('Error:', err);
});
Manually configure a Web3 provider instead of detecting from truffle config
const customProvider = new Web3.providers.HttpProvider('http://localhost:8545');
truffleYargs({
provider: customProvider
});
truffleYargs({
contracts: './custom-build-path/**/*.json'
});
truffleYargs({
contracts: [
Token,
OtherContract,
SafeMath,
]
});
truffleYargs({
contracts: {
Token,
OtherContract,
SafeMath,
}
});