How to use @ethersproject/abi - 10 common examples

To help you get started, we’ve selected a few @ethersproject/abi 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 cgewecke / eth-gas-reporter / lib / gasData.js View on Github external
gasData: []
          };
          this.deployments.push(contractInfo);

          // Report gas used during pre-test deployments (ex: truffle migrate)
          if (contract.deployed && contract.deployed.transactionHash) {
            this.trackNameByAddress(name, contract.deployed.address);
            const receipt = this.sync.getTransactionReceipt(
              contract.deployed.transactionHash
            );
            contractInfo.gasData.push(utils.gas(receipt.gasUsed));
          }

          // Decode, getMethodIDs
          const methodIDs = {};
          const methods = new ethersABI.Interface(contract.abi).functions;

          // Generate sighashes and remap ethers to something similar
          // to abiDecoder.getMethodIDs
          Object.keys(methods).forEach(key => {
            const raw = ejsUtil.keccak256(key);
            const sighash = ejsUtil.bufferToHex(raw).slice(2, 10);
            methodIDs[sighash] = methods[key];
          });

          // Create Method Map;
          Object.keys(methodIDs).forEach(key => {
            const isInterface = contract.bytecode === "0x";
            const isCall = methodIDs[key].type === "call";
            const methodHasName = methodIDs[key].name !== undefined;

            if (methodHasName && !isCall && !isInterface) {
github ethers-io / ethers.js / packages / contracts / lib / index.js View on Github external
Contract.getInterface = function (contractInterface) {
        if (abi_1.Interface.isInterface(contractInterface)) {
            return contractInterface;
        }
        return new abi_1.Interface(contractInterface);
    };
    // @TODO: Allow timeout?
github ethers-io / ethers.js / packages / contracts / lib.esm / index.js View on Github external
static getInterface(contractInterface) {
        if (Interface.isInterface(contractInterface)) {
            return contractInterface;
        }
        return new Interface(contractInterface);
    }
    // @TODO: Allow timeout?
github ethers-io / ethers.js / packages / contracts / lib.esm / index.js View on Github external
static getInterface(contractInterface) {
        if (Interface.isInterface(contractInterface)) {
            return contractInterface;
        }
        return new Interface(contractInterface);
    }
    // @TODO: Allow timeout?
github ethers-io / ethers.js / packages / ethers / utils.js View on Github external
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var abi_1 = require("@ethersproject/abi");
exports.AbiCoder = abi_1.AbiCoder;
exports.defaultAbiCoder = abi_1.defaultAbiCoder;
exports.EventFragment = abi_1.EventFragment;
exports.FormatTypes = abi_1.FormatTypes;
exports.Fragment = abi_1.Fragment;
exports.FunctionFragment = abi_1.FunctionFragment;
exports.Indexed = abi_1.Indexed;
exports.Interface = abi_1.Interface;
exports.ParamType = abi_1.ParamType;
var address_1 = require("@ethersproject/address");
exports.getAddress = address_1.getAddress;
exports.getContractAddress = address_1.getContractAddress;
exports.getIcapAddress = address_1.getIcapAddress;
exports.isAddress = address_1.isAddress;
var base64 = __importStar(require("@ethersproject/base64"));
exports.base64 = base64;
var bytes_1 = require("@ethersproject/bytes");
exports.arrayify = bytes_1.arrayify;
exports.concat = bytes_1.concat;
exports.hexDataSlice = bytes_1.hexDataSlice;
exports.hexDataLength = bytes_1.hexDataLength;
exports.hexlify = bytes_1.hexlify;
exports.hexStripZeros = bytes_1.hexStripZeros;
github ethers-io / ethers.js / packages / contracts / lib / index.js View on Github external
Contract.isIndexed = function (value) {
        return abi_1.Indexed.isIndexed(value);
    };
    Contract.prototype._normalizeRunningEvent = function (runningEvent) {
github ethers-io / ethers.js / packages / ethers / utils.js View on Github external
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var abi_1 = require("@ethersproject/abi");
exports.AbiCoder = abi_1.AbiCoder;
exports.defaultAbiCoder = abi_1.defaultAbiCoder;
exports.EventFragment = abi_1.EventFragment;
exports.FormatTypes = abi_1.FormatTypes;
exports.Fragment = abi_1.Fragment;
exports.FunctionFragment = abi_1.FunctionFragment;
exports.Indexed = abi_1.Indexed;
exports.Interface = abi_1.Interface;
exports.ParamType = abi_1.ParamType;
var address_1 = require("@ethersproject/address");
exports.getAddress = address_1.getAddress;
exports.getContractAddress = address_1.getContractAddress;
exports.getIcapAddress = address_1.getIcapAddress;
exports.isAddress = address_1.isAddress;
var base64 = __importStar(require("@ethersproject/base64"));
exports.base64 = base64;
var bytes_1 = require("@ethersproject/bytes");
github ethers-io / ethers.js / packages / ethers / utils.js View on Github external
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var abi_1 = require("@ethersproject/abi");
exports.AbiCoder = abi_1.AbiCoder;
exports.defaultAbiCoder = abi_1.defaultAbiCoder;
exports.EventFragment = abi_1.EventFragment;
exports.FormatTypes = abi_1.FormatTypes;
exports.Fragment = abi_1.Fragment;
exports.FunctionFragment = abi_1.FunctionFragment;
exports.Indexed = abi_1.Indexed;
exports.Interface = abi_1.Interface;
exports.ParamType = abi_1.ParamType;
var address_1 = require("@ethersproject/address");
exports.getAddress = address_1.getAddress;
exports.getContractAddress = address_1.getContractAddress;
exports.getIcapAddress = address_1.getIcapAddress;
exports.isAddress = address_1.isAddress;
var base64 = __importStar(require("@ethersproject/base64"));
exports.base64 = base64;
var bytes_1 = require("@ethersproject/bytes");
exports.arrayify = bytes_1.arrayify;
exports.concat = bytes_1.concat;
github ethers-io / ethers.js / packages / ethers / utils.js View on Github external
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var abi_1 = require("@ethersproject/abi");
exports.AbiCoder = abi_1.AbiCoder;
exports.defaultAbiCoder = abi_1.defaultAbiCoder;
exports.EventFragment = abi_1.EventFragment;
exports.FormatTypes = abi_1.FormatTypes;
exports.Fragment = abi_1.Fragment;
exports.FunctionFragment = abi_1.FunctionFragment;
exports.Indexed = abi_1.Indexed;
exports.Interface = abi_1.Interface;
exports.ParamType = abi_1.ParamType;
var address_1 = require("@ethersproject/address");
exports.getAddress = address_1.getAddress;
exports.getContractAddress = address_1.getContractAddress;
exports.getIcapAddress = address_1.getIcapAddress;
exports.isAddress = address_1.isAddress;
var base64 = __importStar(require("@ethersproject/base64"));
exports.base64 = base64;
var bytes_1 = require("@ethersproject/bytes");
exports.arrayify = bytes_1.arrayify;
exports.concat = bytes_1.concat;
exports.hexDataSlice = bytes_1.hexDataSlice;
github ethers-io / ethers.js / packages / ethers / utils.js View on Github external
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var abi_1 = require("@ethersproject/abi");
exports.AbiCoder = abi_1.AbiCoder;
exports.defaultAbiCoder = abi_1.defaultAbiCoder;
exports.EventFragment = abi_1.EventFragment;
exports.FormatTypes = abi_1.FormatTypes;
exports.Fragment = abi_1.Fragment;
exports.FunctionFragment = abi_1.FunctionFragment;
exports.Indexed = abi_1.Indexed;
exports.Interface = abi_1.Interface;
exports.ParamType = abi_1.ParamType;
var address_1 = require("@ethersproject/address");
exports.getAddress = address_1.getAddress;
exports.getContractAddress = address_1.getContractAddress;
exports.getIcapAddress = address_1.getIcapAddress;
exports.isAddress = address_1.isAddress;
var base64 = __importStar(require("@ethersproject/base64"));
exports.base64 = base64;
var bytes_1 = require("@ethersproject/bytes");
exports.arrayify = bytes_1.arrayify;
exports.concat = bytes_1.concat;
exports.hexDataSlice = bytes_1.hexDataSlice;
exports.hexDataLength = bytes_1.hexDataLength;