I am trying to transfer ERC20 tokens on private ethereum network(POA)
Transaction flow:
- raw tx object creation on backend.
{
"gasLimit": 37000,
"gasPrice": 4000000000,
"to": <contract address>,
"value": 0,
"chainId": 15,
"data": "0xa9059cbb000000000000000000000000ff70ccdc55a319428fd88809ce848a61087ab2ac0000000000000000000000000000000000000000000000003782dace9d900000"
}
- sign tx on front end.
{ messageHash:
'0x4bbc38ad53cf154ca1445365c9007dfeca0c0cce251945feb2a8ff3bd6de8795',
v: '0x42',
r:
'0xa664add8c614f05d52104a29b16312744cb8849bc5af5cb78a9ba7daf19e8a12',
s:
'0x38c055e9a7c1e5b0321f5d82d832d91da3a2207025756b84c44b8ca31cbbb4f2',
rawTransaction:
'0xf8a80884ee6b280082908894324e19e928239d0c7f8b93247d559b54a4e0d03080b844a9059cbb0000000000000000000000008d75f6db12c444e290db995f2650a68159364e2500000000000000000000000000000000000000000000000270801d946c94000042a0a664add8c614f05d52104a29b16312744cb8849bc5af5cb78a9ba7daf19e8a12a038c055e9a7c1e5b0321f5d82d832d91da3a2207025756b84c44b8ca31cbbb4f2' }
- submit tx from backend data.
web3.eth.sendSignedTransaction(signedData)
.on('receipt',function(receipt:any){
if(receipt.status == false)
throw new Error('transaction failed');
sendSuccessResponse(res, {
txId : receipt.transactionHash
});
})
.catch(function(error:any){
next(error);
})
But when I try to sign transaction on android(using web3j) and submit from backend(web3.js). It fails sometimes(for random receiving addresses such as : 0xFF70ccDC55a319428FD88809cE848a61087Ab2aC
) with error: Transaction has been reverted by the EVM
public String sign(RawTransaction rawTransaction, Credentials credentials) {
byte[] signedMessage;
signedMessage = TransactionEncoder.signMessage(rawTransaction, bigIntToByteArray(15), credentials);
return Numeric.toHexString(signedMessage);
}
version:
Web3.js - 1.2.4
Web3j - org.web3j:core:4.2.0-android
Geth - Geth/v1.9.6-stable-bd059680/linux-amd64/go1.11.5
Network
consensus : POA
No. of nodes : 2