I am trying to make simple transaction using ERC-20 java library. I use mumbai test network for polygon. Code transfers stablecoin from one wallet from another. During approve method call I get following error:

"Error processing transaction request: only replay-protected (EIP-155) transactions allowed over RPC"

When I use rinkeby test network for ethereum and I do same stablecoin transaction it works as expected.

Is it possible to integrate replay-protected (EIP-155) transactions using ERC-20 java library, that will work for both cases (ethereum and polygon)?

        String network = "https://rpc-mumbai.maticvigil.com/";
        String contractAddress = "0xE10a59f3dAAe01e0544E3d45F5579C3eBb7e9c9D";
        String custumerPk = "private key";
        String bridgePk = "private key";
        String bridgeWallet = "0x9d7Be2E6d684Aa8A5995Fe322fF425E9Bdbd6BE7";
        String customerWallet = "0x515e34F4760c7fdcd61d9cAa278f80C15AC7ECdB";

        Web3j web3j = Web3j.build(new HttpService(networkPoly));
        Credentials bridgeCreds = Credentials.create(bridgePk);
        ERC20 bridgeToken = ERC20.load(contractAddress ,web3j,bridgeCreds,new DefaultGasProvider());
        Credentials cutromerCreds = Credentials.create(custoerPk);

        ERC20 cutomerToken = ERC20.load(contractAddress ,web3j,cutromerCreds, new DefaultGasProvider());

        BigInteger amount = new BigInteger("1000000000000000000");

        TransactionReceipt send = cutomerToken.approve(bridgeWallet, amount).send();

        TransactionReceipt send1 = bridgeToken.transferFrom(customerWallet, bridgeWallet, amount).send();

1 Answer 1


You need to give the chainId. this is required after the London Fork, otherwise the tx will not be accepted.

one way to do that is to define a transaction manager, there are many types of transaction managers in Web3j this is 'only' an example:

long chainIdOfPolygon = 80001;
Web3j web3j = Web3j.build(new HttpService(networkPoly));

Credentials bridgeCreds = Credentials.create(bridgePk);
TransactionManager bridgeTokenTxManager = new RawTransactionManager(
    web3j, bridgeCreds, chainIdOfPolygon);
ERC20 bridgeToken = ERC20.load(contractAddress, web3j, bridgeTokenTxManager, new DefaultGasProvider());

Credentials cutromerCreds = Credentials.create(custoerPk);
TransactionManager cutomerTokenTxManager = new RawTransactionManager(
    web3j, cutromerCreds, chainIdOfPolygon);
ERC20 cutomerToken = ERC20.load(contractAddress, web3j , cutomerTokenTxManager, new DefaultGasProvider());
  • Thank you. Works fine in my case Commented Feb 7, 2022 at 9:10
  • @TornikeMaridashvili please make sure you are using the tx manager that fit your needs there are ClientTransactionManager, RawTransactionManager, ReadonlyTransactionManager
    – Majd TL
    Commented Feb 7, 2022 at 9:28

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.