Skip to content

Instantly share code, notes, and snippets.

@jrtapsell
Last active August 15, 2017 10:30
Show Gist options
  • Save jrtapsell/a6e2c3e13616c8ccd7aaefd1a8e7fa17 to your computer and use it in GitHub Desktop.
Save jrtapsell/a6e2c3e13616c8ccd7aaefd1a8e7fa17 to your computer and use it in GitHub Desktop.
class ParityManager(val web3: Parity): TransactionManager(web3) {
val from: String
init {
val accounts = DataProvider.web3.ethAccounts().send().accounts!!
if (accounts.size == 0) {
throw AssertionError("No accounts :(")
}
if (accounts.size > 1) {
throw AssertionError("Too many accounts, please only use 1")
}
from = accounts[0]
}
override fun sendTransaction(
gasPrice: BigInteger?,
gasLimit: BigInteger?,
to: String?, data: String?,
value: BigInteger?): EthSendTransaction {
val ethGetTransactionCount = web3.ethGetTransactionCount(
from, DefaultBlockParameterName.PENDING).send().transactionCount!!
val transaction = Transaction(from, ethGetTransactionCount, gasPrice, gasLimit, to, value, data)
return web3.personalSignAndSendTransaction(transaction, "password").send()
}
override fun getFromAddress() = from
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment