Cannot send EIP-1559 transaction even when forcing type: 2
Expected behavior
Can send EIP-1559 tx
Actual behavior
Legacy tx sent
Steps to reproduce the behavior
These are the versions in package.json
"web3": "^1.5.2"
"@truffle/hdwallet-provider": "^1.5.0"
This is how I try to create an EIP-1559 tx:
- Doesn't specify anything related to gas
web3.eth.sendTransaction({
from: account,
to: toAccount,
value: sendAmount,
})
- Specify tx type and various fee per gas settings:
web3.eth.sendTransaction({
from: account,
to: toAccount,
value: sendAmount,
type: 2,
maxFeePerGas: gasPrice,
maxPriorityFeePerGas: tip,
})
Both result the same (legacy tx)
Logs
https://rinkeby.etherscan.io/tx/0x9eeb2345d0d1453896e15eaa8743b74ba44a3a7c9864c66ba49569e990488dc7
Environment
docker (node:14.17.4-alpine3.11), sending tx on rinkeby testnet
Hi there, thank you for bringing this to our attention. Could you provide a test repo for us to use for debugging? Seems like it might be related to @truffle/hdwallet-provider
Hi again, I was able to submit a type: 0x2 transaction on Rinkeby using
web3.eth.sendTransaction({
from: '0xEe29eDBD1b938175181DCe9E0D818a1c54793525',
to: '0xEe29eDBD1b938175181DCe9E0D818a1c54793525',
value: '0x1',
gasLimit: 21000
})
Could you provide a code example, otherwise I'm going to have to close this as I cannot reproduce
@spacesailor24 Thanks for the reply. I wrote a minimal repo where you can test it:
https://github.com/agro1986/web3-eip1599-test
Best regards
Hi there,
I have a very similar issue when sending a raw transaction with upfront signing through web3.eth.accounts.signTransaction(tx, private_key)
The problem seems to be occurring during the signing, and I cannot find the hex value of the maxPriorityFeePerGas in the signed transaction.
My input to signTransaction looks like the following:
let tx = {
from: '0x...',
to: '0x...',
value: Web3.utils.toHex(eth_value_in_wei),
maxFeePerGas: Web3.utils.toHex(gas_price),
maxPriorityFeePerGas: Web3.utils.toHex(priority_gas_price),
gas: Web3.utils.toHex(gas_limit),
nonce: Web3.utils.toHex(tx_count),
type: '0x2',
data: data
}
Am I doing something wrong or is it an issue with web3js and if so, is there a workaround?
repost
I tried with the given sample repo and code below.
web3.eth.sendTransaction({
from: account,
to: zeroAddress,
value: new web3.utils.BN(1),
type: 2,
maxFeePerGas: new web3.utils.BN(2),
maxPriorityFeePerGas: new web3.utils.BN(1),
})
Tried couple of transactions and all were created as legacy (0).
https://rinkeby.etherscan.io/tx/0x71cfdf047e20406a253692b7c94dfc83262e1e5d1ce2b8f47213f60434f9315c https://rinkeby.etherscan.io/tx/0x371e7cc0b6f6fd12c1c55582a9f781fdcb80215501339978f1500229ba559b18 https://rinkeby.etherscan.io/tx/0xbe03e0fcb521b7580a71729d005ec07aed95c6aafe339f3f6f74f72e35e9b112
Also tried the offline web3.eth.accounts.signTransaction(tx, private_key) but same behaviour.
This issue definitely need to look further details, I suspect somewhere before signing the type is mutated.
I also tried around a bit and found out that for my case, using hex values as input for signTransaction were somehow causing the issue. When using decimals, it is working.
I was able to figure out the problem. Its the issue with the @truffle/hdwallet-provider. That package is using [email protected] to serialize the transactions during signTransaction which does not support EIP-1559 yet. In web3 we are using @ethereumjs/tx which had added support for EIP-1559.
To verify that here is a script which is using @truffle/hdwallet-provider just to get privateKey from mnemonic and using web3 builtin signTransaction internally to serialize the transaction.
const walletUrl = 'wss://eth-rinkeby.alchemyapi.io/v2/[your-key]';
const walletMnemonic = 'xxxxxxx';
const Web3 = require('web3');
const HDWalletProvider = require('@truffle/hdwallet-provider');
async function start() {
const wsProvider = new Web3.providers.WebsocketProvider(walletUrl);
const web3 = new Web3(wsProvider);
// Get the Private Key
const walletProvider = new HDWalletProvider(walletMnemonic, wsProvider);
const account = walletProvider.addresses[0]
const privateKey = walletProvider.wallets[account].privateKey;
// Generate account and add to local wallet
web3.eth.accounts.wallet.add(web3.eth.accounts.privateKeyToAccount('0x' + privateKey.toString('hex')));
await web3.eth.sendTransaction({
from: account,
to: zeroAddress,
value: new web3.utils.BN(2),
type: 2,
maxFeePerGas: new web3.utils.BN('300000000'),
maxPriorityFeePerGas: new web3.utils.BN('2000000000'),
gas: 21000,
}).on('transactionHash', function(txHash) {
console.log('https://rinkeby.etherscan.io/tx/' + txHash);
console.log('transactionHash');
}).on('receipt', function(receipt){
console.log('Received...', receipt);
process.exit(0);
});
}
start();
Here is a ref tx created with above script.
There is already an issue on Ganache to provide support for EIP-1559. I believe once that issue is been worked out all the related packages will also provide support for EIP-1559 including @truffle/hdwallet-provider. Till then feel free to use above code as inspiration for a workaround.
@agro1986 I am closing the issue for now, If you observe same problem with some other findings feel free to re-open the issue.