truffle-artifactor (formerly ether-pudding)
var artifactor = ;artifactor // => a promise// Later...var MyContract = ;MyContract;MyContract;
- Manages contract ABIs, binaries and deployed addresses, so you don't have to.
- Packages up build artifacts into
.sol.jsfiles, which can then be included in your project with a simple
- Includes multiple versions of the same contract in a single package, automatically detecting which artifacts to use based on the network version (more on this below).
- Manages library addresses for linked libraries.
- Manages events, making them available on a per-transaction basis (no more
The artifactor uses truffle-contract, which provides features above and beyond
- Synchronized transactions for better control flow: transactions won't be considered finished until you're guaranteed they've been mined.
- Promises. No more callback hell. Works well with
- Default values for transactions, like
- Returning logs, transaction receipt and transaction hash of every synchronized transaction.
$ npm install truffle-artifactor
Here, we'll generate a
.sol.js files given a JSON object like truffle-schema. This will give us a file which we can later
require into other projects and contexts.
var artifactor = ;// See truffle-schema for more info:var contract_data =abi: ... // Array; required.unlinked_binary: "..." // String; optional.address: "..." // String; optional.;artifactor;
artifactor.save(options, filename[, extra_options])
Save contract data as a
.sol.js file. Returns a Promise.
options: Object. Data that represents this contract:contract_name: "MyContract" // String; optional. Defaults to "Contract"abi: ... // Array; required. Application binary interface.unlinked_binary: "..." // String; optional. Binary without resolve library links.address: "..." // String; optional. Deployed address of contract.network_id: "..." // String; optional. ID of network being saved within abstraction.default_network: "..." // String; optional. ID of default network this abstraction should use.
save()will also accept an already
require'd contract object. i.e.,var MyContract = ;artifactor;
In this case, you can use the
extra_optionsparameter to specify options that aren't managed by the contract abstraction itself.
filename: Path to save contract file.
extra_options: Object. Used if you need to specify other options within a separate object, for instance, when a contract abstraction is passed instead of an
artifactor.saveAll(contracts, directory, options)
Save many contracts to the filesystem at once. Returns a Promise.
contracts: Object. Keys are the contract names and the values are
contract_dataobjects, as in the
save()function above:"MyContract":"abi": ..."unlinked_binary": ..."AnotherContract":// ...
directory: String. Destination directory. Files will be saved via
<contract_name>.sol.jswithin that directory.
options: Object. Same options listed in
Generate the source code that populates the
.sol.js file. Returns a String.
options: Object. Subset of options listed in the
save()function above. Expects:abi: ...unlinked_binary: ...
networks: Object. Contains the information about this contract for each network, keyed by the network id."1": // live network"address": ..."2": // morden network"address": ..."1337": // private network"address": ...
$ npm test