How to use @openzeppelin/contract-loader - 2 common examples

To help you get started, we’ve selected a few @openzeppelin/contract-loader examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenZeppelin / openzeppelin-test-helpers / src / singletons.js View on Github external
async function getDeployedERC1820Registry () {
  const config = getSingletonsConfig();
  const loader = setupLoader({
    provider: web3.currentProvider,
    defaultGas: config.defaultGas,
    defaultSender: config.defaultSender,
  });

  if (config.abstraction === 'truffle') {
    const registry = loader.truffle.fromABI(ERC1820_REGISTRY_ABI);
    return registry.at(ERC1820_REGISTRY_ADDRESS);

  } else if (config.abstraction === 'web3') {
    const registry = loader.web3.fromABI(ERC1820_REGISTRY_ABI);
    registry.options.address = ERC1820_REGISTRY_ADDRESS;

    return new web3.eth.Contract(ERC1820_REGISTRY_ABI, ERC1820_REGISTRY_ADDRESS);

  } else {
github OpenZeppelin / openzeppelin-test-environment / src / setup-loader.ts View on Github external
import { setupLoader } from '@openzeppelin/contract-loader';

import config from './config';
import { defaultSender } from './accounts';
import { provider } from './setup-provider';

if (config.contracts.type !== 'truffle' && config.contracts.type !== 'web3') {
  throw new Error(`Unknown contract type: '${config.contracts.type}'`);
}

export default setupLoader({
  defaultSender,
  defaultGas: config.contracts.defaultGas,
  provider,
})[config.contracts.type];

@openzeppelin/contract-loader

Load contract ABIs from built artifacts and return contract objects

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular @openzeppelin/contract-loader functions