MidnightContract
class 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!")Content copied to clipboard
Types
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
Deploy a new contract instance to the blockchain.
Link copied to clipboard
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).