JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 19791
  • Score
    100M100P100Q142896F
  • License MIT

Load contract ABIs from built artifacts and return contract objects

Package Exports

  • @openzeppelin/contract-loader

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@openzeppelin/contract-loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

OpenZeppelin Contract Loader

NPM Package Build Status

Load contract ABIs from built artifacts. Includes support for both web3-eth-contract and @truffle/contract objects.

Installation

npm install --save-dev @openzeppelin/contract-loader

Usage

web3 contracts

const loader = require('@openzeppelin/contract-loader')
const load = loader.web3({
  web3Contract: web3.eth.Contract,
  defaultSender, // optional
  defaultGas,    // optional - defaults to 8 million
});

// Load artifacts
const ERC20 = load('ERC20');

// Deploy token
const token = await ERC20.deploy().send();

// Query blockchain state and send transactions
const balance = await token.methods.balanceOf(sender).call();
await token.methods.transfer(receiver, balance).send({ from: sender });

truffle contracts

const loader = require('@openzeppelin/contract-loader')
const load = loader.truffle({
  truffleContract: require('@truffle/contract'),
  provider: web3.eth.currentProvider,
  defaultSender, // optional
  defaultGas,    // optional - defaults to 8 million
});

// Load artifacts
const ERC20 = load('ERC20');

// Deploy token
const token = await ERC20.new();

// Query blockchain state and send transactions
const balance = await token.balanceOf(sender);
await token.transfer(receiver, balance, { from: sender });