MidnightContract

High-level interface for calling Midnight smart contract circuits from Android.

Wraps the full pipeline: state fetch → circuit execution → ZK proving → balancing → submission. The developer never touches hex strings, JS expressions, or manual orchestration.

val bboard = MidnightContract.create(config) {
name = "bboard"
contractJs = assets.open("runtime/bboard-contract-iife.js")
address = "4b459404..."
witness("localSecretKey") { WitnessResult(null, secretKeyBytes) }
initialPrivateState = mapOf("secretKey" to ByteArray(32))
coinPublicKey = walletKeys.coinPublicKey
}

val receipt = bboard.call("post", "Hello from Android!")

Types

Link copied to clipboard
object Companion
Link copied to clipboard

DSL builder for creating a MidnightContract.

Properties

Link copied to clipboard

Functions

Link copied to clipboard
suspend fun call(circuitName: String, vararg args: Any?, onProgress: suspend (ContractCallStage) -> Unit? = null): TransactionReceipt

Call a circuit and submit the transaction to the blockchain.

Link copied to clipboard
suspend fun deploy(onProgress: suspend (ContractCallStage) -> Unit? = null): DeployResult

Deploy a new contract instance to the blockchain.

Link copied to clipboard
suspend fun ledger(): MidnightLedger

Read the contract's ledger state losslessly.

Link copied to clipboard
suspend fun prepare(circuitName: String, vararg args: Any?, onProgress: suspend (ContractCallStage) -> Unit? = null): PreparedTransaction

Execute and prove a circuit without submitting (offline mode).