MidnightConfig

Configuration for Midnight contract operations.

Created once per app, shared across all MidnightContract instances. Manages indexer connectivity, transaction balancing, and proving.

Two modes:

  • Remote wallet: provide walletUrl to delegate balancing to mn serve via WebSocket

  • Embedded wallet: provide a TransactionBalancer directly (e.g., MidnightWallet)

val previewConfig = NetworkConfig.forNetwork(MidnightNetwork.PREVIEW)

// Remote wallet (existing pattern)
val config = MidnightConfig.Builder(context)
.indexerUrl(previewConfig.indexerBaseUrl)
.walletUrl("ws://10.0.2.2:9932")
.networkId(MidnightNetwork.PREVIEW.rustNetworkId)
.build()

// Embedded wallet (new pattern)
val config = MidnightConfig.Builder(context)
.indexerUrl(previewConfig.indexerBaseUrl)
.transactionBalancer(myWallet)
.networkId(MidnightNetwork.PREVIEW.rustNetworkId)
.build()

Types

Link copied to clipboard
class Builder(context: Context)
Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun close()

Close connections and release resources.

Link copied to clipboard
suspend fun queryState(address: String): JSONArray?

Read a deployed contract's on-chain state as parsed JSON.

Link copied to clipboard

Submit a previously prepared transaction.