0

I'm trying to call in node.js a function(depositLPandStake) from this conctract "0x4E4De8594aD39cd21971775504702d4B00a1451E", seems like this is an implementation contract from that proxy "0xc9Ae7Dac956f82074437C6D40f67D6a5ABf3E34b". To create contract instance I'm using proxy address and ABI from implementation contract.

Here is a code:

async function runPenrose() {
  const gasPrice = await getGasPrice();
  const wallet = new ethers.Wallet(WALLET_SECRET, web3Provider);

  const PenroseCommunication = new ethers.Contract(
    PenroseProxy,
    PenroseContractABI,
    web3Provider
  );

  const penroseContract = PenroseCommunication.connect(wallet);
  const tokenAmount = await getTokenBalanceWallet(PoolToken);

  return await penroseContract.functions
    .depositLpAndStake(DystopiaPoolAddress, tokenAmount, {
      gasPrice: gasPrice,
      gasLimit: BigNumber.from("500000"),
    })
    .call();
}

And I have this error:

.depositLpAndStake(DystopiaPoolAddress, tokenAmount, {
     ^

TypeError: penroseContract.functions.depositLpAndStake is not a function

Nevertheless polygonscan can find implementation contract and all functions could be used in "write as Proxy" panel, but for some reason I can't do the same in ethers.js

Edit: I solved the problem. The reason is that called function has 2 different implimentation depending on arguments: with argument "amount" or without it, so I trimmed down the ABI, removed unnecessary function implimentation and it's started to work properly.

1
  • You are using etherjs so the call should be penroseContract.depositLpAndStake(...), without the functions (that is a web3js thing).
    – Ismael
    Commented Oct 21, 2022 at 5:53

1 Answer 1

1

Penrose (0xc9Ae7Dac) is a proxy contract and by default, Penrose uses UserProxyInterface (0x4E4De859) implementation whenever an unrecognized function is called. This being said, the Penrose Contract does not implement the function depositLPandStake but happens to be implemented by UserProxyInterface (0x4E4De859). Thus the Penrose ABI does not define the function depositLpAndStake

Replacing Penrose's ABI by UserProxyInterface could do the trick:

 const PenroseCommunication = new ethers.Contract(
    PenroseProxy,
    UserProxyInterfaceABI,
    web3Provider
  );
1
  • Thanks, but actually I already use in my case UserProxyInterfaceABI from here(0x4E4De859), and adress from PenroseProxy(0xc9Ae7Dac), and still have the same error.
    – serbazov
    Commented Oct 14, 2022 at 13:29

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.