以太坊相关包如何支持EIP-1559
Java:https://blog.web3labs.com/announcing-web3j-support-for-eip-1559JS:https://github.com/ethers-io/ethers.js/issues/1610https://github.com/ethers-io/ethers.js/commit/7a12216cfbd3f86b917451924957471b8
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"));
执行成功案例:

GitCode 天启AI是一款由 GitCode 团队打造的智能助手,基于先进的LLM(大语言模型)与多智能体 Agent 技术构建,致力于为用户提供高效、智能、多模态的创作与开发支持。它不仅支持自然语言对话,还具备处理文件、生成 PPT、撰写分析报告、开发 Web 应用等多项能力,真正做到“一句话,让 Al帮你完成复杂任务”。
更多推荐
所有评论(0)