web3.js icon indicating copy to clipboard operation
web3.js copied to clipboard

Import only web3-eth-abi ?

Open blueberry6401 opened this issue 2 years ago • 1 comments

I got trouble finding docs about import only this package. I've tried:

import * as web3EthAbi from 'web3-eth-abi';
web3EthAbi.encodeFunctionCall();
// Got "cannot read property 'utils' of undefined"
import web3EthAbi from 'web3-eth-abi';
web3EthAbi.encodeFunctionCall();
// Got "cannot read property 'encodeFunctionCall' of undefined"

How should I import it?

blueberry6401 avatar Jan 11 '24 02:01 blueberry6401

Hi @blueberry6401 let me know if this works for you:

import { encodeFunctionCall } from "web3-eth-abi";

encodeFunctionCall(...)

//OR

const { encodeFunctionCall } = require("web3-eth-abi");

encodeFunctionCall(...)

Anyway, when I tried this one, it worked well:

import * as web3abi from "web3-eth-abi";

web3abi.encodeFunctionCall();

SantiagoDevRel avatar Jan 11 '24 16:01 SantiagoDevRel

Hi @blueberry6401, closing this due to no response. Let me know if you are still having a problem utilizing the solution above.

mconnelly8 avatar Feb 20 '24 00:02 mconnelly8