Sending Transactions

To send a transaction with Hyphen Android SDK

Creating, Signing, and Sending Transactions

To create, sign, and send a transaction with the Hyphen Android SDK, follow these steps:

// Define the Cadence script for the transaction
val cadenceScript = """
    transaction {
        execute {
            log("Hello World!!!")
        }
    }
""".trimIndent()

// Create, sign, and send the transaction
val txId = HyphenFlow.signAndSendTransaction(
    cadenceScript = cadenceScript,
    arguments = emptyList(),
    withAuthorizer = false
)

// Log the transaction ID
Log.e("Transaction ID", txId) // Outputs: "0x<TXID>"

Explanation:

  • cadenceScript: The Cadence script to be executed in the transaction.

  • arguments: List of arguments for the transaction. In this example, it's an empty list.

  • withAuthorizer: A boolean indicating whether the transaction requires an authorizer. Set to false in this example.

  • txId: The transaction ID returned by the signAndSendTransaction method.

Utilities

Wait for Transaction Seal

To wait for a transaction to be sealed on the Flow blockchain, you can use waitForSeal utility method.

val txId = FlowId(hex = "0x<TXID>")
val txResult = waitForSeal(txId = txId) // return FlowTransactionResult object

Get Transaction Result

To retrieve the result of a specific transaction:

val txId = FlowId(hex = "0x<TXID>")
val txResult = getTransactionResult(txId = txId) // return FlowTransactionResult object

Last updated

Was this helpful?