---
# System prepended metadata

title: 'Coding Task: Transaction mechanism'

---

# Coding Task: Transaction mechanism

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.

```golang
type Ethereum interface {
	GetTransactionCount() (int, error)
	SuggestGasPrice() (int, error)
	SendTransaction(trans *Transaction) error
}

type Transaction struct {
	nonce       int
	maxGasPrice int

	// Transaction data, not related to this task
	data []byte
}

func sendTransaction(trans *Transaction, eth Ethereum) error {
	// Naive implementation that sends each transaction, no matter of nonce or maxGasPrice
	return eth.SendTransaction(trans)
}
```