diff --git a/CHANGELOG.md b/CHANGELOG.md index 89895d199d..a5a4d24635 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,16 +7,12 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Bug Fixes -* fix Transaction.getChainId when v=27 must return null [#2133](https://github.com/hyperledger-web3j/web3j/pull/2133) -* Fix android scripts [#2138](https://github.com/hyperledger-web3j/web3j/pull/2138) * fixed subscription id conflict [#2127](https://github.com/hyperledger/web3j/pull/2127) ### Features * bump snapshot version to 4.12.4 [#2132](https://github.com/hyperledger-web3j/web3j/pull/2132) -* ENS - Label Hash function added [#2140](https://github.com/hyperledger-web3j/web3j/pull/2140) -* Added Dynamic gas providers [#2142](https://github.com/hyperledger-web3j/web3j/pull/2142) -* Added Linea RPC APIs [#2150](https://github.com/hyperledger-web3j/web3j/pull/2150) +* Added LineaEstimateGas api [#2150](https://github.com/hyperledger-web3j/web3j/pull/2150) ### BREAKING CHANGES diff --git a/core/src/main/java/org/web3j/protocol/core/methods/response/EthEstimateGas.java b/core/src/main/java/org/web3j/protocol/core/methods/response/EthEstimateGas.java index 5e1b02cc53..27be74c455 100644 --- a/core/src/main/java/org/web3j/protocol/core/methods/response/EthEstimateGas.java +++ b/core/src/main/java/org/web3j/protocol/core/methods/response/EthEstimateGas.java @@ -20,6 +20,11 @@ /** eth_estimateGas. */ public class EthEstimateGas extends Response { public BigInteger getAmountUsed() { + if (getResult().isEmpty() || getResult() == null) { + System.out.println("Empty/null result for EthEstimateGas"); + return BigInteger.ONE; + } + return Numeric.decodeQuantity(getResult()); } } diff --git a/core/src/main/java/org/web3j/tx/Contract.java b/core/src/main/java/org/web3j/tx/Contract.java index 1d54dd315d..537c50a0e0 100644 --- a/core/src/main/java/org/web3j/tx/Contract.java +++ b/core/src/main/java/org/web3j/tx/Contract.java @@ -42,7 +42,6 @@ import org.web3j.protocol.core.DefaultBlockParameterName; import org.web3j.protocol.core.RemoteCall; import org.web3j.protocol.core.RemoteFunctionCall; -import org.web3j.protocol.core.methods.request.Transaction; import org.web3j.protocol.core.methods.response.EthGetCode; import org.web3j.protocol.core.methods.response.Log; import org.web3j.protocol.core.methods.response.TransactionReceipt; @@ -73,6 +72,7 @@ public abstract class Contract extends ManagedTransaction { public static final String BIN_NOT_PROVIDED = "Bin file was not provided"; public static final String FUNC_DEPLOY = "deploy"; + protected final String contractBinary; protected String contractAddress; protected ContractGasProvider gasProvider; @@ -389,21 +389,22 @@ TransactionReceipt executeTransaction( TransactionReceipt receipt = null; try { + if (gasProvider instanceof ContractEIP1559GasProvider) { ContractEIP1559GasProvider eip1559GasProvider = (ContractEIP1559GasProvider) gasProvider; - - receipt = - sendEIP1559( - eip1559GasProvider.getChainId(), - contractAddress, - data, - weiValue, - eip1559GasProvider.getGasLimit( - getGenericTransaction(data, constructor)), - eip1559GasProvider.getMaxPriorityFeePerGas(), - eip1559GasProvider.getMaxFeePerGas(), - constructor); + if (eip1559GasProvider.isEIP1559Enabled()) { + receipt = + sendEIP1559( + eip1559GasProvider.getChainId(), + contractAddress, + data, + weiValue, + eip1559GasProvider.getGasLimit(funcName), + eip1559GasProvider.getMaxPriorityFeePerGas(funcName), + eip1559GasProvider.getMaxFeePerGas(funcName), + constructor); + } } if (receipt == null) { @@ -412,8 +413,8 @@ TransactionReceipt executeTransaction( contractAddress, data, weiValue, - gasProvider.getGasPrice(), - gasProvider.getGasLimit(getGenericTransaction(data, constructor)), + gasProvider.getGasPrice(funcName), + gasProvider.getGasLimit(funcName), constructor); } } catch (JsonRpcError error) { @@ -447,24 +448,6 @@ TransactionReceipt executeTransaction( return receipt; } - protected Transaction getGenericTransaction(String data, boolean constructor) { - if (constructor) { - return Transaction.createContractTransaction( - this.transactionManager.getFromAddress(), - BigInteger.ONE, - gasProvider.getGasPrice(), - data); - } else { - return Transaction.createFunctionCallTransaction( - this.transactionManager.getFromAddress(), - BigInteger.ONE, - gasProvider.getGasPrice(), - gasProvider.getGasLimit(), - contractAddress, - data); - } - } - protected RemoteFunctionCall executeRemoteCallSingleValueReturn( Function function) { return new RemoteFunctionCall<>(function, () -> executeCallSingleValueReturn(function)); diff --git a/core/src/main/java/org/web3j/tx/gas/ContractEIP1559GasProvider.java b/core/src/main/java/org/web3j/tx/gas/ContractEIP1559GasProvider.java index 7510cbf7d9..2a17deb43d 100644 --- a/core/src/main/java/org/web3j/tx/gas/ContractEIP1559GasProvider.java +++ b/core/src/main/java/org/web3j/tx/gas/ContractEIP1559GasProvider.java @@ -15,9 +15,11 @@ import java.math.BigInteger; public interface ContractEIP1559GasProvider extends ContractGasProvider { + boolean isEIP1559Enabled(); + long getChainId(); - BigInteger getMaxFeePerGas(); + BigInteger getMaxFeePerGas(String contractFunc); - BigInteger getMaxPriorityFeePerGas(); + BigInteger getMaxPriorityFeePerGas(String contractFunc); } diff --git a/core/src/main/java/org/web3j/tx/gas/ContractGasProvider.java b/core/src/main/java/org/web3j/tx/gas/ContractGasProvider.java index ad5c811fd4..6488f24edc 100644 --- a/core/src/main/java/org/web3j/tx/gas/ContractGasProvider.java +++ b/core/src/main/java/org/web3j/tx/gas/ContractGasProvider.java @@ -14,13 +14,14 @@ import java.math.BigInteger; -import org.web3j.protocol.core.methods.request.Transaction; - public interface ContractGasProvider { + BigInteger getGasPrice(String contractFunc); + @Deprecated BigInteger getGasPrice(); - BigInteger getGasLimit(Transaction transaction); + BigInteger getGasLimit(String contractFunc); + @Deprecated BigInteger getGasLimit(); } diff --git a/core/src/main/java/org/web3j/tx/gas/DynamicEIP1559GasProvider.java b/core/src/main/java/org/web3j/tx/gas/DynamicEIP1559GasProvider.java deleted file mode 100644 index 04d3e0e073..0000000000 --- a/core/src/main/java/org/web3j/tx/gas/DynamicEIP1559GasProvider.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2025 Web3 Labs Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package org.web3j.tx.gas; - -import java.io.IOException; -import java.math.BigDecimal; -import java.math.BigInteger; - -import org.web3j.protocol.Web3j; -import org.web3j.protocol.core.DefaultBlockParameterName; -import org.web3j.protocol.core.methods.request.Transaction; -import org.web3j.protocol.core.methods.response.EthEstimateGas; -import org.web3j.protocol.core.methods.response.EthGasPrice; -import org.web3j.protocol.core.methods.response.EthMaxPriorityFeePerGas; - -public class DynamicEIP1559GasProvider implements ContractEIP1559GasProvider, PriorityGasProvider { - private Web3j web3j; - private long chainId; - private final Priority priority; - private final BigDecimal customMultiplier; - private BigInteger maxGasLimit = BigInteger.valueOf(9_000_000); - - public DynamicEIP1559GasProvider(Web3j web3j, long chainId) { - this(web3j, chainId, Priority.NORMAL); - } - - public DynamicEIP1559GasProvider(Web3j web3j, long chainId, Priority priority) { - this(web3j, chainId, priority, BigDecimal.ONE); - } - - public DynamicEIP1559GasProvider( - Web3j web3j, long chainId, Priority priority, BigDecimal customMultiplier) { - this.web3j = web3j; - this.chainId = chainId; - this.priority = priority; - this.customMultiplier = customMultiplier; - } - - @Override - public long getChainId() { - return chainId; - } - - @Override - public BigInteger getMaxFeePerGas() { - try { - BigInteger baseFee = - web3j.ethGetBlockByNumber(DefaultBlockParameterName.LATEST, false) - .send() - .getBlock() - .getBaseFeePerGas(); - - return baseFee.multiply(BigInteger.valueOf(2)).add(getMaxPriorityFeePerGas()); - } catch (IOException e) { - throw new RuntimeException("Failed to get ethMaxFeePerGas"); - } - } - - @Override - public BigInteger getMaxPriorityFeePerGas() { - try { - EthMaxPriorityFeePerGas ethMaxPriorityFeePerGas = - web3j.ethMaxPriorityFeePerGas().send(); - if (ethMaxPriorityFeePerGas.hasError()) { - throw new RuntimeException( - "Error fetching ethMaxPriorityFeePerGas: " - + ethMaxPriorityFeePerGas.getError().getMessage()); - } - return ethMaxPriorityFeePerGas.getMaxPriorityFeePerGas(); - } catch (IOException e) { - throw new RuntimeException("Failed to get ethMaxPriorityFeePerGas"); - } - } - - @Override - public BigInteger getGasPrice() { - return applyPriority(fetchCurrentGasPrice(), priority, customMultiplier); - } - - @Override - public BigInteger getGasLimit(Transaction transaction) { - try { - EthEstimateGas ethEstimateGas = web3j.ethEstimateGas(transaction).send(); - if (ethEstimateGas.hasError()) { - throw new RuntimeException( - "Error estimating gas limit: " + ethEstimateGas.getError().getMessage()); - } - return ethEstimateGas.getAmountUsed(); - } catch (Exception e) { - throw new RuntimeException("Failed to estimate gas limit", e); - } - } - - @Override - public BigInteger getGasLimit() { - return maxGasLimit; - } - - public void setMaxGasLimit(BigInteger gasLimit) { - maxGasLimit = gasLimit; - } - - private BigInteger fetchCurrentGasPrice() { - try { - EthGasPrice ethGasPrice = web3j.ethGasPrice().send(); - if (ethGasPrice.hasError()) { - throw new RuntimeException( - "Error fetching gas price: " + ethGasPrice.getError().getMessage()); - } - return ethGasPrice.getGasPrice(); - } catch (Exception e) { - throw new RuntimeException("Failed to fetch gas price", e); - } - } -} diff --git a/core/src/main/java/org/web3j/tx/gas/DynamicGasProvider.java b/core/src/main/java/org/web3j/tx/gas/DynamicGasProvider.java deleted file mode 100644 index 102453863e..0000000000 --- a/core/src/main/java/org/web3j/tx/gas/DynamicGasProvider.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2025 Web3 Labs Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package org.web3j.tx.gas; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import org.web3j.protocol.Web3j; -import org.web3j.protocol.core.methods.request.Transaction; -import org.web3j.protocol.core.methods.response.EthEstimateGas; -import org.web3j.protocol.core.methods.response.EthGasPrice; - -public class DynamicGasProvider implements ContractGasProvider, PriorityGasProvider { - - private final Web3j web3j; - private final Priority priority; - private final BigDecimal customMultiplier; - private BigInteger maxGasLimit = BigInteger.valueOf(9_000_000); - - public DynamicGasProvider(Web3j web3j) { - this(web3j, Priority.NORMAL); - } - - public DynamicGasProvider(Web3j web3j, Priority priority) { - this(web3j, priority, BigDecimal.ONE); - } - - public DynamicGasProvider(Web3j web3j, Priority priority, BigDecimal customMultiplier) { - this.web3j = web3j; - this.priority = priority; - this.customMultiplier = customMultiplier; - } - - @Override - public BigInteger getGasPrice() { - return applyPriority(fetchCurrentGasPrice(), priority, customMultiplier); - } - - @Override - public BigInteger getGasLimit() { - return maxGasLimit; - } - - public void setMaxGasLimit(BigInteger gasLimit) { - maxGasLimit = gasLimit; - } - - public BigInteger getGasLimit(Transaction transaction) { - try { - EthEstimateGas ethEstimateGas = web3j.ethEstimateGas(transaction).send(); - if (ethEstimateGas.hasError()) { - throw new RuntimeException( - "Error estimating gas limit: " + ethEstimateGas.getError().getMessage()); - } - return ethEstimateGas.getAmountUsed(); - } catch (Exception e) { - throw new RuntimeException("Failed to estimate gas limit", e); - } - } - - private BigInteger fetchCurrentGasPrice() { - try { - EthGasPrice ethGasPrice = web3j.ethGasPrice().send(); - if (ethGasPrice.hasError()) { - throw new RuntimeException( - "Error fetching gas price: " + ethGasPrice.getError().getMessage()); - } - return ethGasPrice.getGasPrice(); - } catch (Exception e) { - throw new RuntimeException("Failed to fetch gas price", e); - } - } -} diff --git a/core/src/main/java/org/web3j/tx/gas/PriorityGasProvider.java b/core/src/main/java/org/web3j/tx/gas/PriorityGasProvider.java deleted file mode 100644 index 2d6217d9d7..0000000000 --- a/core/src/main/java/org/web3j/tx/gas/PriorityGasProvider.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2025 Web3 Labs Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package org.web3j.tx.gas; - -import java.math.BigDecimal; -import java.math.BigInteger; - -public interface PriorityGasProvider { - enum Priority { - FAST, - NORMAL, - SLOW, - CUSTOM - } - - default BigInteger applyPriority( - BigInteger baseGasPrice, Priority priority, BigDecimal customMultiplier) { - - return switch (priority) { - case FAST -> baseGasPrice.multiply(BigInteger.valueOf(2)); // 2x for fast - case NORMAL -> baseGasPrice; // Default gas price - case SLOW -> baseGasPrice.divide(BigInteger.valueOf(2)); // 0.5x for slow - case CUSTOM -> { - if (customMultiplier == null || customMultiplier.compareTo(BigDecimal.ZERO) <= 0) { - throw new IllegalArgumentException( - "Custom multiplier must be a positive value"); - } - yield new BigDecimal(baseGasPrice).multiply(customMultiplier).toBigInteger(); - } - }; - } -} diff --git a/core/src/main/java/org/web3j/tx/gas/StaticEIP1559GasProvider.java b/core/src/main/java/org/web3j/tx/gas/StaticEIP1559GasProvider.java index 929489c1f9..1306b980ee 100644 --- a/core/src/main/java/org/web3j/tx/gas/StaticEIP1559GasProvider.java +++ b/core/src/main/java/org/web3j/tx/gas/StaticEIP1559GasProvider.java @@ -14,8 +14,6 @@ import java.math.BigInteger; -import org.web3j.protocol.core.methods.request.Transaction; - public class StaticEIP1559GasProvider implements ContractEIP1559GasProvider { private long chainId; private BigInteger maxFeePerGas; @@ -33,14 +31,19 @@ public StaticEIP1559GasProvider( this.gasLimit = gasLimit; } + @Override + public BigInteger getGasPrice(String contractFunc) { + return maxFeePerGas; + } + @Override public BigInteger getGasPrice() { return maxFeePerGas; } @Override - public BigInteger getGasLimit(Transaction transaction) { - return getGasLimit(); + public BigInteger getGasLimit(String contractFunc) { + return gasLimit; } @Override @@ -48,18 +51,23 @@ public BigInteger getGasLimit() { return gasLimit; } + @Override + public boolean isEIP1559Enabled() { + return true; + } + @Override public long getChainId() { return chainId; } @Override - public BigInteger getMaxFeePerGas() { + public BigInteger getMaxFeePerGas(String contractFunc) { return maxFeePerGas; } @Override - public BigInteger getMaxPriorityFeePerGas() { + public BigInteger getMaxPriorityFeePerGas(String contractFunc) { return maxPriorityFeePerGas; } } diff --git a/core/src/main/java/org/web3j/tx/gas/StaticGasProvider.java b/core/src/main/java/org/web3j/tx/gas/StaticGasProvider.java index 5df744bb09..078ec8ad35 100644 --- a/core/src/main/java/org/web3j/tx/gas/StaticGasProvider.java +++ b/core/src/main/java/org/web3j/tx/gas/StaticGasProvider.java @@ -14,8 +14,6 @@ import java.math.BigInteger; -import org.web3j.protocol.core.methods.request.Transaction; - @SuppressWarnings("deprecation") public class StaticGasProvider implements ContractGasProvider { private BigInteger gasPrice; @@ -26,14 +24,19 @@ public StaticGasProvider(BigInteger gasPrice, BigInteger gasLimit) { this.gasLimit = gasLimit; } + @Override + public BigInteger getGasPrice(String contractFunc) { + return gasPrice; + } + @Override public BigInteger getGasPrice() { return gasPrice; } @Override - public BigInteger getGasLimit(Transaction transaction) { - return getGasLimit(); + public BigInteger getGasLimit(String contractFunc) { + return gasLimit; } @Override diff --git a/integration-tests/src/test/java/org/web3j/protocol/core/CoreIT.java b/integration-tests/src/test/java/org/web3j/protocol/core/CoreIT.java index 1e908b6d1f..1c86c4ddfd 100644 --- a/integration-tests/src/test/java/org/web3j/protocol/core/CoreIT.java +++ b/integration-tests/src/test/java/org/web3j/protocol/core/CoreIT.java @@ -294,15 +294,30 @@ public void testEthCall(Web3j web3j, ContractGasProvider gasProvider) throws Exc } @Test - public void testEthEstimateGas(Web3j web3j, ContractGasProvider gasProvider) throws Exception { + public void testEthEstimateGas(Web3j web3j, ContractGasProvider gasProvider) + throws InterruptedException { org.web3j.protocol.core.methods.request.Transaction transaction = org.web3j.protocol.core.methods.request.Transaction.createContractTransaction( config.validAccount(), BigInteger.ZERO, // nonce gasProvider.getGasPrice(), config.validContractCode()); - EthEstimateGas ethEstimateGas = web3j.ethEstimateGas(transaction).send(); - assertEquals(ethEstimateGas.getAmountUsed().signum(), 1); + + Thread.sleep(60000); + EthEstimateGas ethEstimateGas; + try { + ethEstimateGas = web3j.ethEstimateGas(transaction).send(); + } catch (Exception e) { + throw new IllegalStateException("error at deploy", e); + } + Thread.sleep(10000); + + try { + assertEquals(ethEstimateGas.getAmountUsed().signum(), 1); + + } catch (Exception e) { + throw new IllegalStateException("error at getAmountUsed", e); + } } @Test diff --git a/integration-tests/src/test/java/org/web3j/protocol/scenarios/ArraysIT.java b/integration-tests/src/test/java/org/web3j/protocol/scenarios/ArraysIT.java index a6d108a180..d492d62dbf 100644 --- a/integration-tests/src/test/java/org/web3j/protocol/scenarios/ArraysIT.java +++ b/integration-tests/src/test/java/org/web3j/protocol/scenarios/ArraysIT.java @@ -39,6 +39,7 @@ public class ArraysIT extends Scenario { @BeforeAll public static void setUp(Web3j web3j) throws Exception { + Scenario.web3j = web3j; ArraysIT.contract = Arrays.deploy( web3j, diff --git a/integration-tests/src/test/java/org/web3j/protocol/scenarios/DynamicGasProviderIT.java b/integration-tests/src/test/java/org/web3j/protocol/scenarios/DynamicGasProviderIT.java deleted file mode 100644 index b154ca7b6c..0000000000 --- a/integration-tests/src/test/java/org/web3j/protocol/scenarios/DynamicGasProviderIT.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2025 Web3 Labs Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package org.web3j.protocol.scenarios; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import org.web3j.EVMTest; -import org.web3j.NodeType; -import org.web3j.protocol.Web3j; -import org.web3j.test.contract.HumanStandardToken; -import org.web3j.tx.gas.ContractGasProvider; -import org.web3j.tx.gas.DynamicGasProvider; -import org.web3j.tx.gas.PriorityGasProvider; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -@EVMTest(type = NodeType.BESU) -public class DynamicGasProviderIT extends Scenario { - static ContractGasProvider dynamicGasProvider; - static final String TOKEN_NAME = "Alice Token"; - static final String TOKEN_SYMBOL = "ATK"; - static final BigInteger TOKEN_DECIMALS = BigInteger.valueOf(18L); - static final BigInteger TOKEN_SUPPLY = BigInteger.valueOf(10_000_000L); - - @BeforeAll - static void setUp(Web3j web3j) throws Exception { - Scenario.web3j = web3j; - dynamicGasProvider = new DynamicGasProvider(web3j); - } - - @Test - public void testContractFunctionalities() throws Exception { - - HumanStandardToken humanStandardToken = - HumanStandardToken.deploy( - web3j, - ALICE, - dynamicGasProvider, - TOKEN_SUPPLY, - TOKEN_NAME, - TOKEN_DECIMALS, - TOKEN_SYMBOL) - .send(); - - String contractAddress = humanStandardToken.getContractAddress(); - - assertTrue(humanStandardToken.isValid()); - assertEquals( - humanStandardToken.getTransactionReceipt().get().getContractAddress(), - contractAddress); - - assertEquals(humanStandardToken.name().send(), TOKEN_NAME); - assertEquals(humanStandardToken.totalSupply().send(), TOKEN_SUPPLY); - - assertNotNull(humanStandardToken.transfer(BOB.getAddress(), BigInteger.ONE).send()); - assertEquals(humanStandardToken.balanceOf(BOB.getAddress()).send(), BigInteger.ONE); - - DynamicGasProvider fastDynamicGasProvider = - new DynamicGasProvider(web3j, PriorityGasProvider.Priority.FAST); - DynamicGasProvider slowDynamicGasProvider = - new DynamicGasProvider(web3j, PriorityGasProvider.Priority.SLOW); - DynamicGasProvider customDynamicGasProvider = - new DynamicGasProvider( - web3j, PriorityGasProvider.Priority.CUSTOM, BigDecimal.valueOf(1.5)); - - assertEquals( - dynamicGasProvider.getGasPrice().multiply(BigInteger.TWO), - fastDynamicGasProvider.getGasPrice()); - assertEquals( - dynamicGasProvider.getGasPrice().divide(BigInteger.TWO), - slowDynamicGasProvider.getGasPrice()); - assertEquals( - new BigDecimal(dynamicGasProvider.getGasPrice()) - .multiply(BigDecimal.valueOf(1.5)) - .toBigInteger(), - customDynamicGasProvider.getGasPrice()); - - humanStandardToken = - HumanStandardToken.load(contractAddress, web3j, ALICE, fastDynamicGasProvider); - - assertEquals(humanStandardToken.name().send(), TOKEN_NAME); - - assertNotNull(humanStandardToken.transfer(BOB.getAddress(), BigInteger.ONE).send()); - assertEquals(humanStandardToken.balanceOf(BOB.getAddress()).send(), BigInteger.TWO); - } -}