• This repository has been archived on 14/Jun/2018
  • Stars
    star
    254
  • Rank 160,264 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A contract packager for Ethereum and Javascript (formerly ether-pudding)

truffle-artifactor (formerly ether-pudding)

⚠️ This repo is deprecated ⚠️

Truffle has moved all modules to a monorepo at trufflesuite/truffle. See you over there!


This package saves contract artifacts into into Javascript files that can be require'd. i.e.,

var artifactor = require("truffle-artifactor");
artifactor.save({/*...*/}, "./MyContract.sol.js") // => a promise

// Later...
var MyContract = require("./MyContract.sol.js");
MyContract.setProvider(myWeb3Provider);
MyContract.deployed().then(function(instance) {
  return instance.doStuff(); // <-- matches the doStuff() function within MyContract.sol.
}).then(function(result) {
  // We just made a transaction, and it's been mined!
  // We're given transaction hash, logs (events) and receipt for further processing.
  console.log(result.tx, result.logs, result.receipt);
});

πŸ‘

Features

  • Manages contract ABIs, binaries and deployed addresses, so you don't have to.
  • Packages up build artifacts into .sol.js files, which can then be included in your project with a simple require.
  • 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 event.watch()!)

The artifactor uses truffle-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-artifactor

Example

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 = require("truffle-artifactor");

// See truffle-schema for more info: https://github.com/trufflesuite/truffle-schema
var contract_data = {
  abi: ...,              // Array; required.
  unlinked_binary: "..." // String; optional.
  address: "..."         // String; optional.
};

artifactor.save(contract_data, "./MyContract.sol.js").then(function() {
  // The file ./MyContract.sol.js now exists, which you can
  // import into your project like any other Javascript file.
});

API

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.
    }

    Note: save() will also accept an already require'd contract object. i.e.,

    var MyContract = require("./path/to/MyContract.sol.js");
    
    artifactor.save(MyContract, ...).then(...);

    In this case, you can use the extra_options parameter 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 options object.

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_data objects, as in the save() function above:

    {
      "MyContract": {
        "abi": ...,
        "unlinked_binary": ...
      }
      "AnotherContract": {
        // ...
      }
    }
  • directory: String. Destination directory. Files will be saved via <contract_name>.sol.js within that directory.

  • options: Object. Same options listed in save() above.

artifactor.generate(options, networks)

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": ...
      }
    }

Running Tests

$ npm test

License

MIT

More Repositories

1

truffle

⚠️ The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
TypeScript
14,021
star
2

ganache-ui

Personal blockchain for Ethereum development
JavaScript
4,647
star
3

ganache-cli-archive

Fast Ethereum RPC client for testing and development. See https://github.com/trufflesuite/ganache for current development.
JavaScript
3,360
star
4

ganache

⚠️ The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
TypeScript
2,618
star
5

drizzle

Reactive Ethereum dapp UI suite
JavaScript
906
star
6

drizzle-legacy

Reactive Ethereum datastore for dapp UIs.
JavaScript
503
star
7

truffle-hdwallet-provider

HD Wallet-enabled Web3 provider
JavaScript
401
star
8

trufflesuite.com

Trufflesuite website source ✨
HTML
182
star
9

drizzle-react-legacy

JavaScript
176
star
10

drizzle-react-components-legacy

A set of useful components for common dapp UI elements.
JavaScript
96
star
11

truffle-core

Core code for Truffle command line tool
JavaScript
93
star
12

truffle-debugger

Core functionality for debugging Solidity files built with Truffle
JavaScript
67
star
13

drizzle-utils

A library for interacting with Ethereum smart contracts based on RxJS streams.
JavaScript
43
star
14

vscode-ext

Truffle for VSCode simplifies how you create, build, debug and deploy smart contracts on Ethereum and EVM-compatible blockchains
TypeScript
38
star
15

trufflesuite.github.io

Staging Repo of Build Artifacts for Truffle Suite. Find the source at https://github.com/trufflesuite/trufflesuite.com
HTML
34
star
16

ethpm-js

Javascript library for publishing and consuming Ethereum packages.
JavaScript
34
star
17

truffle-plugin-debugger

Debug all the things!
TypeScript
30
star
18

truffle-logger-example

Console.log example for Solidity inside Truffle projects
JavaScript
29
star
19

truffle-contract-schema

JSON schema for contract artifacts
JavaScript
25
star
20

truffle-compile

Compiler helper and artifact manager
JavaScript
22
star
21

truffle-init-default

Default project for Truffle: example contracts, migrations and tests
JavaScript
21
star
22

drizzle-vue-plugin

Connect Vue to Drizzle
JavaScript
19
star
23

pet-shop-tutorial

Solution for the Pet Shop tutorial
JavaScript
18
star
24

truffle-default-builder

Default build process for truffle dapps
JavaScript
18
star
25

truffle-migrate

On-chain migrations management
JavaScript
17
star
26

swirl

Make curl easier with ethereum bash completions.
Shell
15
star
27

webinar-episode-01

Code to go along with our webinars
JavaScript
15
star
28

truffle-deployer

Light deployment module for deploying Ethereum contracts
JavaScript
14
star
29

truffle-teams

Continuous Integration for your Truffle Project
13
star
30

ts-lxd

A client for LXD, written in TypeScript
TypeScript
12
star
31

solidity-magic-square

Demo project for testing debugging features
Solidity
11
star
32

unleashed

JavaScript
10
star
33

unleashed_nft_rental_marketplace

JavaScript
10
star
34

truffle-solidity-utils

Utilities for solidity contracts
JavaScript
9
star
35

truffle-blockchain-utils

Utilities for identifying and managing blockchains
JavaScript
9
star
36

unleashed_royalty_standard

JavaScript
8
star
37

dotfiles

Shell
8
star
38

drizzle-event-demo

Using drizzle events
JavaScript
8
star
39

dashboard

JavaScript
8
star
40

artifact-updates

Working Repository for requirements / design of for general-purpose artifacts format
Shell
8
star
41

truffle-provider

Beefed up Provider utility for Truffle
JavaScript
7
star
42

truffle-box

Truffle project boilerplate management
JavaScript
7
star
43

ethpm-registry

Create a new epm-registry on-chain.
JavaScript
7
star
44

truffle-require

Executed a Javascript module within a Truffle context
JavaScript
7
star
45

devcon5-pentesting-ethereum-contracts-with-ganache

https://trfl.co/devcon5
JavaScript
7
star
46

webinar-truffle-badge

Truffle-themed ERC721 (using OpenZeppelin) for exploring the development lifecycle
JavaScript
6
star
47

ci

Truffle Suite continuous integration config
Shell
6
star
48

reselect-tree

Abstraction around reactjs's `reselect`to define trees of selectors
JavaScript
5
star
49

truffle-config

Utility for interacting with truffle.js files
JavaScript
5
star
50

unleashed_rentable_nft

ERC-4907 implementation for Web3 Unleashed Episode 2
JavaScript
5
star
51

solidity-rock-paper-scissors

JavaScript
5
star
52

txlog-to-plantuml

JavaScript
5
star
53

react-eth-tx-params

A component for displaying ethereum tx params
JavaScript
5
star
54

gas-exactimation-tutorial

Solution for the Gas Exactimation tutorial
JavaScript
4
star
55

truffle-checkout

Used to checkout specific versions of Truffle and associated modules for the purposes of development
JavaScript
4
star
56

ganache-filecoin-alpha-cli

Alpha CLI for Ganache's Filecoin integration. Will be replaced by ganache-cli once integration is stable.
JavaScript
4
star
57

trufflecon-block-contender

Demo app for TruffleCon 2019 Gas Estimation and Optimization Workshop
JavaScript
4
star
58

trufflevsix

Visual Studio Extension for Truffle
C#
4
star
59

truffle-init

Initializer for example Truffle projects
JavaScript
3
star
60

wild-truffle

Truffle cores running on large public Truffle projects.
Shell
3
star
61

truffle-contract-sources

Utility for finding all contracts within a directory
JavaScript
3
star
62

truffle-init-bare

Barebones Truffle project
JavaScript
3
star
63

truffle-code-utils

Utilities for parsing EVM bytecode
JavaScript
3
star
64

unleashed_upgrade_contract

JavaScript
3
star
65

vscode-ext-scaffold

JavaScript
3
star
66

the-bet

Truffle project to look to an external service to determine who wins a contract. Used with an upcoming Truffle video.
JavaScript
3
star
67

truffle-resolver

Resolve contract dependencies given multiple configurable dependency sources
JavaScript
3
star
68

useful-internal-notes

Useful notes on Ethereum, Solidity, Vyper, etc
Solidity
2
star
69

solidity-test-cases

Various helpful solidity test cases
Solidity
2
star
70

truffle-provisioner

Provision contract objects for use from multiple sources
JavaScript
2
star
71

vscode-truffle-debugger

TypeScript
2
star
72

SmartPyBasic-Docker

Dockerized command-line version of SmartPy, a Python library for Tezos smart contract development.
Dockerfile
2
star
73

fetch-and-compile-server

TypeScript
2
star
74

declarative-deployments

Collaborative space to work on getting declarative deployments working!
TypeScript
2
star
75

metacoin-playground

A metacoin repo used internally by Truffle Suite
JavaScript
2
star
76

truffle-expect

Simple module for ensuring expected parameters exist
JavaScript
2
star
77

teams-stress

Stress out the Truffle Teams debugger
Solidity
2
star
78

truffle-workflow-compile

Core workflow logic for the `truffle compile` command behavior
JavaScript
2
star
79

ttt-contracts

Smart contracts for the Unity + Consensys Web3 Tic Tac Toe game.
JavaScript
1
star
80

truffle-error

Simple module that allows native Error objects to be extended
JavaScript
1
star
81

ganache-flavors

1
star
82

truffle-debug-utils

Code for integration between Truffle and Truffle Debugger
JavaScript
1
star
83

quorum-tutorial

Solution for the Quorum tutorial
JavaScript
1
star
84

unleashed_optimism_bridge

The tutorial for this repo lives [here](www.trufflesuite.com/guides/optimism-bridge-widget)
JavaScript
1
star
85

txlog-seedlings

Truffle contracts suitable for planting
JavaScript
1
star
86

CaptureTheFlag

JavaScript
1
star
87

unity-plugin

C#
1
star
88

jstezos

1
star
89

preserves

Truffle preserve framework monorepo
TypeScript
1
star
90

clairvoyance

HTML
1
star