---
# System prepended metadata

title: 'Coding Task: Transaction mechanism (Java)'

---

# Coding Task: Transaction mechanism (Java)

In Livepeer we execute Ethereum transactions on the Ethereum network. This process follows two rules:

1. Send transactions one by one, never sent a transaction if the previous one has not completed (`nonce` field is the transaction's sequence number).
2. Do not send a transaction if the current Ethereum gas price is higher than `maxGasPrice` of your transaction.

Implement a mechanism to **queue, send, and retry** sending transactions.

```java

public interface Ethereum {
    int getTransactionCount();
    int suggestGasPrice();
    void sendTransaction(Transaction transaction);
}

public class Transaction {
    private int nonce;
    private int maxGasPrice;

    // Transaction data, not related to this task
    private Object data;
}

public class TransactionManager {
    public void sendTransaction(Transaction transaction, Ethereum eth) {
        // Naive implementation that sends each transaction, no matter of nonce or maxGasPrice
        eth.sendTransaction(trans);
    }
}
```