I'm changing a part of front-end for my dApp from using Moralis to using ethers.js. For some reason I cannot get my head around on how to provide multiple arguments for the function call in a correct manner.

Consider this contract function that does on-chain conversion, using an oracle:

    function getUniversalConversionRate(uint256 coinAmount,address priceFeedAddress) 
    public view returns (uint256) {
        uint256 coinPrice = getUniversalPrice(priceFeedAddress);
        uint256 coinAmountInUsdCents = (coinPrice * coinAmount) /10000000000000000;
        return coinAmountInUsdCents;}

This is its ABI:

        "inputs": [
            {"internalType": "uint256","name": "coinAmount","type": "uint256"},
            {"internalType": "address","name": "priceFeedAddress","type": "address"}],
        "name": "getUniversalConversionRate",
        "outputs": [{"internalType": "uint256","name": "","type": "uint256"}],
        "stateMutability": "view",
        "type": "function"},

And this is how I interact with it:

  const provider = new ethers.providers.JsonRpcProvider("https://rpc...", 80001);
  const signer = new ethers.Wallet("0x...", provider); //saving space
  const administrativeSidechainContract = new ethers.Contract(mainContractAddress, abi, signer)
  async function updateUI() {
  const ethPriceData = await administrativeSidechainContract.getUniversalConversionRate({
       coinAmount: "1", priceFeedAddress: "0x...." })

I provide both arguments which are correct and work in another framework with the same inputs but with ethers i get Error: missing argument: passed to contract (count=1, expectedCount=2, code=MISSING_ARGUMENT, version=contracts/5.6.0) What do I do wrong?

1 Answer 1


You pass parameters like this:

const ethPriceData = await administrativeSidechainContract.getUniversalConversionRate("1", "0x....")

If you want to send ether, set gasLimit etc along with the function call, you can do like this:

const ethPriceData = await administrativeSidechainContract.getUniversalConversionRate("1", "0x....", {value: 100000000000})

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.