paraswap-sdk icon indicating copy to clipboard operation
paraswap-sdk copied to clipboard

Can't approve erc20 token for swap. Error: the method eth_sendTransaction does not exist/is not available. Chain info: Ethereum ropsten

Open OlegDO opened this issue 2 years ago • 3 comments

Problem

Trying to approve before swap LINK (ERC-20 token) to ETH on Ethereum ropsten testnet.

Error msg

Error: Returned error: The method eth_sendTransaction does not exist/is not available

Logs

Source amount: 500000000000000000
User address: 0x57d91Eae4C6Db82f6D92BC2344eed7DB8cD4eA28
ERC-20 token address: 0xb4f7332ed719Eb4839f091EDDB2A3bA309739521

Code example:


private async approveToken(
    srcAmount: string,
    userAddress: string,
    erc20tokenAddress: string
  ): Promise<string> {
    try {
      /**
       * @Tx hash of approved token amount of user address with the particular amount
       */
      console.log("Source amount:", srcAmount);
      console.log("User address:", userAddress);
      console.log("ERC-20 token address:", erc20tokenAddress);
      return await this.paraSwap.approveToken(
        srcAmount,
        userAddress,
        erc20tokenAddress
      );
    } catch (error) {
      throw new Error(getErrorMessage(error, "Failed to approve token"));
    }
  }

OlegDO avatar Jun 03 '22 09:06 OlegDO

It looks like an RPC node issue

mounibec avatar Jun 04 '22 13:06 mounibec

@OlegDO I'm having the same issue. Have you fixed it yet?

nmaddp1995 avatar Feb 19 '24 14:02 nmaddp1995

@mounibec When I try to change RPC, it shows the error unknow account. Could you please support me with the init paraswap SDK with provider that can call apporveToken function. Currently I'm using wagmi but can change to ethers if needed

nmaddp1995 avatar Feb 21 '24 06:02 nmaddp1995