Java:
https://blog.web3labs.com/announcing-web3j-support-for-eip-1559
JS:
https://github.com/ethers-io/ethers.js/issues/1610
https://github.com/ethers-io/ethers.js/commit/7a12216cfbd3f86b917451924957471b8be21a8b
Python:
https://web3py.readthedocs.io/en/stable/web3.eth.html#web3.eth.Eth.send_transaction
这里主要讲述一下Java:
Maven:
<dependency>
<groupId>org.web3j</groupId>
<artifactId>core</artifactId>
<version>4.8.7</version>
</dependency>
Gradle:
dependencies {
implementation "org.web3j:core:4.8.7",
}
注意:web3j的包对于EIP-1559协议目前只支持到4.8.7 过高或过低的版本则不支持该协议。
另外使用RawTransaction写法的同学需要更换转账接口
使用 RawTransaction.createEtherTransaction
public static RawTransaction createEtherTransaction(
long chainId,
BigInteger nonce,
BigInteger gasLimit,
String to,
BigInteger value,
BigInteger maxPriorityFeePerGas,
BigInteger maxFeePerGas) {
return new RawTransaction(
Transaction1559.createEtherTransaction(
chainId, nonce, gasLimit, to, value, maxPriorityFeePerGas, maxFeePerGas));
}
注意:maxPriorityFeePerGas <= maxFeePerGas 详细规则请看上篇文章。
RawTransaction rawTransaction = RawTransaction.createEtherTransaction(chainId.longValue(), nonce, ethGasLimit, to, balance, new BigInteger("20000000000"), new BigInteger("30000000000"));
执行成功案例: