Java Code Examples for org.web3j.protocol.core.methods.response.EthGetTransactionCount#getTransactionCount()
The following examples show how to use
org.web3j.protocol.core.methods.response.EthGetTransactionCount#getTransactionCount() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EthGetTransactionCountTransaction.java From besu with Apache License 2.0 | 5 votes |
@Override public BigInteger execute(final NodeRequests node) { try { EthGetTransactionCount result = node.eth() .ethGetTransactionCount(accountAddress, DefaultBlockParameterName.LATEST) .send(); assertThat(result).isNotNull(); return result.getTransactionCount(); } catch (final IOException e) { throw new RuntimeException(e); } }
Example 2
Source File: BaseIntegrationTest.java From eventeum with Apache License 2.0 | 5 votes |
protected String sendTransaction() throws ExecutionException, InterruptedException, IOException { EthGetTransactionCount ethGetTransactionCount = web3j.ethGetTransactionCount( CREDS.getAddress(), DefaultBlockParameterName.LATEST).sendAsync().get(); BigInteger nonce = ethGetTransactionCount.getTransactionCount(); final Transaction tx = Transaction.createEtherTransaction(CREDS.getAddress(), nonce, GAS_PRICE, GAS_LIMIT, ZERO_ADDRESS, BigInteger.ONE); EthSendTransaction response = web3j.ethSendTransaction(tx).send(); return response.getTransactionHash(); }
Example 3
Source File: BaseIntegrationTest.java From eventeum with Apache License 2.0 | 5 votes |
protected BigInteger getNonce() throws ExecutionException, InterruptedException { final EthGetTransactionCount ethGetTransactionCount = web3j.ethGetTransactionCount( CREDS.getAddress(), DefaultBlockParameterName.LATEST).sendAsync().get(); final BigInteger nonce = ethGetTransactionCount.getTransactionCount(); return nonce; }
Example 4
Source File: EthereumNetworkManager.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
private BigInteger getNonce() { BigInteger nonce = null; try { EthGetTransactionCount txCount = web3jConnection.ethGetTransactionCount(walletManager.getWalletFriendlyAddress(), DefaultBlockParameterName.LATEST).send(); nonce = txCount.getTransactionCount(); } catch (IOException e) { e.printStackTrace(); } return nonce; }
Example 5
Source File: EthereumNetworkManager.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
private BigInteger getNonce() { BigInteger nonce = null; try { EthGetTransactionCount txCount = web3jConnection.ethGetTransactionCount(walletManager.getWalletFriendlyAddress(), DefaultBlockParameterName.LATEST).send(); nonce = txCount.getTransactionCount(); } catch (IOException e) { e.printStackTrace(); } return nonce; }
Example 6
Source File: EthereumNetworkManager.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
private BigInteger getNonce() { BigInteger nonce = null; try { EthGetTransactionCount txCount = web3jConnection.ethGetTransactionCount(walletManager.getWalletFriendlyAddress(), DefaultBlockParameterName.LATEST).send(); nonce = txCount.getTransactionCount(); } catch (IOException e) { e.printStackTrace(); } return nonce; }
Example 7
Source File: EthereumUtils.java From jbpm-work-items with Apache License 2.0 | 5 votes |
public static BigInteger getNextNonce(String address, Web3j web3j) throws Exception { EthGetTransactionCount ethGetTransactionCount = web3j.ethGetTransactionCount( address, DefaultBlockParameterName.LATEST).sendAsync().get(); return ethGetTransactionCount.getTransactionCount(); }
Example 8
Source File: Web3jUtils.java From web3j_demo with Apache License 2.0 | 5 votes |
/** * Return the nonce (tx count) for the specified address. */ public static BigInteger getNonce(Web3j web3j, String address) throws InterruptedException, ExecutionException { EthGetTransactionCount ethGetTransactionCount = web3j.ethGetTransactionCount(address, DefaultBlockParameterName.LATEST).sendAsync().get(); return ethGetTransactionCount.getTransactionCount(); }
Example 9
Source File: Scenario.java From web3j with Apache License 2.0 | 5 votes |
BigInteger getNonce(String address) throws Exception { EthGetTransactionCount ethGetTransactionCount = web3j.ethGetTransactionCount(address, DefaultBlockParameterName.LATEST) .sendAsync() .get(); return ethGetTransactionCount.getTransactionCount(); }
Example 10
Source File: CreateRawTransactionIT.java From web3j with Apache License 2.0 | 5 votes |
BigInteger getNonce(String address) throws Exception { EthGetTransactionCount ethGetTransactionCount = web3j.ethGetTransactionCount(address, DefaultBlockParameterName.LATEST) .sendAsync() .get(); return ethGetTransactionCount.getTransactionCount(); }
Example 11
Source File: RawTransactionManager.java From web3j with Apache License 2.0 | 5 votes |
protected BigInteger getNonce() throws IOException { EthGetTransactionCount ethGetTransactionCount = web3j.ethGetTransactionCount( credentials.getAddress(), DefaultBlockParameterName.PENDING) .send(); return ethGetTransactionCount.getTransactionCount(); }
Example 12
Source File: Scenario.java From etherscan-explorer with GNU General Public License v3.0 | 4 votes |
BigInteger getNonce(String address) throws Exception { EthGetTransactionCount ethGetTransactionCount = web3j.ethGetTransactionCount( address, DefaultBlockParameterName.LATEST).sendAsync().get(); return ethGetTransactionCount.getTransactionCount(); }
Example 13
Source File: CreateRawTransactionIT.java From etherscan-explorer with GNU General Public License v3.0 | 4 votes |
BigInteger getNonce(String address) throws Exception { EthGetTransactionCount ethGetTransactionCount = web3j.ethGetTransactionCount( address, DefaultBlockParameterName.LATEST).sendAsync().get(); return ethGetTransactionCount.getTransactionCount(); }
Example 14
Source File: RawTransactionManager.java From etherscan-explorer with GNU General Public License v3.0 | 4 votes |
protected BigInteger getNonce() throws IOException { EthGetTransactionCount ethGetTransactionCount = web3j.ethGetTransactionCount( credentials.getAddress(), DefaultBlockParameterName.PENDING).send(); return ethGetTransactionCount.getTransactionCount(); }
Example 15
Source File: SendingEther.java From Android-Wallet-Token-ERC20 with Apache License 2.0 | 4 votes |
private BigInteger getNonce() throws ExecutionException, InterruptedException { EthGetTransactionCount ethGetTransactionCount = mWeb3j.ethGetTransactionCount(fromAddress, DefaultBlockParameterName.LATEST).sendAsync().get(); return ethGetTransactionCount.getTransactionCount(); }
Example 16
Source File: TransferDemo.java From web3j_demo with Apache License 2.0 | 4 votes |
/** * Implementation of the Ethers transfer. * <ol> * <li>Get nonce for for the sending account</li> * <li>Create the transaction object</li> * <li>Send the transaction to the network</li> * <li>Wait for the confirmation</li> * </ol> */ void demoTransfer(String fromAddress, String toAddress, BigInteger amountWei) throws Exception { System.out.println("Accounts[1] (to address) " + toAddress + "\n" + "Balance before Tx: " + Web3jUtils.getBalanceEther(web3j, toAddress) + "\n"); System.out.println("Transfer " + Web3jUtils.weiToEther(amountWei) + " Ether to account"); // step 1: get the nonce (tx count for sending address) EthGetTransactionCount transactionCount = web3j .ethGetTransactionCount(fromAddress, DefaultBlockParameterName.LATEST) .sendAsync() .get(); BigInteger nonce = transactionCount.getTransactionCount(); System.out.println("Nonce for sending address (coinbase): " + nonce); // step 2: create the transaction object Transaction transaction = Transaction .createEtherTransaction( fromAddress, nonce, Web3jConstants.GAS_PRICE, Web3jConstants.GAS_LIMIT_ETHER_TX, toAddress, amountWei); // step 3: send the tx to the network EthSendTransaction response = web3j .ethSendTransaction(transaction) .sendAsync() .get(); String txHash = response.getTransactionHash(); System.out.println("Tx hash: " + txHash); // step 4: wait for the confirmation of the network TransactionReceipt receipt = Web3jUtils.waitForReceipt(web3j, txHash); BigInteger gasUsed = receipt.getCumulativeGasUsed(); System.out.println("Tx cost: " + gasUsed + " Gas (" + Web3jUtils.weiToEther(gasUsed.multiply(Web3jConstants.GAS_PRICE)) +" Ether)\n"); System.out.println("Balance after Tx: " + Web3jUtils.getBalanceEther(web3j, toAddress)); }