Skip to content

Instantly share code, notes, and snippets.

@onbjerg
Last active June 5, 2017 19:17
Show Gist options
  • Save onbjerg/b828aa3bdcc6f9ad0a316a2bfc98a304 to your computer and use it in GitHub Desktop.
Save onbjerg/b828aa3bdcc6f9ad0a316a2bfc98a304 to your computer and use it in GitHub Desktop.
// This is an example of how you could use the package
const contracts = require('@aragon/contracts')
// All of the contracts are exposed in the package as you would expect,
// so a contract named e.g. ``KeybaseRegistry`` would be accessible in
// ``contracts.KeybaseRegistry``.
// One could then interact with them through a package like ``truffle-contract``
const provider = new Web3.providers.HttpProvider('http://localhost:8545')
const contract = require('truffle-contract')
const KeybaseRegistryContract = contract(contracts.KeybaseRegistry)
KeybaseRegistryContract.setProvider(provider)
// This is the only JavaScript file in the ``@aragon/contracts`` package
// along with the built contracts
var glob = require('glob')
var path = require('path')
var basePath = './build/contracts'
// Load all of the JSON files in the ./build/contracts directory and expose them
module.exports = glob.sync(
path.resolve(__dirname, basePath, '*.json')
).reduce(function (contracts, file) {
var contract = require(file)
if (contract.contract_name) {
contracts[contract.contract_name] = contract
}
return contracts
}, {})
{
"name": "@aragon/contracts",
"scripts": {
"prepublish": "truffle compile"
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment