truffle-conflux-artifactor
This package saves contract artifacts into JSON files
const Artifactor = require("truffle-conflux-artifactor");
const artifactor = new Artifactor(__dirname);
artifactor.save({});
👏
Features
- Manages contract ABIs, binaries and deployed addresses, so you don't have to.
- Packages up build artifacts into
.json
files, which can then be included in your project with a simple require
. - Manages library addresses for linked libraries.
The artifactor can be used with truffle-conflux-contract, which provides features above and beyond web3
:
- 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
ES6
and async/await
. - Default values for transactions, like
from
address or gas
. - Returning logs, transaction receipt and transaction hash of every synchronized transaction.
Install
$ npm install truffle-conflux-artifactor
Example
Here, we'll generate a .json
files given a JSON object like truffle-conflux-contract-schema. This will give us a file which we can later require
into other projects and contexts.
const Artifactor = require("truffle-conflux-artifactor");
const artifactor = new Artifactor(__dirname);
const contractData = {
contractName: "...",
abi: ...,
metadata: "...",
bytecode: "...",
"x-some-dependency": ...
};
artifactor.save(contractData);
API
artifactor.save(contractData)
Save contract data as a .json
file. Returns a Promise.
-
contractData
: Object. Data that represents this contract:
{
contractName: "MyContract",
abi: ...,
metadata: "...",
bytecode: "...",
deployedBytecode: "...",
sourceMap: "...",
deployedSourceMap: "...",
source: "...",
sourcePath: "...",
ast: ...,
legacyAST: ...,
compiler: ...,
networks: ...,
schemaVersion: "...",
updatedAt: "...",
devdoc: "...",
userdoc: "...",
"x-custom-property": ...
}
artifactor.saveAll(contracts)
Save many contracts to the filesystem at once. Returns a Promise.
-
contracts
: Object. Keys are the contract names and the values are contractData
objects, as in the save()
function above:
{
"MyContract": {
"abi": ...,
"bytecode": "..."
}
"AnotherContract": {
}
}
Running Tests
$ npm test
License
MIT