Socket
Socket
Sign inDemoInstall

@openzeppelin/contract-loader

Package Overview
Dependencies
11
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @openzeppelin/contract-loader

Load contract ABIs from built artifacts and return contract objects


Version published
Maintainers
2
Created

Changelog

Source

0.4.0 (2019-11-8)

  • Reworked API. ([cd8b81]https://github.com/OpenZeppelin/openzeppelin-contract-loader/commit/cd8b81adf1fd36c582d63e940a35e386c6db611f))

Readme

Source

OpenZeppelin Contract Loader

NPM Package Build Status

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

Installation

npm install @openzeppelin/contract-loader

You will also need to install web3-eth-contract and/or @truffle/contract, depending on which abstractions you want to be able to load.

Usage

Basic setup

const { setupLoader } = require('@openzeppelin/contract-loader');

const loader = setupLoader({
  provider,
  defaultSender, // optional
  defaultGas,    // optional - defaults to 8 million
});

Loading web3 contracts

const web3Loader = loader.web3;

// Load from artifacts built by the compiler (stored in .json files)
const ERC20 = web3Loader.fromArtifacts('ERC20');

// Or load directly from an ABI
const abi = [ ... ];
const ERC20 = web3Loader.fromABI(abi);

// 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 });

Loading truffle contracts

const truffleLoader = loader.truffle;

// Load from artifacts built by the compiler (stored in .json files)
const ERC20 = truffleLoader.fromArtifacts('ERC20');

// Or load directly from an ABI
const abi = [ ... ];
const ERC20 = truffleLoader.fromABI(abi);

// 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 });

Keywords

FAQs

Last updated on 08 Nov 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc