paraswap-sdk
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
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"));
}
}
It looks like an RPC node issue
@OlegDO I'm having the same issue. Have you fixed it yet?
@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