Slide 40
Slide 40 text
Read/Write into a Smart
Contract
val greeter = Greeter.load(contractAddress, web3, credentials, gasLimit, gasPrice)
// check contract validity
toast("Greeter valid: ${greeter.isValid}")
// read from contract
val greeting: Future? = greeter.greet().sendAsync()
val convertToString: String? = greeting?.get()
toast(“Smart contract returned: $convertToString")
// write to contract
val transactionReceipt: Future? =
greeter.changeGreeting(smartContractText.text.toString()).sendAsync()
val result =
"Successful transaction. Gas used: ${transactionReceipt?.get()?.blockNumber}
${transactionReceipt?.get()?.gasUsed}"
toast(result)