# Table of Contents - [Midnight Documentation | Midnight Docs](#midnight-documentation-midnight-docs) - [Dev Diaries | Midnight Docs](#dev-diaries-midnight-docs) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [How-To | Midnight Docs](#how-to-midnight-docs) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Search the documentation | Midnight Docs](#search-the-documentation-midnight-docs) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [One doc tagged with "error codes" | Midnight Docs](#one-doc-tagged-with-error-codes-midnight-docs) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [One doc tagged with "rate limits" | Midnight Docs](#one-doc-tagged-with-rate-limits-midnight-docs) - [Midnight Dev Diaries](#midnight-dev-diaries) - [One doc tagged with "authentication" | Midnight Docs](#one-doc-tagged-with-authentication-midnight-docs) - [Tags | Midnight Docs](#tags-midnight-docs) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight APIs | Midnight Docs](#midnight-apis-midnight-docs) - [API reference | Midnight Docs](#api-reference-midnight-docs) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Midnight Dev Diaries](#midnight-dev-diaries) - [Compact runtime API | Midnight Docs](#compact-runtime-api-midnight-docs) - [NetworkId | Midnight Docs](#networkid-midnight-docs) - [ChargedState | Midnight Docs](#chargedstate-midnight-docs) - [CompactTypeBoolean | Midnight Docs](#compacttypeboolean-midnight-docs) - [Midnight Dev Diaries](#midnight-dev-diaries) - [CompactTypeCurvePoint | Midnight Docs](#compacttypecurvepoint-midnight-docs) - [CompactTypeEnum | Midnight Docs](#compacttypeenum-midnight-docs) - [CompactTypeBytes | Midnight Docs](#compacttypebytes-midnight-docs) - [CompactTypeField | Midnight Docs](#compacttypefield-midnight-docs) - [CompactTypeMerkleTreeDigest | Midnight Docs](#compacttypemerkletreedigest-midnight-docs) - [CompactTypeMerkleTreePath | Midnight Docs](#compacttypemerkletreepath-midnight-docs) - [CompactError | Midnight Docs](#compacterror-midnight-docs) - [ContractMaintenanceAuthority | Midnight Docs](#contractmaintenanceauthority-midnight-docs) - [CompactTypeOpaqueString | Midnight Docs](#compacttypeopaquestring-midnight-docs) - [CompactTypeMerkleTreePathEntry | Midnight Docs](#compacttypemerkletreepathentry-midnight-docs) - [CompactTypeOpaqueUint8Array | Midnight Docs](#compacttypeopaqueuint8array-midnight-docs) - [CostModel | Midnight Docs](#costmodel-midnight-docs) - [ContractOperation | Midnight Docs](#contractoperation-midnight-docs) - [VmResults | Midnight Docs](#vmresults-midnight-docs) - [QueryResults | Midnight Docs](#queryresults-midnight-docs) - [StateValue | Midnight Docs](#statevalue-midnight-docs) - [CompactTypeVector | Midnight Docs](#compacttypevector-midnight-docs) - [StateMap | Midnight Docs](#statemap-midnight-docs) - [StateBoundedMerkleTree | Midnight Docs](#stateboundedmerkletree-midnight-docs) - [VmStack | Midnight Docs](#vmstack-midnight-docs) - [CompactTypeUnsignedInteger | Midnight Docs](#compacttypeunsignedinteger-midnight-docs) - [QueryContext | Midnight Docs](#querycontext-midnight-docs) - [ContractState | Midnight Docs](#contractstate-midnight-docs) - [ErrorCodes | Midnight Docs](#errorcodes-midnight-docs) - [APIError | Midnight Docs](#apierror-midnight-docs) - [ErrorCode | Midnight Docs](#errorcode-midnight-docs) - [globals | Midnight Docs](#globals-midnight-docs) - [ServiceUriConfig | Midnight Docs](#serviceuriconfig-midnight-docs) - [DAppConnectorAPI | Midnight Docs](#dappconnectorapi-midnight-docs) - [DAppConnectorWalletState | Midnight Docs](#dappconnectorwalletstate-midnight-docs) - [DAppConnectorWalletAPI | Midnight Docs](#dappconnectorwalletapi-midnight-docs) - [NetworkId | Midnight Docs](#networkid-midnight-docs) - [Midnight DApp connector API | Midnight Docs](#midnight-dapp-connector-api-midnight-docs) - [Midnight.js API | Midnight Docs](#midnight-js-api-midnight-docs) - [Midnight Indexer API Documentation v1 | Midnight Docs](#midnight-indexer-api-documentation-v1-midnight-docs) - [Midnight Dev Diaries](#midnight-dev-diaries) - [NetworkId | Midnight Docs](#networkid-midnight-docs) - [ConstructorContext | Midnight Docs](#constructorcontext-midnight-docs) - [CircuitContext | Midnight Docs](#circuitcontext-midnight-docs) - [CircuitResults | Midnight Docs](#circuitresults-midnight-docs) - [Authentication | Midnight Docs](#authentication-midnight-docs) - [Rate limits | Midnight Docs](#rate-limits-midnight-docs) - [Error codes | Midnight Docs](#error-codes-midnight-docs) - [On-Chain runtime API | Midnight Docs](#on-chain-runtime-api-midnight-docs) - [ConstructorResult | Midnight Docs](#constructorresult-midnight-docs) - [CurvePoint | Midnight Docs](#curvepoint-midnight-docs) - [EncodedQualifiedShieldedCoinInfo | Midnight Docs](#encodedqualifiedshieldedcoininfo-midnight-docs) - [EncodedCoinInfo | Midnight Docs](#encodedcoininfo-midnight-docs) - [MerkleTreePathEntry | Midnight Docs](#merkletreepathentry-midnight-docs) - [MerkleTreePath | Midnight Docs](#merkletreepath-midnight-docs) - [MerkleTreeDigest | Midnight Docs](#merkletreedigest-midnight-docs) - [NativePoint | Midnight Docs](#nativepoint-midnight-docs) - [EncodedRecipient | Midnight Docs](#encodedrecipient-midnight-docs) - [EncodedZswapLocalState | Midnight Docs](#encodedzswaplocalstate-midnight-docs) - [midnight-js-fetch-zk-config-provider | Midnight Docs](#midnight-js-fetch-zk-config-provider-midnight-docs) - [EncodedQualifiedCoinInfo | Midnight Docs](#encodedqualifiedcoininfo-midnight-docs) - [EncodedContractAddress | Midnight Docs](#encodedcontractaddress-midnight-docs) - [midnight-js-logger-provider | Midnight Docs](#midnight-js-logger-provider-midnight-docs) - [midnight-js-http-client-proof-provider | Midnight Docs](#midnight-js-http-client-proof-provider-midnight-docs) - [PartialProofData | Midnight Docs](#partialproofdata-midnight-docs) - [midnight-js-level-private-state-provider | Midnight Docs](#midnight-js-level-private-state-provider-midnight-docs) - [midnight-js-node-zk-config-provider | Midnight Docs](#midnight-js-node-zk-config-provider-midnight-docs) - [packages | Midnight Docs](#packages-midnight-docs) - [midnight-js-indexer-public-data-provider | Midnight Docs](#midnight-js-indexer-public-data-provider-midnight-docs) - [CompactType | Midnight Docs](#compacttype-midnight-docs) - [EncodedCoinPublicKey | Midnight Docs](#encodedcoinpublickey-midnight-docs) - [Recipient | Midnight Docs](#recipient-midnight-docs) - [WitnessContext | Midnight Docs](#witnesscontext-midnight-docs) - [EncodedShieldedCoinInfo | Midnight Docs](#encodedshieldedcoininfo-midnight-docs) - [ZswapLocalState | Midnight Docs](#zswaplocalstate-midnight-docs) - [Ledger API | Midnight Docs](#ledger-api-midnight-docs) - [midnight-js-utils | Midnight Docs](#midnight-js-utils-midnight-docs) - [midnight-js-network-id | Midnight Docs](#midnight-js-network-id-midnight-docs) - [midnight-js-contract | Midnight Docs](#midnight-js-contract-midnight-docs) - [ProofData | Midnight Docs](#proofdata-midnight-docs) - [midnight-js-types | Midnight Docs](#midnight-js-types-midnight-docs) - [Wallet API | Midnight Docs](#wallet-api-midnight-docs) - [Bytes32Descriptor | Midnight Docs](#bytes32descriptor-midnight-docs) - [midnight-js-testing | Midnight Docs](#midnight-js-testing-midnight-docs) - [BooleanDescriptor | Midnight Docs](#booleandescriptor-midnight-docs) - [CompactTypeField | Midnight Docs](#compacttypefield-midnight-docs) - [CompactTypeOpaqueString | Midnight Docs](#compacttypeopaquestring-midnight-docs) - [TRANSACTION_TO_PROVE | Midnight Docs](#transaction-to-prove-midnight-docs) - [NOTHING_TO_PROVE | Midnight Docs](#nothing-to-prove-midnight-docs) - [Compact runtime API | Midnight Docs](#compact-runtime-api-midnight-docs) - [CONTRACT_ADDRESS_BYTE_LENGTH | Midnight Docs](#contract-address-byte-length-midnight-docs) - [MAX_FIELD | Midnight Docs](#max-field-midnight-docs) - [CompactTypeOpaqueUint8Array | Midnight Docs](#compacttypeopaqueuint8array-midnight-docs) - [CompactTypeBoolean | Midnight Docs](#compacttypeboolean-midnight-docs) - [HEX_REGEX_NO_PREFIX | Midnight Docs](#hex-regex-no-prefix-midnight-docs) - [CompactTypeMerkleTreePathEntry | Midnight Docs](#compacttypemerkletreepathentry-midnight-docs) - [MaxUint8Descriptor | Midnight Docs](#maxuint8descriptor-midnight-docs) - [versionString | Midnight Docs](#versionstring-midnight-docs) - [BALANCE_TRANSACTION_TO_PROVE | Midnight Docs](#balance-transaction-to-prove-midnight-docs) - [Reference documentation | Midnight Docs](#reference-documentation-midnight-docs) - [CompactTypeNativePoint | Midnight Docs](#compacttypenativepoint-midnight-docs) - [CompactTypeMerkleTreeDigest | Midnight Docs](#compacttypemerkletreedigest-midnight-docs) - [ContractOperation | Midnight Docs](#contractoperation-midnight-docs) - [QueryResults | Midnight Docs](#queryresults-midnight-docs) - [CostModel | Midnight Docs](#costmodel-midnight-docs) - [StateMap | Midnight Docs](#statemap-midnight-docs) - [VmResults | Midnight Docs](#vmresults-midnight-docs) - [VmStack | Midnight Docs](#vmstack-midnight-docs) - [ContractMaintenanceAuthority | Midnight Docs](#contractmaintenanceauthority-midnight-docs) - [CoinInfoDescriptor | Midnight Docs](#coininfodescriptor-midnight-docs) - [DUMMY_ADDRESS | Midnight Docs](#dummy-address-midnight-docs) - [README | Midnight Docs](#readme-midnight-docs) - [globals | Midnight Docs](#globals-midnight-docs) - [CoinRecipientDescriptor | Midnight Docs](#coinrecipientdescriptor-midnight-docs) - [StateBoundedMerkleTree | Midnight Docs](#stateboundedmerkletree-midnight-docs) - [ContractAddressDescriptor | Midnight Docs](#contractaddressdescriptor-midnight-docs) - [StateValue | Midnight Docs](#statevalue-midnight-docs) - [Ledger API | Midnight Docs](#ledger-api-midnight-docs) - [packages | Midnight Docs](#packages-midnight-docs) - [globals | Midnight Docs](#globals-midnight-docs) - [On-Chain runtime API | Midnight Docs](#on-chain-runtime-api-midnight-docs) - [globals | Midnight Docs](#globals-midnight-docs) - [globals | Midnight Docs](#globals-midnight-docs) - [One doc tagged with "developer-tools" | Midnight Docs](#one-doc-tagged-with-developer-tools-midnight-docs) - [ShieldedCoinInfoDescriptor | Midnight Docs](#shieldedcoininfodescriptor-midnight-docs) - [ShieldedCoinRecipientDescriptor | Midnight Docs](#shieldedcoinrecipientdescriptor-midnight-docs) - [ContractState | Midnight Docs](#contractstate-midnight-docs) - [ZswapCoinPublicKeyDescriptor | Midnight Docs](#zswapcoinpublickeydescriptor-midnight-docs) - [The Compact language | Midnight Docs](#the-compact-language-midnight-docs) - [Formal grammar | Midnight Docs](#formal-grammar-midnight-docs) - [Wallet API | Midnight Docs](#wallet-api-midnight-docs) - [globals | Midnight Docs](#globals-midnight-docs) - [globals | Midnight Docs](#globals-midnight-docs) - [ZSwap API | Midnight Docs](#zswap-api-midnight-docs) - [Wallet | Midnight Docs](#wallet-midnight-docs) - [NetworkId | Midnight Docs](#networkid-midnight-docs) - [Opaque data types | Midnight Docs](#opaque-data-types-midnight-docs) - [2 docs tagged with "developer guide" | Midnight Docs](#2-docs-tagged-with-developer-guide-midnight-docs) - [DApp connector API | Midnight Docs](#dapp-connector-api-midnight-docs) - [One doc tagged with "authentication" | Midnight Docs](#one-doc-tagged-with-authentication-midnight-docs) - [Compact standard library | Midnight Docs](#compact-standard-library-midnight-docs) - [One doc tagged with "typescript" | Midnight Docs](#one-doc-tagged-with-typescript-midnight-docs) - [Midnight APIs | Midnight Docs](#midnight-apis-midnight-docs) - [QueryContext | Midnight Docs](#querycontext-midnight-docs) - [One doc tagged with "midnight.js" | Midnight Docs](#one-doc-tagged-with-midnight-js-midnight-docs) - [One doc tagged with "issues" | Midnight Docs](#one-doc-tagged-with-issues-midnight-docs) - [One doc tagged with "rate limits" | Midnight Docs](#one-doc-tagged-with-rate-limits-midnight-docs) - [One doc tagged with "wallet" | Midnight Docs](#one-doc-tagged-with-wallet-midnight-docs) - [One doc tagged with "error codes" | Midnight Docs](#one-doc-tagged-with-error-codes-midnight-docs) - [Midnight Indexer API Documentation v1 | Midnight Docs](#midnight-indexer-api-documentation-v1-midnight-docs) - [One doc tagged with "integration" | Midnight Docs](#one-doc-tagged-with-integration-midnight-docs) - [Explicit disclosure | Midnight Docs](#explicit-disclosure-midnight-docs) - [ZSwap API | Midnight Docs](#zswap-api-midnight-docs) - [createCoinInfo | Midnight Docs](#createcoininfo-midnight-docs) - [nativeToken | Midnight Docs](#nativetoken-midnight-docs) - [sampleContractAddress | Midnight Docs](#samplecontractaddress-midnight-docs) - [sampleTokenType | Midnight Docs](#sampletokentype-midnight-docs) - [4 docs tagged with "sdk" | Midnight Docs](#4-docs-tagged-with-sdk-midnight-docs) - [sampleCoinPublicKey | Midnight Docs](#samplecoinpublickey-midnight-docs) - [Detailed API reference | Midnight Docs](#detailed-api-reference-midnight-docs) - [EncPublicKeyLegacy | Midnight Docs](#encpublickeylegacy-midnight-docs) - [CoinPublicKeyLegacy | Midnight Docs](#coinpublickeylegacy-midnight-docs) - [Address | Midnight Docs](#address-midnight-docs) - [AddressLegacy | Midnight Docs](#addresslegacy-midnight-docs) - [CoinPublicKey | Midnight Docs](#coinpublickey-midnight-docs) - [TransactionHash | Midnight Docs](#transactionhash-midnight-docs) - [NothingToProve | Midnight Docs](#nothingtoprove-midnight-docs) - [SyncLag | Midnight Docs](#synclag-midnight-docs) - [Ledger data types | Midnight Docs](#ledger-data-types-midnight-docs) - [Tools | Midnight Docs](#tools-midnight-docs) - [Tags | Midnight Docs](#tags-midnight-docs) - [ApplyStage | Midnight Docs](#applystage-midnight-docs) - [ProvingRecipe | Midnight Docs](#provingrecipe-midnight-docs) - [BalanceTransactionToProve | Midnight Docs](#balancetransactiontoprove-midnight-docs) - [globals | Midnight Docs](#globals-midnight-docs) - [TransactionIdentifier | Midnight Docs](#transactionidentifier-midnight-docs) - [TokenType | Midnight Docs](#tokentype-midnight-docs) - [Compact Compiler Manual Page | Midnight Docs](#compact-compiler-manual-page-midnight-docs) - [One doc tagged with "advanced" | Midnight Docs](#one-doc-tagged-with-advanced-midnight-docs) - [One doc tagged with "best practices" | Midnight Docs](#one-doc-tagged-with-best-practices-midnight-docs) - [One doc tagged with "builder" | Midnight Docs](#one-doc-tagged-with-builder-midnight-docs) - [One doc tagged with "bun" | Midnight Docs](#one-doc-tagged-with-bun-midnight-docs) - [Troubleshoot | Midnight Docs](#troubleshoot-midnight-docs) - [Community SDKs | Midnight Docs](#community-sdks-midnight-docs) - [Error codes | Midnight Docs](#error-codes-midnight-docs) - [TokenTransfer | Midnight Docs](#tokentransfer-midnight-docs) - [SyncProgress | Midnight Docs](#syncprogress-midnight-docs) - [TransactionHistoryEntry | Midnight Docs](#transactionhistoryentry-midnight-docs) - [CoinCommitment | Midnight Docs](#coincommitment-midnight-docs) - [ContractAddress | Midnight Docs](#contractaddress-midnight-docs) - [CoinPublicKey | Midnight Docs](#coinpublickey-midnight-docs) - [One doc tagged with "compatibility" | Midnight Docs](#one-doc-tagged-with-compatibility-midnight-docs) - [One doc tagged with "DApps" | Midnight Docs](#one-doc-tagged-with-dapps-midnight-docs) - [One doc tagged with "deployment" | Midnight Docs](#one-doc-tagged-with-deployment-midnight-docs) - [One doc tagged with "development" | Midnight Docs](#one-doc-tagged-with-development-midnight-docs) - [Official SDKs | Midnight Docs](#official-sdks-midnight-docs) - [Visual Studio Code extension for Compact | Midnight Docs](#visual-studio-code-extension-for-compact-midnight-docs) - [TransactionToProve | Midnight Docs](#transactiontoprove-midnight-docs) - [Nonce | Midnight Docs](#nonce-midnight-docs) - [EncPublicKey | Midnight Docs](#encpublickey-midnight-docs) - [One doc tagged with "getting-started" | Midnight Docs](#one-doc-tagged-with-getting-started-midnight-docs) - [One doc tagged with "glossary" | Midnight Docs](#one-doc-tagged-with-glossary-midnight-docs) - [One doc tagged with "dapp" | Midnight Docs](#one-doc-tagged-with-dapp-midnight-docs) - [Midnight SDKs | Midnight Docs](#midnight-sdks-midnight-docs) - [WalletState | Midnight Docs](#walletstate-midnight-docs) - [CoinInfo | Midnight Docs](#coininfo-midnight-docs) - [TokenType | Midnight Docs](#tokentype-midnight-docs) - [Nullifier | Midnight Docs](#nullifier-midnight-docs) - [2 docs tagged with "errors" | Midnight Docs](#2-docs-tagged-with-errors-midnight-docs) - [One doc tagged with "loan" | Midnight Docs](#one-doc-tagged-with-loan-midnight-docs) - [One doc tagged with "Midnight.js" | Midnight Docs](#one-doc-tagged-with-midnight-js-midnight-docs) - [One doc tagged with "nextjs" | Midnight Docs](#one-doc-tagged-with-nextjs-midnight-docs) - [One doc tagged with "nixos" | Midnight Docs](#one-doc-tagged-with-nixos-midnight-docs) - [Writing a contract | Midnight Docs](#writing-a-contract-midnight-docs) - [Alignment | Midnight Docs](#alignment-midnight-docs) - [CoinCommitment | Midnight Docs](#coincommitment-midnight-docs) - [CoinPublicKey | Midnight Docs](#coinpublickey-midnight-docs) - [DomainSeperator | Midnight Docs](#domainseperator-midnight-docs) - [Alignment | Midnight Docs](#alignment-midnight-docs) - [AlignedValue | Midnight Docs](#alignedvalue-midnight-docs) - [AlignmentAtom | Midnight Docs](#alignmentatom-midnight-docs) - [AlignmentSegment | Midnight Docs](#alignmentsegment-midnight-docs) - [CommunicationCommitmentRand | Midnight Docs](#communicationcommitmentrand-midnight-docs) - [EncPublicKey | Midnight Docs](#encpublickey-midnight-docs) - [ContractAction | Midnight Docs](#contractaction-midnight-docs) - [CommunicationCommitment | Midnight Docs](#communicationcommitment-midnight-docs) - [AlignmentSegment | Midnight Docs](#alignmentsegment-midnight-docs) - [AlignmentAtom | Midnight Docs](#alignmentatom-midnight-docs) - [CoinCommitment | Midnight Docs](#coincommitment-midnight-docs) - [CoinPublicKey | Midnight Docs](#coinpublickey-midnight-docs) - [DomainSeperator | Midnight Docs](#domainseperator-midnight-docs) - [ContractAddress | Midnight Docs](#contractaddress-midnight-docs) - [TransactionId | Midnight Docs](#transactionid-midnight-docs) - [TransactionHash | Midnight Docs](#transactionhash-midnight-docs) - [3 docs tagged with "compact" | Midnight Docs](#3-docs-tagged-with-compact-midnight-docs) - [2 docs tagged with "installation" | Midnight Docs](#2-docs-tagged-with-installation-midnight-docs) - [ContractAddress | Midnight Docs](#contractaddress-midnight-docs) - [Fr | Midnight Docs](#fr-midnight-docs) - [Effects | Midnight Docs](#effects-midnight-docs) - [BlockContext | Midnight Docs](#blockcontext-midnight-docs) - [CoinInfo | Midnight Docs](#coininfo-midnight-docs) - [Nullifier | Midnight Docs](#nullifier-midnight-docs) - [Nonce | Midnight Docs](#nonce-midnight-docs) - [GatherResult | Midnight Docs](#gatherresult-midnight-docs) - [Signature | Midnight Docs](#signature-midnight-docs) - [Key | Midnight Docs](#key-midnight-docs) - [SigningKey | Midnight Docs](#signingkey-midnight-docs) - [TransactionHash | Midnight Docs](#transactionhash-midnight-docs) - [QualifiedCoinInfo | Midnight Docs](#qualifiedcoininfo-midnight-docs) - [SignatureVerifyingKey | Midnight Docs](#signatureverifyingkey-midnight-docs) - [TokenType | Midnight Docs](#tokentype-midnight-docs) - [TransactionId | Midnight Docs](#transactionid-midnight-docs) - [Value | Midnight Docs](#value-midnight-docs) - [QualifiedCoinInfo | Midnight Docs](#qualifiedcoininfo-midnight-docs) - [Build using MeshSDK | Midnight Docs](#build-using-meshsdk-midnight-docs) - [Core API methods | Midnight Docs](#core-api-methods-midnight-docs) - [List of error codes | Midnight Docs](#list-of-error-codes-midnight-docs) - [One doc tagged with "preview" | Midnight Docs](#one-doc-tagged-with-preview-midnight-docs) - [One doc tagged with "preprod" | Midnight Docs](#one-doc-tagged-with-preprod-midnight-docs) - [One doc tagged with "react" | Midnight Docs](#one-doc-tagged-with-react-midnight-docs) - [One doc tagged with "npm" | Midnight Docs](#one-doc-tagged-with-npm-midnight-docs) - [One doc tagged with "JavaScript" | Midnight Docs](#one-doc-tagged-with-javascript-midnight-docs) - [AlignedValue | Midnight Docs](#alignedvalue-midnight-docs) - [Nonce | Midnight Docs](#nonce-midnight-docs) - [BlockContext | Midnight Docs](#blockcontext-midnight-docs) - [CoinInfo | Midnight Docs](#coininfo-midnight-docs) - [Effects | Midnight Docs](#effects-midnight-docs) - [GatherResult | Midnight Docs](#gatherresult-midnight-docs) - [SignatureVerifyingKey | Midnight Docs](#signatureverifyingkey-midnight-docs) - [Key | Midnight Docs](#key-midnight-docs) - [SigningKey | Midnight Docs](#signingkey-midnight-docs) - [TokenType | Midnight Docs](#tokentype-midnight-docs) - [Value | Midnight Docs](#value-midnight-docs) - [Fr | Midnight Docs](#fr-midnight-docs) - [Nullifier | Midnight Docs](#nullifier-midnight-docs) - [QualifiedCoinInfo | Midnight Docs](#qualifiedcoininfo-midnight-docs) - [Op | Midnight Docs](#op-midnight-docs) - [EncodedStateValue | Midnight Docs](#encodedstatevalue-midnight-docs) - [Transcript | Midnight Docs](#transcript-midnight-docs) - [Signature | Midnight Docs](#signature-midnight-docs) - [Authentication | Midnight Docs](#authentication-midnight-docs) - [Rate limits | Midnight Docs](#rate-limits-midnight-docs) - [EncodedStateValue | Midnight Docs](#encodedstatevalue-midnight-docs) - [Transcript | Midnight Docs](#transcript-midnight-docs) - [Op | Midnight Docs](#op-midnight-docs) - [SingleUpdate | Midnight Docs](#singleupdate-midnight-docs) - [3 docs tagged with "security" | Midnight Docs](#3-docs-tagged-with-security-midnight-docs) - [Getting started | Midnight Docs](#getting-started-midnight-docs) - [Common SDK integration issues | Midnight Docs](#common-sdk-integration-issues-midnight-docs) - [2 docs tagged with "setup" | Midnight Docs](#2-docs-tagged-with-setup-midnight-docs) - [Midnight.js | Midnight Docs](#midnight-js-midnight-docs) - [Lace wallet integration | Midnight Docs](#lace-wallet-integration-midnight-docs) - [2 docs tagged with "troubleshooting" | Midnight Docs](#2-docs-tagged-with-troubleshooting-midnight-docs) - [2 docs tagged with "tutorial" | Midnight Docs](#2-docs-tagged-with-tutorial-midnight-docs) - [AuthorizedMint | Midnight Docs](#authorizedmint-midnight-docs) - [One doc tagged with "version" | Midnight Docs](#one-doc-tagged-with-version-midnight-docs) - [One doc tagged with "tutorials" | Midnight Docs](#one-doc-tagged-with-tutorials-midnight-docs) - [One doc tagged with "zero-knowledge" | Midnight Docs](#one-doc-tagged-with-zero-knowledge-midnight-docs) - [One doc tagged with "ZK" | Midnight Docs](#one-doc-tagged-with-zk-midnight-docs) - [Input | Midnight Docs](#input-midnight-docs) - [5 docs tagged with "node" | Midnight Docs](#5-docs-tagged-with-node-midnight-docs) - [AlignmentAtom | Midnight Docs](#alignmentatom-midnight-docs) - [Alignment | Midnight Docs](#alignment-midnight-docs) - [AlignmentSegment | Midnight Docs](#alignmentsegment-midnight-docs) - [CoinCommitment | Midnight Docs](#coincommitment-midnight-docs) - [CoinPublicKey | Midnight Docs](#coinpublickey-midnight-docs) - [CommunicationCommitment | Midnight Docs](#communicationcommitment-midnight-docs) - [CoinInfo | Midnight Docs](#coininfo-midnight-docs) - [CommunicationCommitmentRand | Midnight Docs](#communicationcommitmentrand-midnight-docs) - [ContractAddress | Midnight Docs](#contractaddress-midnight-docs) - [BlockContext | Midnight Docs](#blockcontext-midnight-docs) - [MerkleTreeCollapsedUpdate | Midnight Docs](#merkletreecollapsedupdate-midnight-docs) - [ProofErasedOffer | Midnight Docs](#prooferasedoffer-midnight-docs) - [Output | Midnight Docs](#output-midnight-docs) - [ProofErasedInput | Midnight Docs](#prooferasedinput-midnight-docs) - [LedgerParameters | Midnight Docs](#ledgerparameters-midnight-docs) - [EncryptionSecretKey | Midnight Docs](#encryptionsecretkey-midnight-docs) - [3 docs tagged with "smart contract" | Midnight Docs](#3-docs-tagged-with-smart-contract-midnight-docs) - [AlignedValue | Midnight Docs](#alignedvalue-midnight-docs) - [DustTokenType | Midnight Docs](#dusttokentype-midnight-docs) - [CallContext | Midnight Docs](#callcontext-midnight-docs) - [bigIntModFr | Midnight Docs](#bigintmodfr-midnight-docs) - [Nonce | Midnight Docs](#nonce-midnight-docs) - [DomainSeparator | Midnight Docs](#domainseparator-midnight-docs) - [Key | Midnight Docs](#key-midnight-docs) - [DomainSeperator | Midnight Docs](#domainseperator-midnight-docs) - [dummyContractAddress | Midnight Docs](#dummycontractaddress-midnight-docs) - [coinCommitment | Midnight Docs](#coincommitment-midnight-docs) - [PublicAddress | Midnight Docs](#publicaddress-midnight-docs) - [PublicLedgerSegments | Midnight Docs](#publicledgersegments-midnight-docs) - [Effects | Midnight Docs](#effects-midnight-docs) - [EmptyPublicLedger | Midnight Docs](#emptypublicledger-midnight-docs) - [Fr | Midnight Docs](#fr-midnight-docs) - [Nullifier | Midnight Docs](#nullifier-midnight-docs) - [GatherResult | Midnight Docs](#gatherresult-midnight-docs) - [checkProofData | Midnight Docs](#checkproofdata-midnight-docs) - [bigIntModFr | Midnight Docs](#bigintmodfr-midnight-docs) - [coinCommitment | Midnight Docs](#coincommitment-midnight-docs) - [ProofErasedTransaction | Midnight Docs](#prooferasedtransaction-midnight-docs) - [Offer | Midnight Docs](#offer-midnight-docs) - [ProofErasedTransient | Midnight Docs](#prooferasedtransient-midnight-docs) - [ProofErasedOutput | Midnight Docs](#prooferasedoutput-midnight-docs) - [ProofErasedAuthorizedMint | Midnight Docs](#prooferasedauthorizedmint-midnight-docs) - [3 docs tagged with "wallet" | Midnight Docs](#3-docs-tagged-with-wallet-midnight-docs) - [Compact reference | Midnight Docs](#compact-reference-midnight-docs) - [RawTokenType | Midnight Docs](#rawtokentype-midnight-docs) - [QualifiedShieldedCoinInfo | Midnight Docs](#qualifiedshieldedcoininfo-midnight-docs) - [RunningCost | Midnight Docs](#runningcost-midnight-docs) - [communicationCommitment | Midnight Docs](#communicationcommitment-midnight-docs) - [bigIntToValue | Midnight Docs](#biginttovalue-midnight-docs) - [dummyContractAddress | Midnight Docs](#dummycontractaddress-midnight-docs) - [ContractReferenceLocations | Midnight Docs](#contractreferencelocations-midnight-docs) - [SigningKey | Midnight Docs](#signingkey-midnight-docs) - [Signature | Midnight Docs](#signature-midnight-docs) - [ShieldedTokenType | Midnight Docs](#shieldedtokentype-midnight-docs) - [ShieldedCoinInfo | Midnight Docs](#shieldedcoininfo-midnight-docs) - [SignatureVerifyingKey | Midnight Docs](#signatureverifyingkey-midnight-docs) - [QualifiedCoinInfo | Midnight Docs](#qualifiedcoininfo-midnight-docs) - [decodeCoinPublicKey | Midnight Docs](#decodecoinpublickey-midnight-docs) - [decodeContractAddress | Midnight Docs](#decodecontractaddress-midnight-docs) - [decodeTokenType | Midnight Docs](#decodetokentype-midnight-docs) - [ecMul | Midnight Docs](#ecmul-midnight-docs) - [communicationCommitmentRandomness | Midnight Docs](#communicationcommitmentrandomness-midnight-docs) - [ecAdd | Midnight Docs](#ecadd-midnight-docs) - [SparseCompactADT | Midnight Docs](#sparsecompactadt-midnight-docs) - [Op | Midnight Docs](#op-midnight-docs) - [ecMulGenerator | Midnight Docs](#ecmulgenerator-midnight-docs) - [degradeToTransient | Midnight Docs](#degradetotransient-midnight-docs) - [encodeCoinInfo | Midnight Docs](#encodecoininfo-midnight-docs) - [decodeCoinInfo | Midnight Docs](#decodecoininfo-midnight-docs) - [createCoinInfo | Midnight Docs](#createcoininfo-midnight-docs) - [decodeQualifiedCoinInfo | Midnight Docs](#decodequalifiedcoininfo-midnight-docs) - [maxField | Midnight Docs](#maxfield-midnight-docs) - [leafHash | Midnight Docs](#leafhash-midnight-docs) - [checkProofData | Midnight Docs](#checkproofdata-midnight-docs) - [SystemTransaction | Midnight Docs](#systemtransaction-midnight-docs) - [TransactionCostModel | Midnight Docs](#transactioncostmodel-midnight-docs) - [Transient | Midnight Docs](#transient-midnight-docs) - [UnprovenAuthorizedMint | Midnight Docs](#unprovenauthorizedmint-midnight-docs) - [EncodedStateValue | Midnight Docs](#encodedstatevalue-midnight-docs) - [SparseCompactArrayLikeADT | Midnight Docs](#sparsecompactarraylikeadt-midnight-docs) - [encodeCoinPublicKey | Midnight Docs](#encodecoinpublickey-midnight-docs) - [encodeTokenType | Midnight Docs](#encodetokentype-midnight-docs) - [degradeToTransient | Midnight Docs](#degradetotransient-midnight-docs) - [decodeTokenType | Midnight Docs](#decodetokentype-midnight-docs) - [decodeContractAddress | Midnight Docs](#decodecontractaddress-midnight-docs) - [decodeQualifiedCoinInfo | Midnight Docs](#decodequalifiedcoininfo-midnight-docs) - [decodeCoinInfo | Midnight Docs](#decodecoininfo-midnight-docs) - [decodeCoinPublicKey | Midnight Docs](#decodecoinpublickey-midnight-docs) - [bigIntToValue | Midnight Docs](#biginttovalue-midnight-docs) - [SparseCompactCellADT | Midnight Docs](#sparsecompactcelladt-midnight-docs) - [SparseCompactListADT | Midnight Docs](#sparsecompactlistadt-midnight-docs) - [SparseCompactSetADT | Midnight Docs](#sparsecompactsetadt-midnight-docs) - [SparseCompactContractAddress | Midnight Docs](#sparsecompactcontractaddress-midnight-docs) - [maxAlignedSize | Midnight Docs](#maxalignedsize-midnight-docs) - [encodeQualifiedCoinInfo | Midnight Docs](#encodequalifiedcoininfo-midnight-docs) - [encodeContractAddress | Midnight Docs](#encodecontractaddress-midnight-docs) - [leafHash | Midnight Docs](#leafhash-midnight-docs) - [maxField | Midnight Docs](#maxfield-midnight-docs) - [SparseCompactMapADT | Midnight Docs](#sparsecompactmapadt-midnight-docs) - [SparseCompactType | Midnight Docs](#sparsecompacttype-midnight-docs) - [SparseCompactValue | Midnight Docs](#sparsecompactvalue-midnight-docs) - [SparseCompactVector | Midnight Docs](#sparsecompactvector-midnight-docs) - [nativeToken | Midnight Docs](#nativetoken-midnight-docs) - [verifySignature | Midnight Docs](#verifysignature-midnight-docs) - [UnprovenInput | Midnight Docs](#unproveninput-midnight-docs) - [UnprovenOutput | Midnight Docs](#unprovenoutput-midnight-docs) - [UnprovenOffer | Midnight Docs](#unprovenoffer-midnight-docs) - [Transaction | Midnight Docs](#transaction-midnight-docs) - [ZswapChainState | Midnight Docs](#zswapchainstate-midnight-docs) - [ecMulGenerator | Midnight Docs](#ecmulgenerator-midnight-docs) - [encodeCoinInfo | Midnight Docs](#encodecoininfo-midnight-docs) - [sampleCoinPublicKey | Midnight Docs](#samplecoinpublickey-midnight-docs) - [ecAdd | Midnight Docs](#ecadd-midnight-docs) - [UnshieldedTokenType | Midnight Docs](#unshieldedtokentype-midnight-docs) - [UserAddress | Midnight Docs](#useraddress-midnight-docs) - [TokenType | Midnight Docs](#tokentype-midnight-docs) - [Transcript | Midnight Docs](#transcript-midnight-docs) - [SparseCompactStruct | Midnight Docs](#sparsecompactstruct-midnight-docs) - [ContractDeploy | Midnight Docs](#contractdeploy-midnight-docs) - [ContractMaintenanceAuthority | Midnight Docs](#contractmaintenanceauthority-midnight-docs) - [hashToCurve | Midnight Docs](#hashtocurve-midnight-docs) - [sampleTokenType | Midnight Docs](#sampletokentype-midnight-docs) - [signatureVerifyingKey | Midnight Docs](#signatureverifyingkey-midnight-docs) - [signData | Midnight Docs](#signdata-midnight-docs) - [sampleSigningKey | Midnight Docs](#samplesigningkey-midnight-docs) - [sampleContractAddress | Midnight Docs](#samplecontractaddress-midnight-docs) - [encodeTokenType | Midnight Docs](#encodetokentype-midnight-docs) - [maxAlignedSize | Midnight Docs](#maxalignedsize-midnight-docs) - [encodeCoinPublicKey | Midnight Docs](#encodecoinpublickey-midnight-docs) - [Value | Midnight Docs](#value-midnight-docs) - [CostModel | Midnight Docs](#costmodel-midnight-docs) - [ContractOperationVersion | Midnight Docs](#contractoperationversion-midnight-docs) - [ContractOperationVersionedVerifierKey | Midnight Docs](#contractoperationversionedverifierkey-midnight-docs) - [Input | Midnight Docs](#input-midnight-docs) - [AuthorizedMint | Midnight Docs](#authorizedmint-midnight-docs) - [ContractOperation | Midnight Docs](#contractoperation-midnight-docs) - [persistentCommit | Midnight Docs](#persistentcommit-midnight-docs) - [persistentHash | Midnight Docs](#persistenthash-midnight-docs) - [upgradeFromTransient | Midnight Docs](#upgradefromtransient-midnight-docs) - [valueToBigInt | Midnight Docs](#valuetobigint-midnight-docs) - [encodeContractAddress | Midnight Docs](#encodecontractaddress-midnight-docs) - [ecMul | Midnight Docs](#ecmul-midnight-docs) - [encodeQualifiedCoinInfo | Midnight Docs](#encodequalifiedcoininfo-midnight-docs) - [verifySignature | Midnight Docs](#verifysignature-midnight-docs) - [LocalState | Midnight Docs](#localstate-midnight-docs) - [UnprovenTransient | Midnight Docs](#unproventransient-midnight-docs) - [UnprovenTransaction | Midnight Docs](#unproventransaction-midnight-docs) - [ContractCallPrototype | Midnight Docs](#contractcallprototype-midnight-docs) - [ContractCall | Midnight Docs](#contractcall-midnight-docs) - [LocalState | Midnight Docs](#localstate-midnight-docs) - [signatureVerifyingKey | Midnight Docs](#signatureverifyingkey-midnight-docs) - [sampleContractAddress | Midnight Docs](#samplecontractaddress-midnight-docs) - [sampleSigningKey | Midnight Docs](#samplesigningkey-midnight-docs) - [LedgerParameters | Midnight Docs](#ledgerparameters-midnight-docs) - [tokenType | Midnight Docs](#tokentype-midnight-docs) - [hashToCurve | Midnight Docs](#hashtocurve-midnight-docs) - [persistentCommit | Midnight Docs](#persistentcommit-midnight-docs) - [persistentHash | Midnight Docs](#persistenthash-midnight-docs) - [sampleTokenType | Midnight Docs](#sampletokentype-midnight-docs) - [signData | Midnight Docs](#signdata-midnight-docs) - [ContractCallsPrototype | Midnight Docs](#contractcallsprototype-midnight-docs) - [LedgerState | Midnight Docs](#ledgerstate-midnight-docs) - [partitionTranscripts | Midnight Docs](#partitiontranscripts-midnight-docs) - [transientHash | Midnight Docs](#transienthash-midnight-docs) - [transientCommit | Midnight Docs](#transientcommit-midnight-docs) - [valueToBigInt | Midnight Docs](#valuetobigint-midnight-docs) - [EncryptionSecretKey | Midnight Docs](#encryptionsecretkey-midnight-docs) - [ProofErasedInput | Midnight Docs](#prooferasedinput-midnight-docs) - [ProofErasedOffer | Midnight Docs](#prooferasedoffer-midnight-docs) - [Output | Midnight Docs](#output-midnight-docs) - [MerkleTreeCollapsedUpdate | Midnight Docs](#merkletreecollapsedupdate-midnight-docs) - [Offer | Midnight Docs](#offer-midnight-docs) - [StateMap | Midnight Docs](#statemap-midnight-docs) - [tokenType | Midnight Docs](#tokentype-midnight-docs) - [transientCommit | Midnight Docs](#transientcommit-midnight-docs) - [PreTranscript | Midnight Docs](#pretranscript-midnight-docs) - [MaintenanceUpdate | Midnight Docs](#maintenanceupdate-midnight-docs) - [ReplaceAuthority | Midnight Docs](#replaceauthority-midnight-docs) - [ProofErasedOutput | Midnight Docs](#prooferasedoutput-midnight-docs) - [ProofErasedTransient | Midnight Docs](#prooferasedtransient-midnight-docs) - [ProofErasedAuthorizedMint | Midnight Docs](#prooferasedauthorizedmint-midnight-docs) - [Example integration | Midnight Docs](#example-integration-midnight-docs) - [upgradeFromTransient | Midnight Docs](#upgradefromtransient-midnight-docs) - [ProofErasedTransaction | Midnight Docs](#prooferasedtransaction-midnight-docs) - [QueryResults | Midnight Docs](#queryresults-midnight-docs) - [runProgram | Midnight Docs](#runprogram-midnight-docs) - [TransactionCostModel | Midnight Docs](#transactioncostmodel-midnight-docs) - [ContractState | Midnight Docs](#contractstate-midnight-docs) - [SystemTransaction | Midnight Docs](#systemtransaction-midnight-docs) - [runProgram | Midnight Docs](#runprogram-midnight-docs) - [transientHash | Midnight Docs](#transienthash-midnight-docs) - [TransactionResult | Midnight Docs](#transactionresult-midnight-docs) - [VerifierKeyRemove | Midnight Docs](#verifierkeyremove-midnight-docs) - [VmResults | Midnight Docs](#vmresults-midnight-docs) - [VmStack | Midnight Docs](#vmstack-midnight-docs) - [Transient | Midnight Docs](#transient-midnight-docs) - [VerifierKeyInsert | Midnight Docs](#verifierkeyinsert-midnight-docs) - [UnprovenAuthorizedMint | Midnight Docs](#unprovenauthorizedmint-midnight-docs) - [StateBoundedMerkleTree | Midnight Docs](#stateboundedmerkletree-midnight-docs) - [TransactionContext | Midnight Docs](#transactioncontext-midnight-docs) - [StateValue | Midnight Docs](#statevalue-midnight-docs) - [WellFormedStrictness | Midnight Docs](#wellformedstrictness-midnight-docs) - [UnprovenOffer | Midnight Docs](#unprovenoffer-midnight-docs) - [UnprovenTransaction | Midnight Docs](#unproventransaction-midnight-docs) - [UnprovenInput | Midnight Docs](#unproveninput-midnight-docs) - [Transaction | Midnight Docs](#transaction-midnight-docs) - [UnprovenOutput | Midnight Docs](#unprovenoutput-midnight-docs) - [ZswapChainState | Midnight Docs](#zswapchainstate-midnight-docs) - [UnprovenTransient | Midnight Docs](#unproventransient-midnight-docs) - [addField | Midnight Docs](#addfield-midnight-docs) --- # Midnight Documentation | Midnight Docs [Skip to main content](https://docs.midnight.network/#__docusaurus_skipToContent_fallback) Version: v0.0.0 Explore with… ▾ Midnight developer documentation▍ ================================= Midnight helps you keep sensitive data private with zero-knowledge proofs and selective disclosure, without losing on-chain utility. [Start building](https://docs.midnight.network/getting-started/create-mn-app) [Examples](https://github.com/midnightntwrk/midnight-awesome-dapps) [Compact language](https://docs.midnight.network/compact) * * * What is Midnight?[​](https://docs.midnight.network/#what-is-midnight "Direct link to What is Midnight?") --------------------------------------------------------------------------------------------------------- Midnight is a privacy-first blockchain that blends public verifiability with confidential data handling. You can use Midnight's selective disclosure and ZK proofs to build apps that: * Verify correctness without revealing sensitive data * Share only the information users choose to disclose * Prove compliance while keeping private records confidential Midnight’s consensus mechanism ensures agreement on state while preserving privacy and performance. * * * [✦\ \ ### New to blockchain\ \ Learn core ideas related to selective disclosure, ZK proofs, commitments, and how Midnight is different.\ \ Start learning→](https://academy.midnight.network/) [✦\ \ ### Developer\ \ Install tools, scaffold an app, write a contract, and send a private transaction.\ \ Start building→](https://docs.midnight.network/getting-started) [✦\ \ ### Node operators\ \ Run nodes, monitor health, and follow node best practices.\ \ Operate nodes→](https://docs.midnight.network/operate/node-intro) [✦\ \ ### Research and compliance\ \ Explore the runtime, proving system, transaction semantics, and audit paths.\ \ View architecture→](https://docs.midnight.network/develop/how-midnight-works) * * * Participate[​](https://docs.midnight.network/#participate "Direct link to Participate") ---------------------------------------------------------------------------------------- [### GitHub\ \ Explore repositories, track issues, and contribute to development.\ \ Contribute→](https://github.com/midnightntwrk) [### Discord\ \ Chat with the team, get support, and join community calls.\ \ Join→](https://discord.com/invite/midnightnetwork) [### YouTube\ \ Watch walkthroughs, deep dives, and recorded talks from the team.\ \ Watch→](https://www.youtube.com/@midnight.network) [### Hackathons\ \ Build on Midnight, learn from others, and showcase your projects.\ \ Build→](https://midnight.network/hackathon) [### Nightpaper\ \ Read about the architecture, proof system, and design principles.\ \ Read→](https://midnight.network/whitepaper) [### Forum\ \ Discuss development, governance, and announcements with the community.\ \ Discuss→](https://forum.midnight.network/) [### Dev Diaries\ \ Follow development updates, DevRel communication, and community stories.\ \ Read→](https://docs.midnight.network/blog) [### Midnight Blog\ \ Read ecosystem news and major announcements.\ \ Read→](https://midnight.network/blog) --- # Dev Diaries | Midnight Docs [Skip to main content](https://docs.midnight.network/blog#__docusaurus_skipToContent_fallback) { } < /> console.log() | Latest Post ----------- ![Testnet-02 Transition & The Roadmap to Mōhalu](https://docs.midnight.network/img/blog/updates.jpg) January 27, 2026 ### [Testnet-02 Transition & The Roadmap to Mōhalu](https://docs.midnight.network/blog/testnet-02-transition) As we progress through the Hilo phase and prepare for the upcoming milestones of the Midnight Network, we are adjusting testing environments to ensure a seamless transition to a decentralized mainnet. testnetspos By Stevan Lohja Filters ------- Reset Filters Tags: testnetsposcompactmcpaideveloper-toolsnightdustcommunitybeginnermidnightzero-knowledgehackathonblockchainintroweb3dappjavascriptpartner-chainsspoblswalletmidnight.jszkpmeetingindexer Hold Ctrl/Cmd to select multiple Author:All AuthorsStevan LohjaIdris OlubisiJay AlbertKevin MillikinClaude BardeKaleab AbaynehThe Compact TeamSamantha HolstineLauren LeeDevRel Sort by:Newest FirstOldest First All Posts --------- ![Midnight MCP - AI-assisted development for Compact smart contracts](https://docs.midnight.network/img/blog/zkp.jpg) January 21, 2026 ### [Midnight MCP - AI-assisted development for Compact smart contracts](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development) AI coding assistants like Claude, GitHub Copilot, and Cursor have transformed how developers write code. But they have a fundamental limitation: they only know what was in their training data. compactmcpaideveloper-tools ![Architecture Overview DUST and Network Usage](https://docs.midnight.network/img/blog/blockchain.jpg) January 2, 2026 ### [Architecture Overview DUST and Network Usage](https://docs.midnight.network/blog/dust-architecture) To understand this system, it helps to use an analogy. nightdust ![Hacktoberfest Contributor Guide](https://docs.midnight.network/img/blog/ecosystem.jpg) October 15, 2025 ### [Hacktoberfest Contributor Guide](https://docs.midnight.network/blog/hacktoberfest25) Hacktoberfest is a global open-source event held every October, where developers contribute pull requests to public repositories to earn digital rewards. communitybeginner ![Welcome to the Midnight Community Hub! ✨](https://docs.midnight.network/img/blog/ecosystem.jpg) September 16, 2025 ### [Welcome to the Midnight Community Hub! ✨](https://docs.midnight.network/blog/community-hub) The Community Hub serves as a collaborative platform for gathering and managing community-driven contributions. Whether you're proposing new content, requesting features, reporting issues, or ideation for dApps, this repo is your entry point. We use GitHub's built-in features like issues, projects, and automations to ensure ideas are triaged efficiently and turned into actionable tasks. community ![Compact Deep Dive Part 3 - The On-chain Runtime](https://docs.midnight.network/img/blog/zkp.jpg) August 20, 2025 ### [Compact Deep Dive Part 3 - The On-chain Runtime](https://docs.midnight.network/blog/compact-3) This blog post is the third part of the Compact Deep Dive series, which explores how Compact contracts work on the Midnight network. compact ![Introduction to the FungibleToken contract on Midnight](https://docs.midnight.network/img/blog/zkp.jpg) August 20, 2025 ### [Introduction to the FungibleToken contract on Midnight](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin) Introduction to the FungibleToken contract on Midnight midnightcompact ![From Frustration to Framework: Building on Midnight](https://docs.midnight.network/img/blog/hackathons.jpg) August 13, 2025 ### [From Frustration to Framework: Building on Midnight](https://docs.midnight.network/blog/from-frustration-to-framework) After participating in three hackathons this year, I thought I had a good idea of what to expect. Then came the fourth. It began like the others: an idea, a challenge, a blank terminal screen. But this one took an unexpected turn, one I didn't see coming. midnightzero-knowledgehackathonblockchaincompact ![Introducing the Compact Developer Tools](https://docs.midnight.network/img/blog/zkp.jpg) August 1, 2025 ### [Introducing the Compact Developer Tools](https://docs.midnight.network/blog/compact-developer-tools) We are proud to announce the launch of the Compact developer tools! compact ![Learning Web3 from the Ground Up - Understanding Ethereum](https://docs.midnight.network/img/blog/web3.jpg) July 25, 2025 ### [Learning Web3 from the Ground Up - Understanding Ethereum](https://docs.midnight.network/blog/web3-intro-understanding-ethereum) This past week, I started the SheFi course—a program designed to help women dive deeper into Web3 and decentralized finance. One of the first topics it covered was Ethereum: what it is, why it matters, and how it fits into the broader decentralized ecosystem. introblockchainbeginnerweb3 ![Midnight’s First Step Toward Open Source – Say Hello to example-counter and example-bboard](https://docs.midnight.network/img/blog/ecosystem.jpg) July 11, 2025 ### [Midnight’s First Step Toward Open Source – Say Hello to example-counter and example-bboard](https://docs.midnight.network/blog/open-sourcing-examples) Midnight's Developer Relations team is actively shaping how developers learn, build, and experiment with privacy-first apps. In this post, we take a closer look at how DevRel is lowering the barrier to entry for new builders, supporting open-source tools, and helping the community navigate the unique challenges of developing on a privacy-preserving blockchain. dappbeginnerweb3intro ![Learning Web3 from the Ground Up - What Are Zero-Knowledge Proofs (ZKPs)?](https://docs.midnight.network/img/blog/web3.jpg) July 10, 2025 ### [Learning Web3 from the Ground Up - What Are Zero-Knowledge Proofs (ZKPs)?](https://docs.midnight.network/blog/web3-intro-what-are-zkps) Zero-knowledge proofs let you prove you know something without revealing what you know. Here's how this cryptographic breakthrough is revolutionizing privacy in Web3 applications. introblockchainbeginnerweb3 ![How to query the blockchain?](https://docs.midnight.network/img/blog/js.jpg) July 4, 2025 ### [How to query the blockchain?](https://docs.midnight.network/blog/query-the-blockchain) The Midnight blockchain introduces a novel approach to data privacy and compliance in decentralized applications (DApps), leveraging zero-knowledge proofs (ZKPs) and a dual-token system. midnightjavascript ![Compact Deep Dive Part 2 - Circuits and Witnesses](https://docs.midnight.network/img/blog/zkp.jpg) June 25, 2025 ### [Compact Deep Dive Part 2 - Circuits and Witnesses](https://docs.midnight.network/blog/compact-2) This blog post is part of the Compact Deep Dive series, which explores how Compact contracts work on the Midnight network. compact ![Learning Web3 from the Ground Up - Smart Contracts and the Compact Language](https://docs.midnight.network/img/blog/web3.jpg) June 20, 2025 ### [Learning Web3 from the Ground Up - Smart Contracts and the Compact Language](https://docs.midnight.network/blog/web3-intro-smart-contracts-and-compact) As I continue my journey through the world of Web3, I’ve been digging into the building blocks that make privacy-first platforms like Midnight possible (you can catch up on previous posts in the Midnight Dev Diaries!). This week, I focused on two foundational pieces that go hand in hand: smart contracts on Midnight and the Compact language that powers them. introblockchainbeginnerweb3 ![Compact Deep Dive Part 1 - Top-level Contract Structure](https://docs.midnight.network/img/blog/zkp.jpg) June 17, 2025 ### [Compact Deep Dive Part 1 - Top-level Contract Structure](https://docs.midnight.network/blog/compact) This post is part of the Compact Deep Dive series, which explores how Compact contracts work on the Midnight network. compact ![Learning Web3 from the Ground Up - Understanding Selective Disclosure](https://docs.midnight.network/img/blog/web3.jpg) June 13, 2025 ### [Learning Web3 from the Ground Up - Understanding Selective Disclosure](https://docs.midnight.network/blog/web3-intro-selective-disclosure) As I delve deeper into the world of Web3, I've been working my way through foundational concepts to have a better understanding of the industry (check out my last five posts on the Midnight Dev Diaries!). This week, I dove into one of the most practical and privacy-focused ideas I’ve encountered so far: selective disclosure. introblockchainbeginnerweb3 ![Learning Web3 from the Ground Up - Unpacking Merkle Trees and DAOs](https://docs.midnight.network/img/blog/web3.jpg) June 6, 2025 ### [Learning Web3 from the Ground Up - Unpacking Merkle Trees and DAOs](https://docs.midnight.network/blog/web3-intro-merkle-trees-and-dao) As I continue my Web3 learning journey, I've mostly been working through Cardano Academy and Midnight Academy and documenting my findings in the Midnight Dev Diaries. But this week, I decided to branch out and explore a broader range of beginner-friendly resources across the ecosystem. That led me to two foundational concepts that kept coming up: Merkle Trees and Decentralized Autonomous Organizations (DAOs). introblockchainbeginnerweb3 ![Learning Web3 from the Ground Up - A Quick History of Blockchain and Why Tokens Matter](https://docs.midnight.network/img/blog/web3.jpg) May 30, 2025 ### [Learning Web3 from the Ground Up - A Quick History of Blockchain and Why Tokens Matter](https://docs.midnight.network/blog/web3-intro-history-and-tokens) Explore how blockchain platforms have evolved from Bitcoin to Midnight and why tokens are essential to powering decentralized ecosystems. introblockchainbeginnerweb3 ![Midnight Indexer Now Official — Scala Indexer Fully Deprecated](https://docs.midnight.network/img/blog/indexer.jpg) May 22, 2025 ### [Midnight Indexer Now Official — Scala Indexer Fully Deprecated](https://docs.midnight.network/blog/midnight-indexer-replaces-scala) Last month, we introduced the Midnight Indexer, a modular, high-performance indexing service written in Rust. Today, we’re excited to share that the Rust-based Midnight Indexer has officially replaced the legacy Scala-based Pub-Sub Indexer. partner-chainstestnetspo ![Learning Web3 from the Ground Up - Encryption & Practical Byzantine Fault Tolerance](https://docs.midnight.network/img/blog/web3.jpg) May 20, 2025 ### [Learning Web3 from the Ground Up - Encryption & Practical Byzantine Fault Tolerance](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft) Explore how public key encryption and Practical Byzantine Fault Tolerance form the cryptographic and consensus backbone of secure, decentralized blockchain networks like Midnight. introblockchainbeginnerweb3 ![Midnight Testnet Upgrade Key Changes and Validator Reregistration Guide for Partner-Chains v1.5](https://docs.midnight.network/img/blog/ecosystem.jpg) May 20, 2025 ### [Midnight Testnet Upgrade Key Changes and Validator Reregistration Guide for Partner-Chains v1.5](https://docs.midnight.network/blog/midnight-testnet-upgrade-key-changes) A major Midnight Testnet upgrade introduces version 1.5, bringing key changes that require validator re-registration, improved node setup, and enhanced tooling for partner-chain participants. partner-chainstestnetspo ![Learning Web3 from the Ground Up - Hash Functions & Digital Signatures](https://docs.midnight.network/img/blog/web3.jpg) May 7, 2025 ### [Learning Web3 from the Ground Up - Hash Functions & Digital Signatures](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures) Two foundational cryptographic tools—hash functions and digital signatures—ensure data integrity, authenticity, and trust in decentralized Web3 systems like Midnight. introblockchainbeginnerweb3 ![Impact on DApp Developers of the BLS Upgrade](https://docs.midnight.network/img/blog/updates.jpg) April 25, 2025 ### [Impact on DApp Developers of the BLS Upgrade](https://docs.midnight.network/blog/dapp-developers-bls-upgrade) The Midnight testnet upgrade introduces BLS12-381, requiring developers to update the Lace wallet, proof server, and redeploy contracts with the latest Compact compiler. blsdappwallet ![Learning Web3 from the Ground Up - A Beginner's Journey into Blockchain](https://docs.midnight.network/img/blog/beginner.jpg) April 23, 2025 ### [Learning Web3 from the Ground Up - A Beginner's Journey into Blockchain](https://docs.midnight.network/blog/web3-intro) Journey into Web3, unpack key blockchain concepts like decentralization, consensus, and how they shape platforms like Midnight. introblockchainbeginnerweb3 ![How to Connect a DApp to the Lace Wallet?](https://docs.midnight.network/img/blog/wallets.jpg) April 16, 2025 ### [How to Connect a DApp to the Lace Wallet?](https://docs.midnight.network/blog/connect-dapp-lace-wallet) Connect your dApp to the Midnight network using the Lace wallet, with guidance on detection, authorization, and interaction using the MidnightJS API. dappwalletmidnight.js ![Simulating a division in Compact](https://docs.midnight.network/img/blog/ecosystem.jpg) April 16, 2025 ### [Simulating a division in Compact](https://docs.midnight.network/blog/compact-division) Compact makes on-chain logic efficient and secure—while division isn't yet supported, you can use vector subtraction or off-chain computation with witness verification. compact ![Midnight's proving system switched from Pluto Eris to BLS](https://docs.midnight.network/img/blog/zkp.jpg) April 15, 2025 ### [Midnight's proving system switched from Pluto Eris to BLS](https://docs.midnight.network/blog/zkp) Kachina employs non-interactive zero-knowledge proofs to allow users to prove valid state transitions without revealing private data. zkp ![Core Meeting Notes](https://docs.midnight.network/img/blog/meetings.jpg) April 10, 2025 ### [Core Meeting Notes](https://docs.midnight.network/blog/meeting) The Midnight testnet upgrade to Partner-Chains v1.5 requires SPO re-registration, adds BLS support, and is expected to roll out by May 2025. meeting ![From Hex to Bech32m - Midnight’s New Standard for Safer, Smarter Addresses](https://docs.midnight.network/img/blog/wallets.jpg) April 4, 2025 ### [From Hex to Bech32m - Midnight’s New Standard for Safer, Smarter Addresses](https://docs.midnight.network/blog/bech32m-hex) The Midnight ecosystem is evolving—one important change is the new default address format: Bech32m, which is a human-readable address format with error detection. walletmidnight.js ![Introducing the Midnight Indexer](https://docs.midnight.network/img/blog/indexer.jpg) April 3, 2025 ### [Introducing the Midnight Indexer](https://docs.midnight.network/blog/midnight-indexer) We’re excited to announce the release of the new Midnight Indexer — a modular, high-performance indexer that streamlines blockchain data flow from Midnight nodes to end-user apps indexer --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/archive#__docusaurus_skipToContent_fallback) ### 2026[​](https://docs.midnight.network/blog/archive#2026 "Direct link to 2026") * [January 2 - Architecture Overview DUST and Network Usage](https://docs.midnight.network/blog/dust-architecture) * [January 21 - Midnight MCP - AI-assisted development for Compact smart contracts](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development) * [January 27 - Testnet-02 Transition & The Roadmap to Mōhalu](https://docs.midnight.network/blog/testnet-02-transition) ### 2025[​](https://docs.midnight.network/blog/archive#2025 "Direct link to 2025") * [April 3 - Introducing the Midnight Indexer](https://docs.midnight.network/blog/midnight-indexer) * [April 4 - From Hex to Bech32m - Midnight’s New Standard for Safer, Smarter Addresses](https://docs.midnight.network/blog/bech32m-hex) * [April 10 - Core Meeting Notes](https://docs.midnight.network/blog/meeting) * [April 15 - Midnight's proving system switched from Pluto Eris to BLS](https://docs.midnight.network/blog/zkp) * [April 16 - Simulating a division in Compact](https://docs.midnight.network/blog/compact-division) * [April 16 - How to Connect a DApp to the Lace Wallet?](https://docs.midnight.network/blog/connect-dapp-lace-wallet) * [April 23 - Learning Web3 from the Ground Up - A Beginner's Journey into Blockchain](https://docs.midnight.network/blog/web3-intro) * [April 25 - Impact on DApp Developers of the BLS Upgrade](https://docs.midnight.network/blog/dapp-developers-bls-upgrade) * [May 7 - Learning Web3 from the Ground Up - Hash Functions & Digital Signatures](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures) * [May 20 - Midnight Testnet Upgrade Key Changes and Validator Reregistration Guide for Partner-Chains v1.5](https://docs.midnight.network/blog/midnight-testnet-upgrade-key-changes) * [May 20 - Learning Web3 from the Ground Up - Encryption & Practical Byzantine Fault Tolerance](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft) * [May 22 - Midnight Indexer Now Official — Scala Indexer Fully Deprecated](https://docs.midnight.network/blog/midnight-indexer-replaces-scala) * [May 30 - Learning Web3 from the Ground Up - A Quick History of Blockchain and Why Tokens Matter](https://docs.midnight.network/blog/web3-intro-history-and-tokens) * [June 6 - Learning Web3 from the Ground Up - Unpacking Merkle Trees and DAOs](https://docs.midnight.network/blog/web3-intro-merkle-trees-and-dao) * [June 13 - Learning Web3 from the Ground Up - Understanding Selective Disclosure](https://docs.midnight.network/blog/web3-intro-selective-disclosure) * [June 17 - Compact Deep Dive Part 1 - Top-level Contract Structure](https://docs.midnight.network/blog/compact) * [June 20 - Learning Web3 from the Ground Up - Smart Contracts and the Compact Language](https://docs.midnight.network/blog/web3-intro-smart-contracts-and-compact) * [June 25 - Compact Deep Dive Part 2 - Circuits and Witnesses](https://docs.midnight.network/blog/compact-2) * [July 4 - How to query the blockchain?](https://docs.midnight.network/blog/query-the-blockchain) * [July 10 - Learning Web3 from the Ground Up - What Are Zero-Knowledge Proofs (ZKPs)?](https://docs.midnight.network/blog/web3-intro-what-are-zkps) * [July 11 - Midnight’s First Step Toward Open Source – Say Hello to example-counter and example-bboard](https://docs.midnight.network/blog/open-sourcing-examples) * [July 25 - Learning Web3 from the Ground Up - Understanding Ethereum](https://docs.midnight.network/blog/web3-intro-understanding-ethereum) * [August 1 - Introducing the Compact Developer Tools](https://docs.midnight.network/blog/compact-developer-tools) * [August 13 - From Frustration to Framework: Building on Midnight](https://docs.midnight.network/blog/from-frustration-to-framework) * [August 20 - Introduction to the FungibleToken contract on Midnight](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin) * [August 20 - Compact Deep Dive Part 3 - The On-chain Runtime](https://docs.midnight.network/blog/compact-3) * [September 16 - Welcome to the Midnight Community Hub! ✨](https://docs.midnight.network/blog/community-hub) * [October 15 - Hacktoberfest Contributor Guide](https://docs.midnight.network/blog/hacktoberfest25) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/authors#__docusaurus_skipToContent_fallback) Authors ======= * [![DevRel](https://avatars.githubusercontent.com/u/196902235?s=200&v=4)](https://midnight.network/) [DevRel\ ------](https://midnight.network/) 3 Midnight DevRel team * [![Stevan Lohja](https://avatars.githubusercontent.com/u/10556209?v=4)](https://github.com/stevanlohja) [Stevan Lohja\ ------------](https://github.com/stevanlohja) 6 Developer Relations * [![Claude Barde](https://lh3.googleusercontent.com/a/ACg8ocKbtBX_dGSSVvMjktQLuKbD1IFRE_GKS5ND7pOvXW6fAYG0xEM=s576-c-no)](https://github.com/claudebarde) [Claude Barde\ ------------](https://github.com/claudebarde) 5 Developer Relations * [![Samantha Holstine](https://raw.githubusercontent.com/SamanthaHolstine/Working-With-Me/50766c0f0f448c1ab187df7444c1c8e2060c1186/Samantha-Holstine-Headshot.jpg)](https://github.com/samanthaholstine) [Samantha Holstine\ -----------------](https://github.com/samanthaholstine) 9 Senior Developer Relations Engineer * [![Kevin Millikin](https://avatars.githubusercontent.com/u/1971137?v=4)](https://github.com/kmillikin) [Kevin Millikin\ --------------](https://github.com/kmillikin) 3 Language Design Manager * [![Lauren Lee](https://raw.githubusercontent.com/laurenelee/how-i-work/refs/heads/main/lauren-headshot.jpg)](https://github.com/laurenelee) [Lauren Lee\ ----------](https://github.com/laurenelee) 1 Director of Developer Relations * [![Jay Albert](https://raw.githubusercontent.com/JAlbertCode/how-i-work/main/jay-albert-headshot.jpeg)](https://github.com/JAlbertCode) [Jay Albert\ ----------](https://github.com/JAlbertCode) 1 Developer Relations Engineer * ![Guest Author](https://avatars.githubusercontent.com/u/42442393) Guest Author ------------ 0 Contributor * ![Kaleab Abayneh](https://avatars.githubusercontent.com/u/92297934?v=4) Kaleab Abayneh -------------- 1 Guest Contributor * ![The Compact Team](https://avatars.githubusercontent.com/u/196902235?s=200&v=4) The Compact Team ---------------- 1 Compact Language Team * [![Idris Olubisi](https://avatars.githubusercontent.com/u/45847909?v=4t)](https://github.com/Olanetsoft) [Idris Olubisi\ -------------](https://github.com/Olanetsoft) 1 Developer Educator --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/bech32m-hex#__docusaurus_skipToContent_fallback) The Midnight ecosystem is evolving—one important change is the new default address format: Bech32m, which is a human-readable address format with error detection. Midnight now uses Bech32m as the default format for wallet addresses and public keys. This change improves readability, safety, and metadata clarity. Hex is deprecated but still temporarily supported for backward compatibility. Here's how to migrate your dApp. This post explores what that means, why it matters, and how to adapt your applications accordingly. Why Move Away From Hex?[​](https://docs.midnight.network/blog/bech32m-hex#why-move-away-from-hex "Direct link to Why Move Away From Hex?") ------------------------------------------------------------------------------------------------------------------------------------------- Hexadecimal (base-16) encoding has been the long-standing default for representing blockchain addresses due to its simplicity, broad tooling support, and compact format. It provides a direct, low-level view of binary data, making it easy for machines to parse and developers to integrate. However, despite its convenience, hex lacks critical features for modern blockchain applications. It provides no built-in error detection, making it prone to copy-paste mistakes, and it offers no contextual information—such as the network or address type—leading to ambiguity and increased risk in user-facing systems. Introducing Bech32m[​](https://docs.midnight.network/blog/bech32m-hex#introducing-bech32m "Direct link to Introducing Bech32m") -------------------------------------------------------------------------------------------------------------------------------- To address the limitations of hex encoding, the blockchain ecosystem introduced Bech32, a human-readable address format originally developed for Bitcoin SegWit. Bech32m is a refined version of this format, designed specifically to support new cryptographic constructions such as Taproot, and is now used in the Midnight ecosystem. Unlike hex, Bech32m encodes data using a base-32 character set that avoids visually ambiguous characters (like 0 vs O), and includes a strong checksum for detecting errors caused by typos or miscopies. A Bech32m string consists of three parts: a human-readable prefix (HRP) that identifies the network and address type (e.g., `mn_shield-addr_test` for Midnight testnet), a separator (1), and the encoded payload, which contains the actual data (e.g., coin public key and encryption public key). The result is a format that is not only safer and easier for users to handle, but also rich in metadata, making it far more suitable for decentralized applications where clarity and security are critical. Where Bech32m Is Used in Midnight The adoption of Bech32m isn’t limited to a single library — it’s a coordinated shift across the entire Midnight wallet ecosystem. With the release of Wallet SDK 4.0, Wallet API 4.0, DApp Connector API v2.0, and the latest version of the Midnight Lace Wallet, Bech32m is now the default encoding for wallet addresses and public keys. All core components have been updated to expose Bech32m-encoded fields by default while marking the legacy hex fields as deprecated. This ensures a smoother migration path for dApps and infrastructure that still rely on hexadecimal formats, without compromising on future-proofing or safety. Here’s how this looks in practice using the `DAppConnectorWalletState` interface: interface DAppConnectorWalletState { address: string; // ✅ Bech32m-encoded address /** @deprecated please use the `address` field instead. */ addressLegacy: string; coinPublicKey: string; // ✅ Bech32m-encoded coin public key /** @deprecated please use the `coinPublicKey` field instead. */ coinPublicKeyLegacy: string; encryptionPublicKey: string; // ✅ Bech32m-encoded encryption public key /** @deprecated please use the `encryptionPublicKey` field instead. */ encryptionPublicKeyLegacy: string;} Backward Compatibility and Migration[​](https://docs.midnight.network/blog/bech32m-hex#backward-compatibility-and-migration "Direct link to Backward Compatibility and Migration") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- While Bech32m is now the primary format, legacy hex fields are still accessible through the `Legacy` postfixed — but these are officially deprecated and will be removed in future versions. If your dApp or tooling still expects hex values, the SDK provides a utility package to help with conversion: import { decodeBech32mAddress } from '@midnight-ntwrk/wallet-sdk-address-format';const hexAddress = decodeBech32mAddress(address); This ensures you can continue to work with legacy systems while gradually migrating to the safer and more expressive Bech32m format. What You Should Change[​](https://docs.midnight.network/blog/bech32m-hex#what-you-should-change "Direct link to What You Should Change") ----------------------------------------------------------------------------------------------------------------------------------------- If you’re consuming wallet state via the DApp Connector API or Wallet SDK, make sure you: ✅ Switch from `addressLegacy → address` ✅ Switch from `coinPublicKeyLegacy → coinPublicKey` ✅ Switch from `encryptionPublicKeyLegacy → encryptionPublicKey` ✅ Use `@midnight-ntwrk/wallet-sdk-address-format` for conversion where needed Example: import { decodeBech32mAddress } from '@midnight-ntwrk/wallet-sdk-address-format';const hex = decodeBech32mAddress("mtst1q0yz7f64vu..."); TL;DR: Bech32m Is Now the Default[​](https://docs.midnight.network/blog/bech32m-hex#tldr-bech32m-is-now-the-default "Direct link to TL;DR: Bech32m Is Now the Default") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ✅ Bech32m is the default address/public key format across all wallet-related packages ❌ Hex format fields (addressLegacy, coinPublicKeyLegacy, etc.) are deprecated 🛠️ Migration is simple — just use the new fields and types already provided 🔁 Legacy hex values are still temporarily available for backward compatibility 📦 If you're building a dApp, make sure you're using `midnight-js@1.0.0`, which supports both Wallet SDK 4.0.0 and older versions. It also enables compatibility with Bech32m addresses. 💬 Have questions about the migration or need help updating your dApp? Drop us a note in [#dev-corner on Discord](https://discord.com/channels/1165826384975908924/1209887476290682910) . ✅ Migration Checklist * [ ] Use `address`, not `addressLegacy` * [ ] Use `coinPublicKey`, not `coinPublicKeyLegacy` * [ ] Use `encryptionPublicKey`, not `encryptionPublicKeyLegacy` * [ ] Use `@midnight-ntwrk/wallet-sdk-address-format` for any needed conversions * [Why Move Away From Hex?](https://docs.midnight.network/blog/bech32m-hex#why-move-away-from-hex) * [Introducing Bech32m](https://docs.midnight.network/blog/bech32m-hex#introducing-bech32m) * [Backward Compatibility and Migration](https://docs.midnight.network/blog/bech32m-hex#backward-compatibility-and-migration) * [What You Should Change](https://docs.midnight.network/blog/bech32m-hex#what-you-should-change) * [TL;DR: Bech32m Is Now the Default](https://docs.midnight.network/blog/bech32m-hex#tldr-bech32m-is-now-the-default) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/community-hub#__docusaurus_skipToContent_fallback) The Community Hub serves as a collaborative platform for gathering and managing community-driven contributions. Whether you're proposing new content, requesting features, reporting issues, or ideation for dApps, this repo is your entry point. We use GitHub's built-in features like issues, projects, and automations to ensure ideas are triaged efficiently and turned into actionable tasks. How to Contribute[​](https://docs.midnight.network/blog/community-hub#how-to-contribute "Direct link to How to Contribute") ---------------------------------------------------------------------------------------------------------------------------- Ready to jump in? It's as simple as [**creating an issue**](https://github.com/midnightntwrk/community-hub/issues/new/choose) . Our Workflow: From Idea to Reality[​](https://docs.midnight.network/blog/community-hub#our-workflow-from-idea-to-reality "Direct link to Our Workflow: From Idea to Reality") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Step 1: The Community Board (Triage)[​](https://docs.midnight.network/blog/community-hub#step-1-the-community-board-triage "Direct link to Step 1: The Community Board (Triage)") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- All new issues land here for initial review. This board is public, so everyone can see what's being proposed. * `New`: Your issue has been submitted and is awaiting review. * `In Triage`: The triage committee is actively reviewing your submission for validity, clarity, and priority. * `Needs` Discussion: The issue requires more feedback or clarification from the community or the original poster. * `Rejected`: The issue is out-of-scope or invalid. We will always provide a clear explanation. Once an issue is approved, it gets a triaged label and is automatically moved to the next stage. Step 2: The Grab n' Go Board (Development)[​](https://docs.midnight.network/blog/community-hub#step-2-the-grab-n-go-board-development "Direct link to Step 2: The Grab n' Go Board (Development)") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- This board contains approved, ready-to-work-on tasks. It's the community's backlog! * `Ready`: Triaged issues waiting for a contributor to pick them up. Look for labels like good-first-issue if you're new! * `In Progress`: A contributor has assigned themselves the issue and is actively working on it. * `Done`: The work is complete and the issue has been closed (this happens automatically when a linked PR is merged). Choosing the Right Issue Template[​](https://docs.midnight.network/blog/community-hub#choosing-the-right-issue-template "Direct link to Choosing the Right Issue Template") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- To help us categorize and review your ideas faster, please use the best template for your submission: * 📝 `Content Proposal`: Suggest new articles, tutorials, or educational resources to engage the community. * 💡 `Feature Request/Suggestion`: Propose new features or enhancements for our tools and processes. * 🐛 `Bug Report`: Report any defects, errors, or unexpected behavior. Please include clear reproduction steps! * 🌐 `dApp Proposal`: Share your vision for a new decentralized application, integration, or improvement. Selecting a template automatically applies the right labels, helping our automation keep things organized. Our goal is to foster a truly collaborative environment where the collective wisdom of our community helps us build more robust, community-driven solutions. Why Now? The Developer Relations Perspective[​](https://docs.midnight.network/blog/community-hub#why-now-the-developer-relations-perspective "Direct link to Why Now? The Developer Relations Perspective") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ You might be asking, "Why is the Developer Relations (DevRel) team launching this?" That's a great question, and it gets to the very core of our mission! At its heart, Developer Relations is about empowering developers. The Community Board is a natural, powerful extension of this mission. Here’s why it’s so crucial for us: 1. Direct Feedback Loop: Before, collecting structured feedback could be spread across multiple channels. The Community Board centralizes this, giving us a clear, prioritized view of what matters most to you. 2. Transparency and Prioritization: You'll be able to see what other developers are asking for, upvote ideas you support, and even watch as issues move from "Under Review" to "Planned" to "Shipped." This transparency helps you understand our roadmap and how your contributions fit in. 3. Community-Driven Development: We genuinely believe that the best products are built in collaboration with their users. The board allows us to tap into the collective intelligence of our community, surfacing the most impactful ideas and validating them with real-world needs. 4. Building Stronger Relationships: By giving you a clear, actionable way to contribute, we hope to build an even stronger, more engaged community where everyone feels invested in our shared success. * [How to Contribute](https://docs.midnight.network/blog/community-hub#how-to-contribute) * [Our Workflow: From Idea to Reality](https://docs.midnight.network/blog/community-hub#our-workflow-from-idea-to-reality) * [Step 1: The Community Board (Triage)](https://docs.midnight.network/blog/community-hub#step-1-the-community-board-triage) * [Step 2: The Grab n' Go Board (Development)](https://docs.midnight.network/blog/community-hub#step-2-the-grab-n-go-board-development) * [Choosing the Right Issue Template](https://docs.midnight.network/blog/community-hub#choosing-the-right-issue-template) * [Why Now? The Developer Relations Perspective](https://docs.midnight.network/blog/community-hub#why-now-the-developer-relations-perspective) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/compact-developer-tools#__docusaurus_skipToContent_fallback) We are proud to announce the launch of the Compact developer tools! Today we are launching `compact`, a command-line tool that is used for installing the Compact toolchain (e.g., the compiler), keeping it up to date, and invoking the toolchain tools themselves. The developer tools are now the "official" supported way to install and update the toolchain and to invoke other Compact tooling such as the Compact compiler. To avoid confusion, we will make a careful distinction between the "Compact toolchain" and the "Compact developer tools". The toolchain contains the compiler and will eventually contain other tooling that is specific to a particular version of the Compact language. The developer tools include the updater tools and will eventually support other tools that work consistently across different versions of the language. In the initial release, the Compact developer tools are primarily used to manage the installation of a Compact toolchain, but they will support additional tooling in the future. There is no new release of the Compact toolchain yet, but you can already start using the new developer tools to install and invoke the current version of the compiler. The Old Toolchain Installation Method ===================================== Before this new release, installing the Compact toolchain was a manual and tedious process: 1. Developers had to download a ZIP file for a specific compiler version and platform architecture 2. They then had to extract it to a directory included in their PATH 3. On macOS, they would have to give permission to run the two different binaries (the compiler and the ZK-key generator). This process would have to be repeated each time there was a new Compact toolchain release. Keeping multiple versions installed at once was also cumbersome and hard to manage. The New Toolchain Installation Method ===================================== The new way to install the Compact toolchain starts with a one-time installation of the `compact` command-line tool. Once installed, the developer tools can update themselves automatically. To install, run the following command: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/midnightntwrk/compact/releases/latest/download/compact-installer.sh | sh This command will download and run a shell script. It will instruct you how to add the binary directory it uses to your `PATH` environment variable. Once you've done this, the `compact` command line tool is available to use. This tool has a number of useful subcommands that can be invoked. For instance, to **update** the toolchain to the latest version, you will run the command: compact update The output will look something like this (on an Apple Silicon macOS machine, for instance): compact: aarch64-darwin -- 0.24.0 -- installedcompact: aarch64-darwin -- 0.24.0 -- default. This subcommand will switch to the latest version of the toolchain available for your architecture. As of today, this is version 0.24.0 which is reported by the tool. The `compact` tool will download the toolchain artifacts if necessary (you will see a progress meter while it downloads). If you have already downloaded the artifacts, the tool will simply switch the default version to be the latest version. When there is a new Compact toolchain release, such as 0.25.0, you will use the same subcommand as above to update to that new version. You can **check** if there is a new version available using the `check` subcommand like this: compact check If there is a new version available, you will see something like: compact: aarch64-darwin -- Update Available -- 0.24.0compact: Latest version available: 0.25.0. This is reporting that you are on version 0.24.0 and that 0.25.0 is available. note You will not actually see this output until there is a new version available. Instead, you will see that you are on the latest version: compact: aarch64-darwin -- Up to date -- 0.24.0 Switching Toolchain Versions ============================ You can also "update" to any other available toolchain, including previous ones. You can **list** all the versions available with the command: compact list The output will look something like this: compact: available versions→ 0.24.0 - x86_macos, aarch64_macos, x86_linux 0.23.0 - aarch64_macos, x86_linux 0.22.0 - x86_macos, x86_linux This is showing the different versions, and which platforms they are available for. The arrow indicates the current default version, 0.24.0 in this case. This default is whichever you have currently set as the default (via `compact update`). You can pass the flag `--installed` (or `-i`) to `compact list` to see the versions that are actually downloaded locally: compact list --installed The output will probably look like this: compact: installed versions→ 0.24.0 The update subcommand can be used with a specific version to switch to that version. For example: $ compact update 0.23.0compact: aarch64-darwin -- 0.23.0 -- installedcompact: aarch64-darwin -- 0.23.0 -- default.$ compact list --installedcompact: installed versions 0.24.0→ 0.23.0 note If you are on an Intel x86 macOS computer, you will not be able to update to version 0.23.0 because it was not available for that architecture. You can try the same commands above with version 0.22.0 instead. You can now switch back to the latest version with `compact update` or `compact update 0.24.0`. This time, nothing will be downloaded because that version is already installed locally. Invoking the Compiler ===================== In addition to keeping the toolchain updated, the `compact` tool will also be the official supported way to invoke all the toolchain tools themselves. For the time being, the only such tool is the compiler, but we will be building out more tools in the future. The compiler can be invoked with the `compile` subcommand: compact compile This will use the current default version of the toolchain (the one indicated by the arrow in `compact list`). note If you are using macOS, you no longer have to explicitly give permission to run the compiler and ZK-key generation binaries. You can override the default to use a specific (already installed) version by including the version number after a plus (`+`) sign like: compact compile +0.23.0 Looking ahead, we plan to remove the `compactc` executable. Going forward, `compact compile` will become the standard way to invoke the Compact compiler. Built-in Help ============= The `compact` tool and all of its subcommands have detailed help pages provided by the tools themselves. You can see these in two different ways, either using the `help` subcommand or by using the `--help` flag. For the Compact tool itself, you can invoke `compact help` or `compact --help` and you will see the exact same help page. This page shows all the subcommands (`compile` is currently listed at the bottom of the page). It also shows common command line options. For a specific subcommand, such as `update`, you can see detailed help either via `compact help update` or `compact update --help`. You can use the help pages to find all the subcommands and their options. note Because of the way that the tools are currently implemented, you cannot get compiler help via `compact help compile`. Instead, you will have to use `compact compile --help`. Versions ======== The developer tools are separately versioned from the toolchain (i.e., compiler) itself. This is because the tools are capable of managing multiple versions of the toolchain. You can see the version of the developer tools with `compact --version`. That should currently be 0.1.0. You can also see the version of subcommands like `compact update --version`. Currently, built-in subcommands (that is, ones implemented by the developer tools, not the toolchain) all have the same version as the developer tools. You can find the version of the toolchain with `compact list -i` or `compact check` (though the latter will make an Internet check to see if there is a new version). You can also find it from the compiler via `compact compile --version`. This should currently be 0.24.0 if you are on the latest version. As before, the Compact language itself is versioned separately from the toolchain. You can find this from the compiler via `compact compile --language-version`. Keeping the Developer Tools Up to Date ====================================== Once they are installed, the developer tools are capable of keeping themselves up to date. You can check for updates with `compact self check`, and you can update to the latest version of the tool with `compact self update`. We have not provided a way to go back to a previous version of the developer tools themselves, because you generally won't need to do that. You don't necessarily have to update the developer tools themselves all the time, either. You **will** however want to update the developer tools themselves when we make more developer tools available. For example, a future release will include a Compact formatter available via a `compact format` subcommand. You will need to update the developer tools themselves to get access to the formatter tool. We will always announce such updates in the release notes for both the toolchain and the developer tools. How it Works ============ The tool is currently a simple one, but its architecture is flexible and it will eventually support many more different developer tools. If you look at the help pages, you will see that the tools take a `--directory` command-line flag which tells them where to find the toolchain. By default this will be the directory `.compact` in your home directory. If you look in that directory, you will see two subdirectories: `bin` and `versions`. The `versions` subdirectory contains separate subdirectories for each installed version, which contain the toolchain artifacts for that version. The `bin` subdirectory represents the default version, which is just a symbolic link to one of the installed versions. The command line tool is capable of checking for updates and downloading and unzipping toolchain artifacts if necessary. Switching between installed versions just changes the `bin` symbolic link to point to a different installed toolchain. Invoking the toolchain itself just invokes the corresponding default executables in the `bin` directory, or for a specific version if necessary. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/connect-dapp-lace-wallet#__docusaurus_skipToContent_fallback) Connect your dApp to the Midnight network using the Lace wallet, with guidance on detection, authorization, and interaction using the MidnightJS API. > Note that this blog post follows MidnightJS version 1.0.0; the steps described here may change in future versions. As the Midnight blockchain, a network focused on data protection gains momentum, developers building decentralized applications (dApps) need secure and user-friendly ways to connect users to the network to interact with it. The [Lace wallet for Midnight](https://docs.midnight.network/relnotes/lace) , a special edition of the Lace wallet for Cardano developed by the Midnight team and created to work on Midnight, makes this process seamless by injecting a secure interface directly into the browser window. > Note: the use of a special wallet to interact with Midnight is only a temporary solution. In the future, Midnight will be integrated directly into the Lace wallet. In this post, we’ll walk through the exact steps required to detect, connect, and interact with the Lace wallet, unlocking the Midnight network for your dApp. 🧭 Step 1: Detect the Lace Wallet[​](https://docs.midnight.network/blog/connect-dapp-lace-wallet#-step-1-detect-the-lace-wallet "Direct link to 🧭 Step 1: Detect the Lace Wallet") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ The Lace wallet injects an instance of the [DappConnectorApi](https://docs.midnight.network/develop/reference/midnight-api/dapp-connector/) into the global `window` object under `window.midnight.mnLace`. The Dapp Connector API gives you access to various properties and methods that you can use to build interactions between the dapp and the wallet, as well as to read information from the wallet (like the user's address). The very first step is to check for its existence: if (window.midnight && window.midnight.mnLace) { const mnLace = window.midnight.mnLace; // Proceed with next steps} If this object is not present, you can guide the user to install the wallet by linking to the official download page: [https://docs.midnight.network/relnotes/lace](https://docs.midnight.network/relnotes/lace) 🔒 Step 2: Check if the Wallet is Authorized[​](https://docs.midnight.network/blog/connect-dapp-lace-wallet#-step-2-check-if-the-wallet-is-authorized "Direct link to 🔒 Step 2: Check if the Wallet is Authorized") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Before interacting with the wallet, you need to check whether the user has already granted your dApp permission to access their wallet: const isEnabled = await mnLace.isEnabled(); If isEnabled is `true`, your dApp is already authorized and can proceed to access wallet features. If not, you’ll need to explicitly request access (next step). ✅ Step 3: Request Access (Enable)[​](https://docs.midnight.network/blog/connect-dapp-lace-wallet#-step-3-request-access-enable "Direct link to ✅ Step 3: Request Access (Enable)") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- If the user hasn’t yet authorized the dApp, prompt them to connect by calling: const walletApi = await mnLace.enable(); This will trigger a UI popup from the Lace wallet asking the user to approve the connection. Once approved, they gain access to a full wallet API interface. > Note: it is generally consider best practice to have the user interact with the interface to approve the wallet instead of having a popup window opens when the app is loading. 🧾 Step 4: Fetch the User’s Address[​](https://docs.midnight.network/blog/connect-dapp-lace-wallet#-step-4-fetch-the-users-address "Direct link to 🧾 Step 4: Fetch the User’s Address") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Once connected, you can query the wallet for user details using the `state()` method provided by the walletApi: const state = await walletApi.state();const userAddress = state.address; This gives you the user's Midnight network address, which you can use for different things, for example, to display in your UI. 🔧 Step 5: Get Service Configuration (Optional)[​](https://docs.midnight.network/blog/connect-dapp-lace-wallet#-step-5-get-service-configuration-optional "Direct link to 🔧 Step 5: Get Service Configuration (Optional)") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- The wallet also exposes additional configuration metadata, such as [service endpoints](https://docs.midnight.network/develop/reference/midnight-api/dapp-connector/interfaces/ServiceUriConfig) . You can fetch these like so: const config = await mnLace.serviceUriConfig(); It will return an object with the URL for the node, the indexer and the proof server the wallet is currently connected to. This can be useful if your dApp integrates with specific Midnight services or APIs that depend on the current environment, for example, if you need the address of the proof server to prove transactions. 💡 Example Flow[​](https://docs.midnight.network/blog/connect-dapp-lace-wallet#-example-flow "Direct link to 💡 Example Flow") ------------------------------------------------------------------------------------------------------------------------------- Here’s a simplified flow of what your connection logic might look like in plain JavaScript: async function connectToMidnight() { if (window.midnight && window.midnight.mnLace) { const mnLace = window.midnight.mnLace; const walletApi = await mnLace.isEnabled(); const state = await walletApi.state(); console.log("User address:", state.address); const config = await mnLace.serviceUriConfig(); console.log("Service config:", config); } else { alert("Please install the Lace wallet to connect to Midnight."); }} Here’s a quick checklist of what the above code snippet does to connect to Midnight via the Lace wallet: 1. Detect the `window.midnight.mnLace` object. 2. Check authorization with `isEnabled()`. 3. Request access using `enable()` if not already authorized. 4. Retrieve user info like the Midnight address using state(). 5. Optionally fetch service config for advanced usage. With these simple but secure steps, your dApp will be fully connected to the Midnight blockchain using the Lace wallet, giving users a seamless and private experience right in their browser. 🧠 Conclusion[​](https://docs.midnight.network/blog/connect-dapp-lace-wallet#-conclusion "Direct link to 🧠 Conclusion") ------------------------------------------------------------------------------------------------------------------------- Integrating the Lace wallet into your dApp for the Midnight network is a straightforward process that prioritizes both security and user experience. By following the steps outlined—detecting the wallet’s presence, verifying authorization, requesting access, and retrieving user data—you can seamlessly connect users to the Midnight blockchain while maintaining privacy and reliability. The temporary reliance on a dedicated Lace wallet edition ensures compatibility today, but developers should remain aware of future updates that may simplify this process further. As Midnight evolves, adhering to these guidelines will keep your dApp aligned with the network’s standards, empowering users to interact securely with your application. Always reference [the official documentation](https://docs.midnight.network/) for the latest API changes and best practices to ensure your implementation stays up-to-date. * [🧭 Step 1: Detect the Lace Wallet](https://docs.midnight.network/blog/connect-dapp-lace-wallet#-step-1-detect-the-lace-wallet) * [🔒 Step 2: Check if the Wallet is Authorized](https://docs.midnight.network/blog/connect-dapp-lace-wallet#-step-2-check-if-the-wallet-is-authorized) * [✅ Step 3: Request Access (Enable)](https://docs.midnight.network/blog/connect-dapp-lace-wallet#-step-3-request-access-enable) * [🧾 Step 4: Fetch the User’s Address](https://docs.midnight.network/blog/connect-dapp-lace-wallet#-step-4-fetch-the-users-address) * [🔧 Step 5: Get Service Configuration (Optional)](https://docs.midnight.network/blog/connect-dapp-lace-wallet#-step-5-get-service-configuration-optional) * [💡 Example Flow](https://docs.midnight.network/blog/connect-dapp-lace-wallet#-example-flow) * [🧠 Conclusion](https://docs.midnight.network/blog/connect-dapp-lace-wallet#-conclusion) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/compact-division#__docusaurus_skipToContent_fallback) Compact makes on-chain logic efficient and secure—while division isn't yet supported, you can use vector subtraction or off-chain computation with witness verification. As of version 0.22.0 of the [Compact](https://docs.midnight.network/develop/reference/compact/) compiler, division is not yet a part of the arithmetic operations available to the developers. However, two solutions can be considered to either implement a division or verify the result of a division. The vector solution[​](https://docs.midnight.network/blog/compact-division#the-vector-solution "Direct link to The vector solution") ------------------------------------------------------------------------------------------------------------------------------------- > ⚠️ Warning: this solution is presented for demonstration purposes. It is recommended to use the witness solution in your smart contracts. The first solution is to use a vector, subtraction, and the `fold` expression. Here is an example of a module that simulates a division: module DivOne { export struct DivResult { quotient: Uint<128>; remainder: Uint<128>; } // division by subtraction export pure circuit div( dividend: Uint<128>, divisor: Uint<128>, divLoop: Vector<1000, Uint<1>> ): DivResult { assert(divisor != 0, "division by zero"); const [remainder, quotient]: [Uint<128>, Uint<128>] = fold((acc, _) => { const [remaining, counter] = acc; if (remaining < divisor) { return acc; } else { return [(remaining - divisor), counter + 1 as Uint<128>]; } }, [dividend, 0 as Uint<128>], divLoop); return DivResult { quotient: quotient, remainder: remainder }; }} The `DivOne` module implements division entirely within the circuit using a method based on repeated subtraction. It defines a `div` circuit that takes a dividend, divisor, and a fixed-length vector called `divLoop` as inputs. This vector acts as a loop control structure, allowing the fold function to iterate up to 1000 times without unbounded execution. > Note: the `divLoop` doesn't prevent unbounded iteration as unbounded iteration is impossible in Compact. In each iteration, the circuit subtracts the divisor from the remaining dividend and increments the quotient by one, stopping once the remainder is less than the divisor (although the iteration keeps going on). To prevent division by zero, an assertion is included before the loop. The result is returned as a struct of type `DivResult` containing both quotient and remainder. This approach is deterministic and self-contained but limited by the loop length, making it suitable only for small enough quotients. The witness solution[​](https://docs.midnight.network/blog/compact-division#the-witness-solution "Direct link to The witness solution") ---------------------------------------------------------------------------------------------------------------------------------------- The second solution is to receive the result of a division made off-chain and verify on-chain that the result is correct, as illustrated in the following module: module DivTwo { export witness divMod(x: Uint<128>, y: Uint<128>): [Uint<128>, Uint<128>]; export circuit checkDiv(dividend: Uint<128>, divisor: Uint<128>): Boolean { const [quotient, remainder] = divMod(dividend, divisor); assert(remainder < divisor, "remainder error"); assert((quotient * divisor) + remainder == dividend, "division error"); return true; }} The `DivTwo` module takes a different approach by offloading the actual division computation to an external witness function called `divMod`. The witness is expected to return the quotient and remainder for given inputs, but the circuit does not compute them itself. Instead, the `checkDiv` circuit validates the correctness of the witness-provided values using two key assertions: that the remainder is less than the divisor, and that the product of the quotient and divisor plus the remainder equals the original dividend. This method is preferable and more efficient than `DivOne` because it avoids iteration, but it relies on external computation and correct witness values. It is particularly useful when division can be precomputed off-chain. Together, these two approaches showcase the trade-offs involved in implementing division in Compact: the `vector` solution offers a fully in-contract solution that guarantees correctness through computation, while the `witness` solution leverages external computation with in-contract verification for greater efficiency. The choice between them depends on the specific performance and trust model requirements of the application. * [The vector solution](https://docs.midnight.network/blog/compact-division#the-vector-solution) * [The witness solution](https://docs.midnight.network/blog/compact-division#the-witness-solution) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/dust-architecture#__docusaurus_skipToContent_fallback) To understand this system, it helps to use an analogy. * **Night** is like a **Solar Panel**. It is a valuable asset you hold. * **Dust** is like **Electricity**. It represents the computational throughput or gas generated by the Solar Panel (Night). * **Usage**. You consume the Electricity (DUST) as gas to power your operations on the network. Unlike standard cryptocurrencies where you have a static balance (e.g., "I have 5 coins"), your Dust balance changes dynamically based on time and the status of your Night tokens. Dust and network usage[​](https://docs.midnight.network/blog/dust-architecture#dust-and-network-usage "Direct link to Dust and network usage") ----------------------------------------------------------------------------------------------------------------------------------------------- Dust operates similarly to, but separately from, [Zswap](https://github.com/midnightntwrk/midnight-ledger/blob/main/spec/zswap.md) . Dust operates as the resource credit system for Midnight. It function * **Shielded and Non-transferable:** Dust is a shielded capacity resource _only_ for gas. It cannot be transferred between users. * **Dynamic Capacity:** The available gas in a Dust UTXO is dynamically computed and derived from an associated Night UTXO. * **Growth & Decay:** The computed value grows over time to a maximum based on its Night UTXO, and decays to zero after its Night UTXO is spent. * **Non-Persistent:** The system may redistribute it on hardforks. (Note: The Midnight protocol reserves the right to modify Dust allocation rules, e.g., for garbage collection). Design overview[​](https://docs.midnight.network/blog/dust-architecture#design-overview "Direct link to Design overview") -------------------------------------------------------------------------------------------------------------------------- Similar to Zswap, Dust is built on hashes and the commitment/nullifier paradigm. Each Dust UTXO has a **commitment** inserted into an append-only Merkle tree upon creation, and a **nullifier** inserted into a nullifier set upon spending. A Dust "spend" is a 1-to-1 "transfer" (Self-Spend): 1. **Input:** 1 Dust UTXO (nullifier). 2. **Output:** 1 Dust UTXO (commitment). 3. **Fee:** A public declaration of fees paid. It includes a zero-knowledge proof that: 1. The input is valid and exists in the Merkle tree. 2. The output value equals the _updated_ input value minus the gas consumed. 3. The output nullifier is correct, and the owner remains the same. ### Lifecycle: NIGHT generates DUST[​](https://docs.midnight.network/blog/dust-architecture#lifecycle-night-generates-dust "Direct link to Lifecycle: NIGHT generates DUST") Conceptually, Dust is generated over time by held _Night_ UTXOs. As long as a backing Night UTXO remains unspent, the associated Dust UTXO generates value up to a cap ($\\rho$). Once the backing Night is spent, the Dust UTXO "decays" to zero. The following diagram illustrates this lifecycle: The rate of generation depends on the amount of night held ($N$), the ratio of the Dust cap to Night held ($\\rho$), and "time to cap" ($\\Delta$). **Spending Rules:** * Dust may be spent multiple times; a new UTXO is always created, even if its value is zero. * Spending during decay is permitted and does not change the decay rate. * Once the backing Night is spent, Dust immediately starts to decay, even if it was still in the generation phase. * If only a portion of backing Night is spent, the change creates a new Night UTXO (starting fresh Dust generation), while the old Dust UTXO decays. **Implementation Note:** In practice, value is not processed continuously. It is calculated **at the time of spend** using metadata ("generation info"): 1. Creation time of the Dust UTXO. 2. Creation time of the backing Night UTXO. 3. Deletion time of the backing Night UTXO. Since Dust and Night use different keys, a **Registration Table** links Night public keys to Dust public keys. A new Dust UTXO is created if and only if a Night UTXO is created _and_ its key has a table entry. **The Grace Period:** Because Dust usage is shielded, the value is computed for the time of _transaction creation_. To account for network delays, the protocol defines a **Dust Grace Period** (for example, 3 hours). A transaction is accepted if its timestamp is within this window relative to the block time. Preliminaries[​](https://docs.midnight.network/blog/dust-architecture#preliminaries "Direct link to Preliminaries") -------------------------------------------------------------------------------------------------------------------- DUST uses ZK-friendly hashes. type DustSecretKey = Fr;type DustPublicKey = field::Hash; Dust UTXOs have owners, values, and **nonces**. Nonces evolve deterministically to enable wallet recovery. * **First Dust UTXO:** Nonce derived from the originating Night UTXO intent hash. * **Subsequent Dust UTXOs:** Nonce derived from the previous sequence number and owner's secret key. struct DustOutput { initial_value: u128, // Specks at creation owner: DustPublicKey, nonce: field::Hash<(InitialNonce, u32, Fr)>, seq: u32, ctime: Timestamp,} State components include the commitment tree, nullifier set, and root history: struct DustUtxoState { commitments: MerkleTree, commitments_first_free: usize, nullifiers: Set, root_history: TimeFilterMap,} Initial DUST parameters[​](https://docs.midnight.network/blog/dust-architecture#initial-dust-parameters "Direct link to Initial DUST parameters") -------------------------------------------------------------------------------------------------------------------------------------------------- * **Night Unit:** `Star (1 Night = 10^6 Stars)` * **Dust Unit:** `Speck (1 Dust = 10^15 Specks)` const INITIAL_DUST_PARAMETERS: DustParameters = { night_dust_ratio = 5_000_000_000; // 5 DUST per NIGHT generation_decay_rate = 8_267; // ~1 week generation time dust_grace_period = Duration::from_hours(3),}; Dust actions[​](https://docs.midnight.network/blog/dust-architecture#dust-actions "Direct link to Dust actions") ----------------------------------------------------------------------------------------------------------------- Users influence Dust state via **Intents**. struct DustActions { spends: Vec>, registrations: Vec, ctime: Timestamp,} ### Registrations and fees[​](https://docs.midnight.network/blog/dust-architecture#registrations-and-fees "Direct link to Registrations and fees") `DustRegistration` links a Night key to a Dust key. * Registrations happen sequentially. * If a registration transaction uses Night inputs that _were not yet generating Dust_ (meaning that they had no previous registration), the system can "backdate" the registration to use the Dust those inputs _would have generated_ to pay for the gas. Generating DUST[​](https://docs.midnight.network/blog/dust-architecture#generating-dust "Direct link to Generating DUST") -------------------------------------------------------------------------------------------------------------------------- Night inputs/outputs trigger updates to a **Dust Generation Tree**. * **DustGenerationInfo:** Stores the amount of Night, the owner, and the `dtime` (deletion time). * **Address Map:** Links Night Addresses -> Dust Addresses. struct DustGenerationInfo { value: u128, owner: DustPublicKey, nonce: InitialNonce, dtime: Timestamp, // Set to MAX if Night is unspent} Dust value and spends[​](https://docs.midnight.network/blog/dust-architecture#dust-value-and-spends "Direct link to Dust value and spends") -------------------------------------------------------------------------------------------------------------------------------------------- The value of a Dust UTXO is calculated based on four linear time segments: 1. **Generating:** From creation to Capacity (or Night spend). 2. **Constant (Max):** At capacity until Night spend. 3. **Decaying:** From Night spend until value hits zero. 4. **Constant (Zero):** Forever after. ### The Spend transaction[​](https://docs.midnight.network/blog/dust-architecture#the-spend-transaction "Direct link to The Spend transaction") A `DustSpend` consumes a UTXO and creates a new one with updated value minus fees. The validation logic (`dust_spend_valid`) ensures: * `commitment_merkle_tree` contains the input. * `dust_spend.old_nullifier` matches the derived nullifier. * `updated_value` covers the fee. * `new_commitment` is correctly formed. Wallet recovery[​](https://docs.midnight.network/blog/dust-architecture#wallet-recovery "Direct link to Wallet recovery") -------------------------------------------------------------------------------------------------------------------------- Wallets recover funds by: 1. Identifying owned Night UTXOs (the start of the chain). 2. Linearly searching for commitments corresponding to sequence numbers ($0, 1, 2...$). 3. **Privacy:** Wallets should query commitments using bit-prefixes (stochastic filtering) rather than exact lookups to preserve privacy against the indexing service. The implementation[​](https://docs.midnight.network/blog/dust-architecture#the-implementation "Direct link to The implementation") ----------------------------------------------------------------------------------------------------------------------------------- ### DUST Generation from Cardano NIGHT Token — Full Process[​](https://docs.midnight.network/blog/dust-architecture#dust-generation-from-cardano-night-token--full-process "Direct link to DUST Generation from Cardano NIGHT Token — Full Process") The generation of **DUST** from the Cardano **NIGHT** token (cNIGHT) is a cross-chain process managed by the **Native Token Observation Pallet** (`pallet_cnight_observation`) on the Midnight partner chain. ### Summary of the full flow[​](https://docs.midnight.network/blog/dust-architecture#summary-of-the-full-flow "Direct link to Summary of the full flow") 1/ User registers their Cardano reward address + DUST public key on Cardano. 2/ Any time a cNIGHT UTXO is created (received) or spent (sent) by that address, the event is broadcast. 3–4/ The Midnight pallet validates that exactly one valid registration exists and observes the cNIGHT activity. 5–6/ It determines whether it’s a receive (creation) or send (destruction) of cNIGHT → generates corresponding DUST creation or destruction event. 7–9/ All events in a block are batched, wrapped into a single system transaction via LedgerApi, and executed on the Midnight ledger. → Final result: DUST supply and UTXOs are updated 1:1 with cNIGHT movements on Cardano. * * * 👉 **Now that you have an overview of DUST, checkout the [DUST spec](https://github.com/midnightntwrk/midnight-ledger/blob/main/spec/dust.md) on Github!** 👉 **Get involved in [the code](https://raw.githubusercontent.com/midnightntwrk/midnight-node/refs/heads/main/primitives/mainchain-follower/src/data_source/cnight_observation.rs) on Github!** * [Dust and network usage](https://docs.midnight.network/blog/dust-architecture#dust-and-network-usage) * [Design overview](https://docs.midnight.network/blog/dust-architecture#design-overview) * [Lifecycle: NIGHT generates DUST](https://docs.midnight.network/blog/dust-architecture#lifecycle-night-generates-dust) * [Preliminaries](https://docs.midnight.network/blog/dust-architecture#preliminaries) * [Initial DUST parameters](https://docs.midnight.network/blog/dust-architecture#initial-dust-parameters) * [Dust actions](https://docs.midnight.network/blog/dust-architecture#dust-actions) * [Registrations and fees](https://docs.midnight.network/blog/dust-architecture#registrations-and-fees) * [Generating DUST](https://docs.midnight.network/blog/dust-architecture#generating-dust) * [Dust value and spends](https://docs.midnight.network/blog/dust-architecture#dust-value-and-spends) * [The Spend transaction](https://docs.midnight.network/blog/dust-architecture#the-spend-transaction) * [Wallet recovery](https://docs.midnight.network/blog/dust-architecture#wallet-recovery) * [The implementation](https://docs.midnight.network/blog/dust-architecture#the-implementation) * [DUST Generation from Cardano NIGHT Token — Full Process](https://docs.midnight.network/blog/dust-architecture#dust-generation-from-cardano-night-token--full-process) * [Summary of the full flow](https://docs.midnight.network/blog/dust-architecture#summary-of-the-full-flow) --- # How-To | Midnight Docs [Skip to main content](https://docs.midnight.network/develop/how-to#__docusaurus_skipToContent_fallback) Filters ------- SearchTags Hold Ctrl/Cmd to select multiple Reset Filters All How-To Guides (A–Z) ======================= No matching guides. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/compact-2#__docusaurus_skipToContent_fallback) This blog post is part of the Compact Deep Dive series, which explores how Compact contracts work on the Midnight network. Each article focuses on a different technical topic and can be read on its own, but together they provide a fuller picture of how Compact functions in practice. [Compact Deep Dive - Part 1](https://docs.midnight.network/blog/compact) looked at the TypeScript API of the Compact compiler-generated contract implementation. If you haven’t read it yet, we encourage you to start there. This article looks at how circuits and witnesses are actually implemented in JavaScript code generated by the Compact compiler. In part 1, we used the Bulletin Board tutorial contract as an example. We compiled it with the Compact compiler and started looking at the files generated by the compiler. We used Compact toolchain version 0.24.0. Recall the caveat from part 1 that the generated code is an implementation detail of the platform. We freely change it, so it can be different when different versions of the compiler are used. Circuits[​](https://docs.midnight.network/blog/compact-2#circuits "Direct link to Circuits") --------------------------------------------------------------------------------------------- We looked at the bulletin board contract’s `post` circuit. The compiler generated a TypeScript declaration file that includes a declaration for the circuit: post(context: __compactRuntime.CircuitContext, newMessage_0: string): __compactRuntime.CircuitResults; Recall that the types [`CircuitContext`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/interfaces/CircuitContext) and [`CircuitResults`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/interfaces/CircuitResults) came from the Compact runtime used by the compiler. In the file `index.cjs` the compiler has generated a JavaScript implementation of this circuit. You will find this in the `contract` subdirectory of the compiler output directory you gave on the `compact` command line when compiling the contract’s Compact source code. The implementation is installed as a property on the `circuits` object of the contract in class `Contract`’s constructor. The entirety of the code is here (we will drill down into this in the rest of this section): this.circuits = { post: (...args_1) => { if (args_1.length !== 2) throw new __compactRuntime.CompactError(`post: expected 2 arguments (as invoked from Typescript), received ${args_1.length}`); const contextOrig_0 = args_1[0]; const newMessage_0 = args_1[1]; if (!(typeof(contextOrig_0) === 'object' && contextOrig_0.originalState != undefined && contextOrig_0.transactionContext != undefined)) __compactRuntime.type_error('post', 'argument 1 (as invoked from Typescript)', 'bboard.compact line 26 char 1', 'CircuitContext', contextOrig_0) const context = { ...contextOrig_0 }; const partialProofData = { input: { value: _descriptor_4.toValue(newMessage_0), alignment: _descriptor_4.alignment() }, output: undefined, publicTranscript: [], privateTranscriptOutputs: [] }; const result_0 = this.#_post_0(context, partialProofData, newMessage_0); partialProofData.output = { value: [], alignment: [] }; return { result: result_0, context: context, proofData: partialProofData }; }, ### Runtime Type Checks[​](https://docs.midnight.network/blog/compact-2#runtime-type-checks "Direct link to Runtime Type Checks") The first part of this implementation is so-called “boilerplate” code that is generated by the compiler for every circuit. Every circuit has essentially the same code, differing only slightly depending on the number and names of the arguments, file names, and source code positions. Let’s focus on that code first: if (args_1.length !== 2) throw new __compactRuntime.CompactError(`post: expected 2 arguments (as invoked from Typescript), received ${args_1.length}`);const contextOrig_0 = args_1[0];const newMessage_0 = args_1[1];if (!(typeof(contextOrig_0) === 'object' && contextOrig_0.originalState != undefined && contextOrig_0.transactionContext != undefined)) __compactRuntime.type_error('post', 'argument 1 (as invoked from Typescript)', 'bboard.compact line 26 char 1', 'CircuitContext', contextOrig_0)const context = { ...contextOrig_0 }; There are some runtime type checks here. First, we check that the actual number of arguments passed matches the expected number. In this case, that’s two (the second one is the circuit’s parameter `newMessage` and the first one is the `CircuitContext` parameter inserted by the compiler). If not, we’ll throw an exception. This is one way that Compact differs from TypeScript. The JavaScript code produced by the TypeScript compiler does not check argument counts or types at run time because it assumes that the calling code has also passed the TypeScript type checker. Because the correctness of your contracts will depend on it, we do not assume that. Instead, the generated JavaScript code will perform the appropriate checks at run time. A `const` binding is used to give the first argument a name based on `contextOrig` (always) and the second argument is named based on whatever name we used in the Compact source code. The suffixes like `_0` added on variable names is the way that the compiler ensures that it always generates unique names. Then we have some runtime type checks that the first argument actually satisfies the interface for `CircuitContext` defined in the Compact runtime. Finally, we copy the original `CircuitContext` and name it `context`. We do this so that we can mutate the copy without changing the original one that was passed to us. ### Proof Data[​](https://docs.midnight.network/blog/compact-2#proof-data "Direct link to Proof Data") The big-picture view of a `post` transaction is that it runs the JavaScript implementation of the circuit, with full access to the private state provided by its witnesses. Then we ask the proof server to generate a zero-knowledge (ZK) proof that the circuit ran as expected. Specifically, we prove that we know the private data required to produce the observed on-chain behavior—without revealing that private data. In order to do that, we have to collect some information about running the circuit in the so-called “proof data”. We next initialize that data: const partialProofData = { input: { value: _descriptor_4.toValue(newMessage_0), alignment: _descriptor_4.alignment() }, output: undefined, publicTranscript: [], privateTranscriptOutputs: []}; This is a JavaScript value that satisfies the TypeScript interface [`ProofData`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/interfaces/ProofData) from the Compact runtime. To understand this, we need to look inside of the definition. That definition (from the version of the Compact runtime used by the Compact compiler version 0.24.0) is: interface ProofData { input: AlignedValue; output: AlignedValue; privateTranscriptOutputs: AlignedValue[]; publicTranscript: Op[];} This is called `partialProofData` because it will not necessarily contain **all** the proof data that we need. When we run the JavaScript code for the circuit off chain, some conditional branches will be skipped. In these cases, the proof will require 'dummy' data to fill in for branches that were not taken. We’ll explore that in more detail later in the series. The initial value is kind of like the boilerplate we saw before. The properties `input`, `output`, and `publicTranscript` have default initial values. The initial value of `input` depends on the number and types of the parameters to the circuit in Compact: From the TypeScript declaration of ProofData, we can see that `input` has type `AlignedValue`. This is the type alias [`AlignedValue`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/type-aliases/AlignedValue) from the Compact runtime. And from the TypeScript declaration for that we can see that it has a pair of properties, `alignment` and `value`. ### Descriptors[​](https://docs.midnight.network/blog/compact-2#descriptors "Direct link to Descriptors") To fully understand this, let’s take a look at the Compact runtime TypeScript declaration of AlignedValue: type AlignedValue = { alignment: Alignment; value: Value;}; We’ll gloss over `Alignment`, but it’s instructive to see what [`Value`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/type-aliases/Value) is: type Value = Uint8Array[]; So an aligned value is an alignment tag of some kind and a value which is an array of `Uint8Arrays`. This is the ledger’s encoding of Compact values in the on-chain runtime. That’s a different encoding from the JavaScript encoding of the same value. We have two different representations for the same values. One is native JavaScript objects. The other is a binary encoding, used in the on-chain runtime. To convert between these two representations, we use so-called “descriptors”. They are the JavaScript representation of Compact types. More specifically, they are objects implementing the [`CompactType`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/interfaces/CompactType) interface. They have three methods: `toValue` to convert from a JavaScript value to an on-chain value, `fromValue` to convert from an on-chain value to a JavaScript value, and `alignment` to return the alignment of the on-chain value. The code for the `ProofData`’s input (representing the `post` circuit’s `newMessage` argument) was: input: { value: _descriptor_4.toValue(newMessage_0), alignment: _descriptor_4.alignment()}, The compiler generates top-level `const` bindings in JavaScript for a number of descriptors that it has used in the generated JavaScript code. If we look at `_descriptor_4` in `index.cjs` we see: const _descriptor_4 = new __compactRuntime.CompactTypeOpaqueString(); It’s an instance of a descriptor for a Compact value of type `Opaque<"string">`. The Compact runtime defines descriptor classes for all the Compact types, such as [`CompactTypeOpaqueString`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/classes/CompactTypeOpaqueString) . The JavaScript representation of the Compact type `Opaque<"string">` is as a JavaScript string and the ledger representation is as a (tagged) single-element array consisting of the JavaScript string’s UTF-8 encoding. The proof data we will build up while executing the circuit contains ledger representations of values, so we use the descriptor’s `toValue` method to convert the `newMessage` parameter to that representation. ### Wrapping it Up[​](https://docs.midnight.network/blog/compact-2#wrapping-it-up "Direct link to Wrapping it Up") Finally, we have a last little bit of code: const result_0 = this.#_post_0(context, partialProofData, newMessage_0);partialProofData.output = { value: [], alignment: [] };return { result: result_0, context: context, proofData: partialProofData }; This calls a method on the contract named `#_post_0`, which contains the **actual** implementation of the `post` circuit. What we’ve been looking at (the `post` method) is a mostly boilerplate wrapper around this implementation. The implementation method takes the context and passes along the arguments, along with the proof data object we’ve constructed for it. Then after it returns, we will set the `output` property of the proof data. The way that’s set depends on the return type of the Compact circuit. In this case it was the Compact type `[]`, so that’s relatively uninteresting. If you take a look at the `takeDown` circuit in the same contract, you will see the slightly more interesting: partialProofData.output = { value: _descriptor_4.toValue(result_0), alignment: _descriptor_4.alignment() }; Remember that `_descriptor_4` was the one for the Compact type `Opaque<"string">`, and the proof data has ledger values. The circuit implementation in JavaScript will return a JavaScript value, so we need to encode it into the ledger’s representation using `toValue` and `alignment`. And finally, we return the result of the circuit invocation. Recall that this was a [`CircuitResults`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/interfaces/CircuitResults) (where `T` is the contract’s private state type). That interface is in the Compact runtime and it looks like: interface CircuitResults { context: CircuitContext; proofData: ProofData; result: U;} We will look more closely into the actual circuit implementation `#_post_0` in the next article in this series. ### What are Wrappers For?[​](https://docs.midnight.network/blog/compact-2#what-are-wrappers-for "Direct link to What are Wrappers For?") Why do we wrap the implementation in this way? There are a couple of reasons. First, the mostly boilerplate code we have been looking at is used when we call the circuit from JavaScript code in our DApp. So it needs to have the extra runtime checks that we see for safety. But when we call the circuit from another Compact circuit, we do not need these type checks. The Compact type system guarantees that we don’t need extra runtime checks, so we can directly call the implementation function (such as `#_post_0`). And second, when we call a Compact circuit from another one, that is considered part of the same transaction that we are constructing. So in that case, we don’t want to construct a fresh `ProofData` object to pass in, and we don’t want to box up the results in a `CircuitResults` object. We only need to do that at the outermost circuit call, coming from the DApp’s JavaScript code. Witnesses[​](https://docs.midnight.network/blog/compact-2#witnesses "Direct link to Witnesses") ------------------------------------------------------------------------------------------------ Let’s take a quick look at the implementation of witnesses. Our contract has one, and we expect it to be passed in when we construct the contract. The constructor for class `Contract` has some runtime type checking code for that: constructor(...args_0) { if (args_0.length !== 1) throw new __compactRuntime.CompactError(`Contract constructor: expected 1 argument, received ${args_0.length}`); const witnesses_0 = args_0[0]; if (typeof(witnesses_0) !== 'object') throw new __compactRuntime.CompactError('first (witnesses) argument to Contract constructor is not an object'); if (typeof(witnesses_0.localSecretKey) !== 'function') throw new __compactRuntime.CompactError('first (witnesses) argument to Contract constructor does not contain a function-valued field named localSecretKey'); this.witnesses = witnesses_0; Then, probably more interesting, the witnesses are also wrapped. The contract has a method for each witness, like: #_localSecretKey_0(context, partialProofData) { const witnessContext_0 = __compactRuntime.witnessContext(ledger(context.transactionContext.state), context.currentPrivateState, context.transactionContext.address); const [nextPrivateState_0, result_0] = this.witnesses.localSecretKey(witnessContext_0); context.currentPrivateState = nextPrivateState_0; if (!(result_0.buffer instanceof ArrayBuffer && result_0.BYTES_PER_ELEMENT === 1 && result_0.length === 32)) __compactRuntime.type_error('localSecretKey', 'return value', 'bboard.compact line 24 char 1', 'Bytes<32>', result_0) partialProofData.privateTranscriptOutputs.push({ value: _descriptor_2.toValue(result_0), alignment: _descriptor_2.alignment() }); return result_0;} The circuit wrapper `post` was used when we called the circuit from JavaScript code, and bypassed (by directly calling the implementation `#_post_0`) when we called it from Compact code. For witnesses, the situation is reversed. You can call your witnesses (like `witnesses.localSecretKey`) all you want from JavaScript code and we don’t care and won’t even observe it. But if you call them from a Compact circuit, we will need to know about it, so we’ll call a wrapper (like `localSecretKey_0`). Your witness implementation expects to have a `WitnessContext` argument passed to it, so here we’ll construct one to pass in. It contains the ledger, current private state, and the contract’s address. We get the JavaScript representation of the public ledger state using the compiler-generated `ledger` function that we looked at in part 1 of this series. Then we actually invoke your witness implementation, getting the result and a new private state. We mutate the context to update the private state (remember, we copied the original context before invoking a circuit implementation so it was safe to mutate the copied context). Next, we have runtime type checks after the witness returns. This is for the same reason that we check arguments coming in to circuits from JavaScript: we don’t control the witness implementation and we need to make sure that the return value is as expected for the circuit. Compact’s type safety depends on these runtime checks. Finally, we record the witness’s return value in the proof data's private transcript that we are building while running the outermost Compact circuit call. This is private data and so for the ZK proof we construct the proof server will need to know it (so the proof server can prove that it knows the private data). In the next article in this series, "Compact Deep Dive Part 3: The On-Chain Runtime", we will take a closer look at the actual implementation of the `post` circuit from the bulletin board contract and see how it uses the on-chain runtime. * [Circuits](https://docs.midnight.network/blog/compact-2#circuits) * [Runtime Type Checks](https://docs.midnight.network/blog/compact-2#runtime-type-checks) * [Proof Data](https://docs.midnight.network/blog/compact-2#proof-data) * [Descriptors](https://docs.midnight.network/blog/compact-2#descriptors) * [Wrapping it Up](https://docs.midnight.network/blog/compact-2#wrapping-it-up) * [What are Wrappers For?](https://docs.midnight.network/blog/compact-2#what-are-wrappers-for) * [Witnesses](https://docs.midnight.network/blog/compact-2#witnesses) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/compact#__docusaurus_skipToContent_fallback) This post is part of the Compact Deep Dive series, which explores how Compact contracts work on the Midnight network. Each article focuses on a different technical topic and can be read on its own, but together they provide a fuller picture of how Compact functions in practice. The articles assume that you are familiar with Compact to the level of detail covered in the [developer tutorial](https://docs.midnight.network/develop/tutorial/) . Some posts in this series take a deep technical dive into the implementation details of ZK proofs and the Midnight on-chain runtime. These insights reflect the current architecture, but since they describe low-level mechanics, they may change as the platform evolves. One caveat to keep in mind is that almost everything here should be considered an implementation detail. That means that the details are not stable, and they can and will change as we see fit. Overview of the Bulletin Board Contract[​](https://docs.midnight.network/blog/compact#overview-of-the-bulletin-board-contract "Direct link to Overview of the Bulletin Board Contract") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- We'll use our old favorite, [Bulletin Board](https://docs.midnight.network/develop/tutorial/creating/bboard-contract#compiling-the-contract) as an example. We're compiling this with Compact toolchain version 0.24.0. The Compact language is a moving target as we introduce and change features, so this code may not compile with any Compact toolchain version other than 0.24.0. note All the code in this section is Compact code pragma language_version 0.16;import CompactStandardLibrary;export enum State { VACANT, OCCUPIED}export ledger state: State;export ledger message: Maybe>;export ledger instance: Counter;export ledger poster: Bytes<32>;constructor() { state = State.VACANT; message = none>(); instance.increment(1);}witness localSecretKey(): Bytes<32>;export circuit post(newMessage: Opaque<"string">): [] { assert(state == State.VACANT, "Attempted to post to an occupied board"); poster = disclose(publicKey(localSecretKey(), instance as Field as Bytes<32>)); message = disclose(some>(newMessage)); state = State.OCCUPIED;}export circuit takeDown(): Opaque<"string"> { assert(state == State.OCCUPIED, "Attempted to take down post from an empty board"); assert(poster == publicKey(localSecretKey(), instance as Field as Bytes<32>), "Attempted to take down post, but not the current poster"); const formerMsg = message.value; state = State.VACANT; instance.increment(1); message = none>(); return formerMsg;}export circuit publicKey(sk: Bytes<32>, instance: Bytes<32>): Bytes<32> { return persistentHash>>([pad(32, "bboard:pk:"), instance, sk]);} We’ll focus on the `post` circuit. First, let’s refresh your memory about the basics of the contract. It declares a Compact `enum` type for the bulletin board’s state, and it declares some ledger fields. Three of them are mutable ledger cells and one of them is a `Counter`: export enum State { VACANT, OCCUPIED}export ledger state: State;export ledger message: Maybe>;export ledger instance: Counter;export ledger poster: Bytes<32>; There is a witness that has access to private state. This is a foreign function implemented in JavaScript or TypeScript. It looks up the user’s secret key somehow and returns it. The `post` circuit makes sure that the bulletin board is in the `VACANT` state and, if so, uses the witness to get the secret key and updates the three cells in the ledger: witness localSecretKey(): Bytes<32>;export circuit post(newMessage: Opaque<"string">): [] { assert(state == State.VACANT, "Attempted to post to an occupied board"); poster = disclose(publicKey(localSecretKey(), instance as Field as Bytes<32>)); message = disclose(some>(newMessage)); state = State.OCCUPIED;} There is also a helper circuit called `publicKey`, which is used by both the `post` and `takeDown` circuits. Declaring `publicKey` as exported has two effects: * It makes the circuit callable from TypeScript or JavaScript. * It makes it a contract entry point, allowing `publicKey` transactions to be submitted to the Midnight blockchain. export circuit publicKey(sk: Bytes<32>, instance: Bytes<32>): Bytes<32> { return persistentHash>>([pad(32, "bboard:pk:"), instance, sk]);} A Look Under the Hood[​](https://docs.midnight.network/blog/compact#a-look-under-the-hood "Direct link to A Look Under the Hood") ---------------------------------------------------------------------------------------------------------------------------------- Presuming `compact` is in your path, you can compile the Bulletin Board contract directly. If the code is in a file named `bboard.compact`, change to the directory where that file is located. Then run `compact compile`, passing the source file and an output directory: $ compact compile bboard.compact bboard-outCompact version: 0.24.0Compiling 2 circuits: circuit "post" (k=14, rows=10070) circuit "takeDown" (k=14, rows=10087) Overall progress [====================] 2/2 Let’s take a look at what the compiler has generated: $ ls bboard-outcompiler contract keys zkir There are four subdirectories. `compiler` has some metadata about the contract that will be used by composable contracts, which we can just ignore for now. `keys` and `zkir` are related to the ZK proofs which we will talk about in a later article. The compiler has translated the contract code into a JavaScript implementation, which is in the contract subdirectory. We’ll focus on that first. $ ls bboard-out/contractindex.cjs index.cjs.map index.d.cts There are three files here. `index.cjs` is the JavaScript implementation of the contract. (It is JavaScript source code, the `.cjs` extension means that it uses the CommonJS module system.) There is a source map file `index.cjs.map` that can be used for debugging. It connects the JavaScript implementation in `index.cjs` back to the original Compact source code that was in `bboard.compact`. Finally, there is a TypeScript declaration file `index.d.cts` for the JavaScript implementation. This allows the JavaScript code in `index.cjs` to be called from TypeScript (and importantly, type checked by the TypeScript compiler). We have chosen this strategy (a JavaScript implementation with a TypeScript declaration file, instead of a pure TypeScript implementation) for a couple of reasons. First, it lets us generate runtime checks in the JavaScript code for things that wouldn’t be checked by TypeScript’s type system. And second, we can generate a source map for debugging that maps the implementation back to the Compact source code. The source map you would get from the TypeScript compiler would only connect the TypeScript compiler generated JavaScript code back to Compact compiler generated TypeScript, not all the way back to the original Compact source code. TypeScript Declaration[​](https://docs.midnight.network/blog/compact#typescript-declaration "Direct link to TypeScript Declaration") ------------------------------------------------------------------------------------------------------------------------------------- Now, let’s take a first look at the structure of the contract’s implementation by looking inside the TypeScript declaration file `index.d.cts`. We will walk through this file, though not necessarily in order. Before reading further, we encourage you to compile the code to generate this file and take a look at it yourself. Remember, this was generated with Compact toolchain version 0.24.0. If you try the same thing with a different version, you might see different implementation details. ### The Compact Runtime[​](https://docs.midnight.network/blog/compact#the-compact-runtime "Direct link to The Compact Runtime") note All the code in this section is written in TypeScript. The very first thing you will see is: import type * as __compactRuntime from '@midnight-ntwrk/compact-runtime'; This imports the Node.js package `@midnight-ntwrk/compact-runtime` which is an API used by the Compact compiler’s generated JavaScript code. Separating it out like this decouples the runtime from the compiler implementation, and it means that the generated JavaScript code can be smaller. We’ll see later that the Compact runtime is quite complex (it re-exports a large part of the on-chain runtime which is implemented in Rust and compiled to WebAssembly). You can even import this package in your DApp to have your own access to Compact runtime types and functions if necessary. The API documentation for the Compact runtime is available in the [Midnight documentation](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/) . ### Compact `enum` Types[​](https://docs.midnight.network/blog/compact#compact-enum-types "Direct link to compact-enum-types") The bulletin board contract declared a Compact `enum` type for the bulletin board’s state (vacant or occupied). This type was exported (via the `export` keyword) which makes it available to a DApp’s TypeScript or JavaScript implementation, so there is a declaration in the TypeScript declaration file: export enum State { VACANT = 0, OCCUPIED = 1 } If this `enum` type was not exported in Compact, we would not see this declaration. Then, whenever this type appeared in the contract’s API (like in a circuit parameter or in the ledger) we would instead see the the underlying TypeScript representation type `number`. (Try it and see! Remove the `export` keyword for the `enum` in the Compact contract. Note that if you merely want to look at the generated TypeScript or JavaScript contract code you can skip ZK key generation by passing the command-line flag `--skip-zk` to the Compact compiler. This will run much faster.) ### The Compact Ledger[​](https://docs.midnight.network/blog/compact#the-compact-ledger "Direct link to The Compact Ledger") In Compact, the contract’s public state is established by ledger declarations. The compiler collects all of these and exposes them to the DApp in the form of a ledger type: export type Ledger = { readonly state: State; readonly message: { is_some: boolean, value: string }; readonly instance: bigint; readonly poster: Uint8Array;} It has read-only properties for all the ledger fields. They are read-only in TypeScript, because **updating** the ledger actually requires a transaction to be submitted to the chain. A DApp, however, can freely read them from (a snapshot of) the public ledger state. We mentioned before that `State` appears in this API because we exported the Compact `enum` type `State`. Notice that the Compact standard library type `Maybe` does not appear in this API. Instead, the ledger field `message` has the underlying TypeScript type. That’s because we didn’t export the standard library’s `Maybe` type. We could do that with `export { Maybe }` at the top level of our Compact contract, and then we would instead see: export type Maybe = { is_some: boolean; value: a };export type Ledger = { readonly state: State; readonly message: Maybe; readonly instance: bigint; readonly poster: Uint8Array;} There is also a declaration of a function that gives us (a read-only snapshot of) the public ledger state, returning a TypeScript value of type `Ledger` as declared above: export declare function ledger(state: __compactRuntime.StateValue): Ledger; This function takes a value of the Compact runtime’s type [`StateValue`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/classes/StateValue) . We will see in Part 2 of this series how this function is used to pass a `Ledger` to witnesses. ### Compact Circuits[​](https://docs.midnight.network/blog/compact#compact-circuits "Direct link to Compact Circuits") Our contract had three exported circuits. By exporting them, they are made available to be called by the DApp’s TypeScript or JavaScript code, and they form the contract’s entry points. We can see declarations for them in the TypeScript declaration file, in two different places: export type ImpureCircuits = { post(context: __compactRuntime.CircuitContext, newMessage_0: string): __compactRuntime.CircuitResults; takeDown(context: __compactRuntime.CircuitContext): __compactRuntime.CircuitResults;}export type PureCircuits = { publicKey(sk_0: Uint8Array, instance_0: Uint8Array): Uint8Array;}export type Circuits = { post(context: __compactRuntime.CircuitContext, newMessage_0: string): __compactRuntime.CircuitResults; takeDown(context: __compactRuntime.CircuitContext): __compactRuntime.CircuitResults; publicKey(context: __compactRuntime.CircuitContext, sk_0: Uint8Array, instance_0: Uint8Array): __compactRuntime.CircuitResults;} The `post` and `takeDown` circuits are _impure_. In Compact, this basically means that they access (even if only by reading) the public state and/or they invoke witnesses. They are declared in the type `ImpureCircuits`. The generic type parameter `T` here is the type of the contract's private state. The Compact compiler doesn't know what that type is (nor does it need to); it's up to the DApp developer to fill that in. Recall the Compact signature of the `post` circuit was `circuit post(new_message: Opaque<"string">): []`. We can see that the TypeScript API for this circuit is predictably derived from the Compact signature, with a few differences. First, the circuit takes an extra first argument of type `CircuitContext`. This is an interface declared in the [Compact runtime](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/interfaces/CircuitContext) . It contains an encapsulation of the contract's on-chain and private state, some separate Zswap state, and a representation of what the on-chain context would be if the circuit were actually executing on chain (though note, this JavaScript code is **not** what's executed on chain). Second, we can see that the Compact type `Opaque<"string">` is represented by the TypeScript type `string`. One goal of Compact is that the TypeScript representation of Compact types is always predictable. And third, we can see that the return type (in Compact it was `[]`) is actually `CircuitResults`. This is another interface declared in the [Compact runtime](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/interfaces/CircuitResults) . It has the actual return value with TypeScript type `[]`, as well as some proof data required to construct the ZK proof and a new `CircuitContext` representing the public and private state after running the circuit. We won’t focus on `takeDown` here, but you can see that its signature is similarly and predictably derived from the signature of the circuit in Compact. The helper circuit `publicKey` is _pure_. This means that it does not access the public state or invoke witnesses (i.e., it's not impure). It is declared in the type `PureCircuits`. Pure circuits are ones that can run without an instance of the contract. Specifically, they do not need access to the ledger state and they do not have access to private state. You can see that here, because the extra first `CircuitContext` argument is missing, and the return value is a bare TypeScript type rather than a `CircuitResult`. The type `PureCircuits` is not generic, there is no type parameter `T` needed to represent the type of the private state. Finally, these declarations are repeated in the type `Circuits`. The declarations of `post` and `takeDown` are exactly the same as before, but the declaration of `publicKey` has the signature of an impure circuit. This is so that the DApp can make a `publicKey` transaction, without having to worry about the details of whether it's pure or not. There are implementations of these circuits in the compiler-generated JavaScript code for the contract, which we will look at in the next article in this series. ### Compact Witnesses[​](https://docs.midnight.network/blog/compact#compact-witnesses "Direct link to Compact Witnesses") We had a single witness declaration in our contract, which is also reflected in the contract’s TypeScript API: export type Witnesses = { localSecretKey(context: __compactRuntime.WitnessContext): [T, Uint8Array];} The witness’s signature is also predictably derived from the Compact witness declaration. It has an extra first argument of type `WitnessContext`. This interface is declared in the [Compact runtime](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/interfaces/WitnessContext) . It contains a snapshot of the public ledger state, the contract’s private state of type `T`, and the contract’s address. The witness returns a tuple (a two-element TypeScript array) consisting of a new private state of type `T` and the Compact return value. The Compact type `Bytes<32>` is represented by the underlying TypeScript type Uint8Array. The DApp implementation is responsible for providing a witness with this signature when constructing the contract. ### The Contract Type[​](https://docs.midnight.network/blog/compact#the-contract-type "Direct link to The Contract Type") Finally, there is a declaration of the contract type: export declare class Contract = Witnesses> { witnesses: W; circuits: Circuits; impureCircuits: ImpureCircuits; constructor(witnesses: W); initialState(context: __compactRuntime.ConstructorContext): __compactRuntime.ConstructorResult;}export declare const pureCircuits: PureCircuits; It is parameterized over the private state type and the witness type, and it has witnesses, circuits, impure circuits, a constructor, and an initial state all using the type declarations seen above. The pure circuits are a top-level TypeScript value (rather than a contract property), representing the fact that they do not need an instance of the contract. The contract itself is implemented by the compiler-generated JavaScript code in `index.cjs`. In the next article in this series, "Compact Deep Dive – Part 2: Circuits and Witnesses", we’ll begin examining how circuits and witnesses are implemented in the generated code. * [Overview of the Bulletin Board Contract](https://docs.midnight.network/blog/compact#overview-of-the-bulletin-board-contract) * [A Look Under the Hood](https://docs.midnight.network/blog/compact#a-look-under-the-hood) * [TypeScript Declaration](https://docs.midnight.network/blog/compact#typescript-declaration) * [The Compact Runtime](https://docs.midnight.network/blog/compact#the-compact-runtime) * [Compact `enum` Types](https://docs.midnight.network/blog/compact#compact-enum-types) * [The Compact Ledger](https://docs.midnight.network/blog/compact#the-compact-ledger) * [Compact Circuits](https://docs.midnight.network/blog/compact#compact-circuits) * [Compact Witnesses](https://docs.midnight.network/blog/compact#compact-witnesses) * [The Contract Type](https://docs.midnight.network/blog/compact#the-contract-type) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/compact-3#__docusaurus_skipToContent_fallback) This blog post is the third part of the Compact Deep Dive series, which explores how Compact contracts work on the Midnight network. Each article focuses on a different technical topic and can be read on its own, but together they provide a fuller picture of how Compact functions in practice. The first two parts can be found here: * [Part 1: Top-level Contract Structure](https://docs.midnight.network/blog/compact) * [Part 2: Circuits and Witnesses](https://docs.midnight.network/blog/compact-2) This article looks at the on-chain runtime and how public ledger state updates happen in your DApp. The Bulletin Board's `post` Circuit =================================== In the previous parts we used the Bulletin Board example DApp to take a look at contract structure and the implementation of circuits and witnesses. We saw that a contract's exported circuits, such as `post` from the Bulletin Board example, had an outer "wrapper" that called the actual implementation. We will now take a look at that actual implementation. Recall the Compact implementation of `post`: export circuit post(newMessage: Opaque<"string">): [] { assert(state == State.VACANT, "Attempted to post to an occupied board"); poster = disclose(publicKey(localSecretKey(), instance as Field as Bytes<32>)); message = disclose(some>(newMessage)); state = State.OCCUPIED;} It reads the `state` field from the contract's public ledger state and asserts that the bulletin board is vacant. Then it calls the witness `localSecretKey` and uses the return value to derive `poster`, a commitment to the post's author. Finally, it updates three ledger fields (`poster`, `message`, and `state`). We compiled the contract with version 0.25.0 of the Compact compiler. Note that this is a different version than the one used in parts one and two of this series. If you use a different version, the implementation details might be different. The implementation of `post` is in a JavaScript function called `_post_0`. Every line of this function has something new to learn about the way that Compact works, so we will go line by line through it. The first line of this function corresponds to the first line of the Compact circuit: _post_0(context, partialProofData, newMessage_0) { __compactRuntime.assert( _descriptor_0.fromValue( Contract._query( context, partialProofData, [ { dup: { n: 0 } }, { idx: { cached: false, pushPath: false, path: [ { tag: 'value', value: { value: _descriptor_9.toValue(0n), alignment: _descriptor_9.alignment() } }] } }, { popeq: { cached: false, result: undefined } }]).value) === 0, 'Attempted to post to an occupied board'); (Here and below we have reformatted the JavaScript code to fit better on screen. The only change is the indentation.) We will read this line of JavaScript from the inside out. The very first subexpression evaluated in the Compact `post` circuit is simply `state`, which is a read of the ledger's `state` field. This also must be the first thing evaluated in the JavaScript implementation. It is implemented by a call to a compiler-generated static method `_query` on the `Contract` class. (We will take a closer look at `Contract._query` in the next article in this series.) Recall what is happening when `_post_0` is executed in your DApp. The JavaScript code is running locally on a user's machine, with full access to private data from the witnesses it uses. After running the code, the proof server will be used to construct a zero-knowledge (ZK) proof that it did run that code. Then, a transaction will be submitted to the Midnight chain. If the chain verifies the proof, the public ledger state updates specified by the circuit implementation will be performed. The Midnight node uses the [Impact VM](https://docs.midnight.network/develop/how-midnight-works/impact) , a stack-based virtual machine, to perform public ledger state updates. This machine executes a program in a bytecode language called **Impact**. We use the same Impact VM to perform updates to a local copy of the public state when we are running your DApp's code locally before submitting a transaction. The On-Chain Runtime and the Impact VM ====================================== The Compact runtime package includes an embedded version of the on-chain runtime. This is the exact same Rust code that is used to implement the Midnight ledger on the Midnight network nodes. For the Compact runtime, it is compiled to WebAssembly and imported as the [on-chain runtime](https://docs.midnight.network/develop/reference/midnight-api/onchain-runtime/) package. You can actually use this package directly in your DApp, though much of it is re-exported by the higher-level Compact runtime. Sometimes the Compact runtime provides wrapped versions that have a higher-level API (specifically, using JavaScript representations instead of the ledger's native binary representation). note If you use the on-chain runtime package directly in your DApp, it is very important to remember that you are working with a snapshot of the public state. This snapshot was obtained from a Midnight indexer, but while your DApp is running, the chain itself is progressing with other transactions for the same contract. That's part of what it means for a DApp to be "decentralized". The Impact VM performs public ledger state updates, immediately in your DApp's copy and later (when the transaction is run) on chain. There are a host of reasons to use the exact same VM: * Transaction semantics will be identical. * It saves engineering work to implement it (and update it and maintain it) once. * We will need the Impact program to compute fees for the transaction. * The ZK proof will be about this **specific** Impact program. The Impact VM is a stack-based machine. Transactions operate on a stack of values, which are encoded in the ledger's binary representation. The transaction always starts with three values on the stack: 1. First (at the base of the stack), a **context** object for the transaction. 2. Second, an **effects** object collecting actions performed by the transaction. 3. Third, the contract's public state. When a transaction completes, these three values are left on the stack in the same order. Values on the VM's stack are immutable. For instance, a state update is accomplished by **replacing** the state third on the stack with a new one (rather than **mutating** the existing state value). The third argument to `Contract._query` is an array of `Op`s which are JavaScript representations of Impact VM instructions. `Op` is a type [defined](https://docs.midnight.network/develop/reference/midnight-api/onchain-runtime/type-aliases/Op) in the on-chain runtime. Transactions will use a [binary encoding](https://docs.midnight.network/develop/how-midnight-works/impact#programs) of these instructions. The array of instructions is a partial Impact program. A whole program will be built up for the transaction, usually with multiple calls to `Contract._query`. Ledger Read Operations ====================== The Impact code for the ledger read of the field `state` from above was: [ { dup: { n: 0 } }, { idx: { cached: false, pushPath: false, path: [ { tag: 'value', value: { value: _descriptor_9.toValue(0n), alignment: _descriptor_9.alignment() } }] } }, { popeq: { cached: false, result: undefined } }] The first instruction is `dup 0`. Instructions will find their inputs on the Impact VM's stack. They can also have operands which are encoded as part of the instruction, such as the zero in `dup 0`. The `dup N` instruction **duplicates** a value on the stack. The value is found _N_ elements below the top of the stack, so _N_\=0 is the top of the stack. Since this is the first Impact instruction in a `post` transaction, that will be the public ledger state value. Before `dup 0`, the Impact VM's stack had `` in order from the base to the top of the stack. `ledger0` is the initial ledger state of this transaction. After `dup 0`, it will have `` with two copies of the ledger state on top of the stack. This allows subsequent instructions which consume values to execute without losing the public ledger state. The second instruction is `idx [0]`. This instruction **indexes** into the top value on the stack, extracting a subpart of it. It removes the top value on the stack and replaces it with the extracted subpart. The instruction's operand is a path, a sequence of ledger-encoded values (or a special tag `stack`). The two different encodings of values, and the descriptors that convert between them, were described in [Part 2](https://docs.midnight.network/blog/compact-2#descriptors) . Here the instruction uses `_descriptor_9`: const _descriptor_9 = new __compactRuntime.CompactTypeUnsignedInteger(255n, 1); This is an instance of [`CompactTypeUnsignedInteger`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/classes/CompactTypeUnsignedInteger) from the Compact runtime. It takes a maximum value and a size in bytes. So this is the descriptor for a one byte unsigned integer with a maximum value of 255 (that is, just an unsigned byte). The value `0n` is the public ledger state index that the Compact compiler has assigned to the `state` field. Impact has four different indexing instructions: `idx`, `idxc` (cached), `idxp` (push path), and `idxpc` (push path, cached). In the JavaScript representation of instructions, we simply use a pair of boolean properties giving the same four variants. `cached` is true when the value being accessed has already been accessed (that is, read or written) in the same transaction. It can potentially be used for assigning different fees for cached and uncached accesses. In this case, we have not accessed the `state` ledger field yet in the transaction. `pushPath` is a variant that leaves a path in place on the stack for a subsequent write operation. Before `idx [0]`, the VM's stack had ``. After `idx [0]`, it will have `` (where `ledger0` is the entire public ledger state and `state` is the value of the field with that name). The third instruction is `popeq`. This instruction **pops** the top value from the VM's stack. The Impact VM can run in two different modes. It runs in **gathering** mode when it runs locally in a DApp. It runs in **verifying** mode when it executes a contract's public ledger state updates on chain. In gathering mode the popped value is collected (it's used by `Contract._query` as the result of this ledger read). In verifying mode the VM will ensure that the popped value is equal to the instruction's operand. Here we are running in gathering mode, so the instruction's `result` operand is the JavaScript `undefined` value. Before `popeq`, the VM's stack had ``. After `popeq`, it will have ``. These three simple VM instructions implement a top-level ledger read. Assert in Circuits ================== The `post` circuit asserts that the bulletin board's state is vacant. This is implemented by the JavaScript code from above (with the Impact instructions elided): __compactRuntime.assert( _descriptor_0.fromValue( Contract._query( context, partialProofData, /* Impact code */).value) === 0, 'Attempted to post to an occupied board'); `Contract._query` returns an object with a ledger-encoded result. `_descriptor_0` is the descriptor for the the `State` enumeration type, so `_descriptor_0.fromValue` is used to convert it to one of the enumeration values `VACANT=0` or `OCCUPIED=1`. This value is compared via JavaScript's strict equality operator to the vacant value (zero). The assertion itself is implemented by a call to the Compact runtime's `assert` function. If the condition is not true, this will cause the DApp's `post` transaction to fail without ever reaching the Midnight chain. Provided that the assertion succeeds when running the DApp locally, the ZK proof will prove that it suceeded. When the proof is verified on chain, the Midnight network will then know that this assertion was true. The on-chain Impact program will not directly assert this property (that `state` was `State.VACANT`). However, when the `popeq` instruction is run in verifying mode, it will have an operand that indicates the actual value that was popped locally in the DApp. So specifically, if the DApp successfully built a `post` transaction, that instruction will be `popeq 0`. This is subtly different from asserting that the `state` field was 0. If the `assert` were removed from the Compact program and the ledger field read remained, then the Impact program run on chain could have either `popeq 0` or `popeq 1` depending on the actual value that was read by the DApp. Circuit and Witness Calls ========================= The second line of the Compact `post` circuit is: poster = disclose(publicKey(localSecretKey(), instance as Field as Bytes<32>)); This is a write to the ledger's `poster` field. The right-hand side of the write operation is implemented by the JavaScript code: const tmp_0 = this._publicKey_0( this._localSecretKey_0(context, partialProofData), __compactRuntime.convert_bigint_to_Uint8Array( 32, _descriptor_1.fromValue( Contract._query( context, partialProofData, [ { dup: { n: 0 } }, { idx: { cached: false, pushPath: false, path: [ { tag: 'value', value: { value: _descriptor_9.toValue(2n), alignment: _descriptor_9.alignment() } }] } }, { popeq: { cached: true, result: undefined } }]).value))); The compiler has named this value `tmp_0` so it can refer to it later. The call to the witness `localSecretKey` has been compiled into a call to the `_localSecretKey_0` method of the contract. Recall from [Part 2](https://docs.midnight.network/blog/compact-2#witnesses) that this method is a wrapper around the DApp-provided witness implementation. The wrapper performs some type checks on the witness return value, and it records that return value as one of the transaction's private inputs. The Impact code above implements the read of the ledger's `instance` field. It is nearly the same as the code for the read of `state`. The difference is that the Compact compiler has assigned `instance` to index 2. The field `instance` has a `Counter` ledger type. Reading it in Compact [gives a `Uint<64>`](https://docs.midnight.network/develop/reference/compact/ledger-adt#read-1) . The ledger representation of this value is converted to the JavaScript representation (`bigint`) using `_descriptor_1`: const _descriptor_1 = new __compactRuntime.CompactTypeUnsignedInteger(18446744073709551615n, 8); The maximum value here is the maximum unsigned 64-bit integer and the size in bytes is 8. Type Casts in Compact ===================== The Compact code has a sequence of type casts `instance as Field as Bytes<32>`. `instance` is a `Counter`, reading it from the ledger gives a Compact value with type `Uint<64>`. This cannot be directly cast to `Bytes<32>` so the contract uses an intermediate cast to `Field`. There are three distinct kinds of type casts in Compact: upcasts, downcasts, and so-called "cross casts". An upcast is from a type to one of its supertypes. Such a cast will change the static type as seen by the compiler, but it will have no effect at runtime. For example, casting from `Uint<64>` to `Field` is an upcast. That cast was performed statically (that is, by the compiler) but there is no JavaScript code here to implement it. A downcast is from a type to one of its subtypes. Such a cast will not normally change a value's representation, but it will require a runtime check in the compiler-generated JavaScript code. A cross cast is from a type to an unrelated type (with respect to subtyping). For example, casting a `Field` to `Bytes<32>` is a cross cast. These type casts will normally require a representation change. The Compact runtime function [`convert_bigint_to_Uint8Array`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/functions/convert_bigint_to_Uint8Array) performs the representation change in this case. Then there was a call in Compact to the circuit `publicKey`. Here we see that the call goes directly to the JavaScript implementation method `_publicKey_0`, and not to the exported circuit's `publicKey` wrapper. Recall from [Part 2](https://docs.midnight.network/blog/compact-2#what-are-wrappers-for) that the circuit wrapper performed some runtime type checks that we do not need when we call from Compact to Compact (the Compact type system guarantees that these checks aren't needed). More importantly, a circuit's wrapper established a fresh proof data object for a transaction. Since the call to `publicKey` is part of the `post` transaction that the DApp is building, it should reuse the existing proof data. Notice that the `disclose` operator in Compact doesn't do anything at all at runtime. `disclose` was necessary because a value computed from the witness `localSecretKey` was exposed on chain. This is an instruction to the Compact compiler to allow this value to be exposed, but it has no runtime effect. Ledger Writes ============= The right-hand side value named `tmp_0` in JavaScript should be written to the ledger field `poster`. The code to do that is in the next line of JavaScript code: Contract._query( context, partialProofData, [ { push: { storage: false, value: __compactRuntime.StateValue.newCell( { value: _descriptor_9.toValue(3n), alignment: _descriptor_9.alignment() }).encode() } }, { push: { storage: true, value: __compactRuntime.StateValue.newCell( { value: _descriptor_2.toValue(tmp_0), alignment: _descriptor_2.alignment() }).encode() } }, { ins: { cached: false, n: 1 } }]); This is again implemented by a partial Impact program. The Impact code above implements a ledger cell write (in contrast to the read we saw above). The first instruction is `push 3`. Impact's `push` instruction is the dual to the `pop` instruction. Impact has two different variants: `push` and `pushs`. In the JavaScript representation of Impact instructions, they are distinguished by a boolean `storage` property. `storage` is false to indicate that the value is kept solely in the Impact VM's memory and will not be written to the ledger. The second instruction is `pushs tmp_0`. The instruction is `pushs` because `storage` is true (this value will be written to the ledger). The instruction's operand will be the actual `Bytes<32>` value of `tmp_0`. As you would expect, `_descriptor_2` is the descriptor for `Bytes<32>`, used to convert the JavaScript value to a ledger value: const _descriptor_2 = new __compactRuntime.CompactTypeBytes(32); Before executing these two instructions, the Impact VM's stack had ``. After executing these two instructions, it will have ``. The next instruction is `ins 1` which **inserts** into a value on the VM's stack. Impact's `ins` instruction is the dual to the `idx` instruction we saw used for ledger reads. The value to insert is on top of the stack (that is, the `Bytes<32>` value of `tmp_0`). Underneath that is a path consisting of _N_ elements, where _N_ is the operand of the `ins` instruction. In this case, the path has length 1, so it is the singleton sequence `[3]`. This is the index the Compact compiler has assigned to the top-level ledger field `poster`. The insert instruction removes the value under the path (namely, the public ledger state) and replaces it with a new copy of that value with the location denoted by the path updated to have the new value. Before `ins 1`, the Impact VM's stack had ``. After `ins 1`, it will have `` where `ledger1` is a new public ledger state representing the write to `poster`. The remainder of `_post_0` has two more ledger writes and a return of the Compact empty tuple represented by the JavaScript empty array: const tmp_1 = this._some_0(newMessage_0);Contract._query( context, partialProofData, [ { push: { storage: false, value: __compactRuntime.StateValue.newCell( { value: _descriptor_9.toValue(1n), alignment: _descriptor_9.alignment() }).encode() } }, { push: { storage: true, value: __compactRuntime.StateValue.newCell( { value: _descriptor_5.toValue(tmp_1), alignment: _descriptor_5.alignment() }).encode() } }, { ins: { cached: false, n: 1 } }]);Contract._query( context, partialProofData, [ { push: { storage: false, value: __compactRuntime.StateValue.newCell( { value: _descriptor_9.toValue(0n), alignment: _descriptor_9.alignment() }).encode() } }, { push: { storage: true, value: __compactRuntime.StateValue.newCell( { value: _descriptor_0.toValue(1), alignment: _descriptor_0.alignment() }).encode() } }, { ins: { cached: false, n: 1 } }]);return []; Take a look and see if you can see how the code above works. `publicKey` =========== There is one more way that the on-chain runtime is used by Compact. If we take a look at the implementation of the `publicKey` circuit (the actual implementation, not the wrapper for the exported circuit): _publicKey_0(sk_0, instance_0) { return this._persistentHash_0([new Uint8Array([98, 98, 111, 97, 114, 100, 58, 112, 107, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), instance_0, sk_0]);} We see that the padded string literal has been compiled to an explicit `Uint8Array`. We also see a call to a `_persistentHash_0` method, which is the Compact standard library's [`persistentHash` circuit](https://docs.midnight.network/develop/reference/compact/compact-std-library/exports#persistenthash) . The compiler has included a JavaScript implementation of this circuit: _persistentHash_0(value_0) { const result_0 = __compactRuntime.persistentHash(_descriptor_7, value_0); return result_0;} This is a call to the Compact runtime's [`persistentHash` function](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/functions/persistentHash) . This function in the Compact runtime is a thin wrapper around the on-chain runtime's own [`persistentHash`](https://docs.midnight.network/develop/reference/midnight-api/onchain-runtime/functions/persistentHash) . The difference is that the on-chain runtime's version operates on the ledger encoding of values, and the Compact runtime's version uses the descriptor it is passed to do the relevant conversion. So this is the final capability of the on-chain runtime that we will look at here: it contains implementations of functions like `persistentHash` that are shared between the DApp and the Midnight node. In the next article in this series, we will look at how partial Impact programs get collected together and how the compiler-generated JavaScript code produces so-called public inputs and public outputs for the ZK proof that will be generated. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/dapp-developers-bls-upgrade#__docusaurus_skipToContent_fallback) The Midnight testnet upgrade introduces BLS12-381, requiring developers to update the Lace wallet, proof server, and redeploy contracts with the latest Compact compiler. The Midnight testnet is undergoing an [upgrade](https://midnight.network/blog/upcoming-testnet-02-upgrade-all-you-need-to-know) . As part of this upgrade, the proving system will change from Pluto-Eris to BLS12-381. To ensure compatibility and functionality, DApp developers will need to complete the following steps: * [Developer requirements](https://docs.midnight.network/blog/dapp-developers-bls-upgrade#developer-requirements) * [1- Installing the Lace wallet](https://docs.midnight.network/blog/dapp-developers-bls-upgrade#1--installing-the-lace-wallet) * [2- Downloading the proof server](https://docs.midnight.network/blog/dapp-developers-bls-upgrade#2--downloading-the-proof-server) * [3- Updating the Compact compiler and redeploying the smart contracts](https://docs.midnight.network/blog/dapp-developers-bls-upgrade#3--updating-the-compact-compiler-and-redeploying-the-smart-contracts) 1- Installing the Lace wallet[​](https://docs.midnight.network/blog/dapp-developers-bls-upgrade#1--installing-the-lace-wallet "Direct link to 1- Installing the Lace wallet") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ The latest version of the Lace wallet (2.0.0) is available [here](https://docs.midnight.network/relnotes/lace) . It supports the new Bech32m address format. 1. Download and unzip the ZIP file. 2. Open your Chrome or Brave browser. 3. Navigate to the **Extensions** panel. 4. Click **Load unpacked** . 5. Select the folder you just unzipped. 6. After it's installed, you can either create a new wallet, or restore a previous wallet using your saved seed phrase. Once it is done, you should see the new address format that begins with “mn\_shield-addr\_test…” 2- Downloading the proof server[​](https://docs.midnight.network/blog/dapp-developers-bls-upgrade#2--downloading-the-proof-server "Direct link to 2- Downloading the proof server") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ You can download the latest version of the proof server [here](https://docs.midnight.network/relnotes/proof-server) . You can also install it via the command line: docker pull midnightnetwork/proof-server:latest Once downloaded, you can start the proof server with this command: docker run -p 6300:6300 midnightnetwork/proof-server -- midnight-proof-server --network testnet You can find more details in the [documentation](https://docs.midnight.network/develop/tutorial/using/proof-server) . 3- Updating the Compact compiler and redeploying the smart contracts[​](https://docs.midnight.network/blog/dapp-developers-bls-upgrade#3--updating-the-compact-compiler-and-redeploying-the-smart-contracts "Direct link to 3- Updating the Compact compiler and redeploying the smart contracts") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Smart contracts must be redeployed to match the new proof system and the zero-knowledge proofs it creates. As part of this upgrade, the compiler, Compact runtime, and on-chain runtime are all changing. Developers will need to recompile their contracts using the new BLS-compatible compiler, version 0.23.0, which will be released alongside the other upgraded components. After recompiling, developers must rebuild their DApps to use the newly compiled contracts. Additionally, the contracts will require fresh prover and verifier keys for the exported circuits. It will not be sufficient to redeploy with the existing keys; recompilation is necessary to generate the new keys. You can use the same method to deploy contracts as you are used to, or you can take a look [at this example](https://github.com/midnightntwrk/example-counter/blob/1babbcb377317ba705c26545a6808deea7a39975/counter-cli/src/api.ts#L90) and the deploy function to deploy smart contracts to the Midnight testnet. Be sure to use the [latest version of MidnightJS](https://docs.midnight.network/relnotes/midnight-js) to deploy your contracts, as it is the one that supports Bech32m addresses. * [1- Installing the Lace wallet](https://docs.midnight.network/blog/dapp-developers-bls-upgrade#1--installing-the-lace-wallet) * [2- Downloading the proof server](https://docs.midnight.network/blog/dapp-developers-bls-upgrade#2--downloading-the-proof-server) * [3- Updating the Compact compiler and redeploying the smart contracts](https://docs.midnight.network/blog/dapp-developers-bls-upgrade#3--updating-the-compact-compiler-and-redeploying-the-smart-contracts) --- # Search the documentation | Midnight Docs [Skip to main content](https://docs.midnight.network/search#__docusaurus_skipToContent_fallback) Search the documentation ======================== [](https://www.algolia.com/) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/hacktoberfest25#__docusaurus_skipToContent_fallback) **[Hacktoberfest](https://hacktoberfest.com/) ** is a global open-source event held every October, where developers contribute pull requests to public repositories to earn digital rewards. Midnight is joining the celebration by inviting contributors to improve its open-source ecosystem — from smart contracts and DApps to core libraries and documentation. Review the guide to get started. 1\. Registration[​](https://docs.midnight.network/blog/hacktoberfest25#1-registration "Direct link to 1. Registration") ------------------------------------------------------------------------------------------------------------------------ To participate, register at **[https://hacktoberfest.com/auth/](https://hacktoberfest.com/auth/) **. All opportunities to contribute to Midnight’s open source ecosystem will be available through our **[Community Hub](https://github.com/midnightntwrk/community-hub) **. Participants are encouraged to submit six (6) high-quality pull or merge requests between **October 1 and October 31** to earn the official Hacktoberfest digital badge. Review our **[Contribution Guidelines](https://github.com/midnightntwrk/community-hub/blob/main/CONTRIBUTING.md) ** before submitting any work. * * * 2\. Hacktoberfest Participation[​](https://docs.midnight.network/blog/hacktoberfest25#2-hacktoberfest-participation "Direct link to 2. Hacktoberfest Participation") --------------------------------------------------------------------------------------------------------------------------------------------------------------------- Look for issues labeled **`hacktoberfest`** or browse through issues submitted by other community members to find contribution opportunities. * **Docs:** Submit pull requests to the **[Midnight Docs repository](https://github.com/midnightntwrk/midnight-docs) **. * **Core Libraries:** Submit pull requests to **[MidnightJs](https://github.com/midnightntwrk/midnight-js) **. * **No-code / Low-code:** Create pull requests in the **[Community Hub](https://github.com/midnightntwrk/community-hub) ** using the [submission template](https://github.com/midnightntwrk/community-hub/tree/main/Events) . Once reviewed and approved, qualifying issues will be labeled **`hacktoberfest-accepted`**. Have an idea others can contribute to? Create an issue in the **[Community Hub](https://github.com/midnightntwrk/community-hub) ** using the following templates: * `dapp-proposal` * `content-proposal` * `documentation improvement` To earn additional Midnight-specific rewards, visit our **[Zealy quests](https://zealy.io/cw/midnightnetwork/questboard/) ** and complete the tasks under the [Hacktoberfest Competition quest](https://zealy.io/cw/midnightnetwork/questboard/ffd38a52-cc39-42b4-9880-5b64c18face3/3a29aec7-690c-45a0-a17d-93ea78e65011) . * * * 3\. Rewards[​](https://docs.midnight.network/blog/hacktoberfest25#3-rewards "Direct link to 3. Rewards") --------------------------------------------------------------------------------------------------------- ### 🎖️ Holopin Badge[​](https://docs.midnight.network/blog/hacktoberfest25#%EF%B8%8F-holopin-badge "Direct link to 🎖️ Holopin Badge") Receive the official Hacktoberfest digital badge for contributing to open source. ### 👕 Swag[​](https://docs.midnight.network/blog/hacktoberfest25#-swag "Direct link to 👕 Swag") The first 10,000 participants who successfully complete six (6) accepted PRs/MRs will receive the official Hacktoberfest T-shirt. (Terms & Conditions apply.) Top 3 on the **[Zealy Hacktoberfest leaderboard](https://zealy.io/cw/midnightnetwork/leaderboard/bdd692a0-9543-4e56-8820-6c09f4e2a771) ** win a Midnight T-shirt. ### 🌳 Treenation Reward[​](https://docs.midnight.network/blog/hacktoberfest25#-treenation-reward "Direct link to 🌳 Treenation Reward") Every sixth PR/MR qualifying for a T-shirt will also trigger a Treenation tree-planting contribution, helping make the world a greener place. * * * 4\. Acceptable Contribution Types[​](https://docs.midnight.network/blog/hacktoberfest25#4-acceptable-contribution-types "Direct link to 4. Acceptable Contribution Types") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Contributions may include, but are not limited to: * Code updates to MidnightJs * Technical documentation * User experience testing * Technical blog posts or tutorials * Case studies or written articles * Copywriting or editing * Translations * Talks or presentations * Event organization * Podcasts or interviews * Social media campaigns * Blog or video content * Graphic design or visual assets * * * Ready to start contributing? Explore open issues on the **[Midnight Community Hub](https://github.com/midnightntwrk/community-hub) ** and make your mark this Hacktoberfest! * [1\. Registration](https://docs.midnight.network/blog/hacktoberfest25#1-registration) * [2\. Hacktoberfest Participation](https://docs.midnight.network/blog/hacktoberfest25#2-hacktoberfest-participation) * [3\. Rewards](https://docs.midnight.network/blog/hacktoberfest25#3-rewards) * [🎖️ Holopin Badge](https://docs.midnight.network/blog/hacktoberfest25#%EF%B8%8F-holopin-badge) * [👕 Swag](https://docs.midnight.network/blog/hacktoberfest25#-swag) * [🌳 Treenation Reward](https://docs.midnight.network/blog/hacktoberfest25#-treenation-reward) * [4\. Acceptable Contribution Types](https://docs.midnight.network/blog/hacktoberfest25#4-acceptable-contribution-types) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/from-frustration-to-framework#__docusaurus_skipToContent_fallback) After participating in three hackathons this year, I thought I had a good idea of what to expect. Then came the fourth. It began like the others: an idea, a challenge, a blank terminal screen. But this one took an unexpected turn, one I didn't see coming. I had recently left my software engineering role to explore zero-knowledge protocols, an area in which I didn’t have much experience. It was a risk, but one I felt I had to take. I chose to pursue this path not only because zero-knowledge cryptography is built on one of the most elegant branches of mathematics, but also I believe privacy on the blockchain or on the internet is fundamental and should never be an afterthought. One day, my mentor casually mentioned the [African Blockchain Championship](https://www.africanblockchamp.com/) and suggested I look into the Zero-Knowledge track. That small nudge became a turning point. That’s when I discovered [Midnight](https://midnight.network/) ! Meet Midnight: Privacy on the Blockchain ======================================== Midnight is a zero-knowledge proof-based privacy chain developed by Input Output, the parent company of Cardano. As a partner chain of Cardano, it aims to bring rational privacy through zero-knowledge technology to the broader ecosystem. They weren’t just building another blockchain—they were laying the foundation for private, decentralized computation. After diving into the documentation and setting up the tools, everything was finally in place. All that remained… was to begin. Only later did I realize: this wasn’t just the start of another hackathon—it was the beginning of something much bigger. Building on Midnight ==================== Hacking on Midnight was challenging, as building in a testnet environment requires constant learning and adaptation to major changes. Within just a few weeks, significant network updates rendered the existing examples incompatible with the latest SDK versions. As a result, an example had to be cloned and debugged line by line. The example repository was dense, filled with layers of files and directories, and figuring out where to start was a challenge in itself. Fortunately, Midnight’s smart contract language, [Compact](https://docs.midnight.network/develop/reference/compact/) , shares a syntax similar to TypeScript, which eased the learning curve. I pushed forward, determined to build something meaningful and make my mark—but in the end, my attempt fell short. With midterm exams approaching and the hackathon submission deadline close by, I had to make a difficult decision. I decided not to submit a project to the African Blockchain Championship hackathon. Still, a quiet sense of regret lingered. I couldn’t help but wonder: what if I had just pushed a _little_ harder? The Extended Deadline ===================== About a week later, I received an email from the ABC team announcing that the hackathon deadline had been extended. I was thrilled, and I promised myself I’d give it everything this time. It wasn’t long before I was back at it. A few weeks had passed since I’d last touched the project, and during that time, both the network and SDKs had been updated. I gathered my gear, updated my environment, and set out with renewed determination to finally build something solid. I wrote my contract and began debugging, but each change introduced a new layer of complexity. Every update required changes across multiple files. It was frustrating, exhausting, but strangely thrilling. I began thinking of ways to simplify the chaos, to make the process less painful, more intuitive. That’s when I started creating small scripts to streamline the workflow. Earlier that month, I had joined the [Midnight Discord](https://discord.com/invite/midnightnetwork) to ask questions. One week, I jumped on a Discord community call, and to my surprise, I learned about an ongoing Midnight tooling hackathon that was happening asynchronously. Right then, it clicked: _this_ was the hackathon I was meant to be part of from the start. From Personal Tool to Shared Project ==================================== What started as a personal tool suddenly took on a bigger purpose. The hackathon provided me with the opportunity to share my work with others and contribute to shaping the future of smart contract development on Midnight. I took a little detour from my original hackathon submission—promising myself I’d return to it—and began refining the tool, aiming not just to build something functional, but something genuinely useful for newcomers to the ecosystem. Scaffold Midnight & Create Midnight App[​](https://docs.midnight.network/blog/from-frustration-to-framework#scaffold-midnight--create-midnight-app "Direct link to Scaffold Midnight & Create Midnight App") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- That’s how [**Scaffold Midnight**](http://github.com/kaleababayneh/scaffold-midnight) was born, a cloneable GitHub starter template. But I didn’t stop there. I realized it would be even more useful as an npm library, something developers could install with all dependencies bundled and start using right away. So, I polished the project and released the first version as [**create-midnight-app**](https://www.npmjs.com/package/create-midnight-app) . But I didn’t want to stop at solving just one problem. Every issue I fixed revealed another. Through multiple iterations, I kept refining the library. It’s now at version 2.1.7, and I’m actively working to make it compatible with the latest release of Compact. It’s far from perfect, and that’s what makes it exciting. Every day, I wake up with a new idea, a new feature to add, or a better way to improve the developer experience! ![Create Midnight App](https://ibin.co/8rMdmI75JRDl.png) At its core, **create-midnight-app** is a scaffolding npm library for Midnight that automates the entire setup process. Developers can focus solely on writing their Compact contracts; the tool takes care of the rest. It handles wallet creation, faucet requests, balance checks, API configuration, CLI updates, and even function and file change imports are updated automatically. It reduces initial application setup time from over half an hour to just a few minutes. I had several euphoric moments while working on this project, but one instance in particular, stands out. One feature I was eager to build was a way for developers to request testnet tokens without ever leaving their code editor. The simplest idea was to send a request from the terminal directly to the official [Midnight faucet](https://docs.midnight.network/blog/%20https://midnight.network/test-faucet) . But there was a catch—the site is protected by [Cloudflare Turnstile](https://www.cloudflare.com/application-services/products/turnstile/) , which blocks automated requests to prevent spam and abuse. As a hacker, I started looking for a workaround. After some Googling and tips from friends, I tested several paid tools that claimed to bypass CAPTCHA protections. I spent an entire afternoon trying them, but none worked reliably. That’s when I remembered the genesis wallet, whose private key is publicly available. So, I implemented a workaround: instead of calling the faucet, I simulated a faucet transaction by transferring tokens directly from the genesis wallet to the user’s wallet. It’s not a long-term solution, and I know it won’t scale—but for now, it works and helps streamline the developer experience. Submission and Recognition ========================== I finally submitted my project, and the judges’ reactions were incredibly [encouraging](https://youtu.be/xrCEBIBqS-Y?t=4453) —it gave me a renewed sense of inspiration. With that momentum, I turned my focus back to my original hackathon: the African Blockchain Championship. For this challenge, I built an anonymous, censorship-resistant voting platform. In many African countries—across 34 nations—roughly 30–40% of citizens no longer view voting as a fair or trustworthy process (Afrobarometer, 2023). That’s why anonymous voting isn’t just a feature—it’s a necessity. My project, [**Privote**](https://github.com/kaleababayneh/zkvote-midnight) , aims to address this critical issue by leveraging zero-knowledge technology to protect voter identity and integrity. As the submission deadline approached, I ran into a major hurdle: integrating the wallet into the frontend. I reached out to one of the Developer Relations Engineers, who kindly shared some example code. Unfortunately, I couldn’t get it working in time. With the clock ticking, I had to improvise. I quickly built a custom Chrome extension that enabled wallet interaction—running through the terminal on the backend—just in time for submission. While the current version still has some privacy limitations, the smart contract compiles successfully, and users can interact with it on the Midnight testnet—offering a real glimpse of what decentralized, anonymous voting could look like in practice. ![Private Hackathon](https://ibin.co/8rMho4816dhp.png) The Midnight Community ====================== Even though there aren’t many resources available yet, the Midnight community more than makes up for it. Almost every question asked on Discord gets a response. It’s a space where people genuinely support each other—even during hackathons, when we’re technically competing and have little incentive to help other teams. In fact, during the hackathon, I often found myself answering questions in the Telegram group. I even hosted a workshop at the ABC hackathon on how to use **Create Midnight App**, helping others get started quickly and navigate the ecosystem more easily. I also want to take a moment to thank the Midnight team for the recognition they gave me—it truly meant a lot. Beyond placing first in the CLI track, the support and appreciation I received from the community were genuinely heartwarming. I even had the chance to join a community call—not just as a participant this time, but as a [speaker](https://x.com/MidnightNtwrk/status/1942969613496758398) —to share my journey and the lessons I’d learned along the way. Why Now is the Time to Build on Midnight ======================================== And for you—my readers—this is honestly the best time to get involved in the Midnight ecosystem. There’s _almost always_ a hackathon happening (seriously, it's kind of wild!). Right now, they’re even running a [mini DApp hackathon](https://midnight.network/hackathon/midnight-mini-dapp-hackathon) . It’s an excellent opportunity to learn, build, and get your project noticed. ![Midnight Dapp Hackathon](https://ibin.co/8rMcCFquPRqS.png) As for me, I’m currently building something new for the hackathon. While I enjoy working on projects, I’ve found even more fulfillment in developing infrastructure tools. I have a long-term goal of building a web-based Midnight playground where anyone can start writing Compact code and begin interacting with the Midnight testnet without needing to install anything. I hope to continue collaborating with the Midnight team and growing my skills—especially in zero-knowledge protocols—as I continue this journey. * [Scaffold Midnight & Create Midnight App](https://docs.midnight.network/blog/from-frustration-to-framework#scaffold-midnight--create-midnight-app) --- # One doc tagged with "error codes" | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/tags/error-codes#__docusaurus_skipToContent_fallback) [Error codes\ -----------](https://docs.midnight.network/api-reference/overview/error-codes) Learn about the error codes for the Midnight APIs. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#__docusaurus_skipToContent_fallback) Introduction to the FungibleToken contract on Midnight[​](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#introduction-to-the-fungibletoken-contract-on-midnight "Direct link to Introduction to the FungibleToken contract on Midnight") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- **Midnight** is a privacy-first blockchain designed to bring _privacy_ to decentralized applications. It achieves this through [zero-knowledge proofs, programmable data protection, and developer-friendly tools](https://docs.midnight.network/develop/how-midnight-works/) like **Compact**, a TypeScript-based DSL (Domain-Specific Language) for writing privacy-aware smart contracts. [**OpenZeppelin**](https://docs.openzeppelin.com/) is renowned in the Ethereum ecosystem for its battle-tested smart contract libraries, which have secured trillions in on-chain value. Recently, [OpenZeppelin partnered with Midnight](https://midnight.network/blog/openzeppelin-joins-forces-with-midnight-to-shape-the-future-of-privacy-preserving-smart) to bring comparable tooling to the Compact ecosystem, adapting familiar standards like ERC-20 into privacy-preserving variants. In the Ethereum world, the **ERC-20** standard defines a fungible token with public ledger functions like `balanceOf`, `transfer`, `approve`, etc. It exposes transaction data transparently and lacks built-in privacy. The **FungibleToken** contract on Midnight draws inspiration from this, but operates within Midnight’s zero-knowledge, selective-disclosure framework. Fungible tokens are a cornerstone of the blockchain ecosystem, representing digital assets that are interchangeable – much like traditional currency. On various blockchains, these tokens power a wide array of applications, from facilitating seamless transactions and enabling decentralized finance (DeFi) protocols to representing ownership in digital communities and driving the mechanics of in-game economies. Unlike unique non-fungible tokens (NFTs), the value of one fungible token is identical to another of the same type, making them ideal for use cases requiring divisibility and ease of exchange. Their widespread adoption underscores their importance in building liquid and interconnected digital economies. In this article, you'll learn about the core features of the contract, including how it manages ledger state variables, its key entry points and circuits for operations like minting, burning, and transferring tokens, and the essential safety and utility functions provided by the **Utils** and **Initializable** modules. By understanding how these components fit together, you’ll gain insight into how the **FungibleToken** contract balances fungibility, usability, and privacy, providing an essential building block for privacy-preserving DeFi, identity, and tokenized assets on Midnight. * * * Features of the FungibleToken Contract[​](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#features-of-the-fungibletoken-contract "Direct link to Features of the FungibleToken Contract") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- The FungibleToken contract on Midnight utilizes ledger state variables to keep track of balances, allowances, total supply, name, symbol, and decimals. Its functionality is exposed through "circuits" (entry points) like `Mint`, `Burn`, `Transfer`, `Approve`, `TransferFrom`, and `Initialize`, all of which enforce specific zero-knowledge validated transitions and maintain the integrity of the token's state. ### Ledger State Variables[​](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#ledger-state-variables "Direct link to Ledger State Variables") In Compact, the contract defines a structured **state** storing token balances and allowances—similar to ERC-20. The `_balances` map keeps track of the users’ token balances and is updated when a transfer occurs. The `_allowances` map keeps track of the permission given to specific users to spend tokens on behalf of another user: export ledger _balances: Map, Uint<128>>;export ledger _allowances: Map, Map, Uint<128>>>; These values live in the contract's ledger and are updated through transactions sent to the contract. There are other values in the ledger that are set when the contract is deployed: export ledger _totalSupply: Uint<128>;export sealed ledger _name: Opaque<"string">;export sealed ledger _symbol: Opaque<"string">;export sealed ledger _decimals: Uint<8>; These values provide different information about the token managed by the contract, its total supply, its name, its symbol, and its decimal (for display). ### Entry Points and Circuits[​](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#entry-points-and-circuits "Direct link to Entry Points and Circuits") In Compact, entry points are defined as **circuits** (akin to Solidity functions), each modelling a zero-knowledge validated transition. The difference between a circuit entry point and a circuit is that the entry point is callable via a transaction, while the non-entry point circuit is internal. Core circuits include: * **`Mint` / `Burn`** (to mint new tokens or burn existing tokens). * **`Transfer`**: to move tokens between addresses. * **`Approve`**, **`TransferFrom`**: standard ERC-20-style delegation mechanisms. * **`Initialize`**: via the **Initializable** module for contract setup. Each circuit enforces necessary constraints — for example, ensuring sufficient balance, managing allowance decrements, and preserving total supply. In the next step of the contract lifecycle, the different metadata stored in the ledger of the contract are safely initialized. Initialization and Metadata\*\*[​](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#initialization-and-metadata "Direct link to Initialization and Metadata**") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- The following circuits define the essential setup and retrieval logic for the fungible token metadata and users’ balances, enforcing correct initialization. * **`initialize(name_, symbol_, decimals_)`** One-time setup. Calls `Initializable_initialize()`, then stores the (disclosed) name, symbol, and decimals. Every other public circuit asserts that the contract is initialized first. * **`name()` / `symbol()` / `decimals()` / `totalSupply()`** Simple getters that first assert initialized, then return the sealed (read only) ledger values. * **`balanceOf(account)`** Safe map lookup that returns `0` if the account isn’t present (to prevent contract failure if the key is absent). * * * The Transfer Family[​](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#the-transfer-family "Direct link to The Transfer Family") ---------------------------------------------------------------------------------------------------------------------------------------------------------- The `FungibleToken` contract's **transfer** circuits manage token movement. Key circuits include: `transfer` for safe user-initiated transfers, `_unsafeTransfer` for internal token movement, `_transfer` for administrative transfers, `_unsafeUncheckedTransfer` for low-level token movement, and `_update` as the central accounting function for all token operations. These are split into **safe** and **unsafe** variants because **sending to contract addresses is currently disallowed** (until contract-to-contract interactions are supported). “Safe” circuits enforce that policy; “unsafe” ones let you bypass it—explicitly marked as dangerous in comments. * **`transfer(to, value)` → `Boolean`** Safe user-initiated transfer: rejects if `to` is a `ContractAddress`. Internally, it just forwards to the unsafe variant after the check. * **`_unsafeTransfer(to, value)` → `Boolean`** Owner is the caller (`left(ownPublicKey())`). Moves value using the unchecked internal mover, then returns `true`. * **`_transfer(from, to, value)` → `[]`** Admin/extension hook that moves tokens **from an arbitrary `from`** (not necessarily the caller). Still enforces the “no contracts as `to`” rule and then uses the same mover underneath. * **`_unsafeUncheckedTransfer(from, to, value)` → `[]`** The low-level mover checks that neither side is the zero/burn address and then delegates the actual accounting to `_update`. * **`_update(from, to, value)` → `[]`** **Central accounting function** used by all mint/burn/transfer paths. It’s an internal circuit; it cannot be called via a transaction. * If `from` is zero, the **mint** circuit is called, it asserts no `uint128` overflow, and increases `_totalSupply`. * Else, it deducts from `from` balance (or reverts on insufficient funds). * If `to` is zero, the **burn** circuit is called, and it decreases `_totalSupply`. * Else, it adds to `to` balance. This single function guarantees the invariants for every movement of value. The "transfer family" circuits ensure secure token movement, with "safe" variants disallowing transfers to contract addresses and "unsafe" variants providing lower-level control. This leads us to explore how allowances function, enabling delegated token spending. * * * Allowances (approve / spend / transferFrom)[​](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#allowances-approve--spend--transferfrom "Direct link to Allowances (approve / spend / transferFrom)") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ This section details the allowance mechanisms within the FungibleToken contract, which enable users to delegate spending permissions to other addresses. These circuits facilitate secure, approved transfers on behalf of an owner without directly exposing their private keys. * **`allowance(owner, spender)`** Read the nested `_allowances` map, returning `0` when keys are missing (no revert). * **`approve(spender, value)` → `Boolean`** The owner is the caller. Forwards to `_approve(owner, spender, value)` and returns `true`. * **`transferFrom(from, to, value)` → `Boolean`** Safe delegated transfer: enforces the “no contract receiver” rule, then defers to `_unsafeTransferFrom`. * **`_unsafeTransferFrom(from, to, value)` → `Boolean`** The spender is the caller. First spends allowance via `_spendAllowance(from, spender, value)`, then moves value using `_unsafeUncheckedTransfer`. Returns `true`. * **`_approve(owner, spender, value)` → `[]`** It ensures that both the owner and the spender are valid, creates the owner’s entry in the map if needed, and then writes the allowance. (This mirrors OZ’s ERC-20 pattern of public `approve()` → internal `_approve()`.) * **`_spendAllowance(owner, spender, value)` → `[]`** It deducts from the allowance unless it’s “infinite.” The implementation treats **`MAX_UINT128`** as infinite: if `currentAllowance == MAX`, it doesn’t decrement; otherwise, it asserts `currentAllowance ≥ value` and writes back `currentAllowance - value`. This is important because it supports “no-friction approvals” by letting apps set MAX once. So, we just covered how allowances let people delegate token spending—basically, giving others permission to move their tokens. Up next, we'll dive into how we create and delete tokens in the contract. * * * Minting and Burning[​](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#minting-and-burning "Direct link to Minting and Burning") ---------------------------------------------------------------------------------------------------------------------------------------------------------- Here's how the FungibleToken contract handles making and destroying tokens. We'll dive into the `_mint` and `_burn` functions, showing what they do and how they link up with the main accounting system. * **`_mint(account, value)`** (safe) → `[]` It forbids minting **to** a contract address (same contract-to-contract restriction), then forwards to `_unsafeMint`. * **`_unsafeMint(account, value)`** → `[]` It validates the receiver’s address, then calls `_update(burnAddress(), account, value)`—i.e., mint is modelled as a transfer **from** the burn/zero address. * **`_burn(account, value)`** → `[]` It validates the sender’s address, then calls `_update(account, burnAddress(), value)`—i.e., burn is a transfer **to** the burn/zero address. _Note:_ The actual notion of “zero/burn” address is standardized in the Utils module; you can also see helpers like `Utils_isKeyOrAddressZero` and `Utils_isContractAddress`. Because mint and burn also route through `_update`, **total supply is adjusted in exactly one place,** and the same safety checks apply across all flows (including the `uint128` overflow check on mint). The mint and burn circuits, by using the `_update` function, make sure the total supply adjustments are always consistent and that all token flows get the same safety checks. Now, let's dive into the extra safety and utility stuff that the `Utils` and `Initializable` modules bring to the table. * * * Safety and Utility Glue (from `Utils` and `Initializable`)[​](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#safety-and-utility-glue-from-utils-and-initializable "Direct link to safety-and-utility-glue-from-utils-and-initializable") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- This section explores how the `Utils` and `Initializable` modules provide essential safeguards and helpful functionalities. These components are vital for ensuring the contract's integrity and enabling secure, well-managed operations. * **Initialization guards**: The `Initializable_initialize` and `Initializable_assertInitialized` functions serve as crucial initialization guards within the `Initializable` contract. These safeguards ensure that a contract's state is properly set up only once and that subsequent operations only proceed if the contract has been correctly initialized. Every circuit that interacts with or modifies the contract's state is designed to invoke the `assert` function, reinforcing the integrity of the initialization process. * **Address helpers**: * `Utils_isContractAddress(either)` distinguishes user keys from contract addresses. * `Utils_isKeyOrAddressZero(either)` detects the zero/burn address used in `_update`, `_unsafeUncheckedTransfer`, etc. These support the temporary “no contract receiver” policy and zero-address checks. The **Utils** and **Initializable** modules provide crucial safety and utility functions, ensuring the contract's proper setup and secure operation. Now, let's look at how all these different parts of the **FungibleToken** contract work together. * * * How the Pieces Fit Together[​](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#how-the-pieces-fit-together "Direct link to How the Pieces Fit Together") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- This part shows how everything in the FungibleToken contract is hooked up. Whether it's you sending tokens, someone else doing it for you, or tokens being created or destroyed, it all funnels through a few key functions and ultimately lands in the main `_update` function to keep track of everything. * User transfer: `transfer` → _(safe check)_ → `_unsafeTransfer` → `_unsafeUncheckedTransfer` → `_update` (balances/supply) * Delegated transfer: `transferFrom` → _(safe check)_ → `_unsafeTransferFrom` → `_spendAllowance` → `_unsafeUncheckedTransfer` → `_update` * Mint/Burn: `_mint/_unsafeMint` or `_burn` → `_update` (with zero/burn address on one side) This section illustrates how various token operations, from user transfers to minting and burning, ultimately funnel through the central `_update` function for consistent accounting. Now, let's summarize the key takeaways of the **FungibleToken** contract on Midnight. * * * Conclusion[​](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#conclusion "Direct link to Conclusion") ------------------------------------------------------------------------------------------------------------------------------- The **FungibleToken** Compact contract on Midnight is a privacy-aware reimagining of the ERC-20 standard. It maintains the familiar token interfaces—balances, transfers, approvals—but encodes them as ZK-validated circuits within Compact, enabling private, verifiable execution. The contract’s state and logic are shielded by design, exposing only proofs rather than raw data to the blockchain. The ERC-20 standard revolutionized the crypto landscape by providing a common framework for creating and managing digital assets, fostering interoperability, and accelerating the growth of decentralized applications. For Midnight, an ERC-20-based token is crucial as it leverages this established standard while integrating ZK-privacy, offering a familiar yet enhanced experience for developers and users seeking both functionality and confidentiality. This model contrasts sharply with ERC-20 on Ethereum, where all token movements and balances are fully transparent. Here, Midnight allows selective disclosure: users and applications choose what to reveal. The **FungibleToken** contract thus balances fungibility, usability, and privacy—providing an essential building block for privacy-preserving DeFi, identity, and tokenized assets on Midnight. * * * Links[​](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#links "Direct link to Links") ---------------------------------------------------------------------------------------------------------------- Delve deeper into the code, contracts, and comprehensive documentation to enhance your understanding and development skills. These resources are invaluable for building robust and innovative solutions. * FungibleToken contract: [FungibleToken.compact on Github](https://github.com/OpenZeppelin/compact-contracts/blob/main/contracts/fungibleToken/src/FungibleToken.compact) * OpenZeppelin documentation: [docs.openzeppelin.com](https://docs.openzeppelin.com/contracts-compact/0.0.1/fungibletoken) * ERC20 standard: [ethereum.org](https://ethereum.org/en/developers/docs/standards/tokens/erc-20/) * Midnight docs: [Midnight Developer Documentation](https://docs.midnight.network/) * Do you have any questions?: [Midnight Forum](https://forum.midnight.network/) * [Introduction to the FungibleToken contract on Midnight](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#introduction-to-the-fungibletoken-contract-on-midnight) * [Features of the FungibleToken Contract](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#features-of-the-fungibletoken-contract) * [Ledger State Variables](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#ledger-state-variables) * [Entry Points and Circuits](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#entry-points-and-circuits) * [Initialization and Metadata\*\*](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#initialization-and-metadata) * [The Transfer Family](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#the-transfer-family) * [Allowances (approve / spend / transferFrom)](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#allowances-approve--spend--transferfrom) * [Minting and Burning](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#minting-and-burning) * [Safety and Utility Glue (from `Utils` and `Initializable`)](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#safety-and-utility-glue-from-utils-and-initializable) * [How the Pieces Fit Together](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#how-the-pieces-fit-together) * [Conclusion](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#conclusion) * [Links](https://docs.midnight.network/blog/funbigle-token-contract-open-zeppelin#links) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/meeting#__docusaurus_skipToContent_fallback) The Midnight testnet upgrade to Partner-Chains v1.5 requires SPO re-registration, adds BLS support, and is expected to roll out by May 2025. **Date**: April 10, 2025 **Time**: 12:00 PM EDT **Topic**: Midnight Testnet Upgrade (Partner-Chains 1.5, BLS, Ledger Support) Agenda[​](https://docs.midnight.network/blog/meeting#agenda "Direct link to Agenda") ------------------------------------------------------------------------------------- 1. Midnight Testnet Upgrade Overview 2. Impact on Stake Pool Operators (SPOs) 3. Impact on Developers 4. Estimated Timeline 5. Q&A Meeting Notes[​](https://docs.midnight.network/blog/meeting#meeting-notes "Direct link to Meeting Notes") ---------------------------------------------------------------------------------------------------------- ### Midnight Testnet Upgrade Overview[​](https://docs.midnight.network/blog/meeting#midnight-testnet-upgrade-overview "Direct link to Midnight Testnet Upgrade Overview") * Discussed the upcoming Midnight testnet upgrade as detailed in the [official blog post](https://midnight.network/blog/upcoming-testnet-02-upgrade-all-you-need-to-know) . ### Impact on Stake Pool Operators (SPOs)[​](https://docs.midnight.network/blog/meeting#impact-on-stake-pool-operators-spos "Direct link to Impact on Stake Pool Operators (SPOs)") * SPOs are required to re-register for the upgrade. * Improved user experience (UX) for registration: * No dependency on Kupo. * No need for `pc-contracts-cli`. * Support for extended keys. * Enhanced performance for `midnight-node`. ### Impact on Developers[​](https://docs.midnight.network/blog/meeting#impact-on-developers "Direct link to Impact on Developers") * Developers will be expected to update all Midnight components, including: * Midnight JS * Wallet * Faucet * The proving system will transition from Pluto-Eris to BLS, requiring BLS-compatible components. * Compact contracts should remain functional but will need: * Recompilation with BLS support using the proof-server. * Redeployment. ### Estimated Timeline[​](https://docs.midnight.network/blog/meeting#estimated-timeline "Direct link to Estimated Timeline") * **ETA**: Around May 2025 (potentially late April or early May). * A precise maintenance window will be communicated proactively. * Stakeholders are advised to monitor for updates on the exact ETA. Q&A Session[​](https://docs.midnight.network/blog/meeting#qa-session "Direct link to Q&A Session") --------------------------------------------------------------------------------------------------- **Q: Is it possible to eliminate the need for `db-sync` in the future?** * Feedback about `db-sync` has been noted and shared with partner-chains. * For Partner-Chains v1.5 (the version targeted for this upgrade), Kupo has been eliminated. **Q: Where is SPO registration stored if it’s not on-chain, and what happens if the database is removed?** * Registrations are stored on the Cardano preview testnet within Midnight’s partner-chain contract. * Due to the reset, re-registration will be required. * Suggested upgrade sequence: 1. Re-register. 2. Update to the latest `midnight-node` version. 3. Delete the old `midnight-node` database. 4. Run `midnight-node` in validator mode. **Q: Will Midnight Core Calls be recurring?** * Yes, scheduled for the second Thursday of every month. * Additional calls may be organized based on need. **Q: Is there a benchmark for transactions in the Battleship game? (Brick Towers offered to test)** * No specific benchmarks have been established yet. * Game rounds are expected to be significantly faster. **Q: When will the upgrade roll out?** * Target is near May 2025, potentially late April or early May. * A precise maintenance window will be communicated soon. Action Items[​](https://docs.midnight.network/blog/meeting#action-items "Direct link to Action Items") ------------------------------------------------------------------------------------------------------- * **MN Team**: Will share precise maintenance window and ETA for the upgrade. * **SPOs**: Prepare for re-registration and update to Partner-Chains v1.5. * **Developers**: Will be expected to update Midnight components and recompile/deploy contracts with BLS support. * **All**: Join the [Block-Producers](https://discord.com/channels/1165826384975908924/1328720589548032032) channel on Discord to engage in deeper conversations with fellow SPOs. * [Agenda](https://docs.midnight.network/blog/meeting#agenda) * [Meeting Notes](https://docs.midnight.network/blog/meeting#meeting-notes) * [Midnight Testnet Upgrade Overview](https://docs.midnight.network/blog/meeting#midnight-testnet-upgrade-overview) * [Impact on Stake Pool Operators (SPOs)](https://docs.midnight.network/blog/meeting#impact-on-stake-pool-operators-spos) * [Impact on Developers](https://docs.midnight.network/blog/meeting#impact-on-developers) * [Estimated Timeline](https://docs.midnight.network/blog/meeting#estimated-timeline) * [Q&A Session](https://docs.midnight.network/blog/meeting#qa-session) * [Action Items](https://docs.midnight.network/blog/meeting#action-items) --- # One doc tagged with "rate limits" | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/tags/rate-limits#__docusaurus_skipToContent_fallback) [Rate limits\ -----------](https://docs.midnight.network/api-reference/overview/rate-limits) Learn about the rate limits for the Midnight APIs. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/midnight-indexer#__docusaurus_skipToContent_fallback) We’re excited to announce the release of the new [Midnight Indexer](https://docs.midnight.network/relnotes/midnight-indexer) — a modular, high-performance indexer that streamlines blockchain data flow from Midnight nodes to end-user apps This new Indexer retrieves block history, processes data, and makes it available through a flexible GraphQL API supporting queries, mutations, and real-time subscriptions. It is written in Rust and is intended to replace the legacy Scala-based Indexer in the future. It offers significantly improved performance, easier deployments across local and cloud environments, and deep wallet integration. Midnight Indexer supports both PostgreSQL and SQLite. Key Improvements Over the Legacy Indexer[​](https://docs.midnight.network/blog/midnight-indexer#key-improvements-over-the-legacy-indexer "Direct link to Key Improvements Over the Legacy Indexer") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 🦀 Rewritten in Rust for improved speed, reliability, and maintainability 🧱 Modular architecture, replacing the monolithic Scala pub-sub design 🤝 Deep integration with latest wallet tooling (SDK v4+ and Lace Wallet v2.0.0+) 🌐 Flexible GraphQL API with subscription support for real-time updates If you're building on Midnight, now’s the time to begin testing integrations and preparing for migration. The Scala-based Pub-Sub Indexer remains functional for now but is officially deprecated and will be phased out in future releases. 📢 Deprecation Notice While the Scala-based Pub-Sub Indexer remains available for now, it is officially deprecated and will be phased out in future releases. If you’re building on Midnight, now is the time to begin testing the new Indexer and preparing for migration. * [Key Improvements Over the Legacy Indexer](https://docs.midnight.network/blog/midnight-indexer#key-improvements-over-the-legacy-indexer) --- # One doc tagged with "authentication" | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/tags/authentication#__docusaurus_skipToContent_fallback) [Authentication\ --------------](https://docs.midnight.network/api-reference/overview/authentication) Learn about the authentication methods for the Midnight APIs. --- # Tags | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/tags#__docusaurus_skipToContent_fallback) Tags ==== A[​](https://docs.midnight.network/api-reference/tags#A "Direct link to A") ---------------------------------------------------------------------------- * [authentication1](https://docs.midnight.network/api-reference/tags/authentication) * * * E[​](https://docs.midnight.network/api-reference/tags#E "Direct link to E") ---------------------------------------------------------------------------- * [error codes1](https://docs.midnight.network/api-reference/tags/error-codes) * * * R[​](https://docs.midnight.network/api-reference/tags#R "Direct link to R") ---------------------------------------------------------------------------- * [rate limits1](https://docs.midnight.network/api-reference/tags/rate-limits) * * * --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/midnight-indexer-replaces-scala#__docusaurus_skipToContent_fallback) Last month, we introduced the Midnight Indexer, a modular, high-performance indexing service written in Rust. Today, we’re excited to share that the Rust-based Midnight Indexer has officially replaced the legacy Scala-based Pub-Sub Indexer. As of the latest release — v2.1.1 — the new Indexer is now the only supported indexing service for applications building on the Midnight network. What is the Midnight Indexer?[​](https://docs.midnight.network/blog/midnight-indexer-replaces-scala#what-is-the-midnight-indexer "Direct link to What is the Midnight Indexer?") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- The Midnight Indexer is a high-performance, modular system that turns raw node data into queryable information for wallets and applications. It: * Fetches and processes blocks from the Midnight node * Indexes transactions, contract actions, and events * Exposes a GraphQL API supporting queries, mutations, and real-time subscriptions * Connects to wallets securely, delivering filtered, session-scoped data * Supports both PostgreSQL (cloud) and SQLite (local/standalone) How it works[​](https://docs.midnight.network/blog/midnight-indexer-replaces-scala#how-it-works "Direct link to How it works") ------------------------------------------------------------------------------------------------------------------------------- The Indexer is composed of three core components: * **Chain Indexer** - Connects to the node, fetches blocks, extracts transactions and contract activity, and writes to the database. * **Wallet Indexer** - Monitors active wallets and links them to relevant events, enabling personalized real-time data feeds. * **Indexer API** - Serves all indexed data over GraphQL with support for: * Specific queries (by block height/hash, tx ID, or contract address) * Live subscriptions (new blocks, wallet activity, contract calls) * Secure sessions that scope data access per wallet Latest release v2.1.1 highlights[​](https://docs.midnight.network/blog/midnight-indexer-replaces-scala#latest-release-v211-highlights "Direct link to Latest release v2.1.1 highlights") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- The v2.1.1 release brings important patches and internal improvements to the Indexer. It includes bug fixes that correct queries for transactions and contract actions, ensuring they return accurate results. Additionally, the release features refactors that simplify and streamline the application of transactions in the Chain Indexer, using a more idiomatic approach. This version is fully compatible with Midnight Node v0.12, Midnight Wallet v5.0.0 or later, and Lace Wallet v3.0.0 or later. What’s been added since launch?[​](https://docs.midnight.network/blog/midnight-indexer-replaces-scala#whats-been-added-since-launch "Direct link to What’s been added since launch?") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Since the initial release, the Indexer has seen continuous improvements, including: * **GraphQL API Enhancements** * Tracing and counters for operations * Redesign of wallet subscription updates * Cleaner schema naming and contract action handling * **Improved Developer Experience** * Support for Bech32m encoding * Better error logging and observability * Easier configuration and deployment * **More Secure and Stable Sessions** * Wallet session tracking with minimal overhead * Silent handling of harmless database states * **Documentation Updates** * Revised API docs and onboarding materials * Migration notes for teams upgrading from Scala Indexer What this means for you What This Means for You[​](https://docs.midnight.network/blog/midnight-indexer-replaces-scala#what-this-means-for-you "Direct link to What This Means for You") ---------------------------------------------------------------------------------------------------------------------------------------------------------------- The Scala-based Indexer is no longer supported and will not receive further updates. All new development, tooling, and wallet integrations are now aligned with the Rust-based Midnight Indexer. What action do I need to take?[​](https://docs.midnight.network/blog/midnight-indexer-replaces-scala#what-action-do-i-need-to-take "Direct link to What action do I need to take?") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ To ensure full compatibility: * **Update your endpoint** * Replace the legacy Scala endpoint with `https://indexer-rs.testnet-02.midnight.network/api/v1/graphql` * **Test your integrations** * Validate all GraphQL operations (queries, mutations, subscriptions) against the new Indexer. * **Update dependencies** * Midnight Node v0.12+ * Midnight Wallet v5.0.0+ * Lace Wallet v3.0.0+ note The Scala Indexer is no longer supported. All future development is focused on the Rust-based Indexer. Open source release[​](https://docs.midnight.network/blog/midnight-indexer-replaces-scala#open-source-release "Direct link to Open source release") ---------------------------------------------------------------------------------------------------------------------------------------------------- The Rust-based Midnight Indexer is now open-sourced. This means you can view the source code, contribute enhancements, report issues, or fork the project to build your own tools — all directly from [GitHub](https://github.com/midnightntwrk/midnight-indexer) . We welcome contributions from developers at all levels — whether it’s fixing bugs, improving performance, or extending functionality. * [What is the Midnight Indexer?](https://docs.midnight.network/blog/midnight-indexer-replaces-scala#what-is-the-midnight-indexer) * [How it works](https://docs.midnight.network/blog/midnight-indexer-replaces-scala#how-it-works) * [Latest release v2.1.1 highlights](https://docs.midnight.network/blog/midnight-indexer-replaces-scala#latest-release-v211-highlights) * [What’s been added since launch?](https://docs.midnight.network/blog/midnight-indexer-replaces-scala#whats-been-added-since-launch) * [What This Means for You](https://docs.midnight.network/blog/midnight-indexer-replaces-scala#what-this-means-for-you) * [What action do I need to take?](https://docs.midnight.network/blog/midnight-indexer-replaces-scala#what-action-do-i-need-to-take) * [Open source release](https://docs.midnight.network/blog/midnight-indexer-replaces-scala#open-source-release) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/query-the-blockchain#__docusaurus_skipToContent_fallback) The Midnight blockchain introduces a novel approach to data privacy and compliance in decentralized applications (DApps), leveraging zero-knowledge proofs (ZKPs) and a dual-token system. This article provides a comprehensive guide on connecting to the Midnight blockchain, and you will learn how to listen for new blocks and extract data from these blocks using the Polkadot API and the various methods it provides to connect to Substrate-based blockchains, including Midnight. > See the code in action [in this repo](https://github.com/claudebarde/midnight-mempool) > , a simple app that watches the Midnight mempool! **Understanding Midnight's Architecture**[​](https://docs.midnight.network/blog/query-the-blockchain#understanding-midnights-architecture "Direct link to understanding-midnights-architecture") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Midnight is designed to address the limitations of traditional blockchains regarding data privacy. It does so through: * [Zero-Knowledge Proofs (ZKPs)](https://www.google.com/url?q=https://docs.midnight.network/learn/glossary%23zero-knowledge-proof-zkp&sa=D&source=docs&ust=1751469460016839&usg=AOvVaw0GBVs0ZrYgq8Eggpat3hpn) : Enable verification of data without revealing the data itself. * [Dual-Token System](https://www.google.com/url?q=https://docs.midnight.network/learn/introduction/native-token/about-dust&sa=D&source=docs&ust=1751469460016900&usg=AOvVaw1yvGgY8EL1yJB3W61g1LQq) : Uses NIGHT (unshielded) for governance and DUST (shielded) for transaction payments. * [Compact Smart Contract Language](https://www.google.com/url?q=https://docs.midnight.network/develop/reference/compact/&sa=D&source=docs&ust=1751469460016917&usg=AOvVaw0DQvxLVoHOxx7vIhTKZFnG) : A TypeScript-based language facilitating the development of privacy-preserving smart contracts. These features make Midnight suitable for applications requiring data confidentiality, such as healthcare records, financial transactions, and identity verification. Connecting to the Midnight Blockchain[​](https://docs.midnight.network/blog/query-the-blockchain#connecting-to-the-midnight-blockchain "Direct link to Connecting to the Midnight Blockchain") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- The [`@polkadot/api`](https://polkadot.js.org/docs/api/) library provides a WebSocket provider (WsProvider) to connect to Substrate-based blockchains, which includes Midnight. ### Installation[​](https://docs.midnight.network/blog/query-the-blockchain#installation "Direct link to Installation") First, ensure you have the necessary packages installed: npm install @polkadot/api ### Establishing a Connection[​](https://docs.midnight.network/blog/query-the-blockchain#establishing-a-connection "Direct link to Establishing a Connection") Use the WsProvider to connect to a Midnight node: import { ApiPromise, WsProvider } from '@polkadot/api';// Define the WebSocket endpoint for the Midnight node const wsProvider = new WsProvider('wss://rpc.testnet.midnight.network');// Create the API instance const api = await ApiPromise.create({ provider: wsProvider }); Listening for New Blocks[​](https://docs.midnight.network/blog/query-the-blockchain#listening-for-new-blocks "Direct link to Listening for New Blocks") -------------------------------------------------------------------------------------------------------------------------------------------------------- Once connected, you can subscribe to new block headers to listen for new blocks: api.rpc.chain.subscribeNewHeads((lastHeader) => { console.log(`New block #${lastHeader.number} has been added`); }); This function logs the block number each time a new block is added to the chain. Extracting Data from Blocks[​](https://docs.midnight.network/blog/query-the-blockchain#extracting-data-from-blocks "Direct link to Extracting Data from Blocks") ----------------------------------------------------------------------------------------------------------------------------------------------------------------- To extract detailed information from each new block, such as transactions and events, you can use the following approach: api.rpc.chain.subscribeNewHeads(async (lastHeader) => { const blockHash = await api.rpc.chain.getBlockHash(lastHeader.number); const signedBlock = await api.rpc.chain.getBlock(blockHash); const allEvents = await api.query.system.events.at(blockHash); console.log(`nBlock #${lastHeader.number}`); signedBlock.block.extrinsics.forEach((extrinsic, index) => { console.log(`nExtrinsic ${index}: ${extrinsic.method.section}.${extrinsic.method.method}`); console.log(`Arguments: ${extrinsic.args.map((arg) => arg.toString()).join(', ')}`); }); allEvents.forEach(({ event, phase }, index) => { console.log(`nEvent ${index}: ${event.section}.${event.method}`); console.log(`Phase: ${phase.toString()}`); console.log(`Data: ${event.data.toString()}`); }); }); This script subscribes to new block headers, retrieves the full block and its associated events, and logs detailed information about each extrinsic (transaction) and event. What is an extrinsic?[​](https://docs.midnight.network/blog/query-the-blockchain#what-is-an-extrinsic "Direct link to What is an extrinsic?") ---------------------------------------------------------------------------------------------------------------------------------------------- In the context of Substrate-based blockchains like Midnight, an extrinsic refers to any piece of information originating from outside the blockchain's runtime that is submitted to the network for inclusion in a block. Extrinsics are the primary means by which users and external entities interact with the blockchain, enabling state changes and other operations. There are three main types of extrinsics: * **Signed Extrinsics**: These are transactions submitted by users that include a digital signature. They often involve actions like transferring tokens or interacting with smart contracts. The signature ensures authenticity and allows the network to charge transaction fees. * **Unsigned Extrinsics**: These are submitted without a signature and are typically used for operations that don't require user authentication. They might be subject to custom validation logic to prevent misuse. * **Inherent Extrinsics**: Generated by the blockchain itself, these are used for system-level operations, such as setting the timestamp for a new block. They are not propagated through the network like other extrinsics but are included by block producers during block creation. Understanding extrinsics is crucial for developers working with Substrate-based blockchains, as they represent the fundamental mechanism for enacting changes and interacting with the network's state. Conclusion[​](https://docs.midnight.network/blog/query-the-blockchain#conclusion "Direct link to Conclusion") -------------------------------------------------------------------------------------------------------------- By utilizing the WsProvider from the @polkadot/api library, developers can effectively connect to the Midnight blockchain, monitor new blocks in real-time, and extract pertinent data for their applications. This approach provides a robust foundation for building privacy-focused decentralized applications on the Midnight network. > For more information and detailed documentation, visit the [Midnight Developer Hub](https://midnight.network/developer-hub) > . * [**Understanding Midnight's Architecture**](https://docs.midnight.network/blog/query-the-blockchain#understanding-midnights-architecture) * [Connecting to the Midnight Blockchain](https://docs.midnight.network/blog/query-the-blockchain#connecting-to-the-midnight-blockchain) * [Installation](https://docs.midnight.network/blog/query-the-blockchain#installation) * [Establishing a Connection](https://docs.midnight.network/blog/query-the-blockchain#establishing-a-connection) * [Listening for New Blocks](https://docs.midnight.network/blog/query-the-blockchain#listening-for-new-blocks) * [Extracting Data from Blocks](https://docs.midnight.network/blog/query-the-blockchain#extracting-data-from-blocks) * [What is an extrinsic?](https://docs.midnight.network/blog/query-the-blockchain#what-is-an-extrinsic) * [Conclusion](https://docs.midnight.network/blog/query-the-blockchain#conclusion) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/midnight-testnet-upgrade-key-changes#__docusaurus_skipToContent_fallback) A major Midnight Testnet upgrade introduces version 1.5, bringing key changes that require validator re-registration, improved node setup, and enhanced tooling for partner-chain participants. One of the major changes of the [Midnight Testnet upgrade](https://midnight.network/blog/upcoming-testnet-02-upgrade-all-you-need-to-know) is the leap from Partner-Chains version 1.2 to 1.5. This particular change requires Midnight validators to re-register. Why is Midnight taking a leap from 1.2 to 1.5?[​](https://docs.midnight.network/blog/midnight-testnet-upgrade-key-changes#why-is-midnight-taking-a-leap-from-12-to-15 "Direct link to Why is Midnight taking a leap from 1.2 to 1.5?") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- The testnet was operating on v1.2. The upgrade path through v1.4 (specifically the v1.3 -> v1.4 transition) introduced breaking changes in the partner-chain contracts, necessitating a chain reset. To bypass this incompatible intermediate state and minimize disruption, we opted for a direct deployment of the latest stable release, v1.5. How to become a Midnight block producer?[​](https://docs.midnight.network/blog/midnight-testnet-upgrade-key-changes#how-to-become-a-midnight-block-producer "Direct link to How to become a Midnight block producer?") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1. Follow the docs to register your SPO and run a Midnight validator node. The validate section of the Midnight documentation has been updated to reflect the latest changes: [https://docs.midnight.network/validate/run-a-validator/](https://docs.midnight.network/validate/run-a-validator/) 2. Join the Midnight Discord and discuss any questions, issues, or suggestions for improvement in the 📊|block-producers channel: [https://discord.com/invite/midnightnetwork](https://discord.com/invite/midnightnetwork) 3. See [Compatibility Matrix](https://docs.midnight.network/relnotes/support-matrix) for supported component verrsions. Key changes: | Feature/Aspect | v1.2 | v1.5 | | --- | --- | --- | | **CLI Tools** | Users required `partner-chains-cli` and `pc-contracts-cli` binaries, invoked with `./partner-chains-cli `. | Wizards integrated into `midnight-node` commands, e.g., `./midnight-node wizards --help`. No need for separate binaries. | | **Docker Repository** | Hosted at `midnight-ntwrk/midnight-node-docker` (now archived). | Moved to `midnightntwrk/midnight-node-docker` under the official Midnight Foundation org. | | **Service Ports** | Required both Ogmios and Kupo service ports for contract interactions (e.g., registering). | Only Ogmios service port required. | | **Keystore Directory** | Located at `data/chains/testnet-02/…`. | Uses `data/chains/partner_chains_template/…`. New keys generated in `data/chains/undeployed/…` (workaround: rename `undeployed` to `partner_chains_template`). | | **Key Support** | No extended key support; users (e.g., CNTools) had to create new key sets. | Supports BIP32-Ed25519 extended keys. | | **Memory Recommendation** | ~32GB for `midnight-node`. | Reduced to ~16GB due to ledger optimizations. | Common questions: | Question | Answer | | --- | --- | | I was already registered to testnet-02 before this upgrade. Do I have to register again? | Yes. The committee candidate list is completely reset. Therefore, you need to register again. | | I was already registered to testnet-02 before the upgrade. Do I need to deregister? | No. Simply register again to Testnet-02 with the latest Midnight-node version. | | Can I use my existing keys? | Yes. Use them for the registration sequence. | | I was already registered to testnet-02 before the upgrade. In what order should I go about re-registering? | 1\. Optional: Backup your Partner-chain keys if you intend to reuse the same keys.
2\. Stop the Midnight-validator node and delete the Midnight-node db.
3\. Register using the latest documentation.
4\. Run the latest Midnight-node in validator mode and produce blocks. | | I’m not an existing Midnight validator, but interested in registering my SPO as one. Do I have to re-register? | 1\. Register using the latest documentation.
2\. Run the latest Midnight-node in validator mode and produce blocks. | | Is Cardano-db-sync still required? | Yes. The Midnight-node needs a persistent connection to Cardano-db-sync. v1.5 only eliminates the Kupo service from the Partner-chains stack. | * [Why is Midnight taking a leap from 1.2 to 1.5?](https://docs.midnight.network/blog/midnight-testnet-upgrade-key-changes#why-is-midnight-taking-a-leap-from-12-to-15) * [How to become a Midnight block producer?](https://docs.midnight.network/blog/midnight-testnet-upgrade-key-changes#how-to-become-a-midnight-block-producer) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/open-sourcing-examples#__docusaurus_skipToContent_fallback) Midnight's Developer Relations team is actively shaping how developers learn, build, and experiment with privacy-first apps. In this post, we take a closer look at how DevRel is lowering the barrier to entry for new builders, supporting open-source tools, and helping the community navigate the unique challenges of developing on a privacy-preserving blockchain. From ZIP Files to GitHub: Opening the Gates[​](https://docs.midnight.network/blog/open-sourcing-examples#from-zip-files-to-github-opening-the-gates "Direct link to From ZIP Files to GitHub: Opening the Gates") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Midnight is entering a new phase in our developer journey. Until now, developers had to download ZIP files from our documentation site just to get started. No versioning, no collaboration, no visibility. That changes today. The DevRel team is proud to share our first two open source example repositories: [`example-counter`](https://github.com/midnightntwrk/example-counter) and [`example-bboard`](https://github.com/midnightntwrk/example-bboard) . These projects are more than demos. They’re intentionally scoped, composable references designed to help developers explore what’s possible with Midnight’s privacy-first architecture. While our broader engineering team continues to open source core protocol components, these repos mark a different kind of milestone: showing others how to build on top of Midnight’s foundation. With versioned code and public visibility, developers can now fork, remix, and build with confidence. A Simple Contract With a Purpose[​](https://docs.midnight.network/blog/open-sourcing-examples#a-simple-contract-with-a-purpose "Direct link to A Simple Contract With a Purpose") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [`example-counter`](https://github.com/midnightntwrk/example-counter) is a minimal dApp that introduces the fundamentals of building on Midnight. It walks through the full development flow: * Writing a Compact smart contract * Running and compiling locally * Using public state * Deploying to the Midnight testnet * Sending transactions pragma language_version >= 0.16;import CompactStandardLibrary;// public stateexport ledger round: Counter;// transition function changing public stateexport circuit increment(): [] { round.increment(1);} It’s designed to build foundational literacy in Compact and Midnight’s dev tooling. It’s a simple but powerful way to learn Compact and become familiar with the development flow on Midnight. Think of it as a `“Hello, World”` for privacy-enhancing dApp development. Enforcing Rules Without Revealing Identity[​](https://docs.midnight.network/blog/open-sourcing-examples#enforcing-rules-without-revealing-identity "Direct link to Enforcing Rules Without Revealing Identity") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [`example-bboard`](https://github.com/midnightntwrk/example-bboard) goes further. It simulates a public bulletin board, where users can post messages, and only the original author can remove their own post. It’s a small app that teaches a big concept: Midnight enables identity-aware rules without revealing identity. This repo covers how to: * Combine public and private state in a Compact contract * Use zero-knowledge proofs to enforce permissions * Validate ownership locally without exposing identity * Design UI flows that respect user privacy by default It’s especially useful for teams exploring anonymous messaging, private voting, or access control without identity leakage. What It Means to Build in the Open[​](https://docs.midnight.network/blog/open-sourcing-examples#what-it-means-to-build-in-the-open "Direct link to What It Means to Build in the Open") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Speaking personally, I’ve spent most of my DevRel career working in open source. But this is the first time I’ve been part of a company transitioning into it. Open sourcing code isn’t just a technical milestone. It’s a culture shift. Releasing code publicly changes how a team thinks and operates. It means moving from perfectionism to progress. From private Slack threads to public GitHub Issues. From “we’ll fix it internally” to “anyone can help improve it.” It’s a commitment to building alongside others, not just for them. These first example repos mark the beginning of that shift for Midnight. They’re designed to help others learn by doing and to demonstrate that **privacy and collaboration can coexist**. Docs Are Up Next[​](https://docs.midnight.network/blog/open-sourcing-examples#docs-are-up-next "Direct link to Docs Are Up Next") ---------------------------------------------------------------------------------------------------------------------------------- We’re also preparing to open source our \[Midnight Docs repo([https://github.com/midnightntwrk/midnight-docs](https://github.com/midnightntwrk/midnight-docs)\ )\]. This is a major step toward transparency, trust, and co-creation. We want the documentation to grow alongside the ecosystem, which means making it easier for contributors to suggest improvements, fix issues, and help shape the developer experience. What’s Next?[​](https://docs.midnight.network/blog/open-sourcing-examples#whats-next "Direct link to What’s Next?") -------------------------------------------------------------------------------------------------------------------- This is just the start. In the coming months, the DevRel team will: * Publish more example dApps (and build them from scratch in the open) * Create reusable components and templates * Contribute improvements upstream to core tooling * Document real-world use cases for easier onboarding We’re building in the open, for those who want to build with us. Explore the Code[​](https://docs.midnight.network/blog/open-sourcing-examples#explore-the-code "Direct link to Explore the Code") ---------------------------------------------------------------------------------------------------------------------------------- * [`example-counter`](https://github.com/midnightntwrk/example-counter) * [`example-bboard`](https://github.com/midnightntwrk/example-bboard) Join the Conversation[​](https://docs.midnight.network/blog/open-sourcing-examples#join-the-conversation "Direct link to Join the Conversation") ------------------------------------------------------------------------------------------------------------------------------------------------- We’d love to hear your feedback, contributions, and ideas. Drop into [Discord](https://discord.gg/midnightnetwork) , open an issue, or fork a repo and show us what you’ve built. * [From ZIP Files to GitHub: Opening the Gates](https://docs.midnight.network/blog/open-sourcing-examples#from-zip-files-to-github-opening-the-gates) * [A Simple Contract With a Purpose](https://docs.midnight.network/blog/open-sourcing-examples#a-simple-contract-with-a-purpose) * [Enforcing Rules Without Revealing Identity](https://docs.midnight.network/blog/open-sourcing-examples#enforcing-rules-without-revealing-identity) * [What It Means to Build in the Open](https://docs.midnight.network/blog/open-sourcing-examples#what-it-means-to-build-in-the-open) * [Docs Are Up Next](https://docs.midnight.network/blog/open-sourcing-examples#docs-are-up-next) * [What’s Next?](https://docs.midnight.network/blog/open-sourcing-examples#whats-next) * [Explore the Code](https://docs.midnight.network/blog/open-sourcing-examples#explore-the-code) * [Join the Conversation](https://docs.midnight.network/blog/open-sourcing-examples#join-the-conversation) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#__docusaurus_skipToContent_fallback) AI coding assistants like Claude, GitHub Copilot, and Cursor have transformed how developers write code. But they have a fundamental limitation: they only know what was in their training data. Compact, Midnight's smart contract language, isn't in that training data. When you ask an AI assistant to write a Compact contract, it hallucinates. It invents syntax that doesn't exist, references functions that were never defined, and produces code that fails at compile time. Midnight MCP solves this problem. What is MCP?[​](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#what-is-mcp "Direct link to What is MCP?") ----------------------------------------------------------------------------------------------------------------------------------- The _Model Context Protocol_ (MCP) is an open standard that allows AI assistants to access external tools and data sources. Instead of relying solely on training data, an AI assistant with MCP can query live documentation, search codebases, and call APIs. Midnight MCP is an MCP server purpose-built for Midnight development. It gives AI assistants: * **Indexed knowledge** of 102 Midnight repositories * **Real compiler validation** before showing you code * **Semantic search** across documentation and examples * **Version-aware syntax references** for Compact When you ask Claude to write a Compact contract, it queries Midnight MCP for the correct syntax, generates the code, validates it against the real compiler, and only shows you working code. The problem with AI-generated Compact code[​](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#the-problem-with-ai-generated-compact-code "Direct link to The problem with AI-generated Compact code") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Consider this prompt: "Write a simple counter contract in Compact" Without Midnight MCP, an AI assistant might generate: contract Counter { state count: Int = 0; function increment(): Void { count = count + 1; }} This looks plausible. It's also completely wrong: * Compact uses `ledger` for state, not `state`. * There is no `Int` type in Compact. It uses `Uint<32>`, `Field`, and other specific types. * `Void` doesn't exist. Compact uses `[]` for the unit type. * State mutations require witness functions, not direct assignment. The AI hallucinated a language that resembles Solidity but isn't Compact. A developer unfamiliar with Compact might spend hours debugging code that was never valid. Install Midnight MCP[​](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#install-midnight-mcp "Direct link to Install Midnight MCP") ------------------------------------------------------------------------------------------------------------------------------------------------------------ Midnight MCP requires no API keys and installs in under 60 seconds. Add the appropriate configuration to your AI assistant based on the tool you use. ### Claude Desktop[​](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#claude-desktop "Direct link to Claude Desktop") On macOS, edit `~/Library/Application Support/Claude/claude_desktop_config.json`. Add the following configuration to enable Midnight MCP: { "mcpServers": { "midnight": { "command": "npx", "args": ["-y", "midnight-mcp@latest"] } }} ### Cursor[​](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#cursor "Direct link to Cursor") Create or edit `.cursor/mcp.json` in your project root. You can also configure it globally at `~/.cursor/mcp.json` on macOS/Linux or `%USERPROFILE%\.cursor\mcp.json` on Windows. Add the following configuration: { "mcpServers": { "midnight": { "command": "npx", "args": ["-y", "midnight-mcp@latest"] } }} ### VS Code with GitHub Copilot[​](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#vs-code-with-github-copilot "Direct link to VS Code with GitHub Copilot") Create or edit `.vscode/mcp.json` in your project. Add the following configuration to connect Copilot to Midnight MCP: { "servers": { "midnight": { "command": "npx", "args": ["-y", "midnight-mcp@latest"] } }} After adding the configuration, restart your AI assistant. You now have access to [29 Midnight-specific tools](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#29-tools-for-midnight-development) . How Midnight MCP works[​](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#how-midnight-mcp-works "Direct link to How Midnight MCP works") ------------------------------------------------------------------------------------------------------------------------------------------------------------------ Midnight MCP operates as a local server that connects your AI assistant to Midnight's ecosystem. ![Midnight MCP Architecture](https://docs.midnight.network/assets/images/mcp-flow-6300d117555db9ec395e0f419d22de5d.png) When you ask for a Compact contract: 1. The AI assistant calls `midnight-get-latest-syntax` to retrieve current Compact syntax. 2. It generates code using the correct patterns. 3. It calls `midnight-compile-contract` to validate against the real compiler. 4. If compilation fails, it reads the error, fixes the code, and retries. 5. You receive verified, working code. This compile-validate-fix loop happens automatically. You never see the broken intermediate versions. Real compiler integration[​](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#real-compiler-integration "Direct link to Real compiler integration") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Most code-generation tools rely on pattern matching and hope. Midnight MCP validates code against the actual Compact compiler hosted. The compiler catches errors that static analysis cannot, including: * **Type mismatches**: Using `Field` where `Uint<64>` is expected * **Sealed field violations**: Attempting to access sealed state incorrectly * **Disclose rule errors**: Missing or malformed privacy annotations * **Unbound identifiers**: References to undefined variables or types When the compiler returns an error, the response includes the exact line number and column: success: falsemessage: "Line 12:8 - unbound identifier 'totalSupply'"errorDetails: line: 12 column: 8 errorType: error The AI assistant uses this information to fix the code and try again. ### Graceful fallback[​](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#graceful-fallback "Direct link to Graceful fallback") If the hosted compiler is unavailable, Midnight MCP falls back to static analysis. The response indicates which validation method was used: validationType: "compiler" # Real compiler validationvalidationType: "static-analysis-fallback" # Compiler unavailable You always receive validation. The tool never fails silently. Semantic search across 102 repositories[​](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#semantic-search-across-102-repositories "Direct link to Semantic search across 102 repositories") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Today, Midnight MCP indexes every non-archived repository in the Midnight ecosystem: * All 88 repositories from `midnightntwrk`. * 14 community and partner repositories, including OpenZeppelin contracts and hackathon winners. The search is semantic, not keyword-based. For example, a prompt like "find code that handles shielded transactions" returns relevant results even if those exact words don't appear in the code. Prompt: "How do I implement a token with transfer limits?"midnight-search-compact returns:- Token contract examples from midnight-examples- Rate limiting patterns from community repos- Relevant documentation sections 29 tools for Midnight development[​](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#29-tools-for-midnight-development "Direct link to 29 tools for Midnight development") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Midnight MCP provides 29 tools organized by function. ### Search tools[​](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#search-tools "Direct link to Search tools") Use these tools to find code, documentation, and examples across the Midnight ecosystem. | Tool | Purpose | | --- | --- | | `midnight-search-compact` | Search Compact language code across indexed repos | | `midnight-search-docs` | Search official Midnight documentation | | `midnight-search-typescript` | Search TypeScript SDK implementations | | `midnight-fetch-docs` | Fetch live documentation from docs.midnight.network | ### Analysis tools[​](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#analysis-tools "Direct link to Analysis tools") Use these tools to validate, analyze, and review Compact contracts. | Tool | Purpose | | --- | --- | | `midnight-compile-contract` | Validate code against the real Compact compiler | | `midnight-analyze-contract` | Run 15 static security checks | | `midnight-review-contract` | AI-powered security review | | `midnight-extract-contract-structure` | Parse contract structure and exports | ### Generation tools[​](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#generation-tools "Direct link to Generation tools") Use these tools to create new contracts and documentation. | Tool | Purpose | | --- | --- | | `midnight-generate-contract` | Generate contracts from natural language descriptions | | `midnight-document-contract` | Generate documentation in Markdown or JSDoc format | ### Repository tools[​](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#repository-tools "Direct link to Repository tools") Use these tools to access files and syntax references from Midnight repositories. | Tool | Purpose | | --- | --- | | `midnight-get-file` | Retrieve files from any indexed Midnight repository | | `midnight-get-file-at-version` | Get file content at a specific version | | `midnight-compare-syntax` | Compare syntax between Compact versions | | `midnight-get-latest-syntax` | Current Compact syntax reference | | `midnight-get-repo-context` | Everything needed to start coding (compound tool) | | `midnight-list-examples` | List available example contracts | ### Version management tools[​](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#version-management-tools "Direct link to Version management tools") Use these tools to manage upgrades and track changes between Compact versions. | Tool | Purpose | | --- | --- | | `midnight-upgrade-check` | Full upgrade analysis (compound tool) | | `midnight-check-breaking-changes` | Identify breaking changes between versions | | `midnight-get-migration-guide` | Step-by-step migration instructions | Resources and prompts[​](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#resources-and-prompts "Direct link to Resources and prompts") --------------------------------------------------------------------------------------------------------------------------------------------------------------- Beyond tools, Midnight MCP provides nine built-in resources and five interactive prompts. _Resources_ are always-available references that provide quick access to syntax and examples: midnight://syntax/latest Current Compact syntaxmidnight://examples/counter Counter contract examplemidnight://examples/token Token contract examplemidnight://docs/compact Compact language reference _Prompts_ are templates for common tasks that guide you through specific workflows: create-compact-contract Start a new contractdebug-compact-error Fix compilation errorssecurity-review Full security auditcompare-compact-versions Migration assistance Architecture[​](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#architecture "Direct link to Architecture") ------------------------------------------------------------------------------------------------------------------------------------ Midnight MCP is built for reliability: * **Token efficiency**: Outputs YAML by default (20-30% fewer tokens than JSON) * **Compound tools**: Single calls that combine multiple operations * **Graceful degradation**: Falls back to cached data when services are unavailable * **Progress notifications**: Real-time updates during long operations The codebase is fully tested with 206 tests across 10 test suites. What's next[​](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#whats-next "Direct link to What's next") -------------------------------------------------------------------------------------------------------------------------------- Midnight MCP is open source and actively developed. The roadmap includes: * **Full ZK circuit output parsing** from compiler results. * **Contract deployment** directly from AI chat. * **TypeScript SDK integration** for automatic prover code generation. * **Local devnet interaction** for querying balances and submitting transactions. Learn more[​](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#learn-more "Direct link to Learn more") ------------------------------------------------------------------------------------------------------------------------------ Explore the source code and contribute: → [GitHub repository](https://github.com/Olanetsoft/midnight-mcp) → [npm package](https://npmjs.com/package/midnight-mcp) → [API documentation](https://github.com/Olanetsoft/midnight-mcp/blob/main/docs/API.md) _Midnight MCP is a community project. Contributions, issues, and feature requests are welcome._ * [What is MCP?](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#what-is-mcp) * [The problem with AI-generated Compact code](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#the-problem-with-ai-generated-compact-code) * [Install Midnight MCP](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#install-midnight-mcp) * [Claude Desktop](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#claude-desktop) * [Cursor](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#cursor) * [VS Code with GitHub Copilot](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#vs-code-with-github-copilot) * [How Midnight MCP works](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#how-midnight-mcp-works) * [Real compiler integration](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#real-compiler-integration) * [Graceful fallback](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#graceful-fallback) * [Semantic search across 102 repositories](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#semantic-search-across-102-repositories) * [29 tools for Midnight development](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#29-tools-for-midnight-development) * [Search tools](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#search-tools) * [Analysis tools](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#analysis-tools) * [Generation tools](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#generation-tools) * [Repository tools](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#repository-tools) * [Version management tools](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#version-management-tools) * [Resources and prompts](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#resources-and-prompts) * [Architecture](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#architecture) * [What's next](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#whats-next) * [Learn more](https://docs.midnight.network/blog/midnight-mcp-ai-assisted-development#learn-more) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/ai#__docusaurus_skipToContent_fallback) AI coding assistants like Claude, GitHub Copilot, and Cursor have transformed how developers write code. But they have a fundamental limitation: they only know what was in their training data. Compact, Midnight's smart contract language, isn't in that training data. When you ask an AI assistant to write a Compact contract, it hallucinates. It invents syntax that doesn't exist, references functions that were never defined, and produces code that fails at compile time. Midnight MCP solves this problem. What is MCP?[​](https://docs.midnight.network/blog/tags/ai#what-is-mcp "Direct link to What is MCP?") ------------------------------------------------------------------------------------------------------ The _Model Context Protocol_ (MCP) is an open standard that allows AI assistants to access external tools and data sources. Instead of relying solely on training data, an AI assistant with MCP can query live documentation, search codebases, and call APIs. Midnight MCP is an MCP server purpose-built for Midnight development. It gives AI assistants: * **Indexed knowledge** of 102 Midnight repositories * **Real compiler validation** before showing you code * **Semantic search** across documentation and examples * **Version-aware syntax references** for Compact When you ask Claude to write a Compact contract, it queries Midnight MCP for the correct syntax, generates the code, validates it against the real compiler, and only shows you working code. The problem with AI-generated Compact code[​](https://docs.midnight.network/blog/tags/ai#the-problem-with-ai-generated-compact-code "Direct link to The problem with AI-generated Compact code") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Consider this prompt: "Write a simple counter contract in Compact" Without Midnight MCP, an AI assistant might generate: contract Counter { state count: Int = 0; function increment(): Void { count = count + 1; }} This looks plausible. It's also completely wrong: * Compact uses `ledger` for state, not `state`. * There is no `Int` type in Compact. It uses `Uint<32>`, `Field`, and other specific types. * `Void` doesn't exist. Compact uses `[]` for the unit type. * State mutations require witness functions, not direct assignment. The AI hallucinated a language that resembles Solidity but isn't Compact. A developer unfamiliar with Compact might spend hours debugging code that was never valid. Install Midnight MCP[​](https://docs.midnight.network/blog/tags/ai#install-midnight-mcp "Direct link to Install Midnight MCP") ------------------------------------------------------------------------------------------------------------------------------- Midnight MCP requires no API keys and installs in under 60 seconds. Add the appropriate configuration to your AI assistant based on the tool you use. ### Claude Desktop[​](https://docs.midnight.network/blog/tags/ai#claude-desktop "Direct link to Claude Desktop") On macOS, edit `~/Library/Application Support/Claude/claude_desktop_config.json`. Add the following configuration to enable Midnight MCP: { "mcpServers": { "midnight": { "command": "npx", "args": ["-y", "midnight-mcp@latest"] } }} ### Cursor[​](https://docs.midnight.network/blog/tags/ai#cursor "Direct link to Cursor") Create or edit `.cursor/mcp.json` in your project root. You can also configure it globally at `~/.cursor/mcp.json` on macOS/Linux or `%USERPROFILE%\.cursor\mcp.json` on Windows. Add the following configuration: { "mcpServers": { "midnight": { "command": "npx", "args": ["-y", "midnight-mcp@latest"] } }} ### VS Code with GitHub Copilot[​](https://docs.midnight.network/blog/tags/ai#vs-code-with-github-copilot "Direct link to VS Code with GitHub Copilot") Create or edit `.vscode/mcp.json` in your project. Add the following configuration to connect Copilot to Midnight MCP: { "servers": { "midnight": { "command": "npx", "args": ["-y", "midnight-mcp@latest"] } }} After adding the configuration, restart your AI assistant. You now have access to [29 Midnight-specific tools](https://docs.midnight.network/blog/tags/ai#29-tools-for-midnight-development) . How Midnight MCP works[​](https://docs.midnight.network/blog/tags/ai#how-midnight-mcp-works "Direct link to How Midnight MCP works") ------------------------------------------------------------------------------------------------------------------------------------- Midnight MCP operates as a local server that connects your AI assistant to Midnight's ecosystem. ![Midnight MCP Architecture](https://docs.midnight.network/assets/images/mcp-flow-6300d117555db9ec395e0f419d22de5d.png) When you ask for a Compact contract: 1. The AI assistant calls `midnight-get-latest-syntax` to retrieve current Compact syntax. 2. It generates code using the correct patterns. 3. It calls `midnight-compile-contract` to validate against the real compiler. 4. If compilation fails, it reads the error, fixes the code, and retries. 5. You receive verified, working code. This compile-validate-fix loop happens automatically. You never see the broken intermediate versions. Real compiler integration[​](https://docs.midnight.network/blog/tags/ai#real-compiler-integration "Direct link to Real compiler integration") ---------------------------------------------------------------------------------------------------------------------------------------------- Most code-generation tools rely on pattern matching and hope. Midnight MCP validates code against the actual Compact compiler hosted. The compiler catches errors that static analysis cannot, including: * **Type mismatches**: Using `Field` where `Uint<64>` is expected * **Sealed field violations**: Attempting to access sealed state incorrectly * **Disclose rule errors**: Missing or malformed privacy annotations * **Unbound identifiers**: References to undefined variables or types When the compiler returns an error, the response includes the exact line number and column: success: falsemessage: "Line 12:8 - unbound identifier 'totalSupply'"errorDetails: line: 12 column: 8 errorType: error The AI assistant uses this information to fix the code and try again. ### Graceful fallback[​](https://docs.midnight.network/blog/tags/ai#graceful-fallback "Direct link to Graceful fallback") If the hosted compiler is unavailable, Midnight MCP falls back to static analysis. The response indicates which validation method was used: validationType: "compiler" # Real compiler validationvalidationType: "static-analysis-fallback" # Compiler unavailable You always receive validation. The tool never fails silently. Semantic search across 102 repositories[​](https://docs.midnight.network/blog/tags/ai#semantic-search-across-102-repositories "Direct link to Semantic search across 102 repositories") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Today, Midnight MCP indexes every non-archived repository in the Midnight ecosystem: * All 88 repositories from `midnightntwrk`. * 14 community and partner repositories, including OpenZeppelin contracts and hackathon winners. The search is semantic, not keyword-based. For example, a prompt like "find code that handles shielded transactions" returns relevant results even if those exact words don't appear in the code. Prompt: "How do I implement a token with transfer limits?"midnight-search-compact returns:- Token contract examples from midnight-examples- Rate limiting patterns from community repos- Relevant documentation sections 29 tools for Midnight development[​](https://docs.midnight.network/blog/tags/ai#29-tools-for-midnight-development "Direct link to 29 tools for Midnight development") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- Midnight MCP provides 29 tools organized by function. ### Search tools[​](https://docs.midnight.network/blog/tags/ai#search-tools "Direct link to Search tools") Use these tools to find code, documentation, and examples across the Midnight ecosystem. | Tool | Purpose | | --- | --- | | `midnight-search-compact` | Search Compact language code across indexed repos | | `midnight-search-docs` | Search official Midnight documentation | | `midnight-search-typescript` | Search TypeScript SDK implementations | | `midnight-fetch-docs` | Fetch live documentation from docs.midnight.network | ### Analysis tools[​](https://docs.midnight.network/blog/tags/ai#analysis-tools "Direct link to Analysis tools") Use these tools to validate, analyze, and review Compact contracts. | Tool | Purpose | | --- | --- | | `midnight-compile-contract` | Validate code against the real Compact compiler | | `midnight-analyze-contract` | Run 15 static security checks | | `midnight-review-contract` | AI-powered security review | | `midnight-extract-contract-structure` | Parse contract structure and exports | ### Generation tools[​](https://docs.midnight.network/blog/tags/ai#generation-tools "Direct link to Generation tools") Use these tools to create new contracts and documentation. | Tool | Purpose | | --- | --- | | `midnight-generate-contract` | Generate contracts from natural language descriptions | | `midnight-document-contract` | Generate documentation in Markdown or JSDoc format | ### Repository tools[​](https://docs.midnight.network/blog/tags/ai#repository-tools "Direct link to Repository tools") Use these tools to access files and syntax references from Midnight repositories. | Tool | Purpose | | --- | --- | | `midnight-get-file` | Retrieve files from any indexed Midnight repository | | `midnight-get-file-at-version` | Get file content at a specific version | | `midnight-compare-syntax` | Compare syntax between Compact versions | | `midnight-get-latest-syntax` | Current Compact syntax reference | | `midnight-get-repo-context` | Everything needed to start coding (compound tool) | | `midnight-list-examples` | List available example contracts | ### Version management tools[​](https://docs.midnight.network/blog/tags/ai#version-management-tools "Direct link to Version management tools") Use these tools to manage upgrades and track changes between Compact versions. | Tool | Purpose | | --- | --- | | `midnight-upgrade-check` | Full upgrade analysis (compound tool) | | `midnight-check-breaking-changes` | Identify breaking changes between versions | | `midnight-get-migration-guide` | Step-by-step migration instructions | Resources and prompts[​](https://docs.midnight.network/blog/tags/ai#resources-and-prompts "Direct link to Resources and prompts") ---------------------------------------------------------------------------------------------------------------------------------- Beyond tools, Midnight MCP provides nine built-in resources and five interactive prompts. _Resources_ are always-available references that provide quick access to syntax and examples: midnight://syntax/latest Current Compact syntaxmidnight://examples/counter Counter contract examplemidnight://examples/token Token contract examplemidnight://docs/compact Compact language reference _Prompts_ are templates for common tasks that guide you through specific workflows: create-compact-contract Start a new contractdebug-compact-error Fix compilation errorssecurity-review Full security auditcompare-compact-versions Migration assistance Architecture[​](https://docs.midnight.network/blog/tags/ai#architecture "Direct link to Architecture") ------------------------------------------------------------------------------------------------------- Midnight MCP is built for reliability: * **Token efficiency**: Outputs YAML by default (20-30% fewer tokens than JSON) * **Compound tools**: Single calls that combine multiple operations * **Graceful degradation**: Falls back to cached data when services are unavailable * **Progress notifications**: Real-time updates during long operations The codebase is fully tested with 206 tests across 10 test suites. What's next[​](https://docs.midnight.network/blog/tags/ai#whats-next "Direct link to What's next") --------------------------------------------------------------------------------------------------- Midnight MCP is open source and actively developed. The roadmap includes: * **Full ZK circuit output parsing** from compiler results. * **Contract deployment** directly from AI chat. * **TypeScript SDK integration** for automatic prover code generation. * **Local devnet interaction** for querying balances and submitting transactions. Learn more[​](https://docs.midnight.network/blog/tags/ai#learn-more "Direct link to Learn more") ------------------------------------------------------------------------------------------------- Explore the source code and contribute: → [GitHub repository](https://github.com/Olanetsoft/midnight-mcp) → [npm package](https://npmjs.com/package/midnight-mcp) → [API documentation](https://github.com/Olanetsoft/midnight-mcp/blob/main/docs/API.md) _Midnight MCP is a community project. Contributions, issues, and feature requests are welcome._ --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/bls#__docusaurus_skipToContent_fallback) The Midnight testnet upgrade introduces BLS12-381, requiring developers to update the Lace wallet, proof server, and redeploy contracts with the latest Compact compiler. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/dust#__docusaurus_skipToContent_fallback) To understand this system, it helps to use an analogy. * **Night** is like a **Solar Panel**. It is a valuable asset you hold. * **Dust** is like **Electricity**. It represents the computational throughput or gas generated by the Solar Panel (Night). * **Usage**. You consume the Electricity (DUST) as gas to power your operations on the network. Unlike standard cryptocurrencies where you have a static balance (e.g., "I have 5 coins"), your Dust balance changes dynamically based on time and the status of your Night tokens. Dust and network usage[​](https://docs.midnight.network/blog/tags/dust#dust-and-network-usage "Direct link to Dust and network usage") --------------------------------------------------------------------------------------------------------------------------------------- Dust operates similarly to, but separately from, [Zswap](https://github.com/midnightntwrk/midnight-ledger/blob/main/spec/zswap.md) . Dust operates as the resource credit system for Midnight. It function * **Shielded and Non-transferable:** Dust is a shielded capacity resource _only_ for gas. It cannot be transferred between users. * **Dynamic Capacity:** The available gas in a Dust UTXO is dynamically computed and derived from an associated Night UTXO. * **Growth & Decay:** The computed value grows over time to a maximum based on its Night UTXO, and decays to zero after its Night UTXO is spent. * **Non-Persistent:** The system may redistribute it on hardforks. (Note: The Midnight protocol reserves the right to modify Dust allocation rules, e.g., for garbage collection). Design overview[​](https://docs.midnight.network/blog/tags/dust#design-overview "Direct link to Design overview") ------------------------------------------------------------------------------------------------------------------ Similar to Zswap, Dust is built on hashes and the commitment/nullifier paradigm. Each Dust UTXO has a **commitment** inserted into an append-only Merkle tree upon creation, and a **nullifier** inserted into a nullifier set upon spending. A Dust "spend" is a 1-to-1 "transfer" (Self-Spend): 1. **Input:** 1 Dust UTXO (nullifier). 2. **Output:** 1 Dust UTXO (commitment). 3. **Fee:** A public declaration of fees paid. It includes a zero-knowledge proof that: 1. The input is valid and exists in the Merkle tree. 2. The output value equals the _updated_ input value minus the gas consumed. 3. The output nullifier is correct, and the owner remains the same. ### Lifecycle: NIGHT generates DUST[​](https://docs.midnight.network/blog/tags/dust#lifecycle-night-generates-dust "Direct link to Lifecycle: NIGHT generates DUST") Conceptually, Dust is generated over time by held _Night_ UTXOs. As long as a backing Night UTXO remains unspent, the associated Dust UTXO generates value up to a cap ($\\rho$). Once the backing Night is spent, the Dust UTXO "decays" to zero. The following diagram illustrates this lifecycle: The rate of generation depends on the amount of night held ($N$), the ratio of the Dust cap to Night held ($\\rho$), and "time to cap" ($\\Delta$). **Spending Rules:** * Dust may be spent multiple times; a new UTXO is always created, even if its value is zero. * Spending during decay is permitted and does not change the decay rate. * Once the backing Night is spent, Dust immediately starts to decay, even if it was still in the generation phase. * If only a portion of backing Night is spent, the change creates a new Night UTXO (starting fresh Dust generation), while the old Dust UTXO decays. **Implementation Note:** In practice, value is not processed continuously. It is calculated **at the time of spend** using metadata ("generation info"): 1. Creation time of the Dust UTXO. 2. Creation time of the backing Night UTXO. 3. Deletion time of the backing Night UTXO. Since Dust and Night use different keys, a **Registration Table** links Night public keys to Dust public keys. A new Dust UTXO is created if and only if a Night UTXO is created _and_ its key has a table entry. **The Grace Period:** Because Dust usage is shielded, the value is computed for the time of _transaction creation_. To account for network delays, the protocol defines a **Dust Grace Period** (for example, 3 hours). A transaction is accepted if its timestamp is within this window relative to the block time. Preliminaries[​](https://docs.midnight.network/blog/tags/dust#preliminaries "Direct link to Preliminaries") ------------------------------------------------------------------------------------------------------------ DUST uses ZK-friendly hashes. type DustSecretKey = Fr;type DustPublicKey = field::Hash; Dust UTXOs have owners, values, and **nonces**. Nonces evolve deterministically to enable wallet recovery. * **First Dust UTXO:** Nonce derived from the originating Night UTXO intent hash. * **Subsequent Dust UTXOs:** Nonce derived from the previous sequence number and owner's secret key. struct DustOutput { initial_value: u128, // Specks at creation owner: DustPublicKey, nonce: field::Hash<(InitialNonce, u32, Fr)>, seq: u32, ctime: Timestamp,} State components include the commitment tree, nullifier set, and root history: struct DustUtxoState { commitments: MerkleTree, commitments_first_free: usize, nullifiers: Set, root_history: TimeFilterMap,} Initial DUST parameters[​](https://docs.midnight.network/blog/tags/dust#initial-dust-parameters "Direct link to Initial DUST parameters") ------------------------------------------------------------------------------------------------------------------------------------------ * **Night Unit:** `Star (1 Night = 10^6 Stars)` * **Dust Unit:** `Speck (1 Dust = 10^15 Specks)` const INITIAL_DUST_PARAMETERS: DustParameters = { night_dust_ratio = 5_000_000_000; // 5 DUST per NIGHT generation_decay_rate = 8_267; // ~1 week generation time dust_grace_period = Duration::from_hours(3),}; Dust actions[​](https://docs.midnight.network/blog/tags/dust#dust-actions "Direct link to Dust actions") --------------------------------------------------------------------------------------------------------- Users influence Dust state via **Intents**. struct DustActions { spends: Vec>, registrations: Vec, ctime: Timestamp,} ### Registrations and fees[​](https://docs.midnight.network/blog/tags/dust#registrations-and-fees "Direct link to Registrations and fees") `DustRegistration` links a Night key to a Dust key. * Registrations happen sequentially. * If a registration transaction uses Night inputs that _were not yet generating Dust_ (meaning that they had no previous registration), the system can "backdate" the registration to use the Dust those inputs _would have generated_ to pay for the gas. Generating DUST[​](https://docs.midnight.network/blog/tags/dust#generating-dust "Direct link to Generating DUST") ------------------------------------------------------------------------------------------------------------------ Night inputs/outputs trigger updates to a **Dust Generation Tree**. * **DustGenerationInfo:** Stores the amount of Night, the owner, and the `dtime` (deletion time). * **Address Map:** Links Night Addresses -> Dust Addresses. struct DustGenerationInfo { value: u128, owner: DustPublicKey, nonce: InitialNonce, dtime: Timestamp, // Set to MAX if Night is unspent} Dust value and spends[​](https://docs.midnight.network/blog/tags/dust#dust-value-and-spends "Direct link to Dust value and spends") ------------------------------------------------------------------------------------------------------------------------------------ The value of a Dust UTXO is calculated based on four linear time segments: 1. **Generating:** From creation to Capacity (or Night spend). 2. **Constant (Max):** At capacity until Night spend. 3. **Decaying:** From Night spend until value hits zero. 4. **Constant (Zero):** Forever after. ### The Spend transaction[​](https://docs.midnight.network/blog/tags/dust#the-spend-transaction "Direct link to The Spend transaction") A `DustSpend` consumes a UTXO and creates a new one with updated value minus fees. The validation logic (`dust_spend_valid`) ensures: * `commitment_merkle_tree` contains the input. * `dust_spend.old_nullifier` matches the derived nullifier. * `updated_value` covers the fee. * `new_commitment` is correctly formed. Wallet recovery[​](https://docs.midnight.network/blog/tags/dust#wallet-recovery "Direct link to Wallet recovery") ------------------------------------------------------------------------------------------------------------------ Wallets recover funds by: 1. Identifying owned Night UTXOs (the start of the chain). 2. Linearly searching for commitments corresponding to sequence numbers ($0, 1, 2...$). 3. **Privacy:** Wallets should query commitments using bit-prefixes (stochastic filtering) rather than exact lookups to preserve privacy against the indexing service. The implementation[​](https://docs.midnight.network/blog/tags/dust#the-implementation "Direct link to The implementation") --------------------------------------------------------------------------------------------------------------------------- ### DUST Generation from Cardano NIGHT Token — Full Process[​](https://docs.midnight.network/blog/tags/dust#dust-generation-from-cardano-night-token--full-process "Direct link to DUST Generation from Cardano NIGHT Token — Full Process") The generation of **DUST** from the Cardano **NIGHT** token (cNIGHT) is a cross-chain process managed by the **Native Token Observation Pallet** (`pallet_cnight_observation`) on the Midnight partner chain. ### Summary of the full flow[​](https://docs.midnight.network/blog/tags/dust#summary-of-the-full-flow "Direct link to Summary of the full flow") 1/ User registers their Cardano reward address + DUST public key on Cardano. 2/ Any time a cNIGHT UTXO is created (received) or spent (sent) by that address, the event is broadcast. 3–4/ The Midnight pallet validates that exactly one valid registration exists and observes the cNIGHT activity. 5–6/ It determines whether it’s a receive (creation) or send (destruction) of cNIGHT → generates corresponding DUST creation or destruction event. 7–9/ All events in a block are batched, wrapped into a single system transaction via LedgerApi, and executed on the Midnight ledger. → Final result: DUST supply and UTXOs are updated 1:1 with cNIGHT movements on Cardano. * * * 👉 **Now that you have an overview of DUST, checkout the [DUST spec](https://github.com/midnightntwrk/midnight-ledger/blob/main/spec/dust.md) on Github!** 👉 **Get involved in [the code](https://raw.githubusercontent.com/midnightntwrk/midnight-node/refs/heads/main/primitives/mainchain-follower/src/data_source/cnight_observation.rs) on Github!** --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/indexer#__docusaurus_skipToContent_fallback) We’re excited to announce the release of the new [Midnight Indexer](https://docs.midnight.network/relnotes/midnight-indexer) — a modular, high-performance indexer that streamlines blockchain data flow from Midnight nodes to end-user apps --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/community#__docusaurus_skipToContent_fallback) **[Hacktoberfest](https://hacktoberfest.com/) ** is a global open-source event held every October, where developers contribute pull requests to public repositories to earn digital rewards. Midnight is joining the celebration by inviting contributors to improve its open-source ecosystem — from smart contracts and DApps to core libraries and documentation. Review the guide to get started. The Community Hub serves as a collaborative platform for gathering and managing community-driven contributions. Whether you're proposing new content, requesting features, reporting issues, or ideation for dApps, this repo is your entry point. We use GitHub's built-in features like issues, projects, and automations to ensure ideas are triaged efficiently and turned into actionable tasks. How to Contribute[​](https://docs.midnight.network/blog/tags/community#how-to-contribute "Direct link to How to Contribute") ----------------------------------------------------------------------------------------------------------------------------- Ready to jump in? It's as simple as [**creating an issue**](https://github.com/midnightntwrk/community-hub/issues/new/choose) . Our Workflow: From Idea to Reality[​](https://docs.midnight.network/blog/tags/community#our-workflow-from-idea-to-reality "Direct link to Our Workflow: From Idea to Reality") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Step 1: The Community Board (Triage)[​](https://docs.midnight.network/blog/tags/community#step-1-the-community-board-triage "Direct link to Step 1: The Community Board (Triage)") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- All new issues land here for initial review. This board is public, so everyone can see what's being proposed. * `New`: Your issue has been submitted and is awaiting review. * `In Triage`: The triage committee is actively reviewing your submission for validity, clarity, and priority. * `Needs` Discussion: The issue requires more feedback or clarification from the community or the original poster. * `Rejected`: The issue is out-of-scope or invalid. We will always provide a clear explanation. Once an issue is approved, it gets a triaged label and is automatically moved to the next stage. Step 2: The Grab n' Go Board (Development)[​](https://docs.midnight.network/blog/tags/community#step-2-the-grab-n-go-board-development "Direct link to Step 2: The Grab n' Go Board (Development)") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- This board contains approved, ready-to-work-on tasks. It's the community's backlog! * `Ready`: Triaged issues waiting for a contributor to pick them up. Look for labels like good-first-issue if you're new! * `In Progress`: A contributor has assigned themselves the issue and is actively working on it. * `Done`: The work is complete and the issue has been closed (this happens automatically when a linked PR is merged). Choosing the Right Issue Template[​](https://docs.midnight.network/blog/tags/community#choosing-the-right-issue-template "Direct link to Choosing the Right Issue Template") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- To help us categorize and review your ideas faster, please use the best template for your submission: * 📝 `Content Proposal`: Suggest new articles, tutorials, or educational resources to engage the community. * 💡 `Feature Request/Suggestion`: Propose new features or enhancements for our tools and processes. * 🐛 `Bug Report`: Report any defects, errors, or unexpected behavior. Please include clear reproduction steps! * 🌐 `dApp Proposal`: Share your vision for a new decentralized application, integration, or improvement. Selecting a template automatically applies the right labels, helping our automation keep things organized. Our goal is to foster a truly collaborative environment where the collective wisdom of our community helps us build more robust, community-driven solutions. Why Now? The Developer Relations Perspective[​](https://docs.midnight.network/blog/tags/community#why-now-the-developer-relations-perspective "Direct link to Why Now? The Developer Relations Perspective") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- You might be asking, "Why is the Developer Relations (DevRel) team launching this?" That's a great question, and it gets to the very core of our mission! At its heart, Developer Relations is about empowering developers. The Community Board is a natural, powerful extension of this mission. Here’s why it’s so crucial for us: 1. Direct Feedback Loop: Before, collecting structured feedback could be spread across multiple channels. The Community Board centralizes this, giving us a clear, prioritized view of what matters most to you. 2. Transparency and Prioritization: You'll be able to see what other developers are asking for, upvote ideas you support, and even watch as issues move from "Under Review" to "Planned" to "Shipped." This transparency helps you understand our roadmap and how your contributions fit in. 3. Community-Driven Development: We genuinely believe that the best products are built in collaboration with their users. The board allows us to tap into the collective intelligence of our community, surfacing the most impactful ideas and validating them with real-world needs. 4. Building Stronger Relationships: By giving you a clear, actionable way to contribute, we hope to build an even stronger, more engaged community where everyone feels invested in our shared success. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/javascript#__docusaurus_skipToContent_fallback) The Midnight blockchain introduces a novel approach to data privacy and compliance in decentralized applications (DApps), leveraging zero-knowledge proofs (ZKPs) and a dual-token system. This article provides a comprehensive guide on connecting to the Midnight blockchain, and you will learn how to listen for new blocks and extract data from these blocks using the Polkadot API and the various methods it provides to connect to Substrate-based blockchains, including Midnight. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/meeting#__docusaurus_skipToContent_fallback) The Midnight testnet upgrade to Partner-Chains v1.5 requires SPO re-registration, adds BLS support, and is expected to roll out by May 2025. --- # Midnight APIs | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference#__docusaurus_skipToContent_fallback) Explore with… ▾ Collection of Midnight APIs: * [Compact runtime API](https://docs.midnight.network/api-reference/compact-runtime) * [DApp connector API](https://docs.midnight.network/api-reference/dapp-connector) * [Ledger API](https://docs.midnight.network/api-reference/ledger) * [Midnight JS API](https://docs.midnight.network/api-reference/midnight-js) * [On-Chain runtime API](https://docs.midnight.network/api-reference/onchain-runtime) * [Midnight Indexer API](https://docs.midnight.network/api-reference/midnight-indexer) * [Wallet API](https://docs.midnight.network/api-reference/wallet-api) * [ZSwap API](https://docs.midnight.network/api-reference/zswap) --- # API reference | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/category/midnight-indexer-api#__docusaurus_skipToContent_fallback) [📄️ Midnight Indexer API Documentation v1\ -----------------------------------------\ \ The Midnight Indexer API exposes a GraphQL API that enables clients to query and subscribe to blockchain data—blocks, transactions, contracts, and wallet-related events—indexed from the Midnight blockchain. These capabilities facilitate both historical lookups and real-time monitoring.](https://docs.midnight.network/api-reference/midnight-indexer) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/developer-tools#__docusaurus_skipToContent_fallback) AI coding assistants like Claude, GitHub Copilot, and Cursor have transformed how developers write code. But they have a fundamental limitation: they only know what was in their training data. Compact, Midnight's smart contract language, isn't in that training data. When you ask an AI assistant to write a Compact contract, it hallucinates. It invents syntax that doesn't exist, references functions that were never defined, and produces code that fails at compile time. Midnight MCP solves this problem. What is MCP?[​](https://docs.midnight.network/blog/tags/developer-tools#what-is-mcp "Direct link to What is MCP?") ------------------------------------------------------------------------------------------------------------------- The _Model Context Protocol_ (MCP) is an open standard that allows AI assistants to access external tools and data sources. Instead of relying solely on training data, an AI assistant with MCP can query live documentation, search codebases, and call APIs. Midnight MCP is an MCP server purpose-built for Midnight development. It gives AI assistants: * **Indexed knowledge** of 102 Midnight repositories * **Real compiler validation** before showing you code * **Semantic search** across documentation and examples * **Version-aware syntax references** for Compact When you ask Claude to write a Compact contract, it queries Midnight MCP for the correct syntax, generates the code, validates it against the real compiler, and only shows you working code. The problem with AI-generated Compact code[​](https://docs.midnight.network/blog/tags/developer-tools#the-problem-with-ai-generated-compact-code "Direct link to The problem with AI-generated Compact code") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Consider this prompt: "Write a simple counter contract in Compact" Without Midnight MCP, an AI assistant might generate: contract Counter { state count: Int = 0; function increment(): Void { count = count + 1; }} This looks plausible. It's also completely wrong: * Compact uses `ledger` for state, not `state`. * There is no `Int` type in Compact. It uses `Uint<32>`, `Field`, and other specific types. * `Void` doesn't exist. Compact uses `[]` for the unit type. * State mutations require witness functions, not direct assignment. The AI hallucinated a language that resembles Solidity but isn't Compact. A developer unfamiliar with Compact might spend hours debugging code that was never valid. Install Midnight MCP[​](https://docs.midnight.network/blog/tags/developer-tools#install-midnight-mcp "Direct link to Install Midnight MCP") -------------------------------------------------------------------------------------------------------------------------------------------- Midnight MCP requires no API keys and installs in under 60 seconds. Add the appropriate configuration to your AI assistant based on the tool you use. ### Claude Desktop[​](https://docs.midnight.network/blog/tags/developer-tools#claude-desktop "Direct link to Claude Desktop") On macOS, edit `~/Library/Application Support/Claude/claude_desktop_config.json`. Add the following configuration to enable Midnight MCP: { "mcpServers": { "midnight": { "command": "npx", "args": ["-y", "midnight-mcp@latest"] } }} ### Cursor[​](https://docs.midnight.network/blog/tags/developer-tools#cursor "Direct link to Cursor") Create or edit `.cursor/mcp.json` in your project root. You can also configure it globally at `~/.cursor/mcp.json` on macOS/Linux or `%USERPROFILE%\.cursor\mcp.json` on Windows. Add the following configuration: { "mcpServers": { "midnight": { "command": "npx", "args": ["-y", "midnight-mcp@latest"] } }} ### VS Code with GitHub Copilot[​](https://docs.midnight.network/blog/tags/developer-tools#vs-code-with-github-copilot "Direct link to VS Code with GitHub Copilot") Create or edit `.vscode/mcp.json` in your project. Add the following configuration to connect Copilot to Midnight MCP: { "servers": { "midnight": { "command": "npx", "args": ["-y", "midnight-mcp@latest"] } }} After adding the configuration, restart your AI assistant. You now have access to [29 Midnight-specific tools](https://docs.midnight.network/blog/tags/developer-tools#29-tools-for-midnight-development) . How Midnight MCP works[​](https://docs.midnight.network/blog/tags/developer-tools#how-midnight-mcp-works "Direct link to How Midnight MCP works") -------------------------------------------------------------------------------------------------------------------------------------------------- Midnight MCP operates as a local server that connects your AI assistant to Midnight's ecosystem. ![Midnight MCP Architecture](https://docs.midnight.network/assets/images/mcp-flow-6300d117555db9ec395e0f419d22de5d.png) When you ask for a Compact contract: 1. The AI assistant calls `midnight-get-latest-syntax` to retrieve current Compact syntax. 2. It generates code using the correct patterns. 3. It calls `midnight-compile-contract` to validate against the real compiler. 4. If compilation fails, it reads the error, fixes the code, and retries. 5. You receive verified, working code. This compile-validate-fix loop happens automatically. You never see the broken intermediate versions. Real compiler integration[​](https://docs.midnight.network/blog/tags/developer-tools#real-compiler-integration "Direct link to Real compiler integration") ----------------------------------------------------------------------------------------------------------------------------------------------------------- Most code-generation tools rely on pattern matching and hope. Midnight MCP validates code against the actual Compact compiler hosted. The compiler catches errors that static analysis cannot, including: * **Type mismatches**: Using `Field` where `Uint<64>` is expected * **Sealed field violations**: Attempting to access sealed state incorrectly * **Disclose rule errors**: Missing or malformed privacy annotations * **Unbound identifiers**: References to undefined variables or types When the compiler returns an error, the response includes the exact line number and column: success: falsemessage: "Line 12:8 - unbound identifier 'totalSupply'"errorDetails: line: 12 column: 8 errorType: error The AI assistant uses this information to fix the code and try again. ### Graceful fallback[​](https://docs.midnight.network/blog/tags/developer-tools#graceful-fallback "Direct link to Graceful fallback") If the hosted compiler is unavailable, Midnight MCP falls back to static analysis. The response indicates which validation method was used: validationType: "compiler" # Real compiler validationvalidationType: "static-analysis-fallback" # Compiler unavailable You always receive validation. The tool never fails silently. Semantic search across 102 repositories[​](https://docs.midnight.network/blog/tags/developer-tools#semantic-search-across-102-repositories "Direct link to Semantic search across 102 repositories") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Today, Midnight MCP indexes every non-archived repository in the Midnight ecosystem: * All 88 repositories from `midnightntwrk`. * 14 community and partner repositories, including OpenZeppelin contracts and hackathon winners. The search is semantic, not keyword-based. For example, a prompt like "find code that handles shielded transactions" returns relevant results even if those exact words don't appear in the code. Prompt: "How do I implement a token with transfer limits?"midnight-search-compact returns:- Token contract examples from midnight-examples- Rate limiting patterns from community repos- Relevant documentation sections 29 tools for Midnight development[​](https://docs.midnight.network/blog/tags/developer-tools#29-tools-for-midnight-development "Direct link to 29 tools for Midnight development") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Midnight MCP provides 29 tools organized by function. ### Search tools[​](https://docs.midnight.network/blog/tags/developer-tools#search-tools "Direct link to Search tools") Use these tools to find code, documentation, and examples across the Midnight ecosystem. | Tool | Purpose | | --- | --- | | `midnight-search-compact` | Search Compact language code across indexed repos | | `midnight-search-docs` | Search official Midnight documentation | | `midnight-search-typescript` | Search TypeScript SDK implementations | | `midnight-fetch-docs` | Fetch live documentation from docs.midnight.network | ### Analysis tools[​](https://docs.midnight.network/blog/tags/developer-tools#analysis-tools "Direct link to Analysis tools") Use these tools to validate, analyze, and review Compact contracts. | Tool | Purpose | | --- | --- | | `midnight-compile-contract` | Validate code against the real Compact compiler | | `midnight-analyze-contract` | Run 15 static security checks | | `midnight-review-contract` | AI-powered security review | | `midnight-extract-contract-structure` | Parse contract structure and exports | ### Generation tools[​](https://docs.midnight.network/blog/tags/developer-tools#generation-tools "Direct link to Generation tools") Use these tools to create new contracts and documentation. | Tool | Purpose | | --- | --- | | `midnight-generate-contract` | Generate contracts from natural language descriptions | | `midnight-document-contract` | Generate documentation in Markdown or JSDoc format | ### Repository tools[​](https://docs.midnight.network/blog/tags/developer-tools#repository-tools "Direct link to Repository tools") Use these tools to access files and syntax references from Midnight repositories. | Tool | Purpose | | --- | --- | | `midnight-get-file` | Retrieve files from any indexed Midnight repository | | `midnight-get-file-at-version` | Get file content at a specific version | | `midnight-compare-syntax` | Compare syntax between Compact versions | | `midnight-get-latest-syntax` | Current Compact syntax reference | | `midnight-get-repo-context` | Everything needed to start coding (compound tool) | | `midnight-list-examples` | List available example contracts | ### Version management tools[​](https://docs.midnight.network/blog/tags/developer-tools#version-management-tools "Direct link to Version management tools") Use these tools to manage upgrades and track changes between Compact versions. | Tool | Purpose | | --- | --- | | `midnight-upgrade-check` | Full upgrade analysis (compound tool) | | `midnight-check-breaking-changes` | Identify breaking changes between versions | | `midnight-get-migration-guide` | Step-by-step migration instructions | Resources and prompts[​](https://docs.midnight.network/blog/tags/developer-tools#resources-and-prompts "Direct link to Resources and prompts") ----------------------------------------------------------------------------------------------------------------------------------------------- Beyond tools, Midnight MCP provides nine built-in resources and five interactive prompts. _Resources_ are always-available references that provide quick access to syntax and examples: midnight://syntax/latest Current Compact syntaxmidnight://examples/counter Counter contract examplemidnight://examples/token Token contract examplemidnight://docs/compact Compact language reference _Prompts_ are templates for common tasks that guide you through specific workflows: create-compact-contract Start a new contractdebug-compact-error Fix compilation errorssecurity-review Full security auditcompare-compact-versions Migration assistance Architecture[​](https://docs.midnight.network/blog/tags/developer-tools#architecture "Direct link to Architecture") -------------------------------------------------------------------------------------------------------------------- Midnight MCP is built for reliability: * **Token efficiency**: Outputs YAML by default (20-30% fewer tokens than JSON) * **Compound tools**: Single calls that combine multiple operations * **Graceful degradation**: Falls back to cached data when services are unavailable * **Progress notifications**: Real-time updates during long operations The codebase is fully tested with 206 tests across 10 test suites. What's next[​](https://docs.midnight.network/blog/tags/developer-tools#whats-next "Direct link to What's next") ---------------------------------------------------------------------------------------------------------------- Midnight MCP is open source and actively developed. The roadmap includes: * **Full ZK circuit output parsing** from compiler results. * **Contract deployment** directly from AI chat. * **TypeScript SDK integration** for automatic prover code generation. * **Local devnet interaction** for querying balances and submitting transactions. Learn more[​](https://docs.midnight.network/blog/tags/developer-tools#learn-more "Direct link to Learn more") -------------------------------------------------------------------------------------------------------------- Explore the source code and contribute: → [GitHub repository](https://github.com/Olanetsoft/midnight-mcp) → [npm package](https://npmjs.com/package/midnight-mcp) → [API documentation](https://github.com/Olanetsoft/midnight-mcp/blob/main/docs/API.md) _Midnight MCP is a community project. Contributions, issues, and feature requests are welcome._ --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/dapp#__docusaurus_skipToContent_fallback) Midnight's Developer Relations team is actively shaping how developers learn, build, and experiment with privacy-first apps. In this post, we take a closer look at how DevRel is lowering the barrier to entry for new builders, supporting open-source tools, and helping the community navigate the unique challenges of developing on a privacy-preserving blockchain. The Midnight testnet upgrade introduces BLS12-381, requiring developers to update the Lace wallet, proof server, and redeploy contracts with the latest Compact compiler. Connect your dApp to the Midnight network using the Lace wallet, with guidance on detection, authorization, and interaction using the MidnightJS API. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/midnight-js#__docusaurus_skipToContent_fallback) Connect your dApp to the Midnight network using the Lace wallet, with guidance on detection, authorization, and interaction using the MidnightJS API. The Midnight ecosystem is evolving—one important change is the new default address format: Bech32m, which is a human-readable address format with error detection. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/partner-chains#__docusaurus_skipToContent_fallback) Last month, we introduced the Midnight Indexer, a modular, high-performance indexing service written in Rust. Today, we’re excited to share that the Rust-based Midnight Indexer has officially replaced the legacy Scala-based Pub-Sub Indexer. A major Midnight Testnet upgrade introduces version 1.5, bringing key changes that require validator re-registration, improved node setup, and enhanced tooling for partner-chain participants. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/hackathon#__docusaurus_skipToContent_fallback) After participating in three hackathons this year, I thought I had a good idea of what to expect. Then came the fourth. It began like the others: an idea, a challenge, a blank terminal screen. But this one took an unexpected turn, one I didn't see coming. I had recently left my software engineering role to explore zero-knowledge protocols, an area in which I didn’t have much experience. It was a risk, but one I felt I had to take. I chose to pursue this path not only because zero-knowledge cryptography is built on one of the most elegant branches of mathematics, but also I believe privacy on the blockchain or on the internet is fundamental and should never be an afterthought. One day, my mentor casually mentioned the [African Blockchain Championship](https://www.africanblockchamp.com/) and suggested I look into the Zero-Knowledge track. That small nudge became a turning point. That’s when I discovered [Midnight](https://midnight.network/) ! Meet Midnight: Privacy on the Blockchain ======================================== Midnight is a zero-knowledge proof-based privacy chain developed by Input Output, the parent company of Cardano. As a partner chain of Cardano, it aims to bring rational privacy through zero-knowledge technology to the broader ecosystem. They weren’t just building another blockchain—they were laying the foundation for private, decentralized computation. After diving into the documentation and setting up the tools, everything was finally in place. All that remained… was to begin. Only later did I realize: this wasn’t just the start of another hackathon—it was the beginning of something much bigger. Building on Midnight ==================== Hacking on Midnight was challenging, as building in a testnet environment requires constant learning and adaptation to major changes. Within just a few weeks, significant network updates rendered the existing examples incompatible with the latest SDK versions. As a result, an example had to be cloned and debugged line by line. The example repository was dense, filled with layers of files and directories, and figuring out where to start was a challenge in itself. Fortunately, Midnight’s smart contract language, [Compact](https://docs.midnight.network/develop/reference/compact/) , shares a syntax similar to TypeScript, which eased the learning curve. I pushed forward, determined to build something meaningful and make my mark—but in the end, my attempt fell short. With midterm exams approaching and the hackathon submission deadline close by, I had to make a difficult decision. I decided not to submit a project to the African Blockchain Championship hackathon. Still, a quiet sense of regret lingered. I couldn’t help but wonder: what if I had just pushed a _little_ harder? The Extended Deadline ===================== About a week later, I received an email from the ABC team announcing that the hackathon deadline had been extended. I was thrilled, and I promised myself I’d give it everything this time. It wasn’t long before I was back at it. A few weeks had passed since I’d last touched the project, and during that time, both the network and SDKs had been updated. I gathered my gear, updated my environment, and set out with renewed determination to finally build something solid. I wrote my contract and began debugging, but each change introduced a new layer of complexity. Every update required changes across multiple files. It was frustrating, exhausting, but strangely thrilling. I began thinking of ways to simplify the chaos, to make the process less painful, more intuitive. That’s when I started creating small scripts to streamline the workflow. Earlier that month, I had joined the [Midnight Discord](https://discord.com/invite/midnightnetwork) to ask questions. One week, I jumped on a Discord community call, and to my surprise, I learned about an ongoing Midnight tooling hackathon that was happening asynchronously. Right then, it clicked: _this_ was the hackathon I was meant to be part of from the start. From Personal Tool to Shared Project ==================================== What started as a personal tool suddenly took on a bigger purpose. The hackathon provided me with the opportunity to share my work with others and contribute to shaping the future of smart contract development on Midnight. I took a little detour from my original hackathon submission—promising myself I’d return to it—and began refining the tool, aiming not just to build something functional, but something genuinely useful for newcomers to the ecosystem. Scaffold Midnight & Create Midnight App[​](https://docs.midnight.network/blog/tags/hackathon#scaffold-midnight--create-midnight-app "Direct link to Scaffold Midnight & Create Midnight App") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- That’s how [**Scaffold Midnight**](http://github.com/kaleababayneh/scaffold-midnight) was born, a cloneable GitHub starter template. But I didn’t stop there. I realized it would be even more useful as an npm library, something developers could install with all dependencies bundled and start using right away. So, I polished the project and released the first version as [**create-midnight-app**](https://www.npmjs.com/package/create-midnight-app) . But I didn’t want to stop at solving just one problem. Every issue I fixed revealed another. Through multiple iterations, I kept refining the library. It’s now at version 2.1.7, and I’m actively working to make it compatible with the latest release of Compact. It’s far from perfect, and that’s what makes it exciting. Every day, I wake up with a new idea, a new feature to add, or a better way to improve the developer experience! ![Create Midnight App](https://ibin.co/8rMdmI75JRDl.png) At its core, **create-midnight-app** is a scaffolding npm library for Midnight that automates the entire setup process. Developers can focus solely on writing their Compact contracts; the tool takes care of the rest. It handles wallet creation, faucet requests, balance checks, API configuration, CLI updates, and even function and file change imports are updated automatically. It reduces initial application setup time from over half an hour to just a few minutes. I had several euphoric moments while working on this project, but one instance in particular, stands out. One feature I was eager to build was a way for developers to request testnet tokens without ever leaving their code editor. The simplest idea was to send a request from the terminal directly to the official [Midnight faucet](https://docs.midnight.network/blog/tags/%20https://midnight.network/test-faucet) . But there was a catch—the site is protected by [Cloudflare Turnstile](https://www.cloudflare.com/application-services/products/turnstile/) , which blocks automated requests to prevent spam and abuse. As a hacker, I started looking for a workaround. After some Googling and tips from friends, I tested several paid tools that claimed to bypass CAPTCHA protections. I spent an entire afternoon trying them, but none worked reliably. That’s when I remembered the genesis wallet, whose private key is publicly available. So, I implemented a workaround: instead of calling the faucet, I simulated a faucet transaction by transferring tokens directly from the genesis wallet to the user’s wallet. It’s not a long-term solution, and I know it won’t scale—but for now, it works and helps streamline the developer experience. Submission and Recognition ========================== I finally submitted my project, and the judges’ reactions were incredibly [encouraging](https://youtu.be/xrCEBIBqS-Y?t=4453) —it gave me a renewed sense of inspiration. With that momentum, I turned my focus back to my original hackathon: the African Blockchain Championship. For this challenge, I built an anonymous, censorship-resistant voting platform. In many African countries—across 34 nations—roughly 30–40% of citizens no longer view voting as a fair or trustworthy process (Afrobarometer, 2023). That’s why anonymous voting isn’t just a feature—it’s a necessity. My project, [**Privote**](https://github.com/kaleababayneh/zkvote-midnight) , aims to address this critical issue by leveraging zero-knowledge technology to protect voter identity and integrity. As the submission deadline approached, I ran into a major hurdle: integrating the wallet into the frontend. I reached out to one of the Developer Relations Engineers, who kindly shared some example code. Unfortunately, I couldn’t get it working in time. With the clock ticking, I had to improvise. I quickly built a custom Chrome extension that enabled wallet interaction—running through the terminal on the backend—just in time for submission. While the current version still has some privacy limitations, the smart contract compiles successfully, and users can interact with it on the Midnight testnet—offering a real glimpse of what decentralized, anonymous voting could look like in practice. ![Private Hackathon](https://ibin.co/8rMho4816dhp.png) The Midnight Community ====================== Even though there aren’t many resources available yet, the Midnight community more than makes up for it. Almost every question asked on Discord gets a response. It’s a space where people genuinely support each other—even during hackathons, when we’re technically competing and have little incentive to help other teams. In fact, during the hackathon, I often found myself answering questions in the Telegram group. I even hosted a workshop at the ABC hackathon on how to use **Create Midnight App**, helping others get started quickly and navigate the ecosystem more easily. I also want to take a moment to thank the Midnight team for the recognition they gave me—it truly meant a lot. Beyond placing first in the CLI track, the support and appreciation I received from the community were genuinely heartwarming. I even had the chance to join a community call—not just as a participant this time, but as a [speaker](https://x.com/MidnightNtwrk/status/1942969613496758398) —to share my journey and the lessons I’d learned along the way. Why Now is the Time to Build on Midnight ======================================== And for you—my readers—this is honestly the best time to get involved in the Midnight ecosystem. There’s _almost always_ a hackathon happening (seriously, it's kind of wild!). Right now, they’re even running a [mini DApp hackathon](https://midnight.network/hackathon/midnight-mini-dapp-hackathon) . It’s an excellent opportunity to learn, build, and get your project noticed. ![Midnight Dapp Hackathon](https://ibin.co/8rMcCFquPRqS.png) As for me, I’m currently building something new for the hackathon. While I enjoy working on projects, I’ve found even more fulfillment in developing infrastructure tools. I have a long-term goal of building a web-based Midnight playground where anyone can start writing Compact code and begin interacting with the Midnight testnet without needing to install anything. I hope to continue collaborating with the Midnight team and growing my skills—especially in zero-knowledge protocols—as I continue this journey. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/mcp#__docusaurus_skipToContent_fallback) AI coding assistants like Claude, GitHub Copilot, and Cursor have transformed how developers write code. But they have a fundamental limitation: they only know what was in their training data. Compact, Midnight's smart contract language, isn't in that training data. When you ask an AI assistant to write a Compact contract, it hallucinates. It invents syntax that doesn't exist, references functions that were never defined, and produces code that fails at compile time. Midnight MCP solves this problem. What is MCP?[​](https://docs.midnight.network/blog/tags/mcp#what-is-mcp "Direct link to What is MCP?") ------------------------------------------------------------------------------------------------------- The _Model Context Protocol_ (MCP) is an open standard that allows AI assistants to access external tools and data sources. Instead of relying solely on training data, an AI assistant with MCP can query live documentation, search codebases, and call APIs. Midnight MCP is an MCP server purpose-built for Midnight development. It gives AI assistants: * **Indexed knowledge** of 102 Midnight repositories * **Real compiler validation** before showing you code * **Semantic search** across documentation and examples * **Version-aware syntax references** for Compact When you ask Claude to write a Compact contract, it queries Midnight MCP for the correct syntax, generates the code, validates it against the real compiler, and only shows you working code. The problem with AI-generated Compact code[​](https://docs.midnight.network/blog/tags/mcp#the-problem-with-ai-generated-compact-code "Direct link to The problem with AI-generated Compact code") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Consider this prompt: "Write a simple counter contract in Compact" Without Midnight MCP, an AI assistant might generate: contract Counter { state count: Int = 0; function increment(): Void { count = count + 1; }} This looks plausible. It's also completely wrong: * Compact uses `ledger` for state, not `state`. * There is no `Int` type in Compact. It uses `Uint<32>`, `Field`, and other specific types. * `Void` doesn't exist. Compact uses `[]` for the unit type. * State mutations require witness functions, not direct assignment. The AI hallucinated a language that resembles Solidity but isn't Compact. A developer unfamiliar with Compact might spend hours debugging code that was never valid. Install Midnight MCP[​](https://docs.midnight.network/blog/tags/mcp#install-midnight-mcp "Direct link to Install Midnight MCP") -------------------------------------------------------------------------------------------------------------------------------- Midnight MCP requires no API keys and installs in under 60 seconds. Add the appropriate configuration to your AI assistant based on the tool you use. ### Claude Desktop[​](https://docs.midnight.network/blog/tags/mcp#claude-desktop "Direct link to Claude Desktop") On macOS, edit `~/Library/Application Support/Claude/claude_desktop_config.json`. Add the following configuration to enable Midnight MCP: { "mcpServers": { "midnight": { "command": "npx", "args": ["-y", "midnight-mcp@latest"] } }} ### Cursor[​](https://docs.midnight.network/blog/tags/mcp#cursor "Direct link to Cursor") Create or edit `.cursor/mcp.json` in your project root. You can also configure it globally at `~/.cursor/mcp.json` on macOS/Linux or `%USERPROFILE%\.cursor\mcp.json` on Windows. Add the following configuration: { "mcpServers": { "midnight": { "command": "npx", "args": ["-y", "midnight-mcp@latest"] } }} ### VS Code with GitHub Copilot[​](https://docs.midnight.network/blog/tags/mcp#vs-code-with-github-copilot "Direct link to VS Code with GitHub Copilot") Create or edit `.vscode/mcp.json` in your project. Add the following configuration to connect Copilot to Midnight MCP: { "servers": { "midnight": { "command": "npx", "args": ["-y", "midnight-mcp@latest"] } }} After adding the configuration, restart your AI assistant. You now have access to [29 Midnight-specific tools](https://docs.midnight.network/blog/tags/mcp#29-tools-for-midnight-development) . How Midnight MCP works[​](https://docs.midnight.network/blog/tags/mcp#how-midnight-mcp-works "Direct link to How Midnight MCP works") -------------------------------------------------------------------------------------------------------------------------------------- Midnight MCP operates as a local server that connects your AI assistant to Midnight's ecosystem. ![Midnight MCP Architecture](https://docs.midnight.network/assets/images/mcp-flow-6300d117555db9ec395e0f419d22de5d.png) When you ask for a Compact contract: 1. The AI assistant calls `midnight-get-latest-syntax` to retrieve current Compact syntax. 2. It generates code using the correct patterns. 3. It calls `midnight-compile-contract` to validate against the real compiler. 4. If compilation fails, it reads the error, fixes the code, and retries. 5. You receive verified, working code. This compile-validate-fix loop happens automatically. You never see the broken intermediate versions. Real compiler integration[​](https://docs.midnight.network/blog/tags/mcp#real-compiler-integration "Direct link to Real compiler integration") ----------------------------------------------------------------------------------------------------------------------------------------------- Most code-generation tools rely on pattern matching and hope. Midnight MCP validates code against the actual Compact compiler hosted. The compiler catches errors that static analysis cannot, including: * **Type mismatches**: Using `Field` where `Uint<64>` is expected * **Sealed field violations**: Attempting to access sealed state incorrectly * **Disclose rule errors**: Missing or malformed privacy annotations * **Unbound identifiers**: References to undefined variables or types When the compiler returns an error, the response includes the exact line number and column: success: falsemessage: "Line 12:8 - unbound identifier 'totalSupply'"errorDetails: line: 12 column: 8 errorType: error The AI assistant uses this information to fix the code and try again. ### Graceful fallback[​](https://docs.midnight.network/blog/tags/mcp#graceful-fallback "Direct link to Graceful fallback") If the hosted compiler is unavailable, Midnight MCP falls back to static analysis. The response indicates which validation method was used: validationType: "compiler" # Real compiler validationvalidationType: "static-analysis-fallback" # Compiler unavailable You always receive validation. The tool never fails silently. Semantic search across 102 repositories[​](https://docs.midnight.network/blog/tags/mcp#semantic-search-across-102-repositories "Direct link to Semantic search across 102 repositories") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Today, Midnight MCP indexes every non-archived repository in the Midnight ecosystem: * All 88 repositories from `midnightntwrk`. * 14 community and partner repositories, including OpenZeppelin contracts and hackathon winners. The search is semantic, not keyword-based. For example, a prompt like "find code that handles shielded transactions" returns relevant results even if those exact words don't appear in the code. Prompt: "How do I implement a token with transfer limits?"midnight-search-compact returns:- Token contract examples from midnight-examples- Rate limiting patterns from community repos- Relevant documentation sections 29 tools for Midnight development[​](https://docs.midnight.network/blog/tags/mcp#29-tools-for-midnight-development "Direct link to 29 tools for Midnight development") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- Midnight MCP provides 29 tools organized by function. ### Search tools[​](https://docs.midnight.network/blog/tags/mcp#search-tools "Direct link to Search tools") Use these tools to find code, documentation, and examples across the Midnight ecosystem. | Tool | Purpose | | --- | --- | | `midnight-search-compact` | Search Compact language code across indexed repos | | `midnight-search-docs` | Search official Midnight documentation | | `midnight-search-typescript` | Search TypeScript SDK implementations | | `midnight-fetch-docs` | Fetch live documentation from docs.midnight.network | ### Analysis tools[​](https://docs.midnight.network/blog/tags/mcp#analysis-tools "Direct link to Analysis tools") Use these tools to validate, analyze, and review Compact contracts. | Tool | Purpose | | --- | --- | | `midnight-compile-contract` | Validate code against the real Compact compiler | | `midnight-analyze-contract` | Run 15 static security checks | | `midnight-review-contract` | AI-powered security review | | `midnight-extract-contract-structure` | Parse contract structure and exports | ### Generation tools[​](https://docs.midnight.network/blog/tags/mcp#generation-tools "Direct link to Generation tools") Use these tools to create new contracts and documentation. | Tool | Purpose | | --- | --- | | `midnight-generate-contract` | Generate contracts from natural language descriptions | | `midnight-document-contract` | Generate documentation in Markdown or JSDoc format | ### Repository tools[​](https://docs.midnight.network/blog/tags/mcp#repository-tools "Direct link to Repository tools") Use these tools to access files and syntax references from Midnight repositories. | Tool | Purpose | | --- | --- | | `midnight-get-file` | Retrieve files from any indexed Midnight repository | | `midnight-get-file-at-version` | Get file content at a specific version | | `midnight-compare-syntax` | Compare syntax between Compact versions | | `midnight-get-latest-syntax` | Current Compact syntax reference | | `midnight-get-repo-context` | Everything needed to start coding (compound tool) | | `midnight-list-examples` | List available example contracts | ### Version management tools[​](https://docs.midnight.network/blog/tags/mcp#version-management-tools "Direct link to Version management tools") Use these tools to manage upgrades and track changes between Compact versions. | Tool | Purpose | | --- | --- | | `midnight-upgrade-check` | Full upgrade analysis (compound tool) | | `midnight-check-breaking-changes` | Identify breaking changes between versions | | `midnight-get-migration-guide` | Step-by-step migration instructions | Resources and prompts[​](https://docs.midnight.network/blog/tags/mcp#resources-and-prompts "Direct link to Resources and prompts") ----------------------------------------------------------------------------------------------------------------------------------- Beyond tools, Midnight MCP provides nine built-in resources and five interactive prompts. _Resources_ are always-available references that provide quick access to syntax and examples: midnight://syntax/latest Current Compact syntaxmidnight://examples/counter Counter contract examplemidnight://examples/token Token contract examplemidnight://docs/compact Compact language reference _Prompts_ are templates for common tasks that guide you through specific workflows: create-compact-contract Start a new contractdebug-compact-error Fix compilation errorssecurity-review Full security auditcompare-compact-versions Migration assistance Architecture[​](https://docs.midnight.network/blog/tags/mcp#architecture "Direct link to Architecture") -------------------------------------------------------------------------------------------------------- Midnight MCP is built for reliability: * **Token efficiency**: Outputs YAML by default (20-30% fewer tokens than JSON) * **Compound tools**: Single calls that combine multiple operations * **Graceful degradation**: Falls back to cached data when services are unavailable * **Progress notifications**: Real-time updates during long operations The codebase is fully tested with 206 tests across 10 test suites. What's next[​](https://docs.midnight.network/blog/tags/mcp#whats-next "Direct link to What's next") ---------------------------------------------------------------------------------------------------- Midnight MCP is open source and actively developed. The roadmap includes: * **Full ZK circuit output parsing** from compiler results. * **Contract deployment** directly from AI chat. * **TypeScript SDK integration** for automatic prover code generation. * **Local devnet interaction** for querying balances and submitting transactions. Learn more[​](https://docs.midnight.network/blog/tags/mcp#learn-more "Direct link to Learn more") -------------------------------------------------------------------------------------------------- Explore the source code and contribute: → [GitHub repository](https://github.com/Olanetsoft/midnight-mcp) → [npm package](https://npmjs.com/package/midnight-mcp) → [API documentation](https://github.com/Olanetsoft/midnight-mcp/blob/main/docs/API.md) _Midnight MCP is a community project. Contributions, issues, and feature requests are welcome._ --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/spo#__docusaurus_skipToContent_fallback) Last month, we introduced the Midnight Indexer, a modular, high-performance indexing service written in Rust. Today, we’re excited to share that the Rust-based Midnight Indexer has officially replaced the legacy Scala-based Pub-Sub Indexer. A major Midnight Testnet upgrade introduces version 1.5, bringing key changes that require validator re-registration, improved node setup, and enhanced tooling for partner-chain participants. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/spos#__docusaurus_skipToContent_fallback) As we progress through the **Hilo** phase and prepare for the upcoming milestones of the Midnight Network, we are adjusting testing environments to ensure a seamless transition to a decentralized mainnet. Midnight `Testnet-02` has been a monumental success, serving as the crucible for Midnight’s zero-knowledge capabilities. We want to extend our deepest gratitude to the over **180+** Cardano Stake Pool Operators (SPOs) who actively participated in the `Testnet-02` environment and their ongoing support for the Midnight project. In previous communications, we signaled that SPOs would migrate directly to the Midnight `Preview` environment at this stage. However, as we refine the roadmap toward the **Kūkolu** (Federated Mainnet) phase, we have made a strategic pivot. While `Testnet-02` validators may continue to run their nodes until **February 28, 2026**, the Midnight `Preview` environment will be temporarily maintained by core engineering. This shift allows us to: * Perform high velocity testing and rapid iterations. * Finalize the integration of novel features such as the DUST Capacity Exchange. * Ensure a stable, rapid-test environment for core development that would otherwise cause unnecessary disruption and downtime for independent SPOs. | Phase | Milestone | SPO & Validator Role | | --- | --- | --- | | Hilo | Token Genesis | Initial liquidity and NIGHT "Glacier Drop" on Cardano. | | Kūkolu | Federated Mainnet | Ecosystem partners maintain stability during rapid development. | | Mōhalu | Incentivized Mainnet | SPO Onboarding begins including other testing. | | Hua | Full Decentralization | Block production transitions to community. | This keeps the structure clean and focused on phases, milestones, and roles. _Please note: All dates are estimates._ We acknowledge that this change differs from previous expectations, but we believe this path ensures the highest quality environment for SPOs to return for **Mōhalu**. important Validator documentation status[​](https://docs.midnight.network/blog/tags/spos#validator-documentation-status "Direct link to Validator documentation status") --------------------------------------------------------------------------------------------------------------------------------------------------------------- To avoid confusion during this transition, **current validator documentation will be temporarily unpublished** or hidden from the main site. This ensures that **when you return to the docs for the Mōhalu phase, they will be 100% accurate**, refreshed, and aligned with the new architecture. Direct action on your feedback[​](https://docs.midnight.network/blog/tags/spos#direct-action-on-your-feedback "Direct link to Direct action on your feedback") --------------------------------------------------------------------------------------------------------------------------------------------------------------- We recently conducted a feedback survey to understand your operational experience. We heard your feedback regarding documentation, setup friction, and infrastructure control. In preparation for the **Mōhalu** phase, we are implementing the following changes: * We are moving away from a Docker-only distribution. We are now delivering pre-compiled binaries for `midnight-node` and restructuring our documentation to be binary and source-first. While containerization is useful, we recognize that barebones instructions are fundamental for professional SPO infrastructure. * The next node version will completely remove the registration wizard, allowing for a more direct and scriptable registration process. * We are prioritizing new architecture recommendation for secrets management and air-gapped signing guidance. We recognize that for a privacy-focused chain, the security of our validators' keys is paramount. * In the lead up to Mōhalu, we promise more structued communication cadence and dedicated SPO/ validator calls. Staying informed: Subscribe to Midnight Validator Updates[​](https://docs.midnight.network/blog/tags/spos#staying-informed-subscribe-to-midnight-validator-updates "Direct link to Staying informed: Subscribe to Midnight Validator Updates") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 👉 To ensure you receive the latest technical specifications, onboarding guides, and timeline adjustments for the **Mōhalu** phase, we encourage all SPOs to subscribe via the Midnight Validator Digest: [https://mpc.midnight.network/midnight-validator-digest](https://mpc.midnight.network/midnight-validator-digest) 👉 Join other validators and builders in the Midnight Discord server: [https://discord.com/invite/midnightnetwork](https://discord.com/invite/midnightnetwork) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/night#__docusaurus_skipToContent_fallback) To understand this system, it helps to use an analogy. * **Night** is like a **Solar Panel**. It is a valuable asset you hold. * **Dust** is like **Electricity**. It represents the computational throughput or gas generated by the Solar Panel (Night). * **Usage**. You consume the Electricity (DUST) as gas to power your operations on the network. Unlike standard cryptocurrencies where you have a static balance (e.g., "I have 5 coins"), your Dust balance changes dynamically based on time and the status of your Night tokens. Dust and network usage[​](https://docs.midnight.network/blog/tags/night#dust-and-network-usage "Direct link to Dust and network usage") ---------------------------------------------------------------------------------------------------------------------------------------- Dust operates similarly to, but separately from, [Zswap](https://github.com/midnightntwrk/midnight-ledger/blob/main/spec/zswap.md) . Dust operates as the resource credit system for Midnight. It function * **Shielded and Non-transferable:** Dust is a shielded capacity resource _only_ for gas. It cannot be transferred between users. * **Dynamic Capacity:** The available gas in a Dust UTXO is dynamically computed and derived from an associated Night UTXO. * **Growth & Decay:** The computed value grows over time to a maximum based on its Night UTXO, and decays to zero after its Night UTXO is spent. * **Non-Persistent:** The system may redistribute it on hardforks. (Note: The Midnight protocol reserves the right to modify Dust allocation rules, e.g., for garbage collection). Design overview[​](https://docs.midnight.network/blog/tags/night#design-overview "Direct link to Design overview") ------------------------------------------------------------------------------------------------------------------- Similar to Zswap, Dust is built on hashes and the commitment/nullifier paradigm. Each Dust UTXO has a **commitment** inserted into an append-only Merkle tree upon creation, and a **nullifier** inserted into a nullifier set upon spending. A Dust "spend" is a 1-to-1 "transfer" (Self-Spend): 1. **Input:** 1 Dust UTXO (nullifier). 2. **Output:** 1 Dust UTXO (commitment). 3. **Fee:** A public declaration of fees paid. It includes a zero-knowledge proof that: 1. The input is valid and exists in the Merkle tree. 2. The output value equals the _updated_ input value minus the gas consumed. 3. The output nullifier is correct, and the owner remains the same. ### Lifecycle: NIGHT generates DUST[​](https://docs.midnight.network/blog/tags/night#lifecycle-night-generates-dust "Direct link to Lifecycle: NIGHT generates DUST") Conceptually, Dust is generated over time by held _Night_ UTXOs. As long as a backing Night UTXO remains unspent, the associated Dust UTXO generates value up to a cap ($\\rho$). Once the backing Night is spent, the Dust UTXO "decays" to zero. The following diagram illustrates this lifecycle: The rate of generation depends on the amount of night held ($N$), the ratio of the Dust cap to Night held ($\\rho$), and "time to cap" ($\\Delta$). **Spending Rules:** * Dust may be spent multiple times; a new UTXO is always created, even if its value is zero. * Spending during decay is permitted and does not change the decay rate. * Once the backing Night is spent, Dust immediately starts to decay, even if it was still in the generation phase. * If only a portion of backing Night is spent, the change creates a new Night UTXO (starting fresh Dust generation), while the old Dust UTXO decays. **Implementation Note:** In practice, value is not processed continuously. It is calculated **at the time of spend** using metadata ("generation info"): 1. Creation time of the Dust UTXO. 2. Creation time of the backing Night UTXO. 3. Deletion time of the backing Night UTXO. Since Dust and Night use different keys, a **Registration Table** links Night public keys to Dust public keys. A new Dust UTXO is created if and only if a Night UTXO is created _and_ its key has a table entry. **The Grace Period:** Because Dust usage is shielded, the value is computed for the time of _transaction creation_. To account for network delays, the protocol defines a **Dust Grace Period** (for example, 3 hours). A transaction is accepted if its timestamp is within this window relative to the block time. Preliminaries[​](https://docs.midnight.network/blog/tags/night#preliminaries "Direct link to Preliminaries") ------------------------------------------------------------------------------------------------------------- DUST uses ZK-friendly hashes. type DustSecretKey = Fr;type DustPublicKey = field::Hash; Dust UTXOs have owners, values, and **nonces**. Nonces evolve deterministically to enable wallet recovery. * **First Dust UTXO:** Nonce derived from the originating Night UTXO intent hash. * **Subsequent Dust UTXOs:** Nonce derived from the previous sequence number and owner's secret key. struct DustOutput { initial_value: u128, // Specks at creation owner: DustPublicKey, nonce: field::Hash<(InitialNonce, u32, Fr)>, seq: u32, ctime: Timestamp,} State components include the commitment tree, nullifier set, and root history: struct DustUtxoState { commitments: MerkleTree, commitments_first_free: usize, nullifiers: Set, root_history: TimeFilterMap,} Initial DUST parameters[​](https://docs.midnight.network/blog/tags/night#initial-dust-parameters "Direct link to Initial DUST parameters") ------------------------------------------------------------------------------------------------------------------------------------------- * **Night Unit:** `Star (1 Night = 10^6 Stars)` * **Dust Unit:** `Speck (1 Dust = 10^15 Specks)` const INITIAL_DUST_PARAMETERS: DustParameters = { night_dust_ratio = 5_000_000_000; // 5 DUST per NIGHT generation_decay_rate = 8_267; // ~1 week generation time dust_grace_period = Duration::from_hours(3),}; Dust actions[​](https://docs.midnight.network/blog/tags/night#dust-actions "Direct link to Dust actions") ---------------------------------------------------------------------------------------------------------- Users influence Dust state via **Intents**. struct DustActions { spends: Vec>, registrations: Vec, ctime: Timestamp,} ### Registrations and fees[​](https://docs.midnight.network/blog/tags/night#registrations-and-fees "Direct link to Registrations and fees") `DustRegistration` links a Night key to a Dust key. * Registrations happen sequentially. * If a registration transaction uses Night inputs that _were not yet generating Dust_ (meaning that they had no previous registration), the system can "backdate" the registration to use the Dust those inputs _would have generated_ to pay for the gas. Generating DUST[​](https://docs.midnight.network/blog/tags/night#generating-dust "Direct link to Generating DUST") ------------------------------------------------------------------------------------------------------------------- Night inputs/outputs trigger updates to a **Dust Generation Tree**. * **DustGenerationInfo:** Stores the amount of Night, the owner, and the `dtime` (deletion time). * **Address Map:** Links Night Addresses -> Dust Addresses. struct DustGenerationInfo { value: u128, owner: DustPublicKey, nonce: InitialNonce, dtime: Timestamp, // Set to MAX if Night is unspent} Dust value and spends[​](https://docs.midnight.network/blog/tags/night#dust-value-and-spends "Direct link to Dust value and spends") ------------------------------------------------------------------------------------------------------------------------------------- The value of a Dust UTXO is calculated based on four linear time segments: 1. **Generating:** From creation to Capacity (or Night spend). 2. **Constant (Max):** At capacity until Night spend. 3. **Decaying:** From Night spend until value hits zero. 4. **Constant (Zero):** Forever after. ### The Spend transaction[​](https://docs.midnight.network/blog/tags/night#the-spend-transaction "Direct link to The Spend transaction") A `DustSpend` consumes a UTXO and creates a new one with updated value minus fees. The validation logic (`dust_spend_valid`) ensures: * `commitment_merkle_tree` contains the input. * `dust_spend.old_nullifier` matches the derived nullifier. * `updated_value` covers the fee. * `new_commitment` is correctly formed. Wallet recovery[​](https://docs.midnight.network/blog/tags/night#wallet-recovery "Direct link to Wallet recovery") ------------------------------------------------------------------------------------------------------------------- Wallets recover funds by: 1. Identifying owned Night UTXOs (the start of the chain). 2. Linearly searching for commitments corresponding to sequence numbers ($0, 1, 2...$). 3. **Privacy:** Wallets should query commitments using bit-prefixes (stochastic filtering) rather than exact lookups to preserve privacy against the indexing service. The implementation[​](https://docs.midnight.network/blog/tags/night#the-implementation "Direct link to The implementation") ---------------------------------------------------------------------------------------------------------------------------- ### DUST Generation from Cardano NIGHT Token — Full Process[​](https://docs.midnight.network/blog/tags/night#dust-generation-from-cardano-night-token--full-process "Direct link to DUST Generation from Cardano NIGHT Token — Full Process") The generation of **DUST** from the Cardano **NIGHT** token (cNIGHT) is a cross-chain process managed by the **Native Token Observation Pallet** (`pallet_cnight_observation`) on the Midnight partner chain. ### Summary of the full flow[​](https://docs.midnight.network/blog/tags/night#summary-of-the-full-flow "Direct link to Summary of the full flow") 1/ User registers their Cardano reward address + DUST public key on Cardano. 2/ Any time a cNIGHT UTXO is created (received) or spent (sent) by that address, the event is broadcast. 3–4/ The Midnight pallet validates that exactly one valid registration exists and observes the cNIGHT activity. 5–6/ It determines whether it’s a receive (creation) or send (destruction) of cNIGHT → generates corresponding DUST creation or destruction event. 7–9/ All events in a block are batched, wrapped into a single system transaction via LedgerApi, and executed on the Midnight ledger. → Final result: DUST supply and UTXOs are updated 1:1 with cNIGHT movements on Cardano. * * * 👉 **Now that you have an overview of DUST, checkout the [DUST spec](https://github.com/midnightntwrk/midnight-ledger/blob/main/spec/dust.md) on Github!** 👉 **Get involved in [the code](https://raw.githubusercontent.com/midnightntwrk/midnight-node/refs/heads/main/primitives/mainchain-follower/src/data_source/cnight_observation.rs) on Github!** --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/zkp#__docusaurus_skipToContent_fallback) Kachina employs non-interactive zero-knowledge proofs to allow users to prove valid state transitions without revealing private data. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/testnet-02-transition#__docusaurus_skipToContent_fallback) As we progress through the **Hilo** phase and prepare for the upcoming milestones of the Midnight Network, we are adjusting testing environments to ensure a seamless transition to a decentralized mainnet. Midnight `Testnet-02` has been a monumental success, serving as the crucible for Midnight’s zero-knowledge capabilities. We want to extend our deepest gratitude to the over **180+** Cardano Stake Pool Operators (SPOs) who actively participated in the `Testnet-02` environment and their ongoing support for the Midnight project. In previous communications, we signaled that SPOs would migrate directly to the Midnight `Preview` environment at this stage. However, as we refine the roadmap toward the **Kūkolu** (Federated Mainnet) phase, we have made a strategic pivot. While `Testnet-02` validators may continue to run their nodes until **February 28, 2026**, the Midnight `Preview` environment will be temporarily maintained by core engineering. This shift allows us to: * Perform high velocity testing and rapid iterations. * Finalize the integration of novel features such as the DUST Capacity Exchange. * Ensure a stable, rapid-test environment for core development that would otherwise cause unnecessary disruption and downtime for independent SPOs. | Phase | Milestone | SPO & Validator Role | | --- | --- | --- | | Hilo | Token Genesis | Initial liquidity and NIGHT "Glacier Drop" on Cardano. | | Kūkolu | Federated Mainnet | Ecosystem partners maintain stability during rapid development. | | Mōhalu | Incentivized Mainnet | SPO Onboarding begins including other testing. | | Hua | Full Decentralization | Block production transitions to community. | This keeps the structure clean and focused on phases, milestones, and roles. _Please note: All dates are estimates._ We acknowledge that this change differs from previous expectations, but we believe this path ensures the highest quality environment for SPOs to return for **Mōhalu**. important Validator documentation status[​](https://docs.midnight.network/blog/testnet-02-transition#validator-documentation-status "Direct link to Validator documentation status") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- To avoid confusion during this transition, **current validator documentation will be temporarily unpublished** or hidden from the main site. This ensures that **when you return to the docs for the Mōhalu phase, they will be 100% accurate**, refreshed, and aligned with the new architecture. Direct action on your feedback[​](https://docs.midnight.network/blog/testnet-02-transition#direct-action-on-your-feedback "Direct link to Direct action on your feedback") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- We recently conducted a feedback survey to understand your operational experience. We heard your feedback regarding documentation, setup friction, and infrastructure control. In preparation for the **Mōhalu** phase, we are implementing the following changes: * We are moving away from a Docker-only distribution. We are now delivering pre-compiled binaries for `midnight-node` and restructuring our documentation to be binary and source-first. While containerization is useful, we recognize that barebones instructions are fundamental for professional SPO infrastructure. * The next node version will completely remove the registration wizard, allowing for a more direct and scriptable registration process. * We are prioritizing new architecture recommendation for secrets management and air-gapped signing guidance. We recognize that for a privacy-focused chain, the security of our validators' keys is paramount. * In the lead up to Mōhalu, we promise more structued communication cadence and dedicated SPO/ validator calls. Staying informed: Subscribe to Midnight Validator Updates[​](https://docs.midnight.network/blog/testnet-02-transition#staying-informed-subscribe-to-midnight-validator-updates "Direct link to Staying informed: Subscribe to Midnight Validator Updates") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 👉 To ensure you receive the latest technical specifications, onboarding guides, and timeline adjustments for the **Mōhalu** phase, we encourage all SPOs to subscribe via the Midnight Validator Digest: [https://mpc.midnight.network/midnight-validator-digest](https://mpc.midnight.network/midnight-validator-digest) 👉 Join other validators and builders in the Midnight Discord server: [https://discord.com/invite/midnightnetwork](https://discord.com/invite/midnightnetwork) * [Validator documentation status](https://docs.midnight.network/blog/testnet-02-transition#validator-documentation-status) * [Direct action on your feedback](https://docs.midnight.network/blog/testnet-02-transition#direct-action-on-your-feedback) * [Staying informed: Subscribe to Midnight Validator Updates](https://docs.midnight.network/blog/testnet-02-transition#staying-informed-subscribe-to-midnight-validator-updates) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures#__docusaurus_skipToContent_fallback) Two foundational cryptographic tools—hash functions and digital signatures—ensure data integrity, authenticity, and trust in decentralized Web3 systems like Midnight. I'm still at the beginning of my [Web3 journey](https://docs.midnight.network/blog/web3-intro) , and already it’s clear: before you can build the future, you have to understand the foundations. This week, I focused on two key cryptographic building blocks: hash functions and digital signatures. These concepts might initially sound intimidating, but they're at the core of blockchain, ensuring data integrity, authenticity, and security. I learned about them through the "Intro to Blockchain" section of the [Cardano Academy](https://academy.cardanofoundation.org/) —a fantastic first stop on my learning journey. Here's a breakdown of what I took away. Hash Functions – The Digital Fingerprints of Blockchain[​](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures#hash-functions--the-digital-fingerprints-of-blockchain "Direct link to Hash Functions – The Digital Fingerprints of Blockchain") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Hash functions are everywhere in a blockchain—they link blocks, verify data, and secure transactions. Think of a hash function as a digital fingerprint: it takes an input of any size and produces a fixed-length string (called a **hash digest**) that uniquely represents that input. ### Key Properties of Cryptographic Hash Functions[​](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures#key-properties-of-cryptographic-hash-functions "Direct link to Key Properties of Cryptographic Hash Functions") To be helpful in a blockchain or cryptographic setting, hash functions must possess several specific properties that ensure their security and reliability. Some of the most important properties include: * **One-way**: You can go from input to hash, but not vice versa. * **Deterministic**: The same input will always produce the same output. * **Avalanche Effect**: A tiny input change causes a massive output change. * **Preimage Resistance**: You can't guess the input just by looking at the hash. * **Collision Resistance**: It's nearly impossible to find two different inputs that give the same hash. These properties are critical for ensuring that once data is recorded—like a transaction—it can't be altered without detection. ### Real-World Use Cases[​](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures#real-world-use-cases "Direct link to Real-World Use Cases") Hash functions aren’t just theoretical—they’re used all the time in real-world systems to keep data secure. Here are a few practical ways they show up: * **Password storage**: Systems store hashes, not the actual passwords. * **Data integrity**: Hashes are used to check if data has been altered. **Blockchain linking**: Every block contains the previous block's hash—alter one, and the whole chain breaks. Popular hash functions include SHA-256 (used by Bitcoin), SHA-3, and RIPEMD-160. Some older algorithms, such as MD5 and SHA-1, are now considered insecure due to collision vulnerabilities. Digital Signatures – Proving Who Sent What (and That It Wasn't Changed)[​](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures#digital-signatures--proving-who-sent-what-and-that-it-wasnt-changed "Direct link to Digital Signatures – Proving Who Sent What (and That It Wasn't Changed)") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- If hash functions are about verifying data _hasn't changed_, digital signatures go a step further by proving **who sent the data**. This gives us **authenticity** and **non-repudiation**. ### How They Work (In a Nutshell)[​](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures#how-they-work-in-a-nutshell "Direct link to How They Work (In a Nutshell)") The digital signature process cleverly combines hashing and encryption to guarantee both authenticity and integrity. Here's a high-level overview of how it works: 1. **Signing**: The sender hashes the original message and encrypts that hash using their private key, creating the **digital signature**. 2. **Verifying**: The recipient uses the sender's public key to decrypt the signature and then checks if the result matches the hash of the received message. 3. If the hashes match, the message is verified. If not, it's been tampered with. Now, let’s make this less abstract. Think of it like sending a secure email using [PGP (Pretty Good Privacy)](https://www.varonis.com/blog/pgp-encryption) : When you send an encrypted email using PGP, your email client uses your private key to sign the message. Anyone who receives it can use your public key to confirm it was really you who sent it, and that the content hasn’t been changed in transit. The same principles apply to digital signatures on the blockchain: the sender signs a message or transaction, and anyone with the public key can verify it. While the tools and context differ, the underlying idea remains familiar: use cryptographic keys to establish trust without relying on a centralized authority. ### Why This Matters[​](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures#why-this-matters "Direct link to Why This Matters") * Only the private key can create a valid signature. * Anyone can use the public key to verify it. * If someone tampers with the message, the signature will fail verification. ### Types of Digital Signature Algorithms[​](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures#types-of-digital-signature-algorithms "Direct link to Types of Digital Signature Algorithms") Different blockchains and cryptographic systems utilize various signature algorithms, depending on their specific security and performance requirements. A few notable examples are: * **RSA**: Based on the difficulty of factoring large numbers. * **DSA**: Based on the discrete log problem. * **ECDSA**: A more efficient elliptic curve version used by Bitcoin. * **Ed25519**: The one used by Cardano, known for its speed, security, and small key sizes. ### Wallets: Where the Magic Happens[​](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures#wallets-where-the-magic-happens "Direct link to Wallets: Where the Magic Happens") Most of us don’t interact directly with private keys or raw cryptographic operations. Wallets make it manageable by handling keys and signing transactions securely in the background. There are two main types of wallets: * **Custodial wallets**: A third party, such as an exchange, manages your keys. * **Non-custodial wallets**: You control your own keys—more responsibility, but more control. Wallets also fall into two categories: hot (online) and cold (offline) storage. Hardware wallets, such as Ledger or Trezor, are considered cold storage because they keep your keys offline. Cold wallets are generally preferred for long-term or high-value holdings due to their increased security. Conclusion[​](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures#conclusion "Direct link to Conclusion") ----------------------------------------------------------------------------------------------------------------------------------- Hash functions and digital signatures are like the grammar and punctuation of blockchain. They quietly enable much of what makes the ecosystem secure and trustless. Learning about them provided a clearer understanding of how blockchains, such as Cardano, and tools like Midnight operate under the hood. I highly recommend checking out [Cardano Academy](https://academy.cardanofoundation.org/) . It's approachable and well-structured. I also suggest doing your own research and diving into the Midnight documentation and Dev Diaries for more technical depth. Be sure to check out [last week’s blog post](https://docs.midnight.network/blog/web3-intro) on blockchain fundamentals. If you're learning Web3 with me, I'd love to hear what's helped you, what's tripped you up, and what topics you'd like to see explored next. More foundational concepts to come next week! * [Hash Functions – The Digital Fingerprints of Blockchain](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures#hash-functions--the-digital-fingerprints-of-blockchain) * [Key Properties of Cryptographic Hash Functions](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures#key-properties-of-cryptographic-hash-functions) * [Real-World Use Cases](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures#real-world-use-cases) * [Digital Signatures – Proving Who Sent What (and That It Wasn't Changed)](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures#digital-signatures--proving-who-sent-what-and-that-it-wasnt-changed) * [How They Work (In a Nutshell)](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures#how-they-work-in-a-nutshell) * [Why This Matters](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures#why-this-matters) * [Types of Digital Signature Algorithms](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures#types-of-digital-signature-algorithms) * [Wallets: Where the Magic Happens](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures#wallets-where-the-magic-happens) * [Conclusion](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures#conclusion) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/midnight#__docusaurus_skipToContent_fallback) Introduction to the FungibleToken contract on Midnight[​](https://docs.midnight.network/blog/tags/midnight#introduction-to-the-fungibletoken-contract-on-midnight "Direct link to Introduction to the FungibleToken contract on Midnight") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- **Midnight** is a privacy-first blockchain designed to bring _privacy_ to decentralized applications. It achieves this through [zero-knowledge proofs, programmable data protection, and developer-friendly tools](https://docs.midnight.network/develop/how-midnight-works/) like **Compact**, a TypeScript-based DSL (Domain-Specific Language) for writing privacy-aware smart contracts. [**OpenZeppelin**](https://docs.openzeppelin.com/) is renowned in the Ethereum ecosystem for its battle-tested smart contract libraries, which have secured trillions in on-chain value. Recently, [OpenZeppelin partnered with Midnight](https://midnight.network/blog/openzeppelin-joins-forces-with-midnight-to-shape-the-future-of-privacy-preserving-smart) to bring comparable tooling to the Compact ecosystem, adapting familiar standards like ERC-20 into privacy-preserving variants. In the Ethereum world, the **ERC-20** standard defines a fungible token with public ledger functions like `balanceOf`, `transfer`, `approve`, etc. It exposes transaction data transparently and lacks built-in privacy. The **FungibleToken** contract on Midnight draws inspiration from this, but operates within Midnight’s zero-knowledge, selective-disclosure framework. Fungible tokens are a cornerstone of the blockchain ecosystem, representing digital assets that are interchangeable – much like traditional currency. On various blockchains, these tokens power a wide array of applications, from facilitating seamless transactions and enabling decentralized finance (DeFi) protocols to representing ownership in digital communities and driving the mechanics of in-game economies. Unlike unique non-fungible tokens (NFTs), the value of one fungible token is identical to another of the same type, making them ideal for use cases requiring divisibility and ease of exchange. Their widespread adoption underscores their importance in building liquid and interconnected digital economies. In this article, you'll learn about the core features of the contract, including how it manages ledger state variables, its key entry points and circuits for operations like minting, burning, and transferring tokens, and the essential safety and utility functions provided by the **Utils** and **Initializable** modules. By understanding how these components fit together, you’ll gain insight into how the **FungibleToken** contract balances fungibility, usability, and privacy, providing an essential building block for privacy-preserving DeFi, identity, and tokenized assets on Midnight. * * * Features of the FungibleToken Contract[​](https://docs.midnight.network/blog/tags/midnight#features-of-the-fungibletoken-contract "Direct link to Features of the FungibleToken Contract") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- The FungibleToken contract on Midnight utilizes ledger state variables to keep track of balances, allowances, total supply, name, symbol, and decimals. Its functionality is exposed through "circuits" (entry points) like `Mint`, `Burn`, `Transfer`, `Approve`, `TransferFrom`, and `Initialize`, all of which enforce specific zero-knowledge validated transitions and maintain the integrity of the token's state. ### Ledger State Variables[​](https://docs.midnight.network/blog/tags/midnight#ledger-state-variables "Direct link to Ledger State Variables") In Compact, the contract defines a structured **state** storing token balances and allowances—similar to ERC-20. The `_balances` map keeps track of the users’ token balances and is updated when a transfer occurs. The `_allowances` map keeps track of the permission given to specific users to spend tokens on behalf of another user: export ledger _balances: Map, Uint<128>>;export ledger _allowances: Map, Map, Uint<128>>>; These values live in the contract's ledger and are updated through transactions sent to the contract. There are other values in the ledger that are set when the contract is deployed: export ledger _totalSupply: Uint<128>;export sealed ledger _name: Opaque<"string">;export sealed ledger _symbol: Opaque<"string">;export sealed ledger _decimals: Uint<8>; These values provide different information about the token managed by the contract, its total supply, its name, its symbol, and its decimal (for display). ### Entry Points and Circuits[​](https://docs.midnight.network/blog/tags/midnight#entry-points-and-circuits "Direct link to Entry Points and Circuits") In Compact, entry points are defined as **circuits** (akin to Solidity functions), each modelling a zero-knowledge validated transition. The difference between a circuit entry point and a circuit is that the entry point is callable via a transaction, while the non-entry point circuit is internal. Core circuits include: * **`Mint` / `Burn`** (to mint new tokens or burn existing tokens). * **`Transfer`**: to move tokens between addresses. * **`Approve`**, **`TransferFrom`**: standard ERC-20-style delegation mechanisms. * **`Initialize`**: via the **Initializable** module for contract setup. Each circuit enforces necessary constraints — for example, ensuring sufficient balance, managing allowance decrements, and preserving total supply. In the next step of the contract lifecycle, the different metadata stored in the ledger of the contract are safely initialized. Initialization and Metadata\*\*[​](https://docs.midnight.network/blog/tags/midnight#initialization-and-metadata "Direct link to Initialization and Metadata**") ---------------------------------------------------------------------------------------------------------------------------------------------------------------- The following circuits define the essential setup and retrieval logic for the fungible token metadata and users’ balances, enforcing correct initialization. * **`initialize(name_, symbol_, decimals_)`** One-time setup. Calls `Initializable_initialize()`, then stores the (disclosed) name, symbol, and decimals. Every other public circuit asserts that the contract is initialized first. * **`name()` / `symbol()` / `decimals()` / `totalSupply()`** Simple getters that first assert initialized, then return the sealed (read only) ledger values. * **`balanceOf(account)`** Safe map lookup that returns `0` if the account isn’t present (to prevent contract failure if the key is absent). * * * The Transfer Family[​](https://docs.midnight.network/blog/tags/midnight#the-transfer-family "Direct link to The Transfer Family") ---------------------------------------------------------------------------------------------------------------------------------- The `FungibleToken` contract's **transfer** circuits manage token movement. Key circuits include: `transfer` for safe user-initiated transfers, `_unsafeTransfer` for internal token movement, `_transfer` for administrative transfers, `_unsafeUncheckedTransfer` for low-level token movement, and `_update` as the central accounting function for all token operations. These are split into **safe** and **unsafe** variants because **sending to contract addresses is currently disallowed** (until contract-to-contract interactions are supported). “Safe” circuits enforce that policy; “unsafe” ones let you bypass it—explicitly marked as dangerous in comments. * **`transfer(to, value)` → `Boolean`** Safe user-initiated transfer: rejects if `to` is a `ContractAddress`. Internally, it just forwards to the unsafe variant after the check. * **`_unsafeTransfer(to, value)` → `Boolean`** Owner is the caller (`left(ownPublicKey())`). Moves value using the unchecked internal mover, then returns `true`. * **`_transfer(from, to, value)` → `[]`** Admin/extension hook that moves tokens **from an arbitrary `from`** (not necessarily the caller). Still enforces the “no contracts as `to`” rule and then uses the same mover underneath. * **`_unsafeUncheckedTransfer(from, to, value)` → `[]`** The low-level mover checks that neither side is the zero/burn address and then delegates the actual accounting to `_update`. * **`_update(from, to, value)` → `[]`** **Central accounting function** used by all mint/burn/transfer paths. It’s an internal circuit; it cannot be called via a transaction. * If `from` is zero, the **mint** circuit is called, it asserts no `uint128` overflow, and increases `_totalSupply`. * Else, it deducts from `from` balance (or reverts on insufficient funds). * If `to` is zero, the **burn** circuit is called, and it decreases `_totalSupply`. * Else, it adds to `to` balance. This single function guarantees the invariants for every movement of value. The "transfer family" circuits ensure secure token movement, with "safe" variants disallowing transfers to contract addresses and "unsafe" variants providing lower-level control. This leads us to explore how allowances function, enabling delegated token spending. * * * Allowances (approve / spend / transferFrom)[​](https://docs.midnight.network/blog/tags/midnight#allowances-approve--spend--transferfrom "Direct link to Allowances (approve / spend / transferFrom)") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ This section details the allowance mechanisms within the FungibleToken contract, which enable users to delegate spending permissions to other addresses. These circuits facilitate secure, approved transfers on behalf of an owner without directly exposing their private keys. * **`allowance(owner, spender)`** Read the nested `_allowances` map, returning `0` when keys are missing (no revert). * **`approve(spender, value)` → `Boolean`** The owner is the caller. Forwards to `_approve(owner, spender, value)` and returns `true`. * **`transferFrom(from, to, value)` → `Boolean`** Safe delegated transfer: enforces the “no contract receiver” rule, then defers to `_unsafeTransferFrom`. * **`_unsafeTransferFrom(from, to, value)` → `Boolean`** The spender is the caller. First spends allowance via `_spendAllowance(from, spender, value)`, then moves value using `_unsafeUncheckedTransfer`. Returns `true`. * **`_approve(owner, spender, value)` → `[]`** It ensures that both the owner and the spender are valid, creates the owner’s entry in the map if needed, and then writes the allowance. (This mirrors OZ’s ERC-20 pattern of public `approve()` → internal `_approve()`.) * **`_spendAllowance(owner, spender, value)` → `[]`** It deducts from the allowance unless it’s “infinite.” The implementation treats **`MAX_UINT128`** as infinite: if `currentAllowance == MAX`, it doesn’t decrement; otherwise, it asserts `currentAllowance ≥ value` and writes back `currentAllowance - value`. This is important because it supports “no-friction approvals” by letting apps set MAX once. So, we just covered how allowances let people delegate token spending—basically, giving others permission to move their tokens. Up next, we'll dive into how we create and delete tokens in the contract. * * * Minting and Burning[​](https://docs.midnight.network/blog/tags/midnight#minting-and-burning "Direct link to Minting and Burning") ---------------------------------------------------------------------------------------------------------------------------------- Here's how the FungibleToken contract handles making and destroying tokens. We'll dive into the `_mint` and `_burn` functions, showing what they do and how they link up with the main accounting system. * **`_mint(account, value)`** (safe) → `[]` It forbids minting **to** a contract address (same contract-to-contract restriction), then forwards to `_unsafeMint`. * **`_unsafeMint(account, value)`** → `[]` It validates the receiver’s address, then calls `_update(burnAddress(), account, value)`—i.e., mint is modelled as a transfer **from** the burn/zero address. * **`_burn(account, value)`** → `[]` It validates the sender’s address, then calls `_update(account, burnAddress(), value)`—i.e., burn is a transfer **to** the burn/zero address. _Note:_ The actual notion of “zero/burn” address is standardized in the Utils module; you can also see helpers like `Utils_isKeyOrAddressZero` and `Utils_isContractAddress`. Because mint and burn also route through `_update`, **total supply is adjusted in exactly one place,** and the same safety checks apply across all flows (including the `uint128` overflow check on mint). The mint and burn circuits, by using the `_update` function, make sure the total supply adjustments are always consistent and that all token flows get the same safety checks. Now, let's dive into the extra safety and utility stuff that the `Utils` and `Initializable` modules bring to the table. * * * Safety and Utility Glue (from `Utils` and `Initializable`)[​](https://docs.midnight.network/blog/tags/midnight#safety-and-utility-glue-from-utils-and-initializable "Direct link to safety-and-utility-glue-from-utils-and-initializable") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- This section explores how the `Utils` and `Initializable` modules provide essential safeguards and helpful functionalities. These components are vital for ensuring the contract's integrity and enabling secure, well-managed operations. * **Initialization guards**: The `Initializable_initialize` and `Initializable_assertInitialized` functions serve as crucial initialization guards within the `Initializable` contract. These safeguards ensure that a contract's state is properly set up only once and that subsequent operations only proceed if the contract has been correctly initialized. Every circuit that interacts with or modifies the contract's state is designed to invoke the `assert` function, reinforcing the integrity of the initialization process. * **Address helpers**: * `Utils_isContractAddress(either)` distinguishes user keys from contract addresses. * `Utils_isKeyOrAddressZero(either)` detects the zero/burn address used in `_update`, `_unsafeUncheckedTransfer`, etc. These support the temporary “no contract receiver” policy and zero-address checks. The **Utils** and **Initializable** modules provide crucial safety and utility functions, ensuring the contract's proper setup and secure operation. Now, let's look at how all these different parts of the **FungibleToken** contract work together. * * * How the Pieces Fit Together[​](https://docs.midnight.network/blog/tags/midnight#how-the-pieces-fit-together "Direct link to How the Pieces Fit Together") ---------------------------------------------------------------------------------------------------------------------------------------------------------- This part shows how everything in the FungibleToken contract is hooked up. Whether it's you sending tokens, someone else doing it for you, or tokens being created or destroyed, it all funnels through a few key functions and ultimately lands in the main `_update` function to keep track of everything. * User transfer: `transfer` → _(safe check)_ → `_unsafeTransfer` → `_unsafeUncheckedTransfer` → `_update` (balances/supply) * Delegated transfer: `transferFrom` → _(safe check)_ → `_unsafeTransferFrom` → `_spendAllowance` → `_unsafeUncheckedTransfer` → `_update` * Mint/Burn: `_mint/_unsafeMint` or `_burn` → `_update` (with zero/burn address on one side) This section illustrates how various token operations, from user transfers to minting and burning, ultimately funnel through the central `_update` function for consistent accounting. Now, let's summarize the key takeaways of the **FungibleToken** contract on Midnight. * * * Conclusion[​](https://docs.midnight.network/blog/tags/midnight#conclusion "Direct link to Conclusion") ------------------------------------------------------------------------------------------------------- The **FungibleToken** Compact contract on Midnight is a privacy-aware reimagining of the ERC-20 standard. It maintains the familiar token interfaces—balances, transfers, approvals—but encodes them as ZK-validated circuits within Compact, enabling private, verifiable execution. The contract’s state and logic are shielded by design, exposing only proofs rather than raw data to the blockchain. The ERC-20 standard revolutionized the crypto landscape by providing a common framework for creating and managing digital assets, fostering interoperability, and accelerating the growth of decentralized applications. For Midnight, an ERC-20-based token is crucial as it leverages this established standard while integrating ZK-privacy, offering a familiar yet enhanced experience for developers and users seeking both functionality and confidentiality. This model contrasts sharply with ERC-20 on Ethereum, where all token movements and balances are fully transparent. Here, Midnight allows selective disclosure: users and applications choose what to reveal. The **FungibleToken** contract thus balances fungibility, usability, and privacy—providing an essential building block for privacy-preserving DeFi, identity, and tokenized assets on Midnight. * * * Links[​](https://docs.midnight.network/blog/tags/midnight#links "Direct link to Links") ---------------------------------------------------------------------------------------- Delve deeper into the code, contracts, and comprehensive documentation to enhance your understanding and development skills. These resources are invaluable for building robust and innovative solutions. * FungibleToken contract: [FungibleToken.compact on Github](https://github.com/OpenZeppelin/compact-contracts/blob/main/contracts/fungibleToken/src/FungibleToken.compact) * OpenZeppelin documentation: [docs.openzeppelin.com](https://docs.openzeppelin.com/contracts-compact/0.0.1/fungibletoken) * ERC20 standard: [ethereum.org](https://ethereum.org/en/developers/docs/standards/tokens/erc-20/) * Midnight docs: [Midnight Developer Documentation](https://docs.midnight.network/) * Do you have any questions?: [Midnight Forum](https://forum.midnight.network/) After participating in three hackathons this year, I thought I had a good idea of what to expect. Then came the fourth. It began like the others: an idea, a challenge, a blank terminal screen. But this one took an unexpected turn, one I didn't see coming. I had recently left my software engineering role to explore zero-knowledge protocols, an area in which I didn’t have much experience. It was a risk, but one I felt I had to take. I chose to pursue this path not only because zero-knowledge cryptography is built on one of the most elegant branches of mathematics, but also I believe privacy on the blockchain or on the internet is fundamental and should never be an afterthought. One day, my mentor casually mentioned the [African Blockchain Championship](https://www.africanblockchamp.com/) and suggested I look into the Zero-Knowledge track. That small nudge became a turning point. That’s when I discovered [Midnight](https://midnight.network/) ! Meet Midnight: Privacy on the Blockchain ======================================== Midnight is a zero-knowledge proof-based privacy chain developed by Input Output, the parent company of Cardano. As a partner chain of Cardano, it aims to bring rational privacy through zero-knowledge technology to the broader ecosystem. They weren’t just building another blockchain—they were laying the foundation for private, decentralized computation. After diving into the documentation and setting up the tools, everything was finally in place. All that remained… was to begin. Only later did I realize: this wasn’t just the start of another hackathon—it was the beginning of something much bigger. Building on Midnight ==================== Hacking on Midnight was challenging, as building in a testnet environment requires constant learning and adaptation to major changes. Within just a few weeks, significant network updates rendered the existing examples incompatible with the latest SDK versions. As a result, an example had to be cloned and debugged line by line. The example repository was dense, filled with layers of files and directories, and figuring out where to start was a challenge in itself. Fortunately, Midnight’s smart contract language, [Compact](https://docs.midnight.network/develop/reference/compact/) , shares a syntax similar to TypeScript, which eased the learning curve. I pushed forward, determined to build something meaningful and make my mark—but in the end, my attempt fell short. With midterm exams approaching and the hackathon submission deadline close by, I had to make a difficult decision. I decided not to submit a project to the African Blockchain Championship hackathon. Still, a quiet sense of regret lingered. I couldn’t help but wonder: what if I had just pushed a _little_ harder? The Extended Deadline ===================== About a week later, I received an email from the ABC team announcing that the hackathon deadline had been extended. I was thrilled, and I promised myself I’d give it everything this time. It wasn’t long before I was back at it. A few weeks had passed since I’d last touched the project, and during that time, both the network and SDKs had been updated. I gathered my gear, updated my environment, and set out with renewed determination to finally build something solid. I wrote my contract and began debugging, but each change introduced a new layer of complexity. Every update required changes across multiple files. It was frustrating, exhausting, but strangely thrilling. I began thinking of ways to simplify the chaos, to make the process less painful, more intuitive. That’s when I started creating small scripts to streamline the workflow. Earlier that month, I had joined the [Midnight Discord](https://discord.com/invite/midnightnetwork) to ask questions. One week, I jumped on a Discord community call, and to my surprise, I learned about an ongoing Midnight tooling hackathon that was happening asynchronously. Right then, it clicked: _this_ was the hackathon I was meant to be part of from the start. From Personal Tool to Shared Project ==================================== What started as a personal tool suddenly took on a bigger purpose. The hackathon provided me with the opportunity to share my work with others and contribute to shaping the future of smart contract development on Midnight. I took a little detour from my original hackathon submission—promising myself I’d return to it—and began refining the tool, aiming not just to build something functional, but something genuinely useful for newcomers to the ecosystem. Scaffold Midnight & Create Midnight App[​](https://docs.midnight.network/blog/tags/midnight#scaffold-midnight--create-midnight-app "Direct link to Scaffold Midnight & Create Midnight App") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- That’s how [**Scaffold Midnight**](http://github.com/kaleababayneh/scaffold-midnight) was born, a cloneable GitHub starter template. But I didn’t stop there. I realized it would be even more useful as an npm library, something developers could install with all dependencies bundled and start using right away. So, I polished the project and released the first version as [**create-midnight-app**](https://www.npmjs.com/package/create-midnight-app) . But I didn’t want to stop at solving just one problem. Every issue I fixed revealed another. Through multiple iterations, I kept refining the library. It’s now at version 2.1.7, and I’m actively working to make it compatible with the latest release of Compact. It’s far from perfect, and that’s what makes it exciting. Every day, I wake up with a new idea, a new feature to add, or a better way to improve the developer experience! ![Create Midnight App](https://ibin.co/8rMdmI75JRDl.png) At its core, **create-midnight-app** is a scaffolding npm library for Midnight that automates the entire setup process. Developers can focus solely on writing their Compact contracts; the tool takes care of the rest. It handles wallet creation, faucet requests, balance checks, API configuration, CLI updates, and even function and file change imports are updated automatically. It reduces initial application setup time from over half an hour to just a few minutes. I had several euphoric moments while working on this project, but one instance in particular, stands out. One feature I was eager to build was a way for developers to request testnet tokens without ever leaving their code editor. The simplest idea was to send a request from the terminal directly to the official [Midnight faucet](https://docs.midnight.network/blog/tags/%20https://midnight.network/test-faucet) . But there was a catch—the site is protected by [Cloudflare Turnstile](https://www.cloudflare.com/application-services/products/turnstile/) , which blocks automated requests to prevent spam and abuse. As a hacker, I started looking for a workaround. After some Googling and tips from friends, I tested several paid tools that claimed to bypass CAPTCHA protections. I spent an entire afternoon trying them, but none worked reliably. That’s when I remembered the genesis wallet, whose private key is publicly available. So, I implemented a workaround: instead of calling the faucet, I simulated a faucet transaction by transferring tokens directly from the genesis wallet to the user’s wallet. It’s not a long-term solution, and I know it won’t scale—but for now, it works and helps streamline the developer experience. Submission and Recognition ========================== I finally submitted my project, and the judges’ reactions were incredibly [encouraging](https://youtu.be/xrCEBIBqS-Y?t=4453) —it gave me a renewed sense of inspiration. With that momentum, I turned my focus back to my original hackathon: the African Blockchain Championship. For this challenge, I built an anonymous, censorship-resistant voting platform. In many African countries—across 34 nations—roughly 30–40% of citizens no longer view voting as a fair or trustworthy process (Afrobarometer, 2023). That’s why anonymous voting isn’t just a feature—it’s a necessity. My project, [**Privote**](https://github.com/kaleababayneh/zkvote-midnight) , aims to address this critical issue by leveraging zero-knowledge technology to protect voter identity and integrity. As the submission deadline approached, I ran into a major hurdle: integrating the wallet into the frontend. I reached out to one of the Developer Relations Engineers, who kindly shared some example code. Unfortunately, I couldn’t get it working in time. With the clock ticking, I had to improvise. I quickly built a custom Chrome extension that enabled wallet interaction—running through the terminal on the backend—just in time for submission. While the current version still has some privacy limitations, the smart contract compiles successfully, and users can interact with it on the Midnight testnet—offering a real glimpse of what decentralized, anonymous voting could look like in practice. ![Private Hackathon](https://ibin.co/8rMho4816dhp.png) The Midnight Community ====================== Even though there aren’t many resources available yet, the Midnight community more than makes up for it. Almost every question asked on Discord gets a response. It’s a space where people genuinely support each other—even during hackathons, when we’re technically competing and have little incentive to help other teams. In fact, during the hackathon, I often found myself answering questions in the Telegram group. I even hosted a workshop at the ABC hackathon on how to use **Create Midnight App**, helping others get started quickly and navigate the ecosystem more easily. I also want to take a moment to thank the Midnight team for the recognition they gave me—it truly meant a lot. Beyond placing first in the CLI track, the support and appreciation I received from the community were genuinely heartwarming. I even had the chance to join a community call—not just as a participant this time, but as a [speaker](https://x.com/MidnightNtwrk/status/1942969613496758398) —to share my journey and the lessons I’d learned along the way. Why Now is the Time to Build on Midnight ======================================== And for you—my readers—this is honestly the best time to get involved in the Midnight ecosystem. There’s _almost always_ a hackathon happening (seriously, it's kind of wild!). Right now, they’re even running a [mini DApp hackathon](https://midnight.network/hackathon/midnight-mini-dapp-hackathon) . It’s an excellent opportunity to learn, build, and get your project noticed. ![Midnight Dapp Hackathon](https://ibin.co/8rMcCFquPRqS.png) As for me, I’m currently building something new for the hackathon. While I enjoy working on projects, I’ve found even more fulfillment in developing infrastructure tools. I have a long-term goal of building a web-based Midnight playground where anyone can start writing Compact code and begin interacting with the Midnight testnet without needing to install anything. I hope to continue collaborating with the Midnight team and growing my skills—especially in zero-knowledge protocols—as I continue this journey. The Midnight blockchain introduces a novel approach to data privacy and compliance in decentralized applications (DApps), leveraging zero-knowledge proofs (ZKPs) and a dual-token system. This article provides a comprehensive guide on connecting to the Midnight blockchain, and you will learn how to listen for new blocks and extract data from these blocks using the Polkadot API and the various methods it provides to connect to Substrate-based blockchains, including Midnight. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/wallet#__docusaurus_skipToContent_fallback) The Midnight testnet upgrade introduces BLS12-381, requiring developers to update the Lace wallet, proof server, and redeploy contracts with the latest Compact compiler. Connect your dApp to the Midnight network using the Lace wallet, with guidance on detection, authorization, and interaction using the MidnightJS API. The Midnight ecosystem is evolving—one important change is the new default address format: Bech32m, which is a human-readable address format with error detection. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/web3-intro#__docusaurus_skipToContent_fallback) Journey into Web3, unpack key blockchain concepts like decentralization, consensus, and how they shape platforms like Midnight. Joining the Midnight team as a Developer Relations Engineer has been an exciting transition, but also an eye-opening one. While I anticipated a learning curve stepping into the Web3 space, I didn't expect just how fundamentally different it would be from my experiences in Web2. Web3 isn't simply a new tech stack—it's a shift in how we think about data, trust, and ownership. As I began onboarding with Midnight, I quickly realized that to fully understand the value and capabilities of the platform, I first needed to ground myself in the core principles of blockchain and decentralized technologies. I started learning the basics with [Cardano Academy](https://academy.cardanofoundation.org/) as a first pass, and it has been a great resource for getting up to speed on the foundations of Web3. So, if you're also new to Web3 or blockchain and feeling a bit overwhelmed, you're not alone. And if you're a seasoned pro, consider this a little refresher on some foundational topics I’ve started diving into. Here are the core concepts I've been exploring this week as I embark on my journey into the world of decentralized technology. Core Concepts of Blockchain[​](https://docs.midnight.network/blog/web3-intro#core-concepts-of-blockchain "Direct link to Core Concepts of Blockchain") ------------------------------------------------------------------------------------------------------------------------------------------------------- ### Decentralization[​](https://docs.midnight.network/blog/web3-intro#decentralization "Direct link to Decentralization") At its heart, blockchain is about decentralization. Instead of relying on a single authority, such as a bank or server, blockchain distributes control across a network of independent nodes. This makes the system more resilient—there is no single point of failure—and ensures that no single entity can unilaterally change the rules. Decentralization also lays the groundwork for trustless systems, where participants can interact and transact without needing to trust a central authority. ### Consensus Algorithms[​](https://docs.midnight.network/blog/web3-intro#consensus-algorithms "Direct link to Consensus Algorithms") But how do all these independent nodes agree on what's true? That's where consensus algorithms come in. They enable a decentralized network to reach a consensus, even when some nodes are offline or acting maliciously. This idea actually solves a famous problem in distributed systems known as the Byzantine Generals Problem—how to coordinate among parties that can't fully trust each other. Different blockchains address this issue in various ways, which we'll explore shortly. ### Blockchain Structure[​](https://docs.midnight.network/blog/web3-intro#blockchain-structure "Direct link to Blockchain Structure") The term "blockchain" is literal: it's a chain of blocks, each containing data. Every block links to the previous one using a cryptographic hash. This structure makes the data immutable—once it's recorded, you can't change it without altering every block that came after it, which is extremely difficult. This immutability, combined with transparency, is what gives blockchain its auditability and security. Consensus Mechanisms[​](https://docs.midnight.network/blog/web3-intro#consensus-mechanisms "Direct link to Consensus Mechanisms") ---------------------------------------------------------------------------------------------------------------------------------- Now that we've discussed consensus in theory, here's a breakdown of how it works in practice. Different blockchains employ various mechanisms to achieve consensus, each with its strengths, trade-offs, and specific use cases. ### Proof of Work (PoW)[​](https://docs.midnight.network/blog/web3-intro#proof-of-work-pow "Direct link to Proof of Work (PoW)") * **What it uses**: Computational power. * **How it works**: Miners compete to solve complex math problems. The first one to solve one gets to add the next block to the chain. * **Pros**: Secure and well-tested (used by Bitcoin). * **Cons**: Extremely energy-intensive and not very scalable. ### Proof of Stake (PoS)[​](https://docs.midnight.network/blog/web3-intro#proof-of-stake-pos "Direct link to Proof of Stake (PoS)") * **What it uses**: Stake in the network (native tokens). How it works\*\*: Validators are chosen to create new blocks based on how much they've staked. * **Pros**: Much more energy-efficient than PoW, faster transactions. * **Cons**: Can raise concerns around wealth concentration and governance. ### Practical Byzantine Fault Tolerance (PBFT)[​](https://docs.midnight.network/blog/web3-intro#practical-byzantine-fault-tolerance-pbft "Direct link to Practical Byzantine Fault Tolerance (PBFT)") * **What it uses**: Agreement among a known group of nodes. * **How it works**: Nodes exchange messages to confirm transactions, even if some are faulty. * **Pros**: Fast finality, great for permissioned blockchains. * **Cons**: It doesn't scale well for large public networks. It is often used in smaller, permissioned networks because it requires many messages between nodes to agree, which makes it impractical for large public blockchains. ### Other Consensus Models[​](https://docs.midnight.network/blog/web3-intro#other-consensus-models "Direct link to Other Consensus Models") Numerous niche, experimental, and hybrid models are available. Here are a few that caught my attention: * **Proof of Authority (PoA)**: Uses validator identity/reputation and is typically used in permissioned chains. * **Proof of Activity (PoAc)**: A hybrid of PoW and PoS where miners start the process, and validators stake to complete it. * **Proof of Burn/Capacity/Contribution**: Novel methods using resources, effort, or behavior. * **Proof of Elapsed Time (PoET**): Uses secure hardware to ensure fairness. Conclusion[​](https://docs.midnight.network/blog/web3-intro#conclusion "Direct link to Conclusion") ---------------------------------------------------------------------------------------------------- This is just the beginning of my journey, but already, I can see how powerful and complex this space is. Understanding blockchain and consensus mechanisms is like learning the grammar of a new language. It's the foundation for understanding platforms like Midnight and the kinds of problems it's designed to solve. So far, everything I’ve shared has come from one resource: [Cardano Academy](https://academy.cardanofoundation.org/) . It’s been a helpful starting point, but it’s just that – a starting point. I plan to explore many more resources to continue building my knowledge, and I recommend that you do the same. Cardano Academy is a great place to start, but supplementing it with your own research and delving into the Midnight [documentation](https://docs.midnight.network/) and [Dev Diaries](https://docs.midnight.network/blog) can provide a much more well-rounded understanding of Web3. If you're also diving into Web3 for the first time, I hope this helped give you some structure to start your learning. And if you're already immersed in the space, I'd love to hear what helped you connect the dots when you were starting out—please drop a comment or share your favorite learning resources with me! More concepts to come as I dig deeper into Midnight and the wider Web3 world – and I’ll be sharing additional resources along the way as I continue learning. Stay tuned! * [Core Concepts of Blockchain](https://docs.midnight.network/blog/web3-intro#core-concepts-of-blockchain) * [Decentralization](https://docs.midnight.network/blog/web3-intro#decentralization) * [Consensus Algorithms](https://docs.midnight.network/blog/web3-intro#consensus-algorithms) * [Blockchain Structure](https://docs.midnight.network/blog/web3-intro#blockchain-structure) * [Consensus Mechanisms](https://docs.midnight.network/blog/web3-intro#consensus-mechanisms) * [Proof of Work (PoW)](https://docs.midnight.network/blog/web3-intro#proof-of-work-pow) * [Proof of Stake (PoS)](https://docs.midnight.network/blog/web3-intro#proof-of-stake-pos) * [Practical Byzantine Fault Tolerance (PBFT)](https://docs.midnight.network/blog/web3-intro#practical-byzantine-fault-tolerance-pbft) * [Other Consensus Models](https://docs.midnight.network/blog/web3-intro#other-consensus-models) * [Conclusion](https://docs.midnight.network/blog/web3-intro#conclusion) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/testnet#__docusaurus_skipToContent_fallback) As we progress through the **Hilo** phase and prepare for the upcoming milestones of the Midnight Network, we are adjusting testing environments to ensure a seamless transition to a decentralized mainnet. Midnight `Testnet-02` has been a monumental success, serving as the crucible for Midnight’s zero-knowledge capabilities. We want to extend our deepest gratitude to the over **180+** Cardano Stake Pool Operators (SPOs) who actively participated in the `Testnet-02` environment and their ongoing support for the Midnight project. In previous communications, we signaled that SPOs would migrate directly to the Midnight `Preview` environment at this stage. However, as we refine the roadmap toward the **Kūkolu** (Federated Mainnet) phase, we have made a strategic pivot. While `Testnet-02` validators may continue to run their nodes until **February 28, 2026**, the Midnight `Preview` environment will be temporarily maintained by core engineering. This shift allows us to: * Perform high velocity testing and rapid iterations. * Finalize the integration of novel features such as the DUST Capacity Exchange. * Ensure a stable, rapid-test environment for core development that would otherwise cause unnecessary disruption and downtime for independent SPOs. | Phase | Milestone | SPO & Validator Role | | --- | --- | --- | | Hilo | Token Genesis | Initial liquidity and NIGHT "Glacier Drop" on Cardano. | | Kūkolu | Federated Mainnet | Ecosystem partners maintain stability during rapid development. | | Mōhalu | Incentivized Mainnet | SPO Onboarding begins including other testing. | | Hua | Full Decentralization | Block production transitions to community. | This keeps the structure clean and focused on phases, milestones, and roles. _Please note: All dates are estimates._ We acknowledge that this change differs from previous expectations, but we believe this path ensures the highest quality environment for SPOs to return for **Mōhalu**. important Validator documentation status[​](https://docs.midnight.network/blog/tags/testnet#validator-documentation-status "Direct link to Validator documentation status") ------------------------------------------------------------------------------------------------------------------------------------------------------------------ To avoid confusion during this transition, **current validator documentation will be temporarily unpublished** or hidden from the main site. This ensures that **when you return to the docs for the Mōhalu phase, they will be 100% accurate**, refreshed, and aligned with the new architecture. Direct action on your feedback[​](https://docs.midnight.network/blog/tags/testnet#direct-action-on-your-feedback "Direct link to Direct action on your feedback") ------------------------------------------------------------------------------------------------------------------------------------------------------------------ We recently conducted a feedback survey to understand your operational experience. We heard your feedback regarding documentation, setup friction, and infrastructure control. In preparation for the **Mōhalu** phase, we are implementing the following changes: * We are moving away from a Docker-only distribution. We are now delivering pre-compiled binaries for `midnight-node` and restructuring our documentation to be binary and source-first. While containerization is useful, we recognize that barebones instructions are fundamental for professional SPO infrastructure. * The next node version will completely remove the registration wizard, allowing for a more direct and scriptable registration process. * We are prioritizing new architecture recommendation for secrets management and air-gapped signing guidance. We recognize that for a privacy-focused chain, the security of our validators' keys is paramount. * In the lead up to Mōhalu, we promise more structued communication cadence and dedicated SPO/ validator calls. Staying informed: Subscribe to Midnight Validator Updates[​](https://docs.midnight.network/blog/tags/testnet#staying-informed-subscribe-to-midnight-validator-updates "Direct link to Staying informed: Subscribe to Midnight Validator Updates") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 👉 To ensure you receive the latest technical specifications, onboarding guides, and timeline adjustments for the **Mōhalu** phase, we encourage all SPOs to subscribe via the Midnight Validator Digest: [https://mpc.midnight.network/midnight-validator-digest](https://mpc.midnight.network/midnight-validator-digest) 👉 Join other validators and builders in the Midnight Discord server: [https://discord.com/invite/midnightnetwork](https://discord.com/invite/midnightnetwork) Last month, we introduced the Midnight Indexer, a modular, high-performance indexing service written in Rust. Today, we’re excited to share that the Rust-based Midnight Indexer has officially replaced the legacy Scala-based Pub-Sub Indexer. A major Midnight Testnet upgrade introduces version 1.5, bringing key changes that require validator re-registration, improved node setup, and enhanced tooling for partner-chain participants. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#__docusaurus_skipToContent_fallback) Explore how public key encryption and Practical Byzantine Fault Tolerance form the cryptographic and consensus backbone of secure, decentralized blockchain networks like Midnight. I'm still in the early stages of learning about Web3 (see my last two blog posts [here](https://docs.midnight.network/blog/web3-intro) and [here](https://docs.midnight.network/blog/web3-intro-hashing-and-digital-signatures) !), and the deeper I go, the more I realize that the real magic of blockchain isn't just in the code—it's in the cryptography that secures data and the consensus algorithms that coordinate it. As I continue learning, two concepts stood out this week: public key encryption and Practical Byzantine Fault Tolerance (PBFT). These may sound intimidating, but they’re the backbone of how blockchains protect data and reach agreement without a central authority. I explored them through [Cardano Academy's](https://academy.cardanofoundation.org/) Intro to Blockchain series, which continues to be a great entry point for breaking down these core concepts. Here's what I learned—and how these two building blocks shape the infrastructure behind modern blockchain networks. Public Key Encryption – Sending Secrets Without Sharing Keys[​](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#public-key-encryption--sending-secrets-without-sharing-keys "Direct link to Public Key Encryption – Sending Secrets Without Sharing Keys") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Encryption is the backbone of blockchain security. It allows us to send private messages, verify identities, and keep data safe—even across open, decentralized networks like the internet or blockchain itself. This is especially important in Web3, where blockchains are public by default—anyone can view the data, participate in the network, or run a node. At Midnight, encryption plays a key role in protecting sensitive data while still allowing it to live on a public chain. From shielded transactions to selective disclosure, Midnight builds on the principles of public key cryptography to enable privacy without sacrificing decentralization. At a high level, encryption is just the process of turning readable data (called cleartext) into gibberish (ciphertext) so that only the right person can turn it back. But how do we do that without first sharing a secret key? ### The Two Types of Encryption[​](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#the-two-types-of-encryption "Direct link to The Two Types of Encryption") There are two main types of encryption: * **Symmetric encryption**: The same key is used to encrypt and decrypt the message. It's fast, but you need to share that key first, which can be tricky to do securely. * **Asymmetric encryption (also known as public key encryption)**: Uses a key pair—one public and one private. What one key encrypts, the other can decrypt. If you encrypt something with a public key, only the matching private key can unlock it and vice versa. They’re mathematically linked, but guessing one from the other is nearly impossible. The key difference? In symmetric encryption, both people share one secret key. In asymmetric encryption, no shared secret is needed, just a matching key pair. ### A Simple Analogy[​](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#a-simple-analogy "Direct link to A Simple Analogy") Think of symmetric encryption like a shared locker: you and your friend have the same key. Anyone with that key can open the locker. The hard part? Making sure only the two of you have a copy. On the other hand, asymmetric encryption is more like giving everyone a padlock with your name on it (your public key). Anyone can lock a box and send it to you, but only you, holding the matching private key, can open it. ### How It's Used in Blockchain[​](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#how-its-used-in-blockchain "Direct link to How It's Used in Blockchain") When Alice wants to send Bob a secure message: 1. Bob shares his public key. 2. Alice encrypts her message using Bob's public key. 3. Bob receives and decrypts the encrypted message using his private key. Even if someone intercepts the message, it’s unreadable without Bob’s private key. Thanks to the math behind elliptic curves and RSA, it would take more time than the universe has existed to reverse-engineer a private key from a public one with today’s computers. ### Why Not Just Use Public Key Encryption for Everything?[​](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#why-not-just-use-public-key-encryption-for-everything "Direct link to Why Not Just Use Public Key Encryption for Everything?") Public key encryption is powerful but computationally heavy. That's why, in practice, most secure systems (like HTTPS) use a hybrid model: 1. The client and server use public key encryption to securely exchange a temporary session key. 2. From then on, they use symmetric encryption with that shared key to communicate quickly and securely. This is the same approach blockchains often use for performance and scalability—combining the strengths of both methods. * * * Practical Byzantine Fault Tolerance – How Blockchains Reach Consensus[​](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#practical-byzantine-fault-tolerance--how-blockchains-reach-consensus "Direct link to Practical Byzantine Fault Tolerance – How Blockchains Reach Consensus") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Now that we've covered encryption, let's move to something that puzzled me at first: How do blockchains reach consensus without a central decision-maker? That's where consensus algorithms come in. This week, I learned about one of the earliest and most influential: Practical Byzantine Fault Tolerance, or PBFT. ### First, a Quick Refresher on Consensus[​](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#first-a-quick-refresher-on-consensus "Direct link to First, a Quick Refresher on Consensus") Consensus is how distributed systems agree on a single truth, even if some participants are slow, offline, or actively trying to cause problems. It's what lets a decentralized ledger agree on who owns what, and it's essential for any blockchain to function. The "Byzantine" part comes from a famous thought experiment called the Byzantine Generals Problem, in which generals need to coordinate an attack but can't trust their messengers. In blockchain terms, nodes must agree on a block, even if some are lying or malfunctioning. ### What Makes PBFT "Practical"?[​](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#what-makes-pbft-practical "Direct link to What Makes PBFT "Practical"?") PBFT is designed to work in weakly synchronous systems—systems where messages might be delayed, but not indefinitely. It assumes that at most one-third of nodes can be faulty and uses cryptographic signatures to authenticate all messages. That means messages might be delayed, but will eventually arrive, unlike in totally unreliable (asynchronous) systems. PBFT has a built-in process called view change, which automatically replaces a faulty primary when enough nodes detect issues. Here's how it works in broad strokes: 1. A client (like a user submitting a transaction) sends a request to a primary node. 2. That primary broadcasts the request to other replica nodes. 3. Each replica processes the request and responds. 4. The client waits for enough matching replies (2/3 + 1) to confirm the result. Suppose the primary node is unresponsive or sends conflicting messages. In that case, replicas can vote to replace it and elect a new primary. This makes PBFT fault-tolerant and adaptive, critical for blockchains operating in the real world. ### Real-World Analogy[​](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#real-world-analogy "Direct link to Real-World Analogy") Imagine you're on a group project. One person (the "primary") shares the final version of the project. Everyone else ("replicas") reviews it. If enough people agree it's correct, you submit it. But if someone thinks the leader messed up, they can flag it—and if enough people agree, the group picks a new leader. PBFT formalizes this process with message signatures, vote thresholds, and fault limits. ### Where PBFT Shines—and Where It Doesn't[​](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#where-pbft-shinesand-where-it-doesnt "Direct link to Where PBFT Shines—and Where It Doesn't") PBFT excels in small, permissioned networks where all participants are known and vetted, such as enterprise or consortium blockchains. It offers fast and deterministic finality with fewer probabilistic assumptions than models like proof-of-work or proof-of-stake. But there are trade-offs: * It doesn't scale well to hundreds or thousands of nodes—it's communication-heavy. * Nodes must know about each other ahead of time. * It's less decentralized and potentially vulnerable to Sybil attacks if new nodes aren't vetted carefully. That's why PBFT-inspired models are often combined with other mechanisms, like rotating leadership or staking systems, to improve scalability and resilience. Conclusion[​](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#conclusion "Direct link to Conclusion") ------------------------------------------------------------------------------------------------------------------------ Encryption and consensus might sound like deep technical topics (and they are), but at their core, they solve very human problems: How can we keep secrets? And how can we agree on what's true when no one is in charge? Here's a quick overview of both concepts, what they solve, and what they're used for: | Concept | What it solves | Used in | | --- | --- | --- | | Public Key Encryption | Secure communication over open networks | Wallets, HTTPS, block signing | | PBFT | Reaching agreement in the face of faulty/lying nodes | Permissioned blockchains, early crypto projects | Learning about these two areas gave me a clearer view of the building blocks behind secure, decentralized systems like Cardano—and why consensus and cryptography are so tightly intertwined in Web3. All of the material in this post comes from [Cardano Academy](https://academy.cardanofoundation.org/) , which continues to be a fantastic first stop in my Web3 learning journey. I'll be adding more resources over time and sharing what I learn along the way. If you're also getting started, check out the Academy, do some digging on your own, and browse through the [Midnight docs](https://docs.midnight.network/) and [Dev Diaries](https://docs.midnight.network/blog) if you want a glimpse of how these ideas show up in practice. If you're learning along with me, which concepts have been most challenging to wrap your head around? Drop a comment. I’d love to swap resources! More foundational concepts are coming soon! * [Public Key Encryption – Sending Secrets Without Sharing Keys](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#public-key-encryption--sending-secrets-without-sharing-keys) * [The Two Types of Encryption](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#the-two-types-of-encryption) * [A Simple Analogy](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#a-simple-analogy) * [How It's Used in Blockchain](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#how-its-used-in-blockchain) * [Why Not Just Use Public Key Encryption for Everything?](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#why-not-just-use-public-key-encryption-for-everything) * [Practical Byzantine Fault Tolerance – How Blockchains Reach Consensus](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#practical-byzantine-fault-tolerance--how-blockchains-reach-consensus) * [First, a Quick Refresher on Consensus](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#first-a-quick-refresher-on-consensus) * [What Makes PBFT "Practical"?](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#what-makes-pbft-practical) * [Real-World Analogy](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#real-world-analogy) * [Where PBFT Shines—and Where It Doesn't](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#where-pbft-shinesand-where-it-doesnt) * [Conclusion](https://docs.midnight.network/blog/web3-intro-encryption-and-pbft#conclusion) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags#__docusaurus_skipToContent_fallback) Tags ==== A[​](https://docs.midnight.network/blog/tags#A "Direct link to A") ------------------------------------------------------------------- * [ai1](https://docs.midnight.network/blog/tags/ai) * * * B[​](https://docs.midnight.network/blog/tags#B "Direct link to B") ------------------------------------------------------------------- * [beginner11](https://docs.midnight.network/blog/tags/beginner) * [blockchain10](https://docs.midnight.network/blog/tags/blockchain) * [bls1](https://docs.midnight.network/blog/tags/bls) * * * C[​](https://docs.midnight.network/blog/tags#C "Direct link to C") ------------------------------------------------------------------- * [community2](https://docs.midnight.network/blog/tags/community) * [compact8](https://docs.midnight.network/blog/tags/compact) * * * D[​](https://docs.midnight.network/blog/tags#D "Direct link to D") ------------------------------------------------------------------- * [dapp3](https://docs.midnight.network/blog/tags/dapp) * [developer-tools1](https://docs.midnight.network/blog/tags/developer-tools) * [dust1](https://docs.midnight.network/blog/tags/dust) * * * H[​](https://docs.midnight.network/blog/tags#H "Direct link to H") ------------------------------------------------------------------- * [hackathon1](https://docs.midnight.network/blog/tags/hackathon) * * * I[​](https://docs.midnight.network/blog/tags#I "Direct link to I") ------------------------------------------------------------------- * [indexer1](https://docs.midnight.network/blog/tags/indexer) * [intro10](https://docs.midnight.network/blog/tags/intro) * * * J[​](https://docs.midnight.network/blog/tags#J "Direct link to J") ------------------------------------------------------------------- * [javascript1](https://docs.midnight.network/blog/tags/javascript) * * * M[​](https://docs.midnight.network/blog/tags#M "Direct link to M") ------------------------------------------------------------------- * [mcp1](https://docs.midnight.network/blog/tags/mcp) * [meeting1](https://docs.midnight.network/blog/tags/meeting) * [midnight3](https://docs.midnight.network/blog/tags/midnight) * [midnight.js2](https://docs.midnight.network/blog/tags/midnight-js) * * * N[​](https://docs.midnight.network/blog/tags#N "Direct link to N") ------------------------------------------------------------------- * [night1](https://docs.midnight.network/blog/tags/night) * * * P[​](https://docs.midnight.network/blog/tags#P "Direct link to P") ------------------------------------------------------------------- * [partner-chains2](https://docs.midnight.network/blog/tags/partner-chains) * * * S[​](https://docs.midnight.network/blog/tags#S "Direct link to S") ------------------------------------------------------------------- * [spo2](https://docs.midnight.network/blog/tags/spo) * [spos1](https://docs.midnight.network/blog/tags/spos) * * * T[​](https://docs.midnight.network/blog/tags#T "Direct link to T") ------------------------------------------------------------------- * [testnet3](https://docs.midnight.network/blog/tags/testnet) * * * W[​](https://docs.midnight.network/blog/tags#W "Direct link to W") ------------------------------------------------------------------- * [wallet3](https://docs.midnight.network/blog/tags/wallet) * [web310](https://docs.midnight.network/blog/tags/web-3) * * * Z[​](https://docs.midnight.network/blog/tags#Z "Direct link to Z") ------------------------------------------------------------------- * [zero-knowledge1](https://docs.midnight.network/blog/tags/zero-knowledge) * [zkp1](https://docs.midnight.network/blog/tags/zkp) * * * --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/zkp#__docusaurus_skipToContent_fallback) Kachina employs non-interactive zero-knowledge proofs to allow users to prove valid state transitions without revealing private data. Update - April 28, 2025 This transition has been completed. Midnight now uses BLS12-381 as its proving system. Midnight leverages the [Kachina](https://iohk.io/en/research/library/papers/kachina-foundations-of-private-smart-contracts/) protocol for privacy-preserving smart contracts using Universal Composition (UC) model to enable secure, decentralized computations with zero-knowledge proofs, splitting contracts state into public (on-chain) and private (off-chain) components for scalable privacy. Midnight currently uses ZK-SNARKs based on the Kachina framework with the [BLS12-381](https://github.com/zkcrypto/bls12_381) curve for its proving system, ensuring privacy-preserving smart contracts. As part of the [Testnet upgrade on April 28, 2025](https://midnight.network/blog/upcoming-testnet-02-upgrade-all-you-need-to-know) , Midnight switched from [Pluto-Eris](https://github.com/daira/pluto-eris) to BLS12-381 to improve efficiency and security, leveraging BLS12-381's pairing-based properties to enhance performance in transactions. Why Midnight switched to BLS[​](https://docs.midnight.network/blog/zkp#why-midnight-switched-to-bls "Direct link to Why Midnight switched to BLS") --------------------------------------------------------------------------------------------------------------------------------------------------- | | Pluto-Eris | BLS12-381 | | --- | --- | --- | | **Trusted Setup** | Needs ceremony | Existing | | **Cryptography** | Non-standard | Standard | | **Transaction time** | Slower | Faster | | **Transaction size** | 6 kb / proof | 5 kb / proof | | **Tx verification time** | 12 ms / proof | 6 ms / proof | | **Architectural complexity** | High | Low | | **Maintainability** | Hard | Feasible | | **Cost of recursive step** | Smaller circuits / higher CPU cost | Larger circuits / lower CPU cost | ### Moving away from trusted setup ceremony[​](https://docs.midnight.network/blog/zkp#moving-away-from-trusted-setup-ceremony "Direct link to Moving away from trusted setup ceremony") One of the most compelling reasons to adopt BLS12-381 is its use of an existing, standardized trusted setup. Pluto-Eris, by contrast, requires a bespoke ceremony. With BLS12-381, we leverage a pre-established setup that has already been widely vetted and accepted in the cryptographic community. ### Embracing standardized cryptography[​](https://docs.midnight.network/blog/zkp#embracing-standardized-cryptography "Direct link to Embracing standardized cryptography") Pluto-Eris relies on non-standard cryptography, which, while innovative, poses risks in terms of interoperability and long-term support. BLS12-381, however, is built on standard cryptographic primitives that are well-understood, extensively tested, and broadly adopted. Standardization reduces the likelihood of vulnerabilities and ensures compatibility with other systems, making BLS12-381 a more future-proof choice. ### Boosting transaction performance[​](https://docs.midnight.network/blog/zkp#boosting-transaction-performance "Direct link to Boosting transaction performance") Performance is a critical factor in any cryptographic system, and BLS12-381 outshines Pluto Eris across several key metrics. Transactions on BLS12-381 are faster, with verification times slashed from 12 milliseconds per proof in Pluto Eris to just 6 milliseconds. Additionally, transaction sizes are more compact, dropping from 6 kilobytes per proof to 5 kilobytes, allowing for more efficient use of bandwidth and storage. These improvements translate to a smoother, more scalable user experience across the Midnight platform. ### Simplifying architecture and maintenance[​](https://docs.midnight.network/blog/zkp#simplifying-architecture-and-maintenance "Direct link to Simplifying architecture and maintenance") Architectural complexity is another area where BLS12-381 has a clear edge. Pluto Eris is burdened by a high level of complexity, making it harder to maintain. ### Balancing cost and efficiency in recursion[​](https://docs.midnight.network/blog/zkp#balancing-cost-and-efficiency-in-recursion "Direct link to Balancing cost and efficiency in recursion") Recursive proofs are a cornerstone of advanced cryptographic applications, and the two systems handle them differently. Pluto Eris delivers smaller circuits but at a higher CPU cost, which can strain computational resources as usage scales. BLS12-381 flips this tradeoff, opting for larger circuits with a lower CPU cost. In short, BLS12-381 offers a compelling blend of performance, simplicity, and reliability than Pluto Eris. 💥 Impact on developers[​](https://docs.midnight.network/blog/zkp#-impact-on-developers "Direct link to 💥 Impact on developers") ---------------------------------------------------------------------------------------------------------------------------------- The transition to BLS12-381 occurred on April 28, 2025, as part of the Testnet upgrade. This change was not backward compatible, requiring developers to adopt BLS-compatible components. These components include: * midnight.js * wallet * examples * proof-server Existing Compact code remained functional but required recompilation and redeployment to align with the BLS12-381 standard. The transition to BLS12-381 paved the way for a significantly more performant developer experience with faster transactions. 👉 **For support, join the Midnight [Discord](https://discord.com/invite/midnightnetwork) !** Sources[​](https://docs.midnight.network/blog/zkp#sources "Direct link to Sources") ------------------------------------------------------------------------------------ 1. [https://iohk.io/en/research/library/papers/kachina-foundations-of-private-smart-contracts/](https://iohk.io/en/research/library/papers/kachina-foundations-of-private-smart-contracts/) 2. [https://github.com/daira/pluto-eris](https://github.com/daira/pluto-eris) 3. [https://midnight.network/blog/upcoming-testnet-02-upgrade-all-you-need-to-know](https://midnight.network/blog/upcoming-testnet-02-upgrade-all-you-need-to-know) 4. [https://github.com/zkcrypto/bls12\_381](https://github.com/zkcrypto/bls12_381) * [Why Midnight switched to BLS](https://docs.midnight.network/blog/zkp#why-midnight-switched-to-bls) * [Moving away from trusted setup ceremony](https://docs.midnight.network/blog/zkp#moving-away-from-trusted-setup-ceremony) * [Embracing standardized cryptography](https://docs.midnight.network/blog/zkp#embracing-standardized-cryptography) * [Boosting transaction performance](https://docs.midnight.network/blog/zkp#boosting-transaction-performance) * [Simplifying architecture and maintenance](https://docs.midnight.network/blog/zkp#simplifying-architecture-and-maintenance) * [Balancing cost and efficiency in recursion](https://docs.midnight.network/blog/zkp#balancing-cost-and-efficiency-in-recursion) * [💥 Impact on developers](https://docs.midnight.network/blog/zkp#-impact-on-developers) * [Sources](https://docs.midnight.network/blog/zkp#sources) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/zero-knowledge#__docusaurus_skipToContent_fallback) After participating in three hackathons this year, I thought I had a good idea of what to expect. Then came the fourth. It began like the others: an idea, a challenge, a blank terminal screen. But this one took an unexpected turn, one I didn't see coming. I had recently left my software engineering role to explore zero-knowledge protocols, an area in which I didn’t have much experience. It was a risk, but one I felt I had to take. I chose to pursue this path not only because zero-knowledge cryptography is built on one of the most elegant branches of mathematics, but also I believe privacy on the blockchain or on the internet is fundamental and should never be an afterthought. One day, my mentor casually mentioned the [African Blockchain Championship](https://www.africanblockchamp.com/) and suggested I look into the Zero-Knowledge track. That small nudge became a turning point. That’s when I discovered [Midnight](https://midnight.network/) ! Meet Midnight: Privacy on the Blockchain ======================================== Midnight is a zero-knowledge proof-based privacy chain developed by Input Output, the parent company of Cardano. As a partner chain of Cardano, it aims to bring rational privacy through zero-knowledge technology to the broader ecosystem. They weren’t just building another blockchain—they were laying the foundation for private, decentralized computation. After diving into the documentation and setting up the tools, everything was finally in place. All that remained… was to begin. Only later did I realize: this wasn’t just the start of another hackathon—it was the beginning of something much bigger. Building on Midnight ==================== Hacking on Midnight was challenging, as building in a testnet environment requires constant learning and adaptation to major changes. Within just a few weeks, significant network updates rendered the existing examples incompatible with the latest SDK versions. As a result, an example had to be cloned and debugged line by line. The example repository was dense, filled with layers of files and directories, and figuring out where to start was a challenge in itself. Fortunately, Midnight’s smart contract language, [Compact](https://docs.midnight.network/develop/reference/compact/) , shares a syntax similar to TypeScript, which eased the learning curve. I pushed forward, determined to build something meaningful and make my mark—but in the end, my attempt fell short. With midterm exams approaching and the hackathon submission deadline close by, I had to make a difficult decision. I decided not to submit a project to the African Blockchain Championship hackathon. Still, a quiet sense of regret lingered. I couldn’t help but wonder: what if I had just pushed a _little_ harder? The Extended Deadline ===================== About a week later, I received an email from the ABC team announcing that the hackathon deadline had been extended. I was thrilled, and I promised myself I’d give it everything this time. It wasn’t long before I was back at it. A few weeks had passed since I’d last touched the project, and during that time, both the network and SDKs had been updated. I gathered my gear, updated my environment, and set out with renewed determination to finally build something solid. I wrote my contract and began debugging, but each change introduced a new layer of complexity. Every update required changes across multiple files. It was frustrating, exhausting, but strangely thrilling. I began thinking of ways to simplify the chaos, to make the process less painful, more intuitive. That’s when I started creating small scripts to streamline the workflow. Earlier that month, I had joined the [Midnight Discord](https://discord.com/invite/midnightnetwork) to ask questions. One week, I jumped on a Discord community call, and to my surprise, I learned about an ongoing Midnight tooling hackathon that was happening asynchronously. Right then, it clicked: _this_ was the hackathon I was meant to be part of from the start. From Personal Tool to Shared Project ==================================== What started as a personal tool suddenly took on a bigger purpose. The hackathon provided me with the opportunity to share my work with others and contribute to shaping the future of smart contract development on Midnight. I took a little detour from my original hackathon submission—promising myself I’d return to it—and began refining the tool, aiming not just to build something functional, but something genuinely useful for newcomers to the ecosystem. Scaffold Midnight & Create Midnight App[​](https://docs.midnight.network/blog/tags/zero-knowledge#scaffold-midnight--create-midnight-app "Direct link to Scaffold Midnight & Create Midnight App") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- That’s how [**Scaffold Midnight**](http://github.com/kaleababayneh/scaffold-midnight) was born, a cloneable GitHub starter template. But I didn’t stop there. I realized it would be even more useful as an npm library, something developers could install with all dependencies bundled and start using right away. So, I polished the project and released the first version as [**create-midnight-app**](https://www.npmjs.com/package/create-midnight-app) . But I didn’t want to stop at solving just one problem. Every issue I fixed revealed another. Through multiple iterations, I kept refining the library. It’s now at version 2.1.7, and I’m actively working to make it compatible with the latest release of Compact. It’s far from perfect, and that’s what makes it exciting. Every day, I wake up with a new idea, a new feature to add, or a better way to improve the developer experience! ![Create Midnight App](https://ibin.co/8rMdmI75JRDl.png) At its core, **create-midnight-app** is a scaffolding npm library for Midnight that automates the entire setup process. Developers can focus solely on writing their Compact contracts; the tool takes care of the rest. It handles wallet creation, faucet requests, balance checks, API configuration, CLI updates, and even function and file change imports are updated automatically. It reduces initial application setup time from over half an hour to just a few minutes. I had several euphoric moments while working on this project, but one instance in particular, stands out. One feature I was eager to build was a way for developers to request testnet tokens without ever leaving their code editor. The simplest idea was to send a request from the terminal directly to the official [Midnight faucet](https://docs.midnight.network/blog/tags/%20https://midnight.network/test-faucet) . But there was a catch—the site is protected by [Cloudflare Turnstile](https://www.cloudflare.com/application-services/products/turnstile/) , which blocks automated requests to prevent spam and abuse. As a hacker, I started looking for a workaround. After some Googling and tips from friends, I tested several paid tools that claimed to bypass CAPTCHA protections. I spent an entire afternoon trying them, but none worked reliably. That’s when I remembered the genesis wallet, whose private key is publicly available. So, I implemented a workaround: instead of calling the faucet, I simulated a faucet transaction by transferring tokens directly from the genesis wallet to the user’s wallet. It’s not a long-term solution, and I know it won’t scale—but for now, it works and helps streamline the developer experience. Submission and Recognition ========================== I finally submitted my project, and the judges’ reactions were incredibly [encouraging](https://youtu.be/xrCEBIBqS-Y?t=4453) —it gave me a renewed sense of inspiration. With that momentum, I turned my focus back to my original hackathon: the African Blockchain Championship. For this challenge, I built an anonymous, censorship-resistant voting platform. In many African countries—across 34 nations—roughly 30–40% of citizens no longer view voting as a fair or trustworthy process (Afrobarometer, 2023). That’s why anonymous voting isn’t just a feature—it’s a necessity. My project, [**Privote**](https://github.com/kaleababayneh/zkvote-midnight) , aims to address this critical issue by leveraging zero-knowledge technology to protect voter identity and integrity. As the submission deadline approached, I ran into a major hurdle: integrating the wallet into the frontend. I reached out to one of the Developer Relations Engineers, who kindly shared some example code. Unfortunately, I couldn’t get it working in time. With the clock ticking, I had to improvise. I quickly built a custom Chrome extension that enabled wallet interaction—running through the terminal on the backend—just in time for submission. While the current version still has some privacy limitations, the smart contract compiles successfully, and users can interact with it on the Midnight testnet—offering a real glimpse of what decentralized, anonymous voting could look like in practice. ![Private Hackathon](https://ibin.co/8rMho4816dhp.png) The Midnight Community ====================== Even though there aren’t many resources available yet, the Midnight community more than makes up for it. Almost every question asked on Discord gets a response. It’s a space where people genuinely support each other—even during hackathons, when we’re technically competing and have little incentive to help other teams. In fact, during the hackathon, I often found myself answering questions in the Telegram group. I even hosted a workshop at the ABC hackathon on how to use **Create Midnight App**, helping others get started quickly and navigate the ecosystem more easily. I also want to take a moment to thank the Midnight team for the recognition they gave me—it truly meant a lot. Beyond placing first in the CLI track, the support and appreciation I received from the community were genuinely heartwarming. I even had the chance to join a community call—not just as a participant this time, but as a [speaker](https://x.com/MidnightNtwrk/status/1942969613496758398) —to share my journey and the lessons I’d learned along the way. Why Now is the Time to Build on Midnight ======================================== And for you—my readers—this is honestly the best time to get involved in the Midnight ecosystem. There’s _almost always_ a hackathon happening (seriously, it's kind of wild!). Right now, they’re even running a [mini DApp hackathon](https://midnight.network/hackathon/midnight-mini-dapp-hackathon) . It’s an excellent opportunity to learn, build, and get your project noticed. ![Midnight Dapp Hackathon](https://ibin.co/8rMcCFquPRqS.png) As for me, I’m currently building something new for the hackathon. While I enjoy working on projects, I’ve found even more fulfillment in developing infrastructure tools. I have a long-term goal of building a web-based Midnight playground where anyone can start writing Compact code and begin interacting with the Midnight testnet without needing to install anything. I hope to continue collaborating with the Midnight team and growing my skills—especially in zero-knowledge protocols—as I continue this journey. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/intro#__docusaurus_skipToContent_fallback) This past week, I started the SheFi course—a program designed to help women dive deeper into Web3 and decentralized finance. One of the first topics it covered was Ethereum: what it is, why it matters, and how it fits into the broader decentralized ecosystem. To build on what I learned there, I read two excellent overviews: [“A Beginner’s Guide to Ethereum” from Coinbase](https://medium.com/the-coinbase-blog/a-beginners-guide-to-ethereum-46dd486ceecf) and [“Getting Up to Speed on Ethereum” by Matt](https://medium.com/@oneofthemanymatts/getting-up-to-speed-on-ethereum-63ed28821bbe) . Both helped frame Ethereum not just as a cryptocurrency, but as a foundational platform for Web3 applications. Here’s what stood out and why Ethereum remains vital in a rapidly evolving cryptocurrency ecosystem. Ethereum in a Nutshell[​](https://docs.midnight.network/blog/tags/intro#ethereum-in-a-nutshell "Direct link to Ethereum in a Nutshell") ---------------------------------------------------------------------------------------------------------------------------------------- Ethereum is a decentralized computing platform. Think of it like a global computer that anyone can access, but no single person or organization controls it. This is possible because Ethereum is powered by a blockchain—a network of nodes around the world that maintain and validate a shared record of activity. What makes Ethereum special is that it doesn’t just store transactions; it can also run applications. These apps are powered by smart contracts, which are programs deployed to the blockchain that execute exactly as written. The Ethereum network is designed to be open, programmable, and permissionless. That means anyone can build on it, and no one needs approval to use it. This structure has enabled Ethereum to become the foundation for a wide range of decentralized applications (dApps), including financial tools such as lending protocols and stablecoins, as well as NFT marketplaces and decentralized identity systems. Why Ethereum Matters[​](https://docs.midnight.network/blog/tags/intro#why-ethereum-matters "Direct link to Why Ethereum Matters") ---------------------------------------------------------------------------------------------------------------------------------- Ethereum matters because it transforms the internet from a read-write platform into a read-write-execute environment. That is, it enables not just the sharing of information, but also the execution of logic—without relying on centralized intermediaries. This shift opens the door to creating systems that are more transparent, resilient, and accessible. One of Ethereum’s most significant breakthroughs is that it allows developers to write and deploy their own logic onto the network through smart contracts. These contracts can define rules, manage value, and interact with other contracts—all while being trustless and tamper-proof. Once deployed, smart contracts can’t be changed or censored, which means users can interact with them without worrying about backend changes or manipulation. Ether: The Fuel of the Ethereum Network[​](https://docs.midnight.network/blog/tags/intro#ether-the-fuel-of-the-ethereum-network "Direct link to Ether: The Fuel of the Ethereum Network") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Ether (ETH) is the native currency of Ethereum. While many people think of ETH primarily as a cryptocurrency—something you can buy, sell, or hold—its most important role as the fuel for computation. Every operation on the Ethereum network costs gas, and ETH is what you use to pay for it. This is a crucial aspect of Ethereum’s security and incentive structure, ensuring that resources are utilized responsibly and the network remains resilient to spam. When you send a transaction, deploy a smart contract, or interact with a dApp, you’re paying for the network to process that request. The more complex the operation, the more gas it consumes. Gas prices fluctuate based on network demand, and users can choose how much to pay to incentivize faster confirmation. This dynamic creates a market for block space, encouraging developers to write more efficient code. The Power of Smart Contracts[​](https://docs.midnight.network/blog/tags/intro#the-power-of-smart-contracts "Direct link to The Power of Smart Contracts") ---------------------------------------------------------------------------------------------------------------------------------------------------------- Smart contracts are at the heart of what makes Ethereum powerful. These are self-executing programs that live on the blockchain and enforce rules automatically. You don’t need to trust a company or a person; you can trust the code. Smart contracts enable a wide range of use cases, including lending platforms like Aave, decentralized exchanges like Uniswap, and even games like Axie Infinity. Once a smart contract is deployed, it’s public and verifiable. Anyone can inspect the code, interact with it, and build on top of it. This openness fosters a culture of composability—developers can plug into existing contracts, remix them, or build entirely new systems that work together. This is why Ethereum is often referred to as a “LEGO set for financial and digital tools.” Ethereum Today and Tomorrow[​](https://docs.midnight.network/blog/tags/intro#ethereum-today-and-tomorrow "Direct link to Ethereum Today and Tomorrow") ------------------------------------------------------------------------------------------------------------------------------------------------------- Ethereum has come a long way since its launch in 2015. It’s no longer just a niche experiment; it’s the most widely used smart contract platform in the world. However, with that growth has come challenges. Network congestion and high gas fees have made it difficult for some users to interact with dApps affordably. To address these issues, Ethereum has undergone significant upgrades, most notably the transition from proof-of-work to proof-of-stake, known as “The Merge.” Proof-of-stake is a consensus mechanism that allows Ethereum to secure the network using validators who lock up ETH rather than relying on energy-intensive mining. This shift has dramatically reduced Ethereum’s energy usage and paved the way for future scaling efforts, such as sharding and rollups. Rollups are a technique for batching many transactions into a single proof, which can then be submitted to the Ethereum mainnet. This helps scale the network without sacrificing security or decentralization. The Ethereum ecosystem is also growing through layer 2 networks, which are built on top of Ethereum and handle transactions off-chain while still relying on Ethereum for settlement and security. Projects like Arbitrum, Optimism, and zkSync are working to make Ethereum faster and cheaper for everyday users. How Ethereum Connects with Midnight[​](https://docs.midnight.network/blog/tags/intro#how-ethereum-connects-with-midnight "Direct link to How Ethereum Connects with Midnight") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- While Ethereum serves as the foundational smart contract platform for much of Web3, Midnight is designed to complement and extend its capabilities—especially in terms of privacy. In practical terms, this means that developers who are comfortable with the Ethereum ecosystem —its wallets, development environments, and smart contract models—can interact with Midnight using similar patterns. For example, Midnight supports a Solidity-like programming approach through its Compact smart contract language, which compiles to verifiable circuits that enforce privacy constraints. This allows developers to build private versions of applications, such as voting systems, token transfers, and identity verification, that would typically be public on the Ethereum blockchain. Ethereum offers programmability and decentralization, but by default, all on-chain transactions are transparent. Midnight fills in the missing privacy layer. You could imagine a workflow where public assets and smart contracts live on Ethereum, but sensitive data or confidential logic is handled by Midnight—bridging the two networks for richer, privacy-preserving applications. Together, Ethereum and Midnight can be seen as complementary parts of a broader decentralized stack: Ethereum provides openness and composability, while Midnight adds selective disclosure and private computation, enabling developers to build secure and compliant applications in ways that Ethereum alone can’t. Conclusion[​](https://docs.midnight.network/blog/tags/intro#conclusion "Direct link to Conclusion") ---------------------------------------------------------------------------------------------------- Ethereum isn’t just a cryptocurrency—it’s a platform for building a new kind of internet. By combining programmable logic with decentralized infrastructure, Ethereum enables applications that are open, transparent, and user-owned. It’s the foundation of decentralized finance (DeFi), non-fungible tokens (NFTs), and numerous experiments in online interaction. For me, starting with SheFi and reading through these resources helped ground my understanding of what Ethereum is and why it matters. It’s not just about buying coins—it’s about reshaping how we think about trust, ownership, and value in a digital world. I’ll be back next week as I continue diving into the core building blocks of Web3. If you’re just starting out too, I highly recommend giving [Coinbase’s primer](https://medium.com/the-coinbase-blog/a-beginners-guide-to-ethereum-46dd486ceecf) and [Matt’s breakdown](https://medium.com/@oneofthemanymatts/getting-up-to-speed-on-ethereum-63ed28821bbe) a read. Midnight's Developer Relations team is actively shaping how developers learn, build, and experiment with privacy-first apps. In this post, we take a closer look at how DevRel is lowering the barrier to entry for new builders, supporting open-source tools, and helping the community navigate the unique challenges of developing on a privacy-preserving blockchain. Zero-knowledge proofs let you prove you know something without revealing what you know. Here's how this cryptographic breakthrough is revolutionizing privacy in Web3 applications. As I continue my journey through the world of Web3, I’ve been digging into the building blocks that make privacy-first platforms like Midnight possible (you can catch up on previous posts in the Midnight Dev Diaries!). This week, I focused on two foundational pieces that go hand in hand: smart contracts on Midnight and the Compact language that powers them. Smart contracts aren’t new to blockchain, but Midnight’s approach is unique. Instead of executing code directly on-chain, Midnight uses smart contracts to define rules that are enforced off-chain through zero-knowledge proofs. At the center of this system is [Compact](https://docs.midnight.network/develop/reference/compact/lang-ref) —a purpose-built language designed to make writing these privacy-preserving contracts both secure and practical. To better understand how this works in practice, I also worked through [Module 2 of the Midnight Developer Academy](https://docs.midnight.network/academy/module-2) , which covers key concepts such as contract structure, circuit types, and the relationship between the contract and the external logic that executes it. In this post, I’ll break down what makes smart contracts on Midnight different, how Compact is structured, and how the two work together to enable provable logic without exposing sensitive data. What Is a Smart Contract on Midnight?[​](https://docs.midnight.network/blog/tags/intro#what-is-a-smart-contract-on-midnight "Direct link to What Is a Smart Contract on Midnight?") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ At a high level, a smart contract is an autonomous program stored on the blockchain. It defines rules for interaction, checks that those rules are met, and records results—all without needing a trusted third party to enforce them. But Midnight isn’t just any blockchain. It’s a privacy-first platform built with compliance in mind, and that means its smart contracts need to do more than just run logic. They need to protect private data, enable selective disclosure, and uphold security and trust even in adversarial environments. That’s where Compact comes in—a custom domain-specific language explicitly designed to write smart contracts on Midnight. Instead of executing logic directly on-chain like many traditional smart contracts, Compact contracts define the logic to be proven, not the execution environment itself. The contract encodes the rules that must be followed, which are then used as the foundation for a zero-knowledge proof. The actual execution—like processing a transaction, generating a credential, or submitting a vote—happens externally, often in a DApp, backend service, or API. That external system runs the necessary logic and **proves** it followed the contract’s rules by generating a cryptographic proof. The blockchain doesn’t need to know the details—it just verifies that the proof is valid. This separation is what makes Midnight’s model both scalable and privacy-preserving. In other words: the contract sets the rules, your app runs the logic, and the blockchain verifies the outcome, without ever seeing the sensitive inputs. What Is Compact?[​](https://docs.midnight.network/blog/tags/intro#what-is-compact "Direct link to What Is Compact?") --------------------------------------------------------------------------------------------------------------------- Compact is a statically typed, privacy-focused smart contract language tailored to the unique goals of the Midnight network. If you've worked with JavaScript or TypeScript before, you'll find Compact refreshingly approachable. It’s a domain-specific language (DSL) designed to define zero-knowledge proof logic using statically typed circuits that map to off-chain computations. But don’t let the simple syntax fool you—Compact is engineered for privacy-preserving computation using zero-knowledge proofs (ZKPs) under the hood. (For a more technical deep dive into compact, check out part 1 of Kevin Millikin's Compact Deep Dive [here](https://docs.midnight.network/blog/compact) !) A Compact contract is made up of three core components: * **Ledger**: The public, on-chain state of the contract. * **Circuits**: Off-chain logic that can manipulate data, produce proofs, and interact with the ledger. * **Witnesses**: Privately held data, only known to the entity executing the contract. Compact also supports [explicit disclosure](https://docs.midnight.network/develop/reference/compact/explicit_disclosure#conclusion) , meaning developers can define exactly what data gets revealed (and to whom). This provides fine-grained control over what is visible on-chain and what remains private, essential for use cases such as private asset transfers, age-gated access, or confidential voting. Circuits and Privacy[​](https://docs.midnight.network/blog/tags/intro#circuits-and-privacy "Direct link to Circuits and Privacy") ---------------------------------------------------------------------------------------------------------------------------------- One of the most essential takeaways from Module 2 of the Midnight Developer Academy is how circuits work. In Compact, circuits are the functions that users or systems can call to trigger actions. But unlike Web2 APIs or EVM contract functions, these circuits don’t execute logic directly on the blockchain. Instead, they run off-chain and generate zero-knowledge proofs that the logic was followed. In practice, that means: * The contract logic is public. * The data used during execution is private. * The outcome of the logic (e.g., “the rules were followed”) is publicly verifiable using a proof. This is where Midnight’s model shows its strength—users can prove they followed the rules without revealing the exact data that triggered the result. Think “I proved I’m eligible to vote” without revealing who I am or what I voted for. From Theory to Practice[​](https://docs.midnight.network/blog/tags/intro#from-theory-to-practice "Direct link to From Theory to Practice") ------------------------------------------------------------------------------------------------------------------------------------------- In traditional smart contract platforms, everything you do is public by default: data, logic, inputs, outputs. That’s useful for transparency, but it's not always practical, especially for sensitive use cases like health data, financial records, or identity verification. Midnight flips that default. Privacy is built in, and developers opt into disclosure only when it’s needed. Some examples of what you might build with Compact on Midnight: * A voting system where only the outcome is public. * An access control system that verifies user attributes without revealing identities. * A token transfer app that hides amounts or senders while still allowing public verification. Conclusion[​](https://docs.midnight.network/blog/tags/intro#conclusion "Direct link to Conclusion") ---------------------------------------------------------------------------------------------------- Smart contracts are the foundation of decentralized applications—but at Midnight, they’re built for a privacy-first future. Instead of executing every piece of logic on-chain, Midnight separates the contract's logic from its execution. With Compact, developers define the rules of a zero-knowledge proof system, enabling applications to prove facts without exposing sensitive data. It’s a practical shift toward secure, scalable, and user-protective Web3 design. At Midnight, this isn’t just a theoretical improvement—it’s core to how the platform operates. Compact smart contracts let developers write verifiable, auditable logic while keeping inputs and execution off-chain. Combined with ZKPs and shielded transactions, they create an infrastructure that supports real-world use cases without compromising on privacy or decentralization. If you're learning how to build smart contracts in Web3—or just curious how these pieces fit together—I highly recommend diving into [Module 2 of the Midnight Developer Academy](https://docs.midnight.network/academy/module-2) and reviewing the [Compact Language Reference](https://docs.midnight.network/develop/reference/compact/lang-ref) . These resources break down the concepts step by step and show how Midnight’s architecture turns advanced cryptography into practical developer tools. I’ll be back next week with more insights as I continue to unpack the pieces that make privacy-first systems work in the decentralized world. As I delve deeper into the world of Web3, I've been working my way through foundational concepts to have a better understanding of the industry (check out my last five posts on the [Midnight Dev Diaries](https://docs.midnight.network/blog) !). This week, I dove into one of the most practical and privacy-focused ideas I’ve encountered so far: **selective disclosure**. Selective disclosure is more than just a technical feature—it’s the working expression of a broader idea known as **rational privacy**. It allows individuals to prove or reveal only what’s necessary in a given interaction, keeping everything else private. In an ecosystem where trust must be earned without a central authority, this ability to protect personal data while still meeting legal or operational requirements is critical. This post examines how selective disclosure operates, its benefits, and how platforms like Midnight are implementing it through privacy-first smart contracts. What Is Selective Disclosure?[​](https://docs.midnight.network/blog/tags/intro#what-is-selective-disclosure "Direct link to What Is Selective Disclosure?") ------------------------------------------------------------------------------------------------------------------------------------------------------------ In the Web3 world, privacy doesn’t mean keeping everything secret—it means sharing only what’s necessary. [**Selective disclosure**](https://www.identity.com/what-is-selective-disclosure/) is a privacy-preserving technique that enables individuals to disclose specific information for a given interaction while keeping all other personal data confidential. This approach is a practical expression of a broader concept known as [**rational privacy**](https://midnight.network/blog/midnight-at-consensus-2025-building-the-future-of-rational-privacy) . Rational privacy is the idea that privacy shouldn’t be absolute or all-or-nothing—it should be contextual. It recognizes that in many real-world scenarios, users want to share _some_ data to gain access to services or meet legal obligations, but they shouldn't be forced to give up all privacy and security in the process. It’s about striking a balance between personal control, usability, and regulatory compliance. Selective disclosure is the technical implementation of rational privacy. It gives users and developers the cryptographic tools to protect sensitive information by default, while still enabling the right level of transparency when it’s required. This makes it especially relevant for public blockchain networks, where data is immutable and visible by design. A typical example of selective disclosure in action is the use of Verifiable Credentials (VCs). VCs allow users to prove attributes—like age, residency, or educational background—without revealing the entire credential. This aligns with the principles of data minimization and privacy by design, ensuring individuals remain in control of their information. This balance between usability and privacy is what makes selective disclosure so powerful—and so relevant for real-world blockchain applications. But beyond the technical implementation, it's worth asking: what are the practical benefits of using selective disclosure in the first place? Benefits of Selective Disclosure[​](https://docs.midnight.network/blog/tags/intro#benefits-of-selective-disclosure "Direct link to Benefits of Selective Disclosure") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- When integrated thoughtfully, selective disclosure brings both technical and human-centric advantages to decentralized systems. It enables individuals and organizations to meet privacy expectations and compliance standards without sacrificing functionality. Implementing selective disclosure offers several advantages: * **Enhanced Privacy**: Selective disclosure enables users to share only the data necessary for a specific interaction, rather than disclosing full credentials or identity documents. This dramatically reduces the surface area for privacy breaches and surveillance. Whether you’re accessing a service, submitting a form, or interacting with a smart contract, your unnecessary personal data stays out of view. * **Data Minimization and Compliance**: This principle, core to privacy laws such as GDPR and HIPAA, requires that only the minimum amount of personal data necessary for a task is collected or processed. Selective disclosure naturally enforces this, making it easier for developers and organizations to design privacy-respecting systems by default. * **User Empowerment and Control**: In traditional systems, users often hand over their entire dataset for one small verification (e.g., uploading an entire ID just to prove their age). Selective disclosure flips that dynamic, giving users the power to control what they share, when, and with whom. This supports a more user-centric data model, where individuals become the custodians of their credentials. * **Reduced Risk of Data Misuse**: The less information that’s exposed, the lower the risk of that data being lost, stolen, or misused. Selective disclosure reduces the need for centralized data storage (e.g., big ID databases), limiting attack vectors for fraud and identity theft. Even if a transaction or credential presentation is intercepted, only the minimum disclosed attribute is visible, keeping the rest safe. * **Lower Liability and Operational Overhead for Businesses:** Many organizations would prefer not to collect or store sensitive user data due to the associated risks, regulatory requirements, and administrative burdens. Selective disclosure offers a path forward, enabling users to demonstrate eligibility or compliance without requiring businesses to retain or manage that data. This can reduce costs, simplify operations, and improve overall data security posture. While selective disclosure introduces a powerful model for user-centric privacy, it also comes with its own set of technical and usability challenges. Understanding these limitations is essential for builders and organizations aiming to adopt it responsibly. Potential Drawbacks[​](https://docs.midnight.network/blog/tags/intro#potential-drawbacks "Direct link to Potential Drawbacks") ------------------------------------------------------------------------------------------------------------------------------- While selective disclosure strengthens privacy and control, implementing it in real-world systems isn’t always straightforward. Here are some of the common challenges: * **Complexity in Implementation**: Selective disclosure relies on advanced cryptographic techniques, often zero-knowledge proofs or similar privacy-preserving protocols. These require careful design, precise execution, and deep security expertise. For developers new to Web3 or cryptography, like myself, the learning curve can be steep, and mistakes in implementation could compromise the intended privacy protections. * **Verification Difficulties**: When only a fragment of a credential or statement is revealed, verifying its authenticity can become more complicated. Systems must be designed to ensure that partial disclosures can be trusted without needing access to the complete original data. This often requires additional metadata or proofs to be included, which can increase the overall complexity of the system and potentially slow down the verification process. * **Interoperability Challenges**: Not all decentralized identity systems follow the same formats or standards. As a result, credentials issued by one platform may not be easily verifiable on another, especially when using advanced features like selective disclosure. Without widely adopted protocols and infrastructure, cross-platform compatibility can be limited, reducing the broader utility of selectively disclosed data. While these challenges are real, they’re not insurmountable. Much of the current work in privacy-preserving blockchain development, including projects like Midnight, focuses on making selective disclosure more practical, developer-friendly, and interoperable across various ecosystems. Use Cases of Selective Disclosure[​](https://docs.midnight.network/blog/tags/intro#use-cases-of-selective-disclosure "Direct link to Use Cases of Selective Disclosure") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Selective disclosure has powerful, real-world applications wherever individuals or organizations need to prove something without oversharing. It’s beneficial in systems that handle sensitive data but also require compliance, trust, and transparency. Here are a few domains where it shines: * **Digital Identity Verification**: Imagine proving you're over 18 to access a service—without uploading your driver's license or disclosing your full birthdate and address. Selective disclosure lets you present only the relevant fact (e.g., “over 18”) as a verifiable statement, not the whole credential. * **Financial Transactions**: Financial platforms often need to confirm identity or transaction legitimacy (for KYC/AML compliance), but users shouldn’t have to share their entire financial history or wallet activity. Selective disclosure enables sharing only what’s legally necessary—no more, no less. * **Healthcare**: Patients may need to prove their vaccination status or medical eligibility without disclosing their entire health record. Selective disclosure lets them share only the required attribute (e.g., “vaccinated for X”) while keeping the rest private. * **Access Control**: Whether entering a venue or accessing online services, users may be granted or denied access based on attributes like membership, role, or credentials. Selective disclosure can enforce this access logic without revealing unnecessary identifying information. ### Selective Disclosure in the Midnight Network[​](https://docs.midnight.network/blog/tags/intro#selective-disclosure-in-the-midnight-network "Direct link to Selective Disclosure in the Midnight Network") At Midnight, selective disclosure isn’t just a privacy feature—it’s a core design principle grounded in rational privacy. Rational privacy recognizes that while sensitive data must be protected, real-world applications also require controlled visibility for regulatory, legal, or operational reasons. Take financial transactions, for example. A decentralized financial platform built on Midnight may want to keep user balances, transfers, and transaction histories private. However, under anti-money laundering (AML) or know-your-customer (KYC) regulations, certain information may need to be revealed—but only to authorized parties, and only under specific legal conditions. This is where selective disclosure and zero-knowledge proofs come together. Using Midnight's Compact smart contract language, developers can build logic that proves a transaction is valid (e.g., below a certain threshold, or compliant with regulatory filters) without revealing the full transaction details. Meanwhile, if a regulatory audit is triggered, users or auditors could selectively disclose the required pieces of information—nothing more. In this way, Midnight enables builders to create applications that respect individual privacy _and_ comply with regulatory requirements. It’s a practical application of selective disclosure that mirrors how real-world trust operates: share only what’s needed, only when it’s needed, and only with the right people. Conclusion[​](https://docs.midnight.network/blog/tags/intro#conclusion "Direct link to Conclusion") ---------------------------------------------------------------------------------------------------- Selective disclosure offers a flexible and powerful approach to privacy—one that meets people where they are, allowing them to control their information. It enables individuals to share just enough information to satisfy requirements, without exposing more than necessary. Whether you're verifying an identity, proving a credential, or complying with financial regulations, selective disclosure makes privacy practical and effective. At Midnight, this concept becomes more than theoretical. It’s embedded into the platform’s architecture through Compact smart contracts and zero-knowledge proofs, allowing builders to create systems that balance user protection with real-world needs. It’s rational privacy in action. If you're exploring how to build for privacy in Web3—or just learning how these systems work—I encourage you to check out the [Midnight docs](https://docs.midnight.network/) and [Academy](https://docs.midnight.network/academy) for more examples and technical insight, as well as a detailed list of further reading about selective disclosure below: * [What Is Selective Disclosure? – Identity.com](https://www.identity.com/what-is-selective-disclosure/) * [Selective Disclosure Guide – Dock.io](https://www.dock.io/post/selective-disclosure) * [A Refresher on Selective Disclosure and Anti-Fraud Rules – Frost Brown Todd](https://frostbrowntodd.com/a-refresher-on-selective-disclosure-and-anti-fraud-rules/) * [Midnight Academy Module 3 – Midnight Docs](https://docs.midnight.network/academy/module-3) * [Explicit Disclosure Reference – Midnight Docs](https://docs.midnight.network/develop/reference/compact/explicit_disclosure) * [Digital Assets Use Cases – Midnight Docs](https://docs.midnight.network/learn/introduction/use-cases/digital-assets) And, as always, if you’ve come across any great learning resources on privacy or identity in Web3, I’d love to see them—drop a comment or reply with your favorites! I'll be back next week with more insights as I continue unpacking the key building blocks that make decentralized systems work. As I continue my Web3 learning journey, I've mostly been working through [Cardano Academy](https://cardanofoundation.org/academy) and [Midnight Academy](https://docs.midnight.network/academy/) and documenting my findings in the [Midnight Dev Diaries](https://docs.midnight.network/blog) . But this week, I decided to branch out and explore a broader range of beginner-friendly resources across the ecosystem. That led me to two foundational concepts that kept coming up: Merkle Trees and Decentralized Autonomous Organizations (DAOs). These two topics sit at the heart of blockchain's promise—ensuring transparency, verifying data integrity, and enabling decentralized governance. I've broken down the key takeaways below, and if you're curious to go deeper, check out the list of helpful resources I've included at the end. Merkle Trees: Ensuring Data Integrity[​](https://docs.midnight.network/blog/tags/intro#merkle-trees-ensuring-data-integrity "Direct link to Merkle Trees: Ensuring Data Integrity") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ A Merkle Tree, also known as a hash tree, is a data structure that enables efficient and secure verification of large data sets. At its core, it is a special kind of [binary tree](https://www.geeksforgeeks.org/binary-tree-data-structure/) —a structure many Web2 developers will recognize. In a binary tree, each node has at most two children. What makes Merkle Trees different is that instead of storing values directly, they store hashes. These hashes represent data blocks and provide a compact, tamper-evident summary of all the data in the tree. Merkle Trees are crucial in blockchain because they allow a large set of data (like thousands of transactions) to be verified efficiently and securely. Instead of needing to check every transaction, you only need a small subset of hashes (called a Merkle proof) to confirm that a transaction is part of a block. Here's a simplified breakdown of how a Merkle Tree is built: 1. Start with data blocks (like transactions in a block). 2. Each data block is hashed individually. These hashes become the leaf nodes. 3. Pairs of leaf hashes are then hashed together to form the next level of the tree. 4. This process continues, combining hashes pairwise and moving up the tree until you're left with a single root hash, often called the Merkle Root. In short, each leaf node contains the hash of a data block, each non-leaf node contains the hash of its child nodes, and the root hash represents the entire data set. Any change to any single data block will change its hash, which then cascades up the tree, altering the Merkle Root. This property is crucial for blockchain systems, where data immutability and integrity are paramount. In practice, Merkle Trees are used in: * Blockchain Transactions: Ensuring that transactions within a block are untampered. * Proof of Reserves: Cryptocurrency exchanges use Merkle Trees to prove they hold sufficient assets to cover user deposits without revealing individual account balances. DAOs: Redefining Organizational Governance[​](https://docs.midnight.network/blog/tags/intro#daos-redefining-organizational-governance "Direct link to DAOs: Redefining Organizational Governance") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Decentralized Autonomous Organizations (DAOs) are organizations governed by smart contracts on a blockchain, eliminating the need for centralized leadership. They replace traditional top-down leadership with transparent, community-driven governance, all enforced through code—specifically, smart contracts. In a DAO, rules and operations are programmed upfront and stored on-chain. That means anyone can inspect how decisions are made, how funds are allocated, and how proposals are handled. Everything is transparent and auditable by default. Instead of a single CEO or board, decisions are made collectively by the community. Token holders can vote on proposals, and the outcome reflects the weight of their stake in the project. This collective decision-making process is what makes DAOs decentralized by design. And because those rules are enforced automatically by smart contracts, DAOs can operate autonomously without relying on manual intervention or centralized gatekeepers. Once a proposal passes, the smart contract executes the decision just as it was coded—no waiting for someone to push a button. However, DAOs also face challenges, including: * Security Risks: Vulnerabilities in smart contracts can be exploited. * Governance Issues: Low voter participation and token concentration can lead to centralization. DAOs have been utilized in various domains, such as: * Investment Funds: Pooling resources to invest in projects collectively. * Charitable Organizations: Deciding on fund allocation through member voting. * Protocol Governance: Managing and updating blockchain protocols. ### How DAO Voting Works (The Simple Version)[​](https://docs.midnight.network/blog/tags/intro#how-dao-voting-works-the-simple-version "Direct link to How DAO Voting Works (The Simple Version)") Most DAOs use token-based voting to reach decisions: 1. Members hold a governance token, which gives them the right to vote. 2. A proposal is submitted (for example, "Fund a new development project"). 3. Token holders vote for or against the proposal. 4. If a certain threshold is reached (like a quorum or majority), the proposal is accepted and automatically executed by smart contracts. Beyond on-chain voting, many DAOs utilize off-chain governance platforms, such as Snapshot (widely used for token-weighted voting), Aragon Voice, Tally (commonly paired with Governor contracts), or Coordinape (used for decentralized grants and peer voting). These tools offer flexibility, reduce gas costs, and enable more experimental governance setups. The more tokens you hold, the more voting power you wield. This is similar to how shareholders vote in corporations, but the process is entirely on-chain, without intermediaries. Some DAOs use [quadratic voting](https://blog.colony.io/what-is-quadratic-voting-a-guide-to-dao-decision-making/) or other mechanisms to prevent whales (large holders) from dominating the process, but the core idea remains the same: the community drives the roadmap. Interplay Between Merkle Trees and DAOs[​](https://docs.midnight.network/blog/tags/intro#interplay-between-merkle-trees-and-daos "Direct link to Interplay Between Merkle Trees and DAOs") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- While Merkle Trees and DAOs serve different purposes in the blockchain world—one focused on data integrity, the other on governance—they complement each other in powerful ways. Together, DAOs can remain secure, transparent, and efficient even as they scale. For example, instead of storing a complete list of eligible voters, a DAO can publish a Merkle Root representing that list. Individual voters then submit a short cryptographic proof (a Merkle proof) to confirm they're included. This keeps voting lightweight, private, and verifiable. The same method can be used to verify grant recipients or airdrop eligibility—ensuring integrity while saving space and gas costs. Merkle Trees also act as a bridge between off-chain and on-chain activity. Whether it's tracking voting done through Snapshot or verifying community identities, these proofs give DAOs a scalable way to maintain trust and transparency—even as they grow. Merkle Trees provide DAOs with the cryptographic foundation to scale governance without sacrificing transparency or efficiency. Whether it's verifying voter eligibility, proving fund distribution, or bridging off-chain data to on-chain actions, Merkle Trees help DAOs maintain trust and accountability as they grow. It's a powerful example of how foundational blockchain structures support and enhance decentralized decision-making. Conclusion[​](https://docs.midnight.network/blog/tags/intro#conclusion "Direct link to Conclusion") ---------------------------------------------------------------------------------------------------- Together, Merkle Trees and DAOs demonstrate how blockchain technology strikes a balance between technical efficiency and community empowerment. Merkle Trees ensure that large sets of data—like transactions, votes, or recipient lists, can be verified quickly and securely. At the same time, DAOs introduce a way for communities to govern decentralized projects in a transparent and fair manner. When combined, they offer a practical solution for scaling trust without sacrificing decentralization. Whether you're verifying a vote, distributing funds, or proving membership, these tools help build the infrastructure that makes Web3 more than just a technological shift—it becomes a new model for how people coordinate, decide, and build together. Exploring beyond the Cardano and Midnight Academies for the first time in this journey provided me with a broader understanding of how these technologies are explained and applied across the space. If you're learning along with me or want to dig deeper into any of the topics covered, here are some of the materials I found especially helpful: * [Video: Merkle Trees Explained – Simply Explained](https://www.youtube.com/watch?v=3AcQyTs_Es4) * [Introduction to Merkle Trees – Geeks for Geeks](https://www.geeksforgeeks.org/introduction-to-merkle-tree/) * [What Are DAOs – LimeChain Blog](https://limechain.tech/blog/what-are-daos) * [Blockchain Transparency: Merkle Trees & Proof of Reserves – Moralis](https://academy.moralis.io/blog/blockchain-transparency-exploring-merkle-trees-and-proof-of-reserves) * [Everything You Need to Know About Merkle Trees – Bitpanda Academy](https://www.bitpanda.com/academy/en/lessons/everything-you-need-to-know-about-merkle-trees/) * [Introduction to DAOs – Chainalysis](https://www.chainalysis.com/blog/introduction-to-decentralized-autonomous-organizations-daos/) And if you’ve come across other great resources while learning Web3 basics, I’d love to hear them—drop a comment or reply with your favorites! You can also check out the [Midnight docs](https://docs.midnight.network/) for more technical deep dives and real-world use cases. Stay tuned for next week's exploration into other core components of the decentralized world. Explore how blockchain platforms have evolved from Bitcoin to Midnight and why tokens are essential to powering decentralized ecosystems. Explore how public key encryption and Practical Byzantine Fault Tolerance form the cryptographic and consensus backbone of secure, decentralized blockchain networks like Midnight. Two foundational cryptographic tools—hash functions and digital signatures—ensure data integrity, authenticity, and trust in decentralized Web3 systems like Midnight. Journey into Web3, unpack key blockchain concepts like decentralization, consensus, and how they shape platforms like Midnight. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/web3-intro-history-and-tokens#__docusaurus_skipToContent_fallback) Explore how blockchain platforms have evolved from Bitcoin to Midnight and why tokens are essential to powering decentralized ecosystems. I’m still in the early stages of my Web3 learning journey (see my previous posts on the [Midnight Dev Diaries](https://docs.midnight.network/blog) !), and each week unveils new insights and "aha" moments for me. This week, I delved deeper into the Intro to Blockchain section of [Cardano Academy](https://academy.cardanofoundation.org/) , along with [Module 1 of the Midnight Developer Academy](https://docs.midnight.network/academy/module-1) . Rather than just focusing on the technical aspects and step-by-step guides, I shifted my attention to understanding the evolution of blockchain platforms over time, particularly the journey from Bitcoin to more advanced systems like Midnight. This exploration also led me to reflect on the crucial role that tokens play in the functionality and sustainability of decentralized systems. Tokens aren't just mere digital assets; they serve as the economic backbone that incentivizes participation and secures the network. In this post, I want to share two significant topics that helped clarify my understanding this week: 1. How blockchain platforms have progressed from Bitcoin to Midnight 2. How tokens keep decentralized systems running through economic incentives Let's jump in! The Evolution of Blockchain Platforms[​](https://docs.midnight.network/blog/web3-intro-history-and-tokens#the-evolution-of-blockchain-platforms "Direct link to The Evolution of Blockchain Platforms") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- When I first heard about blockchain, I mostly associated it with Bitcoin. However, after diving into more educational content, it became clear that this space has undergone multiple waves of innovation, each building on the last. Here's how we got from the first Bitcoin transaction to the emergence of privacy-focused blockchains like Midnight. ### Bitcoin (2009): A New Way to Move Money[​](https://docs.midnight.network/blog/web3-intro-history-and-tokens#bitcoin-2009-a-new-way-to-move-money "Direct link to Bitcoin (2009): A New Way to Move Money") Blockchain began with Bitcoin, launched in 2009 by the pseudonymous Satoshi Nakamoto. It introduced the idea of a decentralized, peer-to-peer payment network where anyone could send money without relying on banks or intermediaries. Transactions were validated through **proof-of-work** and recorded on a public ledger that anyone could inspect—but no one could alter. This was revolutionary. Bitcoin proved that decentralized digital money was possible—and, in 2010, someone even traded 10,000 BTC for two pizzas. That transaction is now famous for being the first real-world use of Bitcoin and the most expensive pizza ever bought. Still, Bitcoin was narrowly focused: it could securely transfer value but not much else. ### Ethereum (2015): The Rise of Programmable Blockchains[​](https://docs.midnight.network/blog/web3-intro-history-and-tokens#ethereum-2015-the-rise-of-programmable-blockchains "Direct link to Ethereum (2015): The Rise of Programmable Blockchains") Ethereum took the core idea of blockchain and expanded it into something far more flexible. It introduced **smart contracts**—self-executing programs that live on the blockchain and run when certain conditions are met. This turned Ethereum into what its creators called a "world computer": a decentralized platform for building applications that couldn't be shut down or censored. Ethereum is guided by six key principles: * **Atomicity**: All or nothing execution * **Synchrony**: Consistent state across nodes * **Provenance**: Trackable origins * **Permanence**: Durable data storage * **Immortality**: Apps that can't be turned off * **Immutability**: Data that can't be changed once written These principles laid the groundwork for DeFi, NFTs, and DAOs, giving rise to an entire ecosystem of decentralized applications. However, this flexibility came with trade-offs, especially around scalability and high transaction fees. ### Third-Generation Platforms: Cardano and Beyond[​](https://docs.midnight.network/blog/web3-intro-history-and-tokens#third-generation-platforms-cardano-and-beyond "Direct link to Third-Generation Platforms: Cardano and Beyond") Enter the third generation of blockchains. These platforms aim to solve the Blockchain Trilemma: how to balance scalability, security, and decentralization—without sacrificing any of them. Cardano, launched in 2017, is one of the most notable examples. It uses **proof-of-stake** to reduce energy consumption and improve efficiency. But what stood out most to me is that it was built from the ground up with formal research and peer-reviewed design—a very different approach from its predecessors. Cardano also addresses security at the protocol level. Unlike Ethereum, where new tokens are created via smart contracts (which can introduce vulnerabilities), tokens on Cardano are treated as **native assets**. This means they inherit the same security guarantees as the platform's native currency, ADA, and don't require a custom contract to be created or maintained. Other improvements include: * Layer 2 scaling solutions like Hydra * Support for sidechains to improve interoperability * A focus on sustainability by reducing resource consumption through staking is also needed ### Midnight: The Privacy Layer of the Future[​](https://docs.midnight.network/blog/web3-intro-history-and-tokens#midnight-the-privacy-layer-of-the-future "Direct link to Midnight: The Privacy Layer of the Future") Midnight represents a new phase in blockchain evolution focused on privacy and regulatory compliance. It uses tools like [zero-knowledge proofs](https://docs.midnight.network/learn/understanding-midnights-technology/zero-knowledge-proofs) to allow data to remain private on a public blockchain. At the same time, it supports selective disclosure, meaning users can prove compliance (for example, with regulations or audits) without revealing everything. In other words, Midnight blends the decentralization and transparency of blockchain with the privacy needed for real-world use cases—whether it's secure communication, confidential data sharing, or regulated financial applications. Tokenomics 101: Why Tokens Are More Than Just Coins[​](https://docs.midnight.network/blog/web3-intro-history-and-tokens#tokenomics-101-why-tokens-are-more-than-just-coins "Direct link to Tokenomics 101: Why Tokens Are More Than Just Coins") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Once I understood how blockchains evolved, the next big question was: How do they keep running without a central company in charge? The answer lies in tokenomics, the economic design behind each network. ### Tokens as Utility[​](https://docs.midnight.network/blog/web3-intro-history-and-tokens#tokens-as-utility "Direct link to Tokens as Utility") Every blockchain has a native token—Bitcoin has BTC, Ethereum has ETH, Cardano has ADA. But tokens aren't just money. Tokens are **used** to pay transaction fees, deploy contracts, access network features, and more. This creates a built-in incentive system. If using the network requires tokens, and the network is valuable, then tokens have value too. ### Tokens as Incentives[​](https://docs.midnight.network/blog/web3-intro-history-and-tokens#tokens-as-incentives "Direct link to Tokens as Incentives") Blockchain networks need participants to validate transactions, secure the network, and maintain consensus. In return, they reward those participants with tokens. For example: * Miners earn BTC for adding blocks to the Bitcoin chain. * Validators earn ADA in Cardano's proof-of-stake system to secure the network. These rewards are often inflationary, meaning new tokens are regularly minted and distributed. However, that inflation funds the network's infrastructure. ### **Tokens as Governance Tools**[​](https://docs.midnight.network/blog/web3-intro-history-and-tokens#tokens-as-governance-tools "Direct link to tokens-as-governance-tools") Some tokens also allow holders to vote on decisions. In DAO-style systems, governance tokens let users decide protocol upgrades, fee structures, or treasury spending. This turns token holders into active stakeholders, not just passive investors. ### Inflationary vs. Deflationary Models[​](https://docs.midnight.network/blog/web3-intro-history-and-tokens#inflationary-vs-deflationary-models "Direct link to Inflationary vs. Deflationary Models") The way a token's supply is designed can shape behavior: * Inflationary models (e.g., Polkadot) continually mint new tokens to incentivize active participation. * Deflationary models (e.g., Bitcoin) cap the total supply or burn tokens to reduce circulation. Each model has trade-offs: Inflation can reward contributors but reduce long-term value, while deflation can increase scarcity but discourage spending. Many modern projects use hybrid models. For example, Ethereum burns a portion of transaction fees to offset inflation while still issuing new tokens to validators. Conclusion[​](https://docs.midnight.network/blog/web3-intro-history-and-tokens#conclusion "Direct link to Conclusion") ----------------------------------------------------------------------------------------------------------------------- Understanding where blockchain originated and how tokens drive these systems provided me with a much clearer view of the ecosystem I'm entering. It's not just about code or decentralization for its sake. It's about designing systems where people are economically motivated to do the right thing. And just like the technology itself, the economics behind blockchains are still evolving. If you're learning Web3 too or just curious how all the pieces fit together, be sure to take a look at the [Midnight docs](https://docs.midnight.network/) , [Dev Diaries](https://docs.midnight.network/blog) , and the newly published modules in the [Midnight Developer Academy](https://docs.midnight.network/academy/module-1) . More foundational concepts are coming next week—stay tuned! * [The Evolution of Blockchain Platforms](https://docs.midnight.network/blog/web3-intro-history-and-tokens#the-evolution-of-blockchain-platforms) * [Bitcoin (2009): A New Way to Move Money](https://docs.midnight.network/blog/web3-intro-history-and-tokens#bitcoin-2009-a-new-way-to-move-money) * [Ethereum (2015): The Rise of Programmable Blockchains](https://docs.midnight.network/blog/web3-intro-history-and-tokens#ethereum-2015-the-rise-of-programmable-blockchains) * [Third-Generation Platforms: Cardano and Beyond](https://docs.midnight.network/blog/web3-intro-history-and-tokens#third-generation-platforms-cardano-and-beyond) * [Midnight: The Privacy Layer of the Future](https://docs.midnight.network/blog/web3-intro-history-and-tokens#midnight-the-privacy-layer-of-the-future) * [Tokenomics 101: Why Tokens Are More Than Just Coins](https://docs.midnight.network/blog/web3-intro-history-and-tokens#tokenomics-101-why-tokens-are-more-than-just-coins) * [Tokens as Utility](https://docs.midnight.network/blog/web3-intro-history-and-tokens#tokens-as-utility) * [Tokens as Incentives](https://docs.midnight.network/blog/web3-intro-history-and-tokens#tokens-as-incentives) * [**Tokens as Governance Tools**](https://docs.midnight.network/blog/web3-intro-history-and-tokens#tokens-as-governance-tools) * [Inflationary vs. Deflationary Models](https://docs.midnight.network/blog/web3-intro-history-and-tokens#inflationary-vs-deflationary-models) * [Conclusion](https://docs.midnight.network/blog/web3-intro-history-and-tokens#conclusion) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/web3-intro-merkle-trees-and-dao#__docusaurus_skipToContent_fallback) As I continue my Web3 learning journey, I've mostly been working through [Cardano Academy](https://cardanofoundation.org/academy) and [Midnight Academy](https://docs.midnight.network/academy/) and documenting my findings in the [Midnight Dev Diaries](https://docs.midnight.network/blog) . But this week, I decided to branch out and explore a broader range of beginner-friendly resources across the ecosystem. That led me to two foundational concepts that kept coming up: Merkle Trees and Decentralized Autonomous Organizations (DAOs). These two topics sit at the heart of blockchain's promise—ensuring transparency, verifying data integrity, and enabling decentralized governance. I've broken down the key takeaways below, and if you're curious to go deeper, check out the list of helpful resources I've included at the end. Merkle Trees: Ensuring Data Integrity[​](https://docs.midnight.network/blog/web3-intro-merkle-trees-and-dao#merkle-trees-ensuring-data-integrity "Direct link to Merkle Trees: Ensuring Data Integrity") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- A Merkle Tree, also known as a hash tree, is a data structure that enables efficient and secure verification of large data sets. At its core, it is a special kind of [binary tree](https://www.geeksforgeeks.org/binary-tree-data-structure/) —a structure many Web2 developers will recognize. In a binary tree, each node has at most two children. What makes Merkle Trees different is that instead of storing values directly, they store hashes. These hashes represent data blocks and provide a compact, tamper-evident summary of all the data in the tree. Merkle Trees are crucial in blockchain because they allow a large set of data (like thousands of transactions) to be verified efficiently and securely. Instead of needing to check every transaction, you only need a small subset of hashes (called a Merkle proof) to confirm that a transaction is part of a block. Here's a simplified breakdown of how a Merkle Tree is built: 1. Start with data blocks (like transactions in a block). 2. Each data block is hashed individually. These hashes become the leaf nodes. 3. Pairs of leaf hashes are then hashed together to form the next level of the tree. 4. This process continues, combining hashes pairwise and moving up the tree until you're left with a single root hash, often called the Merkle Root. In short, each leaf node contains the hash of a data block, each non-leaf node contains the hash of its child nodes, and the root hash represents the entire data set. Any change to any single data block will change its hash, which then cascades up the tree, altering the Merkle Root. This property is crucial for blockchain systems, where data immutability and integrity are paramount. In practice, Merkle Trees are used in: * Blockchain Transactions: Ensuring that transactions within a block are untampered. * Proof of Reserves: Cryptocurrency exchanges use Merkle Trees to prove they hold sufficient assets to cover user deposits without revealing individual account balances. DAOs: Redefining Organizational Governance[​](https://docs.midnight.network/blog/web3-intro-merkle-trees-and-dao#daos-redefining-organizational-governance "Direct link to DAOs: Redefining Organizational Governance") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Decentralized Autonomous Organizations (DAOs) are organizations governed by smart contracts on a blockchain, eliminating the need for centralized leadership. They replace traditional top-down leadership with transparent, community-driven governance, all enforced through code—specifically, smart contracts. In a DAO, rules and operations are programmed upfront and stored on-chain. That means anyone can inspect how decisions are made, how funds are allocated, and how proposals are handled. Everything is transparent and auditable by default. Instead of a single CEO or board, decisions are made collectively by the community. Token holders can vote on proposals, and the outcome reflects the weight of their stake in the project. This collective decision-making process is what makes DAOs decentralized by design. And because those rules are enforced automatically by smart contracts, DAOs can operate autonomously without relying on manual intervention or centralized gatekeepers. Once a proposal passes, the smart contract executes the decision just as it was coded—no waiting for someone to push a button. However, DAOs also face challenges, including: * Security Risks: Vulnerabilities in smart contracts can be exploited. * Governance Issues: Low voter participation and token concentration can lead to centralization. DAOs have been utilized in various domains, such as: * Investment Funds: Pooling resources to invest in projects collectively. * Charitable Organizations: Deciding on fund allocation through member voting. * Protocol Governance: Managing and updating blockchain protocols. ### How DAO Voting Works (The Simple Version)[​](https://docs.midnight.network/blog/web3-intro-merkle-trees-and-dao#how-dao-voting-works-the-simple-version "Direct link to How DAO Voting Works (The Simple Version)") Most DAOs use token-based voting to reach decisions: 1. Members hold a governance token, which gives them the right to vote. 2. A proposal is submitted (for example, "Fund a new development project"). 3. Token holders vote for or against the proposal. 4. If a certain threshold is reached (like a quorum or majority), the proposal is accepted and automatically executed by smart contracts. Beyond on-chain voting, many DAOs utilize off-chain governance platforms, such as Snapshot (widely used for token-weighted voting), Aragon Voice, Tally (commonly paired with Governor contracts), or Coordinape (used for decentralized grants and peer voting). These tools offer flexibility, reduce gas costs, and enable more experimental governance setups. The more tokens you hold, the more voting power you wield. This is similar to how shareholders vote in corporations, but the process is entirely on-chain, without intermediaries. Some DAOs use [quadratic voting](https://blog.colony.io/what-is-quadratic-voting-a-guide-to-dao-decision-making/) or other mechanisms to prevent whales (large holders) from dominating the process, but the core idea remains the same: the community drives the roadmap. Interplay Between Merkle Trees and DAOs[​](https://docs.midnight.network/blog/web3-intro-merkle-trees-and-dao#interplay-between-merkle-trees-and-daos "Direct link to Interplay Between Merkle Trees and DAOs") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- While Merkle Trees and DAOs serve different purposes in the blockchain world—one focused on data integrity, the other on governance—they complement each other in powerful ways. Together, DAOs can remain secure, transparent, and efficient even as they scale. For example, instead of storing a complete list of eligible voters, a DAO can publish a Merkle Root representing that list. Individual voters then submit a short cryptographic proof (a Merkle proof) to confirm they're included. This keeps voting lightweight, private, and verifiable. The same method can be used to verify grant recipients or airdrop eligibility—ensuring integrity while saving space and gas costs. Merkle Trees also act as a bridge between off-chain and on-chain activity. Whether it's tracking voting done through Snapshot or verifying community identities, these proofs give DAOs a scalable way to maintain trust and transparency—even as they grow. Merkle Trees provide DAOs with the cryptographic foundation to scale governance without sacrificing transparency or efficiency. Whether it's verifying voter eligibility, proving fund distribution, or bridging off-chain data to on-chain actions, Merkle Trees help DAOs maintain trust and accountability as they grow. It's a powerful example of how foundational blockchain structures support and enhance decentralized decision-making. Conclusion[​](https://docs.midnight.network/blog/web3-intro-merkle-trees-and-dao#conclusion "Direct link to Conclusion") ------------------------------------------------------------------------------------------------------------------------- Together, Merkle Trees and DAOs demonstrate how blockchain technology strikes a balance between technical efficiency and community empowerment. Merkle Trees ensure that large sets of data—like transactions, votes, or recipient lists, can be verified quickly and securely. At the same time, DAOs introduce a way for communities to govern decentralized projects in a transparent and fair manner. When combined, they offer a practical solution for scaling trust without sacrificing decentralization. Whether you're verifying a vote, distributing funds, or proving membership, these tools help build the infrastructure that makes Web3 more than just a technological shift—it becomes a new model for how people coordinate, decide, and build together. Exploring beyond the Cardano and Midnight Academies for the first time in this journey provided me with a broader understanding of how these technologies are explained and applied across the space. If you're learning along with me or want to dig deeper into any of the topics covered, here are some of the materials I found especially helpful: * [Video: Merkle Trees Explained – Simply Explained](https://www.youtube.com/watch?v=3AcQyTs_Es4) * [Introduction to Merkle Trees – Geeks for Geeks](https://www.geeksforgeeks.org/introduction-to-merkle-tree/) * [What Are DAOs – LimeChain Blog](https://limechain.tech/blog/what-are-daos) * [Blockchain Transparency: Merkle Trees & Proof of Reserves – Moralis](https://academy.moralis.io/blog/blockchain-transparency-exploring-merkle-trees-and-proof-of-reserves) * [Everything You Need to Know About Merkle Trees – Bitpanda Academy](https://www.bitpanda.com/academy/en/lessons/everything-you-need-to-know-about-merkle-trees/) * [Introduction to DAOs – Chainalysis](https://www.chainalysis.com/blog/introduction-to-decentralized-autonomous-organizations-daos/) And if you’ve come across other great resources while learning Web3 basics, I’d love to hear them—drop a comment or reply with your favorites! You can also check out the [Midnight docs](https://docs.midnight.network/) for more technical deep dives and real-world use cases. Stay tuned for next week's exploration into other core components of the decentralized world. * [Merkle Trees: Ensuring Data Integrity](https://docs.midnight.network/blog/web3-intro-merkle-trees-and-dao#merkle-trees-ensuring-data-integrity) * [DAOs: Redefining Organizational Governance](https://docs.midnight.network/blog/web3-intro-merkle-trees-and-dao#daos-redefining-organizational-governance) * [How DAO Voting Works (The Simple Version)](https://docs.midnight.network/blog/web3-intro-merkle-trees-and-dao#how-dao-voting-works-the-simple-version) * [Interplay Between Merkle Trees and DAOs](https://docs.midnight.network/blog/web3-intro-merkle-trees-and-dao#interplay-between-merkle-trees-and-daos) * [Conclusion](https://docs.midnight.network/blog/web3-intro-merkle-trees-and-dao#conclusion) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/web3-intro-understanding-ethereum#__docusaurus_skipToContent_fallback) This past week, I started the SheFi course—a program designed to help women dive deeper into Web3 and decentralized finance. One of the first topics it covered was Ethereum: what it is, why it matters, and how it fits into the broader decentralized ecosystem. To build on what I learned there, I read two excellent overviews: [“A Beginner’s Guide to Ethereum” from Coinbase](https://medium.com/the-coinbase-blog/a-beginners-guide-to-ethereum-46dd486ceecf) and [“Getting Up to Speed on Ethereum” by Matt](https://medium.com/@oneofthemanymatts/getting-up-to-speed-on-ethereum-63ed28821bbe) . Both helped frame Ethereum not just as a cryptocurrency, but as a foundational platform for Web3 applications. Here’s what stood out and why Ethereum remains vital in a rapidly evolving cryptocurrency ecosystem. Ethereum in a Nutshell[​](https://docs.midnight.network/blog/web3-intro-understanding-ethereum#ethereum-in-a-nutshell "Direct link to Ethereum in a Nutshell") --------------------------------------------------------------------------------------------------------------------------------------------------------------- Ethereum is a decentralized computing platform. Think of it like a global computer that anyone can access, but no single person or organization controls it. This is possible because Ethereum is powered by a blockchain—a network of nodes around the world that maintain and validate a shared record of activity. What makes Ethereum special is that it doesn’t just store transactions; it can also run applications. These apps are powered by smart contracts, which are programs deployed to the blockchain that execute exactly as written. The Ethereum network is designed to be open, programmable, and permissionless. That means anyone can build on it, and no one needs approval to use it. This structure has enabled Ethereum to become the foundation for a wide range of decentralized applications (dApps), including financial tools such as lending protocols and stablecoins, as well as NFT marketplaces and decentralized identity systems. Why Ethereum Matters[​](https://docs.midnight.network/blog/web3-intro-understanding-ethereum#why-ethereum-matters "Direct link to Why Ethereum Matters") --------------------------------------------------------------------------------------------------------------------------------------------------------- Ethereum matters because it transforms the internet from a read-write platform into a read-write-execute environment. That is, it enables not just the sharing of information, but also the execution of logic—without relying on centralized intermediaries. This shift opens the door to creating systems that are more transparent, resilient, and accessible. One of Ethereum’s most significant breakthroughs is that it allows developers to write and deploy their own logic onto the network through smart contracts. These contracts can define rules, manage value, and interact with other contracts—all while being trustless and tamper-proof. Once deployed, smart contracts can’t be changed or censored, which means users can interact with them without worrying about backend changes or manipulation. Ether: The Fuel of the Ethereum Network[​](https://docs.midnight.network/blog/web3-intro-understanding-ethereum#ether-the-fuel-of-the-ethereum-network "Direct link to Ether: The Fuel of the Ethereum Network") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Ether (ETH) is the native currency of Ethereum. While many people think of ETH primarily as a cryptocurrency—something you can buy, sell, or hold—its most important role as the fuel for computation. Every operation on the Ethereum network costs gas, and ETH is what you use to pay for it. This is a crucial aspect of Ethereum’s security and incentive structure, ensuring that resources are utilized responsibly and the network remains resilient to spam. When you send a transaction, deploy a smart contract, or interact with a dApp, you’re paying for the network to process that request. The more complex the operation, the more gas it consumes. Gas prices fluctuate based on network demand, and users can choose how much to pay to incentivize faster confirmation. This dynamic creates a market for block space, encouraging developers to write more efficient code. The Power of Smart Contracts[​](https://docs.midnight.network/blog/web3-intro-understanding-ethereum#the-power-of-smart-contracts "Direct link to The Power of Smart Contracts") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Smart contracts are at the heart of what makes Ethereum powerful. These are self-executing programs that live on the blockchain and enforce rules automatically. You don’t need to trust a company or a person; you can trust the code. Smart contracts enable a wide range of use cases, including lending platforms like Aave, decentralized exchanges like Uniswap, and even games like Axie Infinity. Once a smart contract is deployed, it’s public and verifiable. Anyone can inspect the code, interact with it, and build on top of it. This openness fosters a culture of composability—developers can plug into existing contracts, remix them, or build entirely new systems that work together. This is why Ethereum is often referred to as a “LEGO set for financial and digital tools.” Ethereum Today and Tomorrow[​](https://docs.midnight.network/blog/web3-intro-understanding-ethereum#ethereum-today-and-tomorrow "Direct link to Ethereum Today and Tomorrow") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Ethereum has come a long way since its launch in 2015. It’s no longer just a niche experiment; it’s the most widely used smart contract platform in the world. However, with that growth has come challenges. Network congestion and high gas fees have made it difficult for some users to interact with dApps affordably. To address these issues, Ethereum has undergone significant upgrades, most notably the transition from proof-of-work to proof-of-stake, known as “The Merge.” Proof-of-stake is a consensus mechanism that allows Ethereum to secure the network using validators who lock up ETH rather than relying on energy-intensive mining. This shift has dramatically reduced Ethereum’s energy usage and paved the way for future scaling efforts, such as sharding and rollups. Rollups are a technique for batching many transactions into a single proof, which can then be submitted to the Ethereum mainnet. This helps scale the network without sacrificing security or decentralization. The Ethereum ecosystem is also growing through layer 2 networks, which are built on top of Ethereum and handle transactions off-chain while still relying on Ethereum for settlement and security. Projects like Arbitrum, Optimism, and zkSync are working to make Ethereum faster and cheaper for everyday users. How Ethereum Connects with Midnight[​](https://docs.midnight.network/blog/web3-intro-understanding-ethereum#how-ethereum-connects-with-midnight "Direct link to How Ethereum Connects with Midnight") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ While Ethereum serves as the foundational smart contract platform for much of Web3, Midnight is designed to complement and extend its capabilities—especially in terms of privacy. In practical terms, this means that developers who are comfortable with the Ethereum ecosystem —its wallets, development environments, and smart contract models—can interact with Midnight using similar patterns. For example, Midnight supports a Solidity-like programming approach through its Compact smart contract language, which compiles to verifiable circuits that enforce privacy constraints. This allows developers to build private versions of applications, such as voting systems, token transfers, and identity verification, that would typically be public on the Ethereum blockchain. Ethereum offers programmability and decentralization, but by default, all on-chain transactions are transparent. Midnight fills in the missing privacy layer. You could imagine a workflow where public assets and smart contracts live on Ethereum, but sensitive data or confidential logic is handled by Midnight—bridging the two networks for richer, privacy-preserving applications. Together, Ethereum and Midnight can be seen as complementary parts of a broader decentralized stack: Ethereum provides openness and composability, while Midnight adds selective disclosure and private computation, enabling developers to build secure and compliant applications in ways that Ethereum alone can’t. Conclusion[​](https://docs.midnight.network/blog/web3-intro-understanding-ethereum#conclusion "Direct link to Conclusion") --------------------------------------------------------------------------------------------------------------------------- Ethereum isn’t just a cryptocurrency—it’s a platform for building a new kind of internet. By combining programmable logic with decentralized infrastructure, Ethereum enables applications that are open, transparent, and user-owned. It’s the foundation of decentralized finance (DeFi), non-fungible tokens (NFTs), and numerous experiments in online interaction. For me, starting with SheFi and reading through these resources helped ground my understanding of what Ethereum is and why it matters. It’s not just about buying coins—it’s about reshaping how we think about trust, ownership, and value in a digital world. I’ll be back next week as I continue diving into the core building blocks of Web3. If you’re just starting out too, I highly recommend giving [Coinbase’s primer](https://medium.com/the-coinbase-blog/a-beginners-guide-to-ethereum-46dd486ceecf) and [Matt’s breakdown](https://medium.com/@oneofthemanymatts/getting-up-to-speed-on-ethereum-63ed28821bbe) a read. * [Ethereum in a Nutshell](https://docs.midnight.network/blog/web3-intro-understanding-ethereum#ethereum-in-a-nutshell) * [Why Ethereum Matters](https://docs.midnight.network/blog/web3-intro-understanding-ethereum#why-ethereum-matters) * [Ether: The Fuel of the Ethereum Network](https://docs.midnight.network/blog/web3-intro-understanding-ethereum#ether-the-fuel-of-the-ethereum-network) * [The Power of Smart Contracts](https://docs.midnight.network/blog/web3-intro-understanding-ethereum#the-power-of-smart-contracts) * [Ethereum Today and Tomorrow](https://docs.midnight.network/blog/web3-intro-understanding-ethereum#ethereum-today-and-tomorrow) * [How Ethereum Connects with Midnight](https://docs.midnight.network/blog/web3-intro-understanding-ethereum#how-ethereum-connects-with-midnight) * [Conclusion](https://docs.midnight.network/blog/web3-intro-understanding-ethereum#conclusion) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/web3-intro-smart-contracts-and-compact#__docusaurus_skipToContent_fallback) As I continue my journey through the world of Web3, I’ve been digging into the building blocks that make privacy-first platforms like Midnight possible (you can catch up on previous posts in the Midnight Dev Diaries!). This week, I focused on two foundational pieces that go hand in hand: smart contracts on Midnight and the Compact language that powers them. Smart contracts aren’t new to blockchain, but Midnight’s approach is unique. Instead of executing code directly on-chain, Midnight uses smart contracts to define rules that are enforced off-chain through zero-knowledge proofs. At the center of this system is [Compact](https://docs.midnight.network/develop/reference/compact/lang-ref) —a purpose-built language designed to make writing these privacy-preserving contracts both secure and practical. To better understand how this works in practice, I also worked through [Module 2 of the Midnight Developer Academy](https://docs.midnight.network/academy/module-2) , which covers key concepts such as contract structure, circuit types, and the relationship between the contract and the external logic that executes it. In this post, I’ll break down what makes smart contracts on Midnight different, how Compact is structured, and how the two work together to enable provable logic without exposing sensitive data. What Is a Smart Contract on Midnight?[​](https://docs.midnight.network/blog/web3-intro-smart-contracts-and-compact#what-is-a-smart-contract-on-midnight "Direct link to What Is a Smart Contract on Midnight?") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- At a high level, a smart contract is an autonomous program stored on the blockchain. It defines rules for interaction, checks that those rules are met, and records results—all without needing a trusted third party to enforce them. But Midnight isn’t just any blockchain. It’s a privacy-first platform built with compliance in mind, and that means its smart contracts need to do more than just run logic. They need to protect private data, enable selective disclosure, and uphold security and trust even in adversarial environments. That’s where Compact comes in—a custom domain-specific language explicitly designed to write smart contracts on Midnight. Instead of executing logic directly on-chain like many traditional smart contracts, Compact contracts define the logic to be proven, not the execution environment itself. The contract encodes the rules that must be followed, which are then used as the foundation for a zero-knowledge proof. The actual execution—like processing a transaction, generating a credential, or submitting a vote—happens externally, often in a DApp, backend service, or API. That external system runs the necessary logic and **proves** it followed the contract’s rules by generating a cryptographic proof. The blockchain doesn’t need to know the details—it just verifies that the proof is valid. This separation is what makes Midnight’s model both scalable and privacy-preserving. In other words: the contract sets the rules, your app runs the logic, and the blockchain verifies the outcome, without ever seeing the sensitive inputs. What Is Compact?[​](https://docs.midnight.network/blog/web3-intro-smart-contracts-and-compact#what-is-compact "Direct link to What Is Compact?") ------------------------------------------------------------------------------------------------------------------------------------------------- Compact is a statically typed, privacy-focused smart contract language tailored to the unique goals of the Midnight network. If you've worked with JavaScript or TypeScript before, you'll find Compact refreshingly approachable. It’s a domain-specific language (DSL) designed to define zero-knowledge proof logic using statically typed circuits that map to off-chain computations. But don’t let the simple syntax fool you—Compact is engineered for privacy-preserving computation using zero-knowledge proofs (ZKPs) under the hood. (For a more technical deep dive into compact, check out part 1 of Kevin Millikin's Compact Deep Dive [here](https://docs.midnight.network/blog/compact) !) A Compact contract is made up of three core components: * **Ledger**: The public, on-chain state of the contract. * **Circuits**: Off-chain logic that can manipulate data, produce proofs, and interact with the ledger. * **Witnesses**: Privately held data, only known to the entity executing the contract. Compact also supports [explicit disclosure](https://docs.midnight.network/develop/reference/compact/explicit_disclosure#conclusion) , meaning developers can define exactly what data gets revealed (and to whom). This provides fine-grained control over what is visible on-chain and what remains private, essential for use cases such as private asset transfers, age-gated access, or confidential voting. Circuits and Privacy[​](https://docs.midnight.network/blog/web3-intro-smart-contracts-and-compact#circuits-and-privacy "Direct link to Circuits and Privacy") -------------------------------------------------------------------------------------------------------------------------------------------------------------- One of the most essential takeaways from Module 2 of the Midnight Developer Academy is how circuits work. In Compact, circuits are the functions that users or systems can call to trigger actions. But unlike Web2 APIs or EVM contract functions, these circuits don’t execute logic directly on the blockchain. Instead, they run off-chain and generate zero-knowledge proofs that the logic was followed. In practice, that means: * The contract logic is public. * The data used during execution is private. * The outcome of the logic (e.g., “the rules were followed”) is publicly verifiable using a proof. This is where Midnight’s model shows its strength—users can prove they followed the rules without revealing the exact data that triggered the result. Think “I proved I’m eligible to vote” without revealing who I am or what I voted for. From Theory to Practice[​](https://docs.midnight.network/blog/web3-intro-smart-contracts-and-compact#from-theory-to-practice "Direct link to From Theory to Practice") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- In traditional smart contract platforms, everything you do is public by default: data, logic, inputs, outputs. That’s useful for transparency, but it's not always practical, especially for sensitive use cases like health data, financial records, or identity verification. Midnight flips that default. Privacy is built in, and developers opt into disclosure only when it’s needed. Some examples of what you might build with Compact on Midnight: * A voting system where only the outcome is public. * An access control system that verifies user attributes without revealing identities. * A token transfer app that hides amounts or senders while still allowing public verification. Conclusion[​](https://docs.midnight.network/blog/web3-intro-smart-contracts-and-compact#conclusion "Direct link to Conclusion") -------------------------------------------------------------------------------------------------------------------------------- Smart contracts are the foundation of decentralized applications—but at Midnight, they’re built for a privacy-first future. Instead of executing every piece of logic on-chain, Midnight separates the contract's logic from its execution. With Compact, developers define the rules of a zero-knowledge proof system, enabling applications to prove facts without exposing sensitive data. It’s a practical shift toward secure, scalable, and user-protective Web3 design. At Midnight, this isn’t just a theoretical improvement—it’s core to how the platform operates. Compact smart contracts let developers write verifiable, auditable logic while keeping inputs and execution off-chain. Combined with ZKPs and shielded transactions, they create an infrastructure that supports real-world use cases without compromising on privacy or decentralization. If you're learning how to build smart contracts in Web3—or just curious how these pieces fit together—I highly recommend diving into [Module 2 of the Midnight Developer Academy](https://docs.midnight.network/academy/module-2) and reviewing the [Compact Language Reference](https://docs.midnight.network/develop/reference/compact/lang-ref) . These resources break down the concepts step by step and show how Midnight’s architecture turns advanced cryptography into practical developer tools. I’ll be back next week with more insights as I continue to unpack the pieces that make privacy-first systems work in the decentralized world. * [What Is a Smart Contract on Midnight?](https://docs.midnight.network/blog/web3-intro-smart-contracts-and-compact#what-is-a-smart-contract-on-midnight) * [What Is Compact?](https://docs.midnight.network/blog/web3-intro-smart-contracts-and-compact#what-is-compact) * [Circuits and Privacy](https://docs.midnight.network/blog/web3-intro-smart-contracts-and-compact#circuits-and-privacy) * [From Theory to Practice](https://docs.midnight.network/blog/web3-intro-smart-contracts-and-compact#from-theory-to-practice) * [Conclusion](https://docs.midnight.network/blog/web3-intro-smart-contracts-and-compact#conclusion) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/beginner#__docusaurus_skipToContent_fallback) **[Hacktoberfest](https://hacktoberfest.com/) ** is a global open-source event held every October, where developers contribute pull requests to public repositories to earn digital rewards. Midnight is joining the celebration by inviting contributors to improve its open-source ecosystem — from smart contracts and DApps to core libraries and documentation. Review the guide to get started. This past week, I started the SheFi course—a program designed to help women dive deeper into Web3 and decentralized finance. One of the first topics it covered was Ethereum: what it is, why it matters, and how it fits into the broader decentralized ecosystem. To build on what I learned there, I read two excellent overviews: [“A Beginner’s Guide to Ethereum” from Coinbase](https://medium.com/the-coinbase-blog/a-beginners-guide-to-ethereum-46dd486ceecf) and [“Getting Up to Speed on Ethereum” by Matt](https://medium.com/@oneofthemanymatts/getting-up-to-speed-on-ethereum-63ed28821bbe) . Both helped frame Ethereum not just as a cryptocurrency, but as a foundational platform for Web3 applications. Here’s what stood out and why Ethereum remains vital in a rapidly evolving cryptocurrency ecosystem. Ethereum in a Nutshell[​](https://docs.midnight.network/blog/tags/beginner#ethereum-in-a-nutshell "Direct link to Ethereum in a Nutshell") ------------------------------------------------------------------------------------------------------------------------------------------- Ethereum is a decentralized computing platform. Think of it like a global computer that anyone can access, but no single person or organization controls it. This is possible because Ethereum is powered by a blockchain—a network of nodes around the world that maintain and validate a shared record of activity. What makes Ethereum special is that it doesn’t just store transactions; it can also run applications. These apps are powered by smart contracts, which are programs deployed to the blockchain that execute exactly as written. The Ethereum network is designed to be open, programmable, and permissionless. That means anyone can build on it, and no one needs approval to use it. This structure has enabled Ethereum to become the foundation for a wide range of decentralized applications (dApps), including financial tools such as lending protocols and stablecoins, as well as NFT marketplaces and decentralized identity systems. Why Ethereum Matters[​](https://docs.midnight.network/blog/tags/beginner#why-ethereum-matters "Direct link to Why Ethereum Matters") ------------------------------------------------------------------------------------------------------------------------------------- Ethereum matters because it transforms the internet from a read-write platform into a read-write-execute environment. That is, it enables not just the sharing of information, but also the execution of logic—without relying on centralized intermediaries. This shift opens the door to creating systems that are more transparent, resilient, and accessible. One of Ethereum’s most significant breakthroughs is that it allows developers to write and deploy their own logic onto the network through smart contracts. These contracts can define rules, manage value, and interact with other contracts—all while being trustless and tamper-proof. Once deployed, smart contracts can’t be changed or censored, which means users can interact with them without worrying about backend changes or manipulation. Ether: The Fuel of the Ethereum Network[​](https://docs.midnight.network/blog/tags/beginner#ether-the-fuel-of-the-ethereum-network "Direct link to Ether: The Fuel of the Ethereum Network") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Ether (ETH) is the native currency of Ethereum. While many people think of ETH primarily as a cryptocurrency—something you can buy, sell, or hold—its most important role as the fuel for computation. Every operation on the Ethereum network costs gas, and ETH is what you use to pay for it. This is a crucial aspect of Ethereum’s security and incentive structure, ensuring that resources are utilized responsibly and the network remains resilient to spam. When you send a transaction, deploy a smart contract, or interact with a dApp, you’re paying for the network to process that request. The more complex the operation, the more gas it consumes. Gas prices fluctuate based on network demand, and users can choose how much to pay to incentivize faster confirmation. This dynamic creates a market for block space, encouraging developers to write more efficient code. The Power of Smart Contracts[​](https://docs.midnight.network/blog/tags/beginner#the-power-of-smart-contracts "Direct link to The Power of Smart Contracts") ------------------------------------------------------------------------------------------------------------------------------------------------------------- Smart contracts are at the heart of what makes Ethereum powerful. These are self-executing programs that live on the blockchain and enforce rules automatically. You don’t need to trust a company or a person; you can trust the code. Smart contracts enable a wide range of use cases, including lending platforms like Aave, decentralized exchanges like Uniswap, and even games like Axie Infinity. Once a smart contract is deployed, it’s public and verifiable. Anyone can inspect the code, interact with it, and build on top of it. This openness fosters a culture of composability—developers can plug into existing contracts, remix them, or build entirely new systems that work together. This is why Ethereum is often referred to as a “LEGO set for financial and digital tools.” Ethereum Today and Tomorrow[​](https://docs.midnight.network/blog/tags/beginner#ethereum-today-and-tomorrow "Direct link to Ethereum Today and Tomorrow") ---------------------------------------------------------------------------------------------------------------------------------------------------------- Ethereum has come a long way since its launch in 2015. It’s no longer just a niche experiment; it’s the most widely used smart contract platform in the world. However, with that growth has come challenges. Network congestion and high gas fees have made it difficult for some users to interact with dApps affordably. To address these issues, Ethereum has undergone significant upgrades, most notably the transition from proof-of-work to proof-of-stake, known as “The Merge.” Proof-of-stake is a consensus mechanism that allows Ethereum to secure the network using validators who lock up ETH rather than relying on energy-intensive mining. This shift has dramatically reduced Ethereum’s energy usage and paved the way for future scaling efforts, such as sharding and rollups. Rollups are a technique for batching many transactions into a single proof, which can then be submitted to the Ethereum mainnet. This helps scale the network without sacrificing security or decentralization. The Ethereum ecosystem is also growing through layer 2 networks, which are built on top of Ethereum and handle transactions off-chain while still relying on Ethereum for settlement and security. Projects like Arbitrum, Optimism, and zkSync are working to make Ethereum faster and cheaper for everyday users. How Ethereum Connects with Midnight[​](https://docs.midnight.network/blog/tags/beginner#how-ethereum-connects-with-midnight "Direct link to How Ethereum Connects with Midnight") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- While Ethereum serves as the foundational smart contract platform for much of Web3, Midnight is designed to complement and extend its capabilities—especially in terms of privacy. In practical terms, this means that developers who are comfortable with the Ethereum ecosystem —its wallets, development environments, and smart contract models—can interact with Midnight using similar patterns. For example, Midnight supports a Solidity-like programming approach through its Compact smart contract language, which compiles to verifiable circuits that enforce privacy constraints. This allows developers to build private versions of applications, such as voting systems, token transfers, and identity verification, that would typically be public on the Ethereum blockchain. Ethereum offers programmability and decentralization, but by default, all on-chain transactions are transparent. Midnight fills in the missing privacy layer. You could imagine a workflow where public assets and smart contracts live on Ethereum, but sensitive data or confidential logic is handled by Midnight—bridging the two networks for richer, privacy-preserving applications. Together, Ethereum and Midnight can be seen as complementary parts of a broader decentralized stack: Ethereum provides openness and composability, while Midnight adds selective disclosure and private computation, enabling developers to build secure and compliant applications in ways that Ethereum alone can’t. Conclusion[​](https://docs.midnight.network/blog/tags/beginner#conclusion "Direct link to Conclusion") ------------------------------------------------------------------------------------------------------- Ethereum isn’t just a cryptocurrency—it’s a platform for building a new kind of internet. By combining programmable logic with decentralized infrastructure, Ethereum enables applications that are open, transparent, and user-owned. It’s the foundation of decentralized finance (DeFi), non-fungible tokens (NFTs), and numerous experiments in online interaction. For me, starting with SheFi and reading through these resources helped ground my understanding of what Ethereum is and why it matters. It’s not just about buying coins—it’s about reshaping how we think about trust, ownership, and value in a digital world. I’ll be back next week as I continue diving into the core building blocks of Web3. If you’re just starting out too, I highly recommend giving [Coinbase’s primer](https://medium.com/the-coinbase-blog/a-beginners-guide-to-ethereum-46dd486ceecf) and [Matt’s breakdown](https://medium.com/@oneofthemanymatts/getting-up-to-speed-on-ethereum-63ed28821bbe) a read. Midnight's Developer Relations team is actively shaping how developers learn, build, and experiment with privacy-first apps. In this post, we take a closer look at how DevRel is lowering the barrier to entry for new builders, supporting open-source tools, and helping the community navigate the unique challenges of developing on a privacy-preserving blockchain. Zero-knowledge proofs let you prove you know something without revealing what you know. Here's how this cryptographic breakthrough is revolutionizing privacy in Web3 applications. As I continue my journey through the world of Web3, I’ve been digging into the building blocks that make privacy-first platforms like Midnight possible (you can catch up on previous posts in the Midnight Dev Diaries!). This week, I focused on two foundational pieces that go hand in hand: smart contracts on Midnight and the Compact language that powers them. Smart contracts aren’t new to blockchain, but Midnight’s approach is unique. Instead of executing code directly on-chain, Midnight uses smart contracts to define rules that are enforced off-chain through zero-knowledge proofs. At the center of this system is [Compact](https://docs.midnight.network/develop/reference/compact/lang-ref) —a purpose-built language designed to make writing these privacy-preserving contracts both secure and practical. To better understand how this works in practice, I also worked through [Module 2 of the Midnight Developer Academy](https://docs.midnight.network/academy/module-2) , which covers key concepts such as contract structure, circuit types, and the relationship between the contract and the external logic that executes it. In this post, I’ll break down what makes smart contracts on Midnight different, how Compact is structured, and how the two work together to enable provable logic without exposing sensitive data. What Is a Smart Contract on Midnight?[​](https://docs.midnight.network/blog/tags/beginner#what-is-a-smart-contract-on-midnight "Direct link to What Is a Smart Contract on Midnight?") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- At a high level, a smart contract is an autonomous program stored on the blockchain. It defines rules for interaction, checks that those rules are met, and records results—all without needing a trusted third party to enforce them. But Midnight isn’t just any blockchain. It’s a privacy-first platform built with compliance in mind, and that means its smart contracts need to do more than just run logic. They need to protect private data, enable selective disclosure, and uphold security and trust even in adversarial environments. That’s where Compact comes in—a custom domain-specific language explicitly designed to write smart contracts on Midnight. Instead of executing logic directly on-chain like many traditional smart contracts, Compact contracts define the logic to be proven, not the execution environment itself. The contract encodes the rules that must be followed, which are then used as the foundation for a zero-knowledge proof. The actual execution—like processing a transaction, generating a credential, or submitting a vote—happens externally, often in a DApp, backend service, or API. That external system runs the necessary logic and **proves** it followed the contract’s rules by generating a cryptographic proof. The blockchain doesn’t need to know the details—it just verifies that the proof is valid. This separation is what makes Midnight’s model both scalable and privacy-preserving. In other words: the contract sets the rules, your app runs the logic, and the blockchain verifies the outcome, without ever seeing the sensitive inputs. What Is Compact?[​](https://docs.midnight.network/blog/tags/beginner#what-is-compact "Direct link to What Is Compact?") ------------------------------------------------------------------------------------------------------------------------ Compact is a statically typed, privacy-focused smart contract language tailored to the unique goals of the Midnight network. If you've worked with JavaScript or TypeScript before, you'll find Compact refreshingly approachable. It’s a domain-specific language (DSL) designed to define zero-knowledge proof logic using statically typed circuits that map to off-chain computations. But don’t let the simple syntax fool you—Compact is engineered for privacy-preserving computation using zero-knowledge proofs (ZKPs) under the hood. (For a more technical deep dive into compact, check out part 1 of Kevin Millikin's Compact Deep Dive [here](https://docs.midnight.network/blog/compact) !) A Compact contract is made up of three core components: * **Ledger**: The public, on-chain state of the contract. * **Circuits**: Off-chain logic that can manipulate data, produce proofs, and interact with the ledger. * **Witnesses**: Privately held data, only known to the entity executing the contract. Compact also supports [explicit disclosure](https://docs.midnight.network/develop/reference/compact/explicit_disclosure#conclusion) , meaning developers can define exactly what data gets revealed (and to whom). This provides fine-grained control over what is visible on-chain and what remains private, essential for use cases such as private asset transfers, age-gated access, or confidential voting. Circuits and Privacy[​](https://docs.midnight.network/blog/tags/beginner#circuits-and-privacy "Direct link to Circuits and Privacy") ------------------------------------------------------------------------------------------------------------------------------------- One of the most essential takeaways from Module 2 of the Midnight Developer Academy is how circuits work. In Compact, circuits are the functions that users or systems can call to trigger actions. But unlike Web2 APIs or EVM contract functions, these circuits don’t execute logic directly on the blockchain. Instead, they run off-chain and generate zero-knowledge proofs that the logic was followed. In practice, that means: * The contract logic is public. * The data used during execution is private. * The outcome of the logic (e.g., “the rules were followed”) is publicly verifiable using a proof. This is where Midnight’s model shows its strength—users can prove they followed the rules without revealing the exact data that triggered the result. Think “I proved I’m eligible to vote” without revealing who I am or what I voted for. From Theory to Practice[​](https://docs.midnight.network/blog/tags/beginner#from-theory-to-practice "Direct link to From Theory to Practice") ---------------------------------------------------------------------------------------------------------------------------------------------- In traditional smart contract platforms, everything you do is public by default: data, logic, inputs, outputs. That’s useful for transparency, but it's not always practical, especially for sensitive use cases like health data, financial records, or identity verification. Midnight flips that default. Privacy is built in, and developers opt into disclosure only when it’s needed. Some examples of what you might build with Compact on Midnight: * A voting system where only the outcome is public. * An access control system that verifies user attributes without revealing identities. * A token transfer app that hides amounts or senders while still allowing public verification. Conclusion[​](https://docs.midnight.network/blog/tags/beginner#conclusion "Direct link to Conclusion") ------------------------------------------------------------------------------------------------------- Smart contracts are the foundation of decentralized applications—but at Midnight, they’re built for a privacy-first future. Instead of executing every piece of logic on-chain, Midnight separates the contract's logic from its execution. With Compact, developers define the rules of a zero-knowledge proof system, enabling applications to prove facts without exposing sensitive data. It’s a practical shift toward secure, scalable, and user-protective Web3 design. At Midnight, this isn’t just a theoretical improvement—it’s core to how the platform operates. Compact smart contracts let developers write verifiable, auditable logic while keeping inputs and execution off-chain. Combined with ZKPs and shielded transactions, they create an infrastructure that supports real-world use cases without compromising on privacy or decentralization. If you're learning how to build smart contracts in Web3—or just curious how these pieces fit together—I highly recommend diving into [Module 2 of the Midnight Developer Academy](https://docs.midnight.network/academy/module-2) and reviewing the [Compact Language Reference](https://docs.midnight.network/develop/reference/compact/lang-ref) . These resources break down the concepts step by step and show how Midnight’s architecture turns advanced cryptography into practical developer tools. I’ll be back next week with more insights as I continue to unpack the pieces that make privacy-first systems work in the decentralized world. As I delve deeper into the world of Web3, I've been working my way through foundational concepts to have a better understanding of the industry (check out my last five posts on the [Midnight Dev Diaries](https://docs.midnight.network/blog) !). This week, I dove into one of the most practical and privacy-focused ideas I’ve encountered so far: **selective disclosure**. Selective disclosure is more than just a technical feature—it’s the working expression of a broader idea known as **rational privacy**. It allows individuals to prove or reveal only what’s necessary in a given interaction, keeping everything else private. In an ecosystem where trust must be earned without a central authority, this ability to protect personal data while still meeting legal or operational requirements is critical. This post examines how selective disclosure operates, its benefits, and how platforms like Midnight are implementing it through privacy-first smart contracts. What Is Selective Disclosure?[​](https://docs.midnight.network/blog/tags/beginner#what-is-selective-disclosure "Direct link to What Is Selective Disclosure?") --------------------------------------------------------------------------------------------------------------------------------------------------------------- In the Web3 world, privacy doesn’t mean keeping everything secret—it means sharing only what’s necessary. [**Selective disclosure**](https://www.identity.com/what-is-selective-disclosure/) is a privacy-preserving technique that enables individuals to disclose specific information for a given interaction while keeping all other personal data confidential. This approach is a practical expression of a broader concept known as [**rational privacy**](https://midnight.network/blog/midnight-at-consensus-2025-building-the-future-of-rational-privacy) . Rational privacy is the idea that privacy shouldn’t be absolute or all-or-nothing—it should be contextual. It recognizes that in many real-world scenarios, users want to share _some_ data to gain access to services or meet legal obligations, but they shouldn't be forced to give up all privacy and security in the process. It’s about striking a balance between personal control, usability, and regulatory compliance. Selective disclosure is the technical implementation of rational privacy. It gives users and developers the cryptographic tools to protect sensitive information by default, while still enabling the right level of transparency when it’s required. This makes it especially relevant for public blockchain networks, where data is immutable and visible by design. A typical example of selective disclosure in action is the use of Verifiable Credentials (VCs). VCs allow users to prove attributes—like age, residency, or educational background—without revealing the entire credential. This aligns with the principles of data minimization and privacy by design, ensuring individuals remain in control of their information. This balance between usability and privacy is what makes selective disclosure so powerful—and so relevant for real-world blockchain applications. But beyond the technical implementation, it's worth asking: what are the practical benefits of using selective disclosure in the first place? Benefits of Selective Disclosure[​](https://docs.midnight.network/blog/tags/beginner#benefits-of-selective-disclosure "Direct link to Benefits of Selective Disclosure") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- When integrated thoughtfully, selective disclosure brings both technical and human-centric advantages to decentralized systems. It enables individuals and organizations to meet privacy expectations and compliance standards without sacrificing functionality. Implementing selective disclosure offers several advantages: * **Enhanced Privacy**: Selective disclosure enables users to share only the data necessary for a specific interaction, rather than disclosing full credentials or identity documents. This dramatically reduces the surface area for privacy breaches and surveillance. Whether you’re accessing a service, submitting a form, or interacting with a smart contract, your unnecessary personal data stays out of view. * **Data Minimization and Compliance**: This principle, core to privacy laws such as GDPR and HIPAA, requires that only the minimum amount of personal data necessary for a task is collected or processed. Selective disclosure naturally enforces this, making it easier for developers and organizations to design privacy-respecting systems by default. * **User Empowerment and Control**: In traditional systems, users often hand over their entire dataset for one small verification (e.g., uploading an entire ID just to prove their age). Selective disclosure flips that dynamic, giving users the power to control what they share, when, and with whom. This supports a more user-centric data model, where individuals become the custodians of their credentials. * **Reduced Risk of Data Misuse**: The less information that’s exposed, the lower the risk of that data being lost, stolen, or misused. Selective disclosure reduces the need for centralized data storage (e.g., big ID databases), limiting attack vectors for fraud and identity theft. Even if a transaction or credential presentation is intercepted, only the minimum disclosed attribute is visible, keeping the rest safe. * **Lower Liability and Operational Overhead for Businesses:** Many organizations would prefer not to collect or store sensitive user data due to the associated risks, regulatory requirements, and administrative burdens. Selective disclosure offers a path forward, enabling users to demonstrate eligibility or compliance without requiring businesses to retain or manage that data. This can reduce costs, simplify operations, and improve overall data security posture. While selective disclosure introduces a powerful model for user-centric privacy, it also comes with its own set of technical and usability challenges. Understanding these limitations is essential for builders and organizations aiming to adopt it responsibly. Potential Drawbacks[​](https://docs.midnight.network/blog/tags/beginner#potential-drawbacks "Direct link to Potential Drawbacks") ---------------------------------------------------------------------------------------------------------------------------------- While selective disclosure strengthens privacy and control, implementing it in real-world systems isn’t always straightforward. Here are some of the common challenges: * **Complexity in Implementation**: Selective disclosure relies on advanced cryptographic techniques, often zero-knowledge proofs or similar privacy-preserving protocols. These require careful design, precise execution, and deep security expertise. For developers new to Web3 or cryptography, like myself, the learning curve can be steep, and mistakes in implementation could compromise the intended privacy protections. * **Verification Difficulties**: When only a fragment of a credential or statement is revealed, verifying its authenticity can become more complicated. Systems must be designed to ensure that partial disclosures can be trusted without needing access to the complete original data. This often requires additional metadata or proofs to be included, which can increase the overall complexity of the system and potentially slow down the verification process. * **Interoperability Challenges**: Not all decentralized identity systems follow the same formats or standards. As a result, credentials issued by one platform may not be easily verifiable on another, especially when using advanced features like selective disclosure. Without widely adopted protocols and infrastructure, cross-platform compatibility can be limited, reducing the broader utility of selectively disclosed data. While these challenges are real, they’re not insurmountable. Much of the current work in privacy-preserving blockchain development, including projects like Midnight, focuses on making selective disclosure more practical, developer-friendly, and interoperable across various ecosystems. Use Cases of Selective Disclosure[​](https://docs.midnight.network/blog/tags/beginner#use-cases-of-selective-disclosure "Direct link to Use Cases of Selective Disclosure") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Selective disclosure has powerful, real-world applications wherever individuals or organizations need to prove something without oversharing. It’s beneficial in systems that handle sensitive data but also require compliance, trust, and transparency. Here are a few domains where it shines: * **Digital Identity Verification**: Imagine proving you're over 18 to access a service—without uploading your driver's license or disclosing your full birthdate and address. Selective disclosure lets you present only the relevant fact (e.g., “over 18”) as a verifiable statement, not the whole credential. * **Financial Transactions**: Financial platforms often need to confirm identity or transaction legitimacy (for KYC/AML compliance), but users shouldn’t have to share their entire financial history or wallet activity. Selective disclosure enables sharing only what’s legally necessary—no more, no less. * **Healthcare**: Patients may need to prove their vaccination status or medical eligibility without disclosing their entire health record. Selective disclosure lets them share only the required attribute (e.g., “vaccinated for X”) while keeping the rest private. * **Access Control**: Whether entering a venue or accessing online services, users may be granted or denied access based on attributes like membership, role, or credentials. Selective disclosure can enforce this access logic without revealing unnecessary identifying information. ### Selective Disclosure in the Midnight Network[​](https://docs.midnight.network/blog/tags/beginner#selective-disclosure-in-the-midnight-network "Direct link to Selective Disclosure in the Midnight Network") At Midnight, selective disclosure isn’t just a privacy feature—it’s a core design principle grounded in rational privacy. Rational privacy recognizes that while sensitive data must be protected, real-world applications also require controlled visibility for regulatory, legal, or operational reasons. Take financial transactions, for example. A decentralized financial platform built on Midnight may want to keep user balances, transfers, and transaction histories private. However, under anti-money laundering (AML) or know-your-customer (KYC) regulations, certain information may need to be revealed—but only to authorized parties, and only under specific legal conditions. This is where selective disclosure and zero-knowledge proofs come together. Using Midnight's Compact smart contract language, developers can build logic that proves a transaction is valid (e.g., below a certain threshold, or compliant with regulatory filters) without revealing the full transaction details. Meanwhile, if a regulatory audit is triggered, users or auditors could selectively disclose the required pieces of information—nothing more. In this way, Midnight enables builders to create applications that respect individual privacy _and_ comply with regulatory requirements. It’s a practical application of selective disclosure that mirrors how real-world trust operates: share only what’s needed, only when it’s needed, and only with the right people. Conclusion[​](https://docs.midnight.network/blog/tags/beginner#conclusion "Direct link to Conclusion") ------------------------------------------------------------------------------------------------------- Selective disclosure offers a flexible and powerful approach to privacy—one that meets people where they are, allowing them to control their information. It enables individuals to share just enough information to satisfy requirements, without exposing more than necessary. Whether you're verifying an identity, proving a credential, or complying with financial regulations, selective disclosure makes privacy practical and effective. At Midnight, this concept becomes more than theoretical. It’s embedded into the platform’s architecture through Compact smart contracts and zero-knowledge proofs, allowing builders to create systems that balance user protection with real-world needs. It’s rational privacy in action. If you're exploring how to build for privacy in Web3—or just learning how these systems work—I encourage you to check out the [Midnight docs](https://docs.midnight.network/) and [Academy](https://docs.midnight.network/academy) for more examples and technical insight, as well as a detailed list of further reading about selective disclosure below: * [What Is Selective Disclosure? – Identity.com](https://www.identity.com/what-is-selective-disclosure/) * [Selective Disclosure Guide – Dock.io](https://www.dock.io/post/selective-disclosure) * [A Refresher on Selective Disclosure and Anti-Fraud Rules – Frost Brown Todd](https://frostbrowntodd.com/a-refresher-on-selective-disclosure-and-anti-fraud-rules/) * [Midnight Academy Module 3 – Midnight Docs](https://docs.midnight.network/academy/module-3) * [Explicit Disclosure Reference – Midnight Docs](https://docs.midnight.network/develop/reference/compact/explicit_disclosure) * [Digital Assets Use Cases – Midnight Docs](https://docs.midnight.network/learn/introduction/use-cases/digital-assets) And, as always, if you’ve come across any great learning resources on privacy or identity in Web3, I’d love to see them—drop a comment or reply with your favorites! I'll be back next week with more insights as I continue unpacking the key building blocks that make decentralized systems work. As I continue my Web3 learning journey, I've mostly been working through [Cardano Academy](https://cardanofoundation.org/academy) and [Midnight Academy](https://docs.midnight.network/academy/) and documenting my findings in the [Midnight Dev Diaries](https://docs.midnight.network/blog) . But this week, I decided to branch out and explore a broader range of beginner-friendly resources across the ecosystem. That led me to two foundational concepts that kept coming up: Merkle Trees and Decentralized Autonomous Organizations (DAOs). These two topics sit at the heart of blockchain's promise—ensuring transparency, verifying data integrity, and enabling decentralized governance. I've broken down the key takeaways below, and if you're curious to go deeper, check out the list of helpful resources I've included at the end. Merkle Trees: Ensuring Data Integrity[​](https://docs.midnight.network/blog/tags/beginner#merkle-trees-ensuring-data-integrity "Direct link to Merkle Trees: Ensuring Data Integrity") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- A Merkle Tree, also known as a hash tree, is a data structure that enables efficient and secure verification of large data sets. At its core, it is a special kind of [binary tree](https://www.geeksforgeeks.org/binary-tree-data-structure/) —a structure many Web2 developers will recognize. In a binary tree, each node has at most two children. What makes Merkle Trees different is that instead of storing values directly, they store hashes. These hashes represent data blocks and provide a compact, tamper-evident summary of all the data in the tree. Merkle Trees are crucial in blockchain because they allow a large set of data (like thousands of transactions) to be verified efficiently and securely. Instead of needing to check every transaction, you only need a small subset of hashes (called a Merkle proof) to confirm that a transaction is part of a block. Here's a simplified breakdown of how a Merkle Tree is built: 1. Start with data blocks (like transactions in a block). 2. Each data block is hashed individually. These hashes become the leaf nodes. 3. Pairs of leaf hashes are then hashed together to form the next level of the tree. 4. This process continues, combining hashes pairwise and moving up the tree until you're left with a single root hash, often called the Merkle Root. In short, each leaf node contains the hash of a data block, each non-leaf node contains the hash of its child nodes, and the root hash represents the entire data set. Any change to any single data block will change its hash, which then cascades up the tree, altering the Merkle Root. This property is crucial for blockchain systems, where data immutability and integrity are paramount. In practice, Merkle Trees are used in: * Blockchain Transactions: Ensuring that transactions within a block are untampered. * Proof of Reserves: Cryptocurrency exchanges use Merkle Trees to prove they hold sufficient assets to cover user deposits without revealing individual account balances. DAOs: Redefining Organizational Governance[​](https://docs.midnight.network/blog/tags/beginner#daos-redefining-organizational-governance "Direct link to DAOs: Redefining Organizational Governance") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Decentralized Autonomous Organizations (DAOs) are organizations governed by smart contracts on a blockchain, eliminating the need for centralized leadership. They replace traditional top-down leadership with transparent, community-driven governance, all enforced through code—specifically, smart contracts. In a DAO, rules and operations are programmed upfront and stored on-chain. That means anyone can inspect how decisions are made, how funds are allocated, and how proposals are handled. Everything is transparent and auditable by default. Instead of a single CEO or board, decisions are made collectively by the community. Token holders can vote on proposals, and the outcome reflects the weight of their stake in the project. This collective decision-making process is what makes DAOs decentralized by design. And because those rules are enforced automatically by smart contracts, DAOs can operate autonomously without relying on manual intervention or centralized gatekeepers. Once a proposal passes, the smart contract executes the decision just as it was coded—no waiting for someone to push a button. However, DAOs also face challenges, including: * Security Risks: Vulnerabilities in smart contracts can be exploited. * Governance Issues: Low voter participation and token concentration can lead to centralization. DAOs have been utilized in various domains, such as: * Investment Funds: Pooling resources to invest in projects collectively. * Charitable Organizations: Deciding on fund allocation through member voting. * Protocol Governance: Managing and updating blockchain protocols. ### How DAO Voting Works (The Simple Version)[​](https://docs.midnight.network/blog/tags/beginner#how-dao-voting-works-the-simple-version "Direct link to How DAO Voting Works (The Simple Version)") Most DAOs use token-based voting to reach decisions: 1. Members hold a governance token, which gives them the right to vote. 2. A proposal is submitted (for example, "Fund a new development project"). 3. Token holders vote for or against the proposal. 4. If a certain threshold is reached (like a quorum or majority), the proposal is accepted and automatically executed by smart contracts. Beyond on-chain voting, many DAOs utilize off-chain governance platforms, such as Snapshot (widely used for token-weighted voting), Aragon Voice, Tally (commonly paired with Governor contracts), or Coordinape (used for decentralized grants and peer voting). These tools offer flexibility, reduce gas costs, and enable more experimental governance setups. The more tokens you hold, the more voting power you wield. This is similar to how shareholders vote in corporations, but the process is entirely on-chain, without intermediaries. Some DAOs use [quadratic voting](https://blog.colony.io/what-is-quadratic-voting-a-guide-to-dao-decision-making/) or other mechanisms to prevent whales (large holders) from dominating the process, but the core idea remains the same: the community drives the roadmap. Interplay Between Merkle Trees and DAOs[​](https://docs.midnight.network/blog/tags/beginner#interplay-between-merkle-trees-and-daos "Direct link to Interplay Between Merkle Trees and DAOs") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- While Merkle Trees and DAOs serve different purposes in the blockchain world—one focused on data integrity, the other on governance—they complement each other in powerful ways. Together, DAOs can remain secure, transparent, and efficient even as they scale. For example, instead of storing a complete list of eligible voters, a DAO can publish a Merkle Root representing that list. Individual voters then submit a short cryptographic proof (a Merkle proof) to confirm they're included. This keeps voting lightweight, private, and verifiable. The same method can be used to verify grant recipients or airdrop eligibility—ensuring integrity while saving space and gas costs. Merkle Trees also act as a bridge between off-chain and on-chain activity. Whether it's tracking voting done through Snapshot or verifying community identities, these proofs give DAOs a scalable way to maintain trust and transparency—even as they grow. Merkle Trees provide DAOs with the cryptographic foundation to scale governance without sacrificing transparency or efficiency. Whether it's verifying voter eligibility, proving fund distribution, or bridging off-chain data to on-chain actions, Merkle Trees help DAOs maintain trust and accountability as they grow. It's a powerful example of how foundational blockchain structures support and enhance decentralized decision-making. Conclusion[​](https://docs.midnight.network/blog/tags/beginner#conclusion "Direct link to Conclusion") ------------------------------------------------------------------------------------------------------- Together, Merkle Trees and DAOs demonstrate how blockchain technology strikes a balance between technical efficiency and community empowerment. Merkle Trees ensure that large sets of data—like transactions, votes, or recipient lists, can be verified quickly and securely. At the same time, DAOs introduce a way for communities to govern decentralized projects in a transparent and fair manner. When combined, they offer a practical solution for scaling trust without sacrificing decentralization. Whether you're verifying a vote, distributing funds, or proving membership, these tools help build the infrastructure that makes Web3 more than just a technological shift—it becomes a new model for how people coordinate, decide, and build together. Exploring beyond the Cardano and Midnight Academies for the first time in this journey provided me with a broader understanding of how these technologies are explained and applied across the space. If you're learning along with me or want to dig deeper into any of the topics covered, here are some of the materials I found especially helpful: * [Video: Merkle Trees Explained – Simply Explained](https://www.youtube.com/watch?v=3AcQyTs_Es4) * [Introduction to Merkle Trees – Geeks for Geeks](https://www.geeksforgeeks.org/introduction-to-merkle-tree/) * [What Are DAOs – LimeChain Blog](https://limechain.tech/blog/what-are-daos) * [Blockchain Transparency: Merkle Trees & Proof of Reserves – Moralis](https://academy.moralis.io/blog/blockchain-transparency-exploring-merkle-trees-and-proof-of-reserves) * [Everything You Need to Know About Merkle Trees – Bitpanda Academy](https://www.bitpanda.com/academy/en/lessons/everything-you-need-to-know-about-merkle-trees/) * [Introduction to DAOs – Chainalysis](https://www.chainalysis.com/blog/introduction-to-decentralized-autonomous-organizations-daos/) And if you’ve come across other great resources while learning Web3 basics, I’d love to hear them—drop a comment or reply with your favorites! You can also check out the [Midnight docs](https://docs.midnight.network/) for more technical deep dives and real-world use cases. Stay tuned for next week's exploration into other core components of the decentralized world. Explore how blockchain platforms have evolved from Bitcoin to Midnight and why tokens are essential to powering decentralized ecosystems. Explore how public key encryption and Practical Byzantine Fault Tolerance form the cryptographic and consensus backbone of secure, decentralized blockchain networks like Midnight. Two foundational cryptographic tools—hash functions and digital signatures—ensure data integrity, authenticity, and trust in decentralized Web3 systems like Midnight. Journey into Web3, unpack key blockchain concepts like decentralization, consensus, and how they shape platforms like Midnight. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/web3-intro-what-are-zkps#__docusaurus_skipToContent_fallback) Zero-knowledge proofs let you prove you know something without revealing what you know. Here's how this cryptographic breakthrough is revolutionizing privacy in Web3 applications. As I continue exploring the foundations of Web3, last week I focused on [Smart Contracts and Compact](https://docs.midnight.network/blog/web3-intro-smart-contracts-and-compact) —Midnight’s purpose-built smart contract language. Together, these two elements form the foundation for defining and enforcing logic in privacy-preserving applications. But logic alone isn’t enough in a decentralized system, especially when privacy is a priority. That’s where zero-knowledge proofs (ZKPs) come in. ZKPs enable the verification of a statement's truth without revealing the underlying justification. They let applications enforce smart contract rules while keeping sensitive data private—an essential capability for building systems that balance trust, utility, and confidentiality. In this post, I’ll break down what zero-knowledge proofs are, how they work, and how Midnight uses them to support privacy, compliance, and secure dApp development. What Are Zero-Knowledge Proofs?[​](https://docs.midnight.network/blog/web3-intro-what-are-zkps#what-are-zero-knowledge-proofs "Direct link to What Are Zero-Knowledge Proofs?") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- A zero-knowledge proof allows someone (the prover) to prove to another party (the verifier) that a specific statement is true, without revealing any additional information beyond the fact itself. Think of it like this: instead of handing over your complete ID to prove you're over 18, you could use a ZKP to prove you're above the age threshold, without disclosing your exact birthday, name, or ID number. This cryptographic technique is built on three foundational properties: * Completeness: If the statement is true, the prover can convince the verifier that it is true. * Soundness: If the statement is false, no dishonest prover can convince the verifier that it is true. * Zero-knowledge: The verifier learns nothing beyond the truth of the statement. Interactive vs. Non-Interactive Proofs[​](https://docs.midnight.network/blog/web3-intro-what-are-zkps#interactive-vs-non-interactive-proofs "Direct link to Interactive vs. Non-Interactive Proofs") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Early ZKPs required a back-and-forth exchange between prover and verifier—these are called interactive proofs. But in decentralized systems, interaction isn’t always feasible. That’s where non-interactive proofs come in. Non-interactive ZKPs let a prover generate a single proof that anyone can verify at any time, with no additional input. Protocols like zk-SNARKs and zk-STARKs make this possible, often using techniques like the [Fiat–Shamir heuristic](https://www.zkdocs.com/docs/zkdocs/protocol-primitives/fiat-shamir/) to simulate interaction using cryptographic hashes. This makes non-interactive ZKPs ideal for blockchains, where proofs need to be public, reusable, and verifiable by anyone. Types of Zero-Knowledge Proof Systems[​](https://docs.midnight.network/blog/web3-intro-what-are-zkps#types-of-zero-knowledge-proof-systems "Direct link to Types of Zero-Knowledge Proof Systems") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Different ZKP systems come with different tradeoffs in terms of size, speed, and trust requirements: * Groth16 (zk-SNARK): Very small proofs, fast verification, but requires a trusted setup per circuit. * Plonk (zk-SNARK): Slightly larger proofs, slower verification, but only needs a one-time universal setup. * Bulletproofs: No trusted setup, but proof size grows with complexity. * zk-STARKs: Transparent (no trusted setup), post-quantum secure, but with large proof sizes. Midnight utilizes a Plonk-derived system called [Halo 2](https://electriccoin.co/blog/explaining-halo-2/) , which supports recursive proofs and eliminates trusted setup in specific configurations, making it an ideal choice for privacy-preserving dApps that require both flexibility and scalability. How Do ZKPs Work?[​](https://docs.midnight.network/blog/web3-intro-what-are-zkps#how-do-zkps-work "Direct link to How Do ZKPs Work?") -------------------------------------------------------------------------------------------------------------------------------------- The idea behind zero-knowledge proofs might seem almost magical: one party (the prover) can prove to another (the verifier) that a statement is true, without revealing the _why_. But this is no sleight of hand—it’s grounded in rigorous cryptography and clever use of mathematical structures. At the heart of a ZKP is a “statement” that the prover wants to validate without revealing the underlying secret. That statement gets encoded into a circuit, which represents the logical rules or constraints that need to be satisfied. The prover then uses a special cryptographic key, known as the proving key, along with the secret input (called the witness), to generate a succinct proof. The verifier can then check this proof using a verifying key, confirming the rules were followed, without ever seeing the private input. This process makes ZKPs ideal for privacy-preserving smart contracts. In traditional systems, all data must be made public to verify that an action is legitimate. But with ZKPs, we can shift the trust model: rather than inspecting the data itself, the verifier checks a cryptographic proof that the data complies with the rules. Midnight takes this further by embedding ZKPs directly into the structure and execution of smart contracts. In Midnight, the verification key of a compiled Compact smart contract becomes the identity of that contract on-chain. When users interact with it, they’re not just calling a function—they’re submitting proof that they've complied with the logic defined by that contract, without revealing their inputs. Here's a high-level flow of how this works: 1. Setup: A circuit is created. A proving key and a verifying key are generated. 2. Proof Generation: The prover uses their secret (a witness) and the proving key to generate a cryptographic proof. 3. Verification: The verifier uses the verifying key and the proof to confirm the statement is true, without learning anything else. This process ensures that the smart contract logic is executed exactly as intended, without exposing the underlying data. Midnight’s Approach to ZKPs[​](https://docs.midnight.network/blog/web3-intro-what-are-zkps#midnights-approach-to-zkps "Direct link to Midnight’s Approach to ZKPs") -------------------------------------------------------------------------------------------------------------------------------------------------------------------- Midnight utilizes zero-knowledge proofs not only for theoretical privacy but also to enable real-world compliance and usability. Let’s walk through a few key elements of how ZKPs show up on the Midnight network: ### Confidential Transactions[​](https://docs.midnight.network/blog/web3-intro-what-are-zkps#confidential-transactions "Direct link to Confidential Transactions") Users can transfer assets on Midnight without revealing the sender, receiver, or amount. ZKPs are used to prove that a transaction is valid (i.e., no double spending, balances add up) without revealing specific details. This ensures both privacy and integrity. ### Selective Disclosure and Compliance[​](https://docs.midnight.network/blog/web3-intro-what-are-zkps#selective-disclosure-and-compliance "Direct link to Selective Disclosure and Compliance") Midnight supports “shielded” and “unshielded” data modes. You can keep your transaction data private by default, but also selectively disclose specific information (via a ZKP or viewing key) to a regulator, auditor, or another authorized party. This enables use cases like “prove I’m a citizen of Country X” or “prove I’m not sanctioned” without revealing your complete identity or wallet history. For more information about selective disclosure, read my overview [here](https://docs.midnight.network/blog/web3-intro-selective-disclosure) ! ### Decentralized Identity[​](https://docs.midnight.network/blog/web3-intro-what-are-zkps#decentralized-identity "Direct link to Decentralized Identity") ZKPs are key to proving facts about identity without revealing full credentials. Midnight supports workflows like proving KYC status (“A trusted provider has verified me”) using a proof, not a document. This allows users to interact with services that require identity checks—such as exchanges or marketplaces—without exposing sensitive personal data. ### Scalability via Recursive Proofs[​](https://docs.midnight.network/blog/web3-intro-what-are-zkps#scalability-via-recursive-proofs "Direct link to Scalability via Recursive Proofs") ZKPs also compress large computations into tiny proofs. That makes them ideal for batching transactions or reducing blockchain bloat. Midnight’s use of recursive proofs allows smart contracts and transactions to scale more efficiently than traditional blockchains. Real-World Use Cases on Midnight[​](https://docs.midnight.network/blog/web3-intro-what-are-zkps#real-world-use-cases-on-midnight "Direct link to Real-World Use Cases on Midnight") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Some examples of ZKP-powered applications on Midnight are: * Voting: Prove you’re eligible to vote and that your vote was counted, without revealing your identity or your vote. * Whistleblowing: Submit a report anonymously, proving only that you’re authorized (e.g., an employee). * Private Asset Swaps: Use Midnight’s Zswap to exchange tokens confidentially without revealing terms or participants. * KYC Onboarding: Prove compliance status to a platform or dApp without exposing documents. * Tokenized Real-World Assets: Keep ownership private while maintaining auditable transfer records. These use cases show how ZKPs on Midnight turn privacy into a practical feature, not just a theoretical promise. They lay the groundwork for a future where developers can build secure, compliant, and data-protecting applications by default. Conclusion[​](https://docs.midnight.network/blog/web3-intro-what-are-zkps#conclusion "Direct link to Conclusion") ------------------------------------------------------------------------------------------------------------------ Zero-knowledge proofs bring trust to trustless systems. They make it possible to prove something is true—like compliance with laws, asset ownership, or user eligibility—without revealing any sensitive details. Midnight makes ZKPs more than theoretical. They’re deeply integrated into its smart contract architecture, transaction model, and developer tooling. Paired with the Compact language (covered in last week’s post), they create a robust foundation for building privacy-first decentralized applications. If you’re interested in learning more, check out: * [Midnight Developer Academy Module 3](https://docs.midnight.network/academy/module-3) * [Zero-Knowledge Proofs](https://docs.midnight.network/learn/understanding-midnights-technology/zero-knowledge-proofs) in the [Midnight Docs](https://docs.midnight.network/) And if you’ve come across excellent ZKP explanations or tutorials, I’d love to hear about them—please share your favorites! See you next week as I continue to unpack the core ideas that power privacy in Web3! * [What Are Zero-Knowledge Proofs?](https://docs.midnight.network/blog/web3-intro-what-are-zkps#what-are-zero-knowledge-proofs) * [Interactive vs. Non-Interactive Proofs](https://docs.midnight.network/blog/web3-intro-what-are-zkps#interactive-vs-non-interactive-proofs) * [Types of Zero-Knowledge Proof Systems](https://docs.midnight.network/blog/web3-intro-what-are-zkps#types-of-zero-knowledge-proof-systems) * [How Do ZKPs Work?](https://docs.midnight.network/blog/web3-intro-what-are-zkps#how-do-zkps-work) * [Midnight’s Approach to ZKPs](https://docs.midnight.network/blog/web3-intro-what-are-zkps#midnights-approach-to-zkps) * [Confidential Transactions](https://docs.midnight.network/blog/web3-intro-what-are-zkps#confidential-transactions) * [Selective Disclosure and Compliance](https://docs.midnight.network/blog/web3-intro-what-are-zkps#selective-disclosure-and-compliance) * [Decentralized Identity](https://docs.midnight.network/blog/web3-intro-what-are-zkps#decentralized-identity) * [Scalability via Recursive Proofs](https://docs.midnight.network/blog/web3-intro-what-are-zkps#scalability-via-recursive-proofs) * [Real-World Use Cases on Midnight](https://docs.midnight.network/blog/web3-intro-what-are-zkps#real-world-use-cases-on-midnight) * [Conclusion](https://docs.midnight.network/blog/web3-intro-what-are-zkps#conclusion) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/blockchain#__docusaurus_skipToContent_fallback) After participating in three hackathons this year, I thought I had a good idea of what to expect. Then came the fourth. It began like the others: an idea, a challenge, a blank terminal screen. But this one took an unexpected turn, one I didn't see coming. I had recently left my software engineering role to explore zero-knowledge protocols, an area in which I didn’t have much experience. It was a risk, but one I felt I had to take. I chose to pursue this path not only because zero-knowledge cryptography is built on one of the most elegant branches of mathematics, but also I believe privacy on the blockchain or on the internet is fundamental and should never be an afterthought. One day, my mentor casually mentioned the [African Blockchain Championship](https://www.africanblockchamp.com/) and suggested I look into the Zero-Knowledge track. That small nudge became a turning point. That’s when I discovered [Midnight](https://midnight.network/) ! Meet Midnight: Privacy on the Blockchain ======================================== Midnight is a zero-knowledge proof-based privacy chain developed by Input Output, the parent company of Cardano. As a partner chain of Cardano, it aims to bring rational privacy through zero-knowledge technology to the broader ecosystem. They weren’t just building another blockchain—they were laying the foundation for private, decentralized computation. After diving into the documentation and setting up the tools, everything was finally in place. All that remained… was to begin. Only later did I realize: this wasn’t just the start of another hackathon—it was the beginning of something much bigger. Building on Midnight ==================== Hacking on Midnight was challenging, as building in a testnet environment requires constant learning and adaptation to major changes. Within just a few weeks, significant network updates rendered the existing examples incompatible with the latest SDK versions. As a result, an example had to be cloned and debugged line by line. The example repository was dense, filled with layers of files and directories, and figuring out where to start was a challenge in itself. Fortunately, Midnight’s smart contract language, [Compact](https://docs.midnight.network/develop/reference/compact/) , shares a syntax similar to TypeScript, which eased the learning curve. I pushed forward, determined to build something meaningful and make my mark—but in the end, my attempt fell short. With midterm exams approaching and the hackathon submission deadline close by, I had to make a difficult decision. I decided not to submit a project to the African Blockchain Championship hackathon. Still, a quiet sense of regret lingered. I couldn’t help but wonder: what if I had just pushed a _little_ harder? The Extended Deadline ===================== About a week later, I received an email from the ABC team announcing that the hackathon deadline had been extended. I was thrilled, and I promised myself I’d give it everything this time. It wasn’t long before I was back at it. A few weeks had passed since I’d last touched the project, and during that time, both the network and SDKs had been updated. I gathered my gear, updated my environment, and set out with renewed determination to finally build something solid. I wrote my contract and began debugging, but each change introduced a new layer of complexity. Every update required changes across multiple files. It was frustrating, exhausting, but strangely thrilling. I began thinking of ways to simplify the chaos, to make the process less painful, more intuitive. That’s when I started creating small scripts to streamline the workflow. Earlier that month, I had joined the [Midnight Discord](https://discord.com/invite/midnightnetwork) to ask questions. One week, I jumped on a Discord community call, and to my surprise, I learned about an ongoing Midnight tooling hackathon that was happening asynchronously. Right then, it clicked: _this_ was the hackathon I was meant to be part of from the start. From Personal Tool to Shared Project ==================================== What started as a personal tool suddenly took on a bigger purpose. The hackathon provided me with the opportunity to share my work with others and contribute to shaping the future of smart contract development on Midnight. I took a little detour from my original hackathon submission—promising myself I’d return to it—and began refining the tool, aiming not just to build something functional, but something genuinely useful for newcomers to the ecosystem. Scaffold Midnight & Create Midnight App[​](https://docs.midnight.network/blog/tags/blockchain#scaffold-midnight--create-midnight-app "Direct link to Scaffold Midnight & Create Midnight App") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- That’s how [**Scaffold Midnight**](http://github.com/kaleababayneh/scaffold-midnight) was born, a cloneable GitHub starter template. But I didn’t stop there. I realized it would be even more useful as an npm library, something developers could install with all dependencies bundled and start using right away. So, I polished the project and released the first version as [**create-midnight-app**](https://www.npmjs.com/package/create-midnight-app) . But I didn’t want to stop at solving just one problem. Every issue I fixed revealed another. Through multiple iterations, I kept refining the library. It’s now at version 2.1.7, and I’m actively working to make it compatible with the latest release of Compact. It’s far from perfect, and that’s what makes it exciting. Every day, I wake up with a new idea, a new feature to add, or a better way to improve the developer experience! ![Create Midnight App](https://ibin.co/8rMdmI75JRDl.png) At its core, **create-midnight-app** is a scaffolding npm library for Midnight that automates the entire setup process. Developers can focus solely on writing their Compact contracts; the tool takes care of the rest. It handles wallet creation, faucet requests, balance checks, API configuration, CLI updates, and even function and file change imports are updated automatically. It reduces initial application setup time from over half an hour to just a few minutes. I had several euphoric moments while working on this project, but one instance in particular, stands out. One feature I was eager to build was a way for developers to request testnet tokens without ever leaving their code editor. The simplest idea was to send a request from the terminal directly to the official [Midnight faucet](https://docs.midnight.network/blog/tags/%20https://midnight.network/test-faucet) . But there was a catch—the site is protected by [Cloudflare Turnstile](https://www.cloudflare.com/application-services/products/turnstile/) , which blocks automated requests to prevent spam and abuse. As a hacker, I started looking for a workaround. After some Googling and tips from friends, I tested several paid tools that claimed to bypass CAPTCHA protections. I spent an entire afternoon trying them, but none worked reliably. That’s when I remembered the genesis wallet, whose private key is publicly available. So, I implemented a workaround: instead of calling the faucet, I simulated a faucet transaction by transferring tokens directly from the genesis wallet to the user’s wallet. It’s not a long-term solution, and I know it won’t scale—but for now, it works and helps streamline the developer experience. Submission and Recognition ========================== I finally submitted my project, and the judges’ reactions were incredibly [encouraging](https://youtu.be/xrCEBIBqS-Y?t=4453) —it gave me a renewed sense of inspiration. With that momentum, I turned my focus back to my original hackathon: the African Blockchain Championship. For this challenge, I built an anonymous, censorship-resistant voting platform. In many African countries—across 34 nations—roughly 30–40% of citizens no longer view voting as a fair or trustworthy process (Afrobarometer, 2023). That’s why anonymous voting isn’t just a feature—it’s a necessity. My project, [**Privote**](https://github.com/kaleababayneh/zkvote-midnight) , aims to address this critical issue by leveraging zero-knowledge technology to protect voter identity and integrity. As the submission deadline approached, I ran into a major hurdle: integrating the wallet into the frontend. I reached out to one of the Developer Relations Engineers, who kindly shared some example code. Unfortunately, I couldn’t get it working in time. With the clock ticking, I had to improvise. I quickly built a custom Chrome extension that enabled wallet interaction—running through the terminal on the backend—just in time for submission. While the current version still has some privacy limitations, the smart contract compiles successfully, and users can interact with it on the Midnight testnet—offering a real glimpse of what decentralized, anonymous voting could look like in practice. ![Private Hackathon](https://ibin.co/8rMho4816dhp.png) The Midnight Community ====================== Even though there aren’t many resources available yet, the Midnight community more than makes up for it. Almost every question asked on Discord gets a response. It’s a space where people genuinely support each other—even during hackathons, when we’re technically competing and have little incentive to help other teams. In fact, during the hackathon, I often found myself answering questions in the Telegram group. I even hosted a workshop at the ABC hackathon on how to use **Create Midnight App**, helping others get started quickly and navigate the ecosystem more easily. I also want to take a moment to thank the Midnight team for the recognition they gave me—it truly meant a lot. Beyond placing first in the CLI track, the support and appreciation I received from the community were genuinely heartwarming. I even had the chance to join a community call—not just as a participant this time, but as a [speaker](https://x.com/MidnightNtwrk/status/1942969613496758398) —to share my journey and the lessons I’d learned along the way. Why Now is the Time to Build on Midnight ======================================== And for you—my readers—this is honestly the best time to get involved in the Midnight ecosystem. There’s _almost always_ a hackathon happening (seriously, it's kind of wild!). Right now, they’re even running a [mini DApp hackathon](https://midnight.network/hackathon/midnight-mini-dapp-hackathon) . It’s an excellent opportunity to learn, build, and get your project noticed. ![Midnight Dapp Hackathon](https://ibin.co/8rMcCFquPRqS.png) As for me, I’m currently building something new for the hackathon. While I enjoy working on projects, I’ve found even more fulfillment in developing infrastructure tools. I have a long-term goal of building a web-based Midnight playground where anyone can start writing Compact code and begin interacting with the Midnight testnet without needing to install anything. I hope to continue collaborating with the Midnight team and growing my skills—especially in zero-knowledge protocols—as I continue this journey. This past week, I started the SheFi course—a program designed to help women dive deeper into Web3 and decentralized finance. One of the first topics it covered was Ethereum: what it is, why it matters, and how it fits into the broader decentralized ecosystem. To build on what I learned there, I read two excellent overviews: [“A Beginner’s Guide to Ethereum” from Coinbase](https://medium.com/the-coinbase-blog/a-beginners-guide-to-ethereum-46dd486ceecf) and [“Getting Up to Speed on Ethereum” by Matt](https://medium.com/@oneofthemanymatts/getting-up-to-speed-on-ethereum-63ed28821bbe) . Both helped frame Ethereum not just as a cryptocurrency, but as a foundational platform for Web3 applications. Here’s what stood out and why Ethereum remains vital in a rapidly evolving cryptocurrency ecosystem. Ethereum in a Nutshell[​](https://docs.midnight.network/blog/tags/blockchain#ethereum-in-a-nutshell "Direct link to Ethereum in a Nutshell") --------------------------------------------------------------------------------------------------------------------------------------------- Ethereum is a decentralized computing platform. Think of it like a global computer that anyone can access, but no single person or organization controls it. This is possible because Ethereum is powered by a blockchain—a network of nodes around the world that maintain and validate a shared record of activity. What makes Ethereum special is that it doesn’t just store transactions; it can also run applications. These apps are powered by smart contracts, which are programs deployed to the blockchain that execute exactly as written. The Ethereum network is designed to be open, programmable, and permissionless. That means anyone can build on it, and no one needs approval to use it. This structure has enabled Ethereum to become the foundation for a wide range of decentralized applications (dApps), including financial tools such as lending protocols and stablecoins, as well as NFT marketplaces and decentralized identity systems. Why Ethereum Matters[​](https://docs.midnight.network/blog/tags/blockchain#why-ethereum-matters "Direct link to Why Ethereum Matters") --------------------------------------------------------------------------------------------------------------------------------------- Ethereum matters because it transforms the internet from a read-write platform into a read-write-execute environment. That is, it enables not just the sharing of information, but also the execution of logic—without relying on centralized intermediaries. This shift opens the door to creating systems that are more transparent, resilient, and accessible. One of Ethereum’s most significant breakthroughs is that it allows developers to write and deploy their own logic onto the network through smart contracts. These contracts can define rules, manage value, and interact with other contracts—all while being trustless and tamper-proof. Once deployed, smart contracts can’t be changed or censored, which means users can interact with them without worrying about backend changes or manipulation. Ether: The Fuel of the Ethereum Network[​](https://docs.midnight.network/blog/tags/blockchain#ether-the-fuel-of-the-ethereum-network "Direct link to Ether: The Fuel of the Ethereum Network") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Ether (ETH) is the native currency of Ethereum. While many people think of ETH primarily as a cryptocurrency—something you can buy, sell, or hold—its most important role as the fuel for computation. Every operation on the Ethereum network costs gas, and ETH is what you use to pay for it. This is a crucial aspect of Ethereum’s security and incentive structure, ensuring that resources are utilized responsibly and the network remains resilient to spam. When you send a transaction, deploy a smart contract, or interact with a dApp, you’re paying for the network to process that request. The more complex the operation, the more gas it consumes. Gas prices fluctuate based on network demand, and users can choose how much to pay to incentivize faster confirmation. This dynamic creates a market for block space, encouraging developers to write more efficient code. The Power of Smart Contracts[​](https://docs.midnight.network/blog/tags/blockchain#the-power-of-smart-contracts "Direct link to The Power of Smart Contracts") --------------------------------------------------------------------------------------------------------------------------------------------------------------- Smart contracts are at the heart of what makes Ethereum powerful. These are self-executing programs that live on the blockchain and enforce rules automatically. You don’t need to trust a company or a person; you can trust the code. Smart contracts enable a wide range of use cases, including lending platforms like Aave, decentralized exchanges like Uniswap, and even games like Axie Infinity. Once a smart contract is deployed, it’s public and verifiable. Anyone can inspect the code, interact with it, and build on top of it. This openness fosters a culture of composability—developers can plug into existing contracts, remix them, or build entirely new systems that work together. This is why Ethereum is often referred to as a “LEGO set for financial and digital tools.” Ethereum Today and Tomorrow[​](https://docs.midnight.network/blog/tags/blockchain#ethereum-today-and-tomorrow "Direct link to Ethereum Today and Tomorrow") ------------------------------------------------------------------------------------------------------------------------------------------------------------ Ethereum has come a long way since its launch in 2015. It’s no longer just a niche experiment; it’s the most widely used smart contract platform in the world. However, with that growth has come challenges. Network congestion and high gas fees have made it difficult for some users to interact with dApps affordably. To address these issues, Ethereum has undergone significant upgrades, most notably the transition from proof-of-work to proof-of-stake, known as “The Merge.” Proof-of-stake is a consensus mechanism that allows Ethereum to secure the network using validators who lock up ETH rather than relying on energy-intensive mining. This shift has dramatically reduced Ethereum’s energy usage and paved the way for future scaling efforts, such as sharding and rollups. Rollups are a technique for batching many transactions into a single proof, which can then be submitted to the Ethereum mainnet. This helps scale the network without sacrificing security or decentralization. The Ethereum ecosystem is also growing through layer 2 networks, which are built on top of Ethereum and handle transactions off-chain while still relying on Ethereum for settlement and security. Projects like Arbitrum, Optimism, and zkSync are working to make Ethereum faster and cheaper for everyday users. How Ethereum Connects with Midnight[​](https://docs.midnight.network/blog/tags/blockchain#how-ethereum-connects-with-midnight "Direct link to How Ethereum Connects with Midnight") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ While Ethereum serves as the foundational smart contract platform for much of Web3, Midnight is designed to complement and extend its capabilities—especially in terms of privacy. In practical terms, this means that developers who are comfortable with the Ethereum ecosystem —its wallets, development environments, and smart contract models—can interact with Midnight using similar patterns. For example, Midnight supports a Solidity-like programming approach through its Compact smart contract language, which compiles to verifiable circuits that enforce privacy constraints. This allows developers to build private versions of applications, such as voting systems, token transfers, and identity verification, that would typically be public on the Ethereum blockchain. Ethereum offers programmability and decentralization, but by default, all on-chain transactions are transparent. Midnight fills in the missing privacy layer. You could imagine a workflow where public assets and smart contracts live on Ethereum, but sensitive data or confidential logic is handled by Midnight—bridging the two networks for richer, privacy-preserving applications. Together, Ethereum and Midnight can be seen as complementary parts of a broader decentralized stack: Ethereum provides openness and composability, while Midnight adds selective disclosure and private computation, enabling developers to build secure and compliant applications in ways that Ethereum alone can’t. Conclusion[​](https://docs.midnight.network/blog/tags/blockchain#conclusion "Direct link to Conclusion") --------------------------------------------------------------------------------------------------------- Ethereum isn’t just a cryptocurrency—it’s a platform for building a new kind of internet. By combining programmable logic with decentralized infrastructure, Ethereum enables applications that are open, transparent, and user-owned. It’s the foundation of decentralized finance (DeFi), non-fungible tokens (NFTs), and numerous experiments in online interaction. For me, starting with SheFi and reading through these resources helped ground my understanding of what Ethereum is and why it matters. It’s not just about buying coins—it’s about reshaping how we think about trust, ownership, and value in a digital world. I’ll be back next week as I continue diving into the core building blocks of Web3. If you’re just starting out too, I highly recommend giving [Coinbase’s primer](https://medium.com/the-coinbase-blog/a-beginners-guide-to-ethereum-46dd486ceecf) and [Matt’s breakdown](https://medium.com/@oneofthemanymatts/getting-up-to-speed-on-ethereum-63ed28821bbe) a read. Zero-knowledge proofs let you prove you know something without revealing what you know. Here's how this cryptographic breakthrough is revolutionizing privacy in Web3 applications. As I continue my journey through the world of Web3, I’ve been digging into the building blocks that make privacy-first platforms like Midnight possible (you can catch up on previous posts in the Midnight Dev Diaries!). This week, I focused on two foundational pieces that go hand in hand: smart contracts on Midnight and the Compact language that powers them. Smart contracts aren’t new to blockchain, but Midnight’s approach is unique. Instead of executing code directly on-chain, Midnight uses smart contracts to define rules that are enforced off-chain through zero-knowledge proofs. At the center of this system is [Compact](https://docs.midnight.network/develop/reference/compact/lang-ref) —a purpose-built language designed to make writing these privacy-preserving contracts both secure and practical. To better understand how this works in practice, I also worked through [Module 2 of the Midnight Developer Academy](https://docs.midnight.network/academy/module-2) , which covers key concepts such as contract structure, circuit types, and the relationship between the contract and the external logic that executes it. In this post, I’ll break down what makes smart contracts on Midnight different, how Compact is structured, and how the two work together to enable provable logic without exposing sensitive data. What Is a Smart Contract on Midnight?[​](https://docs.midnight.network/blog/tags/blockchain#what-is-a-smart-contract-on-midnight "Direct link to What Is a Smart Contract on Midnight?") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- At a high level, a smart contract is an autonomous program stored on the blockchain. It defines rules for interaction, checks that those rules are met, and records results—all without needing a trusted third party to enforce them. But Midnight isn’t just any blockchain. It’s a privacy-first platform built with compliance in mind, and that means its smart contracts need to do more than just run logic. They need to protect private data, enable selective disclosure, and uphold security and trust even in adversarial environments. That’s where Compact comes in—a custom domain-specific language explicitly designed to write smart contracts on Midnight. Instead of executing logic directly on-chain like many traditional smart contracts, Compact contracts define the logic to be proven, not the execution environment itself. The contract encodes the rules that must be followed, which are then used as the foundation for a zero-knowledge proof. The actual execution—like processing a transaction, generating a credential, or submitting a vote—happens externally, often in a DApp, backend service, or API. That external system runs the necessary logic and **proves** it followed the contract’s rules by generating a cryptographic proof. The blockchain doesn’t need to know the details—it just verifies that the proof is valid. This separation is what makes Midnight’s model both scalable and privacy-preserving. In other words: the contract sets the rules, your app runs the logic, and the blockchain verifies the outcome, without ever seeing the sensitive inputs. What Is Compact?[​](https://docs.midnight.network/blog/tags/blockchain#what-is-compact "Direct link to What Is Compact?") -------------------------------------------------------------------------------------------------------------------------- Compact is a statically typed, privacy-focused smart contract language tailored to the unique goals of the Midnight network. If you've worked with JavaScript or TypeScript before, you'll find Compact refreshingly approachable. It’s a domain-specific language (DSL) designed to define zero-knowledge proof logic using statically typed circuits that map to off-chain computations. But don’t let the simple syntax fool you—Compact is engineered for privacy-preserving computation using zero-knowledge proofs (ZKPs) under the hood. (For a more technical deep dive into compact, check out part 1 of Kevin Millikin's Compact Deep Dive [here](https://docs.midnight.network/blog/compact) !) A Compact contract is made up of three core components: * **Ledger**: The public, on-chain state of the contract. * **Circuits**: Off-chain logic that can manipulate data, produce proofs, and interact with the ledger. * **Witnesses**: Privately held data, only known to the entity executing the contract. Compact also supports [explicit disclosure](https://docs.midnight.network/develop/reference/compact/explicit_disclosure#conclusion) , meaning developers can define exactly what data gets revealed (and to whom). This provides fine-grained control over what is visible on-chain and what remains private, essential for use cases such as private asset transfers, age-gated access, or confidential voting. Circuits and Privacy[​](https://docs.midnight.network/blog/tags/blockchain#circuits-and-privacy "Direct link to Circuits and Privacy") --------------------------------------------------------------------------------------------------------------------------------------- One of the most essential takeaways from Module 2 of the Midnight Developer Academy is how circuits work. In Compact, circuits are the functions that users or systems can call to trigger actions. But unlike Web2 APIs or EVM contract functions, these circuits don’t execute logic directly on the blockchain. Instead, they run off-chain and generate zero-knowledge proofs that the logic was followed. In practice, that means: * The contract logic is public. * The data used during execution is private. * The outcome of the logic (e.g., “the rules were followed”) is publicly verifiable using a proof. This is where Midnight’s model shows its strength—users can prove they followed the rules without revealing the exact data that triggered the result. Think “I proved I’m eligible to vote” without revealing who I am or what I voted for. From Theory to Practice[​](https://docs.midnight.network/blog/tags/blockchain#from-theory-to-practice "Direct link to From Theory to Practice") ------------------------------------------------------------------------------------------------------------------------------------------------ In traditional smart contract platforms, everything you do is public by default: data, logic, inputs, outputs. That’s useful for transparency, but it's not always practical, especially for sensitive use cases like health data, financial records, or identity verification. Midnight flips that default. Privacy is built in, and developers opt into disclosure only when it’s needed. Some examples of what you might build with Compact on Midnight: * A voting system where only the outcome is public. * An access control system that verifies user attributes without revealing identities. * A token transfer app that hides amounts or senders while still allowing public verification. Conclusion[​](https://docs.midnight.network/blog/tags/blockchain#conclusion "Direct link to Conclusion") --------------------------------------------------------------------------------------------------------- Smart contracts are the foundation of decentralized applications—but at Midnight, they’re built for a privacy-first future. Instead of executing every piece of logic on-chain, Midnight separates the contract's logic from its execution. With Compact, developers define the rules of a zero-knowledge proof system, enabling applications to prove facts without exposing sensitive data. It’s a practical shift toward secure, scalable, and user-protective Web3 design. At Midnight, this isn’t just a theoretical improvement—it’s core to how the platform operates. Compact smart contracts let developers write verifiable, auditable logic while keeping inputs and execution off-chain. Combined with ZKPs and shielded transactions, they create an infrastructure that supports real-world use cases without compromising on privacy or decentralization. If you're learning how to build smart contracts in Web3—or just curious how these pieces fit together—I highly recommend diving into [Module 2 of the Midnight Developer Academy](https://docs.midnight.network/academy/module-2) and reviewing the [Compact Language Reference](https://docs.midnight.network/develop/reference/compact/lang-ref) . These resources break down the concepts step by step and show how Midnight’s architecture turns advanced cryptography into practical developer tools. I’ll be back next week with more insights as I continue to unpack the pieces that make privacy-first systems work in the decentralized world. As I delve deeper into the world of Web3, I've been working my way through foundational concepts to have a better understanding of the industry (check out my last five posts on the [Midnight Dev Diaries](https://docs.midnight.network/blog) !). This week, I dove into one of the most practical and privacy-focused ideas I’ve encountered so far: **selective disclosure**. Selective disclosure is more than just a technical feature—it’s the working expression of a broader idea known as **rational privacy**. It allows individuals to prove or reveal only what’s necessary in a given interaction, keeping everything else private. In an ecosystem where trust must be earned without a central authority, this ability to protect personal data while still meeting legal or operational requirements is critical. This post examines how selective disclosure operates, its benefits, and how platforms like Midnight are implementing it through privacy-first smart contracts. What Is Selective Disclosure?[​](https://docs.midnight.network/blog/tags/blockchain#what-is-selective-disclosure "Direct link to What Is Selective Disclosure?") ----------------------------------------------------------------------------------------------------------------------------------------------------------------- In the Web3 world, privacy doesn’t mean keeping everything secret—it means sharing only what’s necessary. [**Selective disclosure**](https://www.identity.com/what-is-selective-disclosure/) is a privacy-preserving technique that enables individuals to disclose specific information for a given interaction while keeping all other personal data confidential. This approach is a practical expression of a broader concept known as [**rational privacy**](https://midnight.network/blog/midnight-at-consensus-2025-building-the-future-of-rational-privacy) . Rational privacy is the idea that privacy shouldn’t be absolute or all-or-nothing—it should be contextual. It recognizes that in many real-world scenarios, users want to share _some_ data to gain access to services or meet legal obligations, but they shouldn't be forced to give up all privacy and security in the process. It’s about striking a balance between personal control, usability, and regulatory compliance. Selective disclosure is the technical implementation of rational privacy. It gives users and developers the cryptographic tools to protect sensitive information by default, while still enabling the right level of transparency when it’s required. This makes it especially relevant for public blockchain networks, where data is immutable and visible by design. A typical example of selective disclosure in action is the use of Verifiable Credentials (VCs). VCs allow users to prove attributes—like age, residency, or educational background—without revealing the entire credential. This aligns with the principles of data minimization and privacy by design, ensuring individuals remain in control of their information. This balance between usability and privacy is what makes selective disclosure so powerful—and so relevant for real-world blockchain applications. But beyond the technical implementation, it's worth asking: what are the practical benefits of using selective disclosure in the first place? Benefits of Selective Disclosure[​](https://docs.midnight.network/blog/tags/blockchain#benefits-of-selective-disclosure "Direct link to Benefits of Selective Disclosure") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- When integrated thoughtfully, selective disclosure brings both technical and human-centric advantages to decentralized systems. It enables individuals and organizations to meet privacy expectations and compliance standards without sacrificing functionality. Implementing selective disclosure offers several advantages: * **Enhanced Privacy**: Selective disclosure enables users to share only the data necessary for a specific interaction, rather than disclosing full credentials or identity documents. This dramatically reduces the surface area for privacy breaches and surveillance. Whether you’re accessing a service, submitting a form, or interacting with a smart contract, your unnecessary personal data stays out of view. * **Data Minimization and Compliance**: This principle, core to privacy laws such as GDPR and HIPAA, requires that only the minimum amount of personal data necessary for a task is collected or processed. Selective disclosure naturally enforces this, making it easier for developers and organizations to design privacy-respecting systems by default. * **User Empowerment and Control**: In traditional systems, users often hand over their entire dataset for one small verification (e.g., uploading an entire ID just to prove their age). Selective disclosure flips that dynamic, giving users the power to control what they share, when, and with whom. This supports a more user-centric data model, where individuals become the custodians of their credentials. * **Reduced Risk of Data Misuse**: The less information that’s exposed, the lower the risk of that data being lost, stolen, or misused. Selective disclosure reduces the need for centralized data storage (e.g., big ID databases), limiting attack vectors for fraud and identity theft. Even if a transaction or credential presentation is intercepted, only the minimum disclosed attribute is visible, keeping the rest safe. * **Lower Liability and Operational Overhead for Businesses:** Many organizations would prefer not to collect or store sensitive user data due to the associated risks, regulatory requirements, and administrative burdens. Selective disclosure offers a path forward, enabling users to demonstrate eligibility or compliance without requiring businesses to retain or manage that data. This can reduce costs, simplify operations, and improve overall data security posture. While selective disclosure introduces a powerful model for user-centric privacy, it also comes with its own set of technical and usability challenges. Understanding these limitations is essential for builders and organizations aiming to adopt it responsibly. Potential Drawbacks[​](https://docs.midnight.network/blog/tags/blockchain#potential-drawbacks "Direct link to Potential Drawbacks") ------------------------------------------------------------------------------------------------------------------------------------ While selective disclosure strengthens privacy and control, implementing it in real-world systems isn’t always straightforward. Here are some of the common challenges: * **Complexity in Implementation**: Selective disclosure relies on advanced cryptographic techniques, often zero-knowledge proofs or similar privacy-preserving protocols. These require careful design, precise execution, and deep security expertise. For developers new to Web3 or cryptography, like myself, the learning curve can be steep, and mistakes in implementation could compromise the intended privacy protections. * **Verification Difficulties**: When only a fragment of a credential or statement is revealed, verifying its authenticity can become more complicated. Systems must be designed to ensure that partial disclosures can be trusted without needing access to the complete original data. This often requires additional metadata or proofs to be included, which can increase the overall complexity of the system and potentially slow down the verification process. * **Interoperability Challenges**: Not all decentralized identity systems follow the same formats or standards. As a result, credentials issued by one platform may not be easily verifiable on another, especially when using advanced features like selective disclosure. Without widely adopted protocols and infrastructure, cross-platform compatibility can be limited, reducing the broader utility of selectively disclosed data. While these challenges are real, they’re not insurmountable. Much of the current work in privacy-preserving blockchain development, including projects like Midnight, focuses on making selective disclosure more practical, developer-friendly, and interoperable across various ecosystems. Use Cases of Selective Disclosure[​](https://docs.midnight.network/blog/tags/blockchain#use-cases-of-selective-disclosure "Direct link to Use Cases of Selective Disclosure") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Selective disclosure has powerful, real-world applications wherever individuals or organizations need to prove something without oversharing. It’s beneficial in systems that handle sensitive data but also require compliance, trust, and transparency. Here are a few domains where it shines: * **Digital Identity Verification**: Imagine proving you're over 18 to access a service—without uploading your driver's license or disclosing your full birthdate and address. Selective disclosure lets you present only the relevant fact (e.g., “over 18”) as a verifiable statement, not the whole credential. * **Financial Transactions**: Financial platforms often need to confirm identity or transaction legitimacy (for KYC/AML compliance), but users shouldn’t have to share their entire financial history or wallet activity. Selective disclosure enables sharing only what’s legally necessary—no more, no less. * **Healthcare**: Patients may need to prove their vaccination status or medical eligibility without disclosing their entire health record. Selective disclosure lets them share only the required attribute (e.g., “vaccinated for X”) while keeping the rest private. * **Access Control**: Whether entering a venue or accessing online services, users may be granted or denied access based on attributes like membership, role, or credentials. Selective disclosure can enforce this access logic without revealing unnecessary identifying information. ### Selective Disclosure in the Midnight Network[​](https://docs.midnight.network/blog/tags/blockchain#selective-disclosure-in-the-midnight-network "Direct link to Selective Disclosure in the Midnight Network") At Midnight, selective disclosure isn’t just a privacy feature—it’s a core design principle grounded in rational privacy. Rational privacy recognizes that while sensitive data must be protected, real-world applications also require controlled visibility for regulatory, legal, or operational reasons. Take financial transactions, for example. A decentralized financial platform built on Midnight may want to keep user balances, transfers, and transaction histories private. However, under anti-money laundering (AML) or know-your-customer (KYC) regulations, certain information may need to be revealed—but only to authorized parties, and only under specific legal conditions. This is where selective disclosure and zero-knowledge proofs come together. Using Midnight's Compact smart contract language, developers can build logic that proves a transaction is valid (e.g., below a certain threshold, or compliant with regulatory filters) without revealing the full transaction details. Meanwhile, if a regulatory audit is triggered, users or auditors could selectively disclose the required pieces of information—nothing more. In this way, Midnight enables builders to create applications that respect individual privacy _and_ comply with regulatory requirements. It’s a practical application of selective disclosure that mirrors how real-world trust operates: share only what’s needed, only when it’s needed, and only with the right people. Conclusion[​](https://docs.midnight.network/blog/tags/blockchain#conclusion "Direct link to Conclusion") --------------------------------------------------------------------------------------------------------- Selective disclosure offers a flexible and powerful approach to privacy—one that meets people where they are, allowing them to control their information. It enables individuals to share just enough information to satisfy requirements, without exposing more than necessary. Whether you're verifying an identity, proving a credential, or complying with financial regulations, selective disclosure makes privacy practical and effective. At Midnight, this concept becomes more than theoretical. It’s embedded into the platform’s architecture through Compact smart contracts and zero-knowledge proofs, allowing builders to create systems that balance user protection with real-world needs. It’s rational privacy in action. If you're exploring how to build for privacy in Web3—or just learning how these systems work—I encourage you to check out the [Midnight docs](https://docs.midnight.network/) and [Academy](https://docs.midnight.network/academy) for more examples and technical insight, as well as a detailed list of further reading about selective disclosure below: * [What Is Selective Disclosure? – Identity.com](https://www.identity.com/what-is-selective-disclosure/) * [Selective Disclosure Guide – Dock.io](https://www.dock.io/post/selective-disclosure) * [A Refresher on Selective Disclosure and Anti-Fraud Rules – Frost Brown Todd](https://frostbrowntodd.com/a-refresher-on-selective-disclosure-and-anti-fraud-rules/) * [Midnight Academy Module 3 – Midnight Docs](https://docs.midnight.network/academy/module-3) * [Explicit Disclosure Reference – Midnight Docs](https://docs.midnight.network/develop/reference/compact/explicit_disclosure) * [Digital Assets Use Cases – Midnight Docs](https://docs.midnight.network/learn/introduction/use-cases/digital-assets) And, as always, if you’ve come across any great learning resources on privacy or identity in Web3, I’d love to see them—drop a comment or reply with your favorites! I'll be back next week with more insights as I continue unpacking the key building blocks that make decentralized systems work. As I continue my Web3 learning journey, I've mostly been working through [Cardano Academy](https://cardanofoundation.org/academy) and [Midnight Academy](https://docs.midnight.network/academy/) and documenting my findings in the [Midnight Dev Diaries](https://docs.midnight.network/blog) . But this week, I decided to branch out and explore a broader range of beginner-friendly resources across the ecosystem. That led me to two foundational concepts that kept coming up: Merkle Trees and Decentralized Autonomous Organizations (DAOs). These two topics sit at the heart of blockchain's promise—ensuring transparency, verifying data integrity, and enabling decentralized governance. I've broken down the key takeaways below, and if you're curious to go deeper, check out the list of helpful resources I've included at the end. Merkle Trees: Ensuring Data Integrity[​](https://docs.midnight.network/blog/tags/blockchain#merkle-trees-ensuring-data-integrity "Direct link to Merkle Trees: Ensuring Data Integrity") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- A Merkle Tree, also known as a hash tree, is a data structure that enables efficient and secure verification of large data sets. At its core, it is a special kind of [binary tree](https://www.geeksforgeeks.org/binary-tree-data-structure/) —a structure many Web2 developers will recognize. In a binary tree, each node has at most two children. What makes Merkle Trees different is that instead of storing values directly, they store hashes. These hashes represent data blocks and provide a compact, tamper-evident summary of all the data in the tree. Merkle Trees are crucial in blockchain because they allow a large set of data (like thousands of transactions) to be verified efficiently and securely. Instead of needing to check every transaction, you only need a small subset of hashes (called a Merkle proof) to confirm that a transaction is part of a block. Here's a simplified breakdown of how a Merkle Tree is built: 1. Start with data blocks (like transactions in a block). 2. Each data block is hashed individually. These hashes become the leaf nodes. 3. Pairs of leaf hashes are then hashed together to form the next level of the tree. 4. This process continues, combining hashes pairwise and moving up the tree until you're left with a single root hash, often called the Merkle Root. In short, each leaf node contains the hash of a data block, each non-leaf node contains the hash of its child nodes, and the root hash represents the entire data set. Any change to any single data block will change its hash, which then cascades up the tree, altering the Merkle Root. This property is crucial for blockchain systems, where data immutability and integrity are paramount. In practice, Merkle Trees are used in: * Blockchain Transactions: Ensuring that transactions within a block are untampered. * Proof of Reserves: Cryptocurrency exchanges use Merkle Trees to prove they hold sufficient assets to cover user deposits without revealing individual account balances. DAOs: Redefining Organizational Governance[​](https://docs.midnight.network/blog/tags/blockchain#daos-redefining-organizational-governance "Direct link to DAOs: Redefining Organizational Governance") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Decentralized Autonomous Organizations (DAOs) are organizations governed by smart contracts on a blockchain, eliminating the need for centralized leadership. They replace traditional top-down leadership with transparent, community-driven governance, all enforced through code—specifically, smart contracts. In a DAO, rules and operations are programmed upfront and stored on-chain. That means anyone can inspect how decisions are made, how funds are allocated, and how proposals are handled. Everything is transparent and auditable by default. Instead of a single CEO or board, decisions are made collectively by the community. Token holders can vote on proposals, and the outcome reflects the weight of their stake in the project. This collective decision-making process is what makes DAOs decentralized by design. And because those rules are enforced automatically by smart contracts, DAOs can operate autonomously without relying on manual intervention or centralized gatekeepers. Once a proposal passes, the smart contract executes the decision just as it was coded—no waiting for someone to push a button. However, DAOs also face challenges, including: * Security Risks: Vulnerabilities in smart contracts can be exploited. * Governance Issues: Low voter participation and token concentration can lead to centralization. DAOs have been utilized in various domains, such as: * Investment Funds: Pooling resources to invest in projects collectively. * Charitable Organizations: Deciding on fund allocation through member voting. * Protocol Governance: Managing and updating blockchain protocols. ### How DAO Voting Works (The Simple Version)[​](https://docs.midnight.network/blog/tags/blockchain#how-dao-voting-works-the-simple-version "Direct link to How DAO Voting Works (The Simple Version)") Most DAOs use token-based voting to reach decisions: 1. Members hold a governance token, which gives them the right to vote. 2. A proposal is submitted (for example, "Fund a new development project"). 3. Token holders vote for or against the proposal. 4. If a certain threshold is reached (like a quorum or majority), the proposal is accepted and automatically executed by smart contracts. Beyond on-chain voting, many DAOs utilize off-chain governance platforms, such as Snapshot (widely used for token-weighted voting), Aragon Voice, Tally (commonly paired with Governor contracts), or Coordinape (used for decentralized grants and peer voting). These tools offer flexibility, reduce gas costs, and enable more experimental governance setups. The more tokens you hold, the more voting power you wield. This is similar to how shareholders vote in corporations, but the process is entirely on-chain, without intermediaries. Some DAOs use [quadratic voting](https://blog.colony.io/what-is-quadratic-voting-a-guide-to-dao-decision-making/) or other mechanisms to prevent whales (large holders) from dominating the process, but the core idea remains the same: the community drives the roadmap. Interplay Between Merkle Trees and DAOs[​](https://docs.midnight.network/blog/tags/blockchain#interplay-between-merkle-trees-and-daos "Direct link to Interplay Between Merkle Trees and DAOs") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ While Merkle Trees and DAOs serve different purposes in the blockchain world—one focused on data integrity, the other on governance—they complement each other in powerful ways. Together, DAOs can remain secure, transparent, and efficient even as they scale. For example, instead of storing a complete list of eligible voters, a DAO can publish a Merkle Root representing that list. Individual voters then submit a short cryptographic proof (a Merkle proof) to confirm they're included. This keeps voting lightweight, private, and verifiable. The same method can be used to verify grant recipients or airdrop eligibility—ensuring integrity while saving space and gas costs. Merkle Trees also act as a bridge between off-chain and on-chain activity. Whether it's tracking voting done through Snapshot or verifying community identities, these proofs give DAOs a scalable way to maintain trust and transparency—even as they grow. Merkle Trees provide DAOs with the cryptographic foundation to scale governance without sacrificing transparency or efficiency. Whether it's verifying voter eligibility, proving fund distribution, or bridging off-chain data to on-chain actions, Merkle Trees help DAOs maintain trust and accountability as they grow. It's a powerful example of how foundational blockchain structures support and enhance decentralized decision-making. Conclusion[​](https://docs.midnight.network/blog/tags/blockchain#conclusion "Direct link to Conclusion") --------------------------------------------------------------------------------------------------------- Together, Merkle Trees and DAOs demonstrate how blockchain technology strikes a balance between technical efficiency and community empowerment. Merkle Trees ensure that large sets of data—like transactions, votes, or recipient lists, can be verified quickly and securely. At the same time, DAOs introduce a way for communities to govern decentralized projects in a transparent and fair manner. When combined, they offer a practical solution for scaling trust without sacrificing decentralization. Whether you're verifying a vote, distributing funds, or proving membership, these tools help build the infrastructure that makes Web3 more than just a technological shift—it becomes a new model for how people coordinate, decide, and build together. Exploring beyond the Cardano and Midnight Academies for the first time in this journey provided me with a broader understanding of how these technologies are explained and applied across the space. If you're learning along with me or want to dig deeper into any of the topics covered, here are some of the materials I found especially helpful: * [Video: Merkle Trees Explained – Simply Explained](https://www.youtube.com/watch?v=3AcQyTs_Es4) * [Introduction to Merkle Trees – Geeks for Geeks](https://www.geeksforgeeks.org/introduction-to-merkle-tree/) * [What Are DAOs – LimeChain Blog](https://limechain.tech/blog/what-are-daos) * [Blockchain Transparency: Merkle Trees & Proof of Reserves – Moralis](https://academy.moralis.io/blog/blockchain-transparency-exploring-merkle-trees-and-proof-of-reserves) * [Everything You Need to Know About Merkle Trees – Bitpanda Academy](https://www.bitpanda.com/academy/en/lessons/everything-you-need-to-know-about-merkle-trees/) * [Introduction to DAOs – Chainalysis](https://www.chainalysis.com/blog/introduction-to-decentralized-autonomous-organizations-daos/) And if you’ve come across other great resources while learning Web3 basics, I’d love to hear them—drop a comment or reply with your favorites! You can also check out the [Midnight docs](https://docs.midnight.network/) for more technical deep dives and real-world use cases. Stay tuned for next week's exploration into other core components of the decentralized world. Explore how blockchain platforms have evolved from Bitcoin to Midnight and why tokens are essential to powering decentralized ecosystems. Explore how public key encryption and Practical Byzantine Fault Tolerance form the cryptographic and consensus backbone of secure, decentralized blockchain networks like Midnight. Two foundational cryptographic tools—hash functions and digital signatures—ensure data integrity, authenticity, and trust in decentralized Web3 systems like Midnight. Journey into Web3, unpack key blockchain concepts like decentralization, consensus, and how they shape platforms like Midnight. --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/web3-intro-selective-disclosure#__docusaurus_skipToContent_fallback) As I delve deeper into the world of Web3, I've been working my way through foundational concepts to have a better understanding of the industry (check out my last five posts on the [Midnight Dev Diaries](https://docs.midnight.network/blog) !). This week, I dove into one of the most practical and privacy-focused ideas I’ve encountered so far: **selective disclosure**. Selective disclosure is more than just a technical feature—it’s the working expression of a broader idea known as **rational privacy**. It allows individuals to prove or reveal only what’s necessary in a given interaction, keeping everything else private. In an ecosystem where trust must be earned without a central authority, this ability to protect personal data while still meeting legal or operational requirements is critical. This post examines how selective disclosure operates, its benefits, and how platforms like Midnight are implementing it through privacy-first smart contracts. What Is Selective Disclosure?[​](https://docs.midnight.network/blog/web3-intro-selective-disclosure#what-is-selective-disclosure "Direct link to What Is Selective Disclosure?") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- In the Web3 world, privacy doesn’t mean keeping everything secret—it means sharing only what’s necessary. [**Selective disclosure**](https://www.identity.com/what-is-selective-disclosure/) is a privacy-preserving technique that enables individuals to disclose specific information for a given interaction while keeping all other personal data confidential. This approach is a practical expression of a broader concept known as [**rational privacy**](https://midnight.network/blog/midnight-at-consensus-2025-building-the-future-of-rational-privacy) . Rational privacy is the idea that privacy shouldn’t be absolute or all-or-nothing—it should be contextual. It recognizes that in many real-world scenarios, users want to share _some_ data to gain access to services or meet legal obligations, but they shouldn't be forced to give up all privacy and security in the process. It’s about striking a balance between personal control, usability, and regulatory compliance. Selective disclosure is the technical implementation of rational privacy. It gives users and developers the cryptographic tools to protect sensitive information by default, while still enabling the right level of transparency when it’s required. This makes it especially relevant for public blockchain networks, where data is immutable and visible by design. A typical example of selective disclosure in action is the use of Verifiable Credentials (VCs). VCs allow users to prove attributes—like age, residency, or educational background—without revealing the entire credential. This aligns with the principles of data minimization and privacy by design, ensuring individuals remain in control of their information. This balance between usability and privacy is what makes selective disclosure so powerful—and so relevant for real-world blockchain applications. But beyond the technical implementation, it's worth asking: what are the practical benefits of using selective disclosure in the first place? Benefits of Selective Disclosure[​](https://docs.midnight.network/blog/web3-intro-selective-disclosure#benefits-of-selective-disclosure "Direct link to Benefits of Selective Disclosure") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- When integrated thoughtfully, selective disclosure brings both technical and human-centric advantages to decentralized systems. It enables individuals and organizations to meet privacy expectations and compliance standards without sacrificing functionality. Implementing selective disclosure offers several advantages: * **Enhanced Privacy**: Selective disclosure enables users to share only the data necessary for a specific interaction, rather than disclosing full credentials or identity documents. This dramatically reduces the surface area for privacy breaches and surveillance. Whether you’re accessing a service, submitting a form, or interacting with a smart contract, your unnecessary personal data stays out of view. * **Data Minimization and Compliance**: This principle, core to privacy laws such as GDPR and HIPAA, requires that only the minimum amount of personal data necessary for a task is collected or processed. Selective disclosure naturally enforces this, making it easier for developers and organizations to design privacy-respecting systems by default. * **User Empowerment and Control**: In traditional systems, users often hand over their entire dataset for one small verification (e.g., uploading an entire ID just to prove their age). Selective disclosure flips that dynamic, giving users the power to control what they share, when, and with whom. This supports a more user-centric data model, where individuals become the custodians of their credentials. * **Reduced Risk of Data Misuse**: The less information that’s exposed, the lower the risk of that data being lost, stolen, or misused. Selective disclosure reduces the need for centralized data storage (e.g., big ID databases), limiting attack vectors for fraud and identity theft. Even if a transaction or credential presentation is intercepted, only the minimum disclosed attribute is visible, keeping the rest safe. * **Lower Liability and Operational Overhead for Businesses:** Many organizations would prefer not to collect or store sensitive user data due to the associated risks, regulatory requirements, and administrative burdens. Selective disclosure offers a path forward, enabling users to demonstrate eligibility or compliance without requiring businesses to retain or manage that data. This can reduce costs, simplify operations, and improve overall data security posture. While selective disclosure introduces a powerful model for user-centric privacy, it also comes with its own set of technical and usability challenges. Understanding these limitations is essential for builders and organizations aiming to adopt it responsibly. Potential Drawbacks[​](https://docs.midnight.network/blog/web3-intro-selective-disclosure#potential-drawbacks "Direct link to Potential Drawbacks") ---------------------------------------------------------------------------------------------------------------------------------------------------- While selective disclosure strengthens privacy and control, implementing it in real-world systems isn’t always straightforward. Here are some of the common challenges: * **Complexity in Implementation**: Selective disclosure relies on advanced cryptographic techniques, often zero-knowledge proofs or similar privacy-preserving protocols. These require careful design, precise execution, and deep security expertise. For developers new to Web3 or cryptography, like myself, the learning curve can be steep, and mistakes in implementation could compromise the intended privacy protections. * **Verification Difficulties**: When only a fragment of a credential or statement is revealed, verifying its authenticity can become more complicated. Systems must be designed to ensure that partial disclosures can be trusted without needing access to the complete original data. This often requires additional metadata or proofs to be included, which can increase the overall complexity of the system and potentially slow down the verification process. * **Interoperability Challenges**: Not all decentralized identity systems follow the same formats or standards. As a result, credentials issued by one platform may not be easily verifiable on another, especially when using advanced features like selective disclosure. Without widely adopted protocols and infrastructure, cross-platform compatibility can be limited, reducing the broader utility of selectively disclosed data. While these challenges are real, they’re not insurmountable. Much of the current work in privacy-preserving blockchain development, including projects like Midnight, focuses on making selective disclosure more practical, developer-friendly, and interoperable across various ecosystems. Use Cases of Selective Disclosure[​](https://docs.midnight.network/blog/web3-intro-selective-disclosure#use-cases-of-selective-disclosure "Direct link to Use Cases of Selective Disclosure") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Selective disclosure has powerful, real-world applications wherever individuals or organizations need to prove something without oversharing. It’s beneficial in systems that handle sensitive data but also require compliance, trust, and transparency. Here are a few domains where it shines: * **Digital Identity Verification**: Imagine proving you're over 18 to access a service—without uploading your driver's license or disclosing your full birthdate and address. Selective disclosure lets you present only the relevant fact (e.g., “over 18”) as a verifiable statement, not the whole credential. * **Financial Transactions**: Financial platforms often need to confirm identity or transaction legitimacy (for KYC/AML compliance), but users shouldn’t have to share their entire financial history or wallet activity. Selective disclosure enables sharing only what’s legally necessary—no more, no less. * **Healthcare**: Patients may need to prove their vaccination status or medical eligibility without disclosing their entire health record. Selective disclosure lets them share only the required attribute (e.g., “vaccinated for X”) while keeping the rest private. * **Access Control**: Whether entering a venue or accessing online services, users may be granted or denied access based on attributes like membership, role, or credentials. Selective disclosure can enforce this access logic without revealing unnecessary identifying information. ### Selective Disclosure in the Midnight Network[​](https://docs.midnight.network/blog/web3-intro-selective-disclosure#selective-disclosure-in-the-midnight-network "Direct link to Selective Disclosure in the Midnight Network") At Midnight, selective disclosure isn’t just a privacy feature—it’s a core design principle grounded in rational privacy. Rational privacy recognizes that while sensitive data must be protected, real-world applications also require controlled visibility for regulatory, legal, or operational reasons. Take financial transactions, for example. A decentralized financial platform built on Midnight may want to keep user balances, transfers, and transaction histories private. However, under anti-money laundering (AML) or know-your-customer (KYC) regulations, certain information may need to be revealed—but only to authorized parties, and only under specific legal conditions. This is where selective disclosure and zero-knowledge proofs come together. Using Midnight's Compact smart contract language, developers can build logic that proves a transaction is valid (e.g., below a certain threshold, or compliant with regulatory filters) without revealing the full transaction details. Meanwhile, if a regulatory audit is triggered, users or auditors could selectively disclose the required pieces of information—nothing more. In this way, Midnight enables builders to create applications that respect individual privacy _and_ comply with regulatory requirements. It’s a practical application of selective disclosure that mirrors how real-world trust operates: share only what’s needed, only when it’s needed, and only with the right people. Conclusion[​](https://docs.midnight.network/blog/web3-intro-selective-disclosure#conclusion "Direct link to Conclusion") ------------------------------------------------------------------------------------------------------------------------- Selective disclosure offers a flexible and powerful approach to privacy—one that meets people where they are, allowing them to control their information. It enables individuals to share just enough information to satisfy requirements, without exposing more than necessary. Whether you're verifying an identity, proving a credential, or complying with financial regulations, selective disclosure makes privacy practical and effective. At Midnight, this concept becomes more than theoretical. It’s embedded into the platform’s architecture through Compact smart contracts and zero-knowledge proofs, allowing builders to create systems that balance user protection with real-world needs. It’s rational privacy in action. If you're exploring how to build for privacy in Web3—or just learning how these systems work—I encourage you to check out the [Midnight docs](https://docs.midnight.network/) and [Academy](https://docs.midnight.network/academy) for more examples and technical insight, as well as a detailed list of further reading about selective disclosure below: * [What Is Selective Disclosure? – Identity.com](https://www.identity.com/what-is-selective-disclosure/) * [Selective Disclosure Guide – Dock.io](https://www.dock.io/post/selective-disclosure) * [A Refresher on Selective Disclosure and Anti-Fraud Rules – Frost Brown Todd](https://frostbrowntodd.com/a-refresher-on-selective-disclosure-and-anti-fraud-rules/) * [Midnight Academy Module 3 – Midnight Docs](https://docs.midnight.network/academy/module-3) * [Explicit Disclosure Reference – Midnight Docs](https://docs.midnight.network/develop/reference/compact/explicit_disclosure) * [Digital Assets Use Cases – Midnight Docs](https://docs.midnight.network/learn/introduction/use-cases/digital-assets) And, as always, if you’ve come across any great learning resources on privacy or identity in Web3, I’d love to see them—drop a comment or reply with your favorites! I'll be back next week with more insights as I continue unpacking the key building blocks that make decentralized systems work. * [What Is Selective Disclosure?](https://docs.midnight.network/blog/web3-intro-selective-disclosure#what-is-selective-disclosure) * [Benefits of Selective Disclosure](https://docs.midnight.network/blog/web3-intro-selective-disclosure#benefits-of-selective-disclosure) * [Potential Drawbacks](https://docs.midnight.network/blog/web3-intro-selective-disclosure#potential-drawbacks) * [Use Cases of Selective Disclosure](https://docs.midnight.network/blog/web3-intro-selective-disclosure#use-cases-of-selective-disclosure) * [Selective Disclosure in the Midnight Network](https://docs.midnight.network/blog/web3-intro-selective-disclosure#selective-disclosure-in-the-midnight-network) * [Conclusion](https://docs.midnight.network/blog/web3-intro-selective-disclosure#conclusion) --- # Compact runtime API | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/compact-runtime v0.14.0** * * * Compact runtime library ======================= This API provides runtime primitives used by Compact's TypeScript output, both for use by the compiler output directly, and to utilise it or reproduce its behaviour. This API re-exports a number of items from `@midnight-ntwrk/onchain-runtime-v2`, and wraps others in a more TypeScript-friendly API. Key parts of the API are: * setNetworkId, required to ensure the right network is being targeted * [CircuitContext](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitContext) , and [CircuitResults](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitResults) part of the input and output definition of all circuits * [WitnessContext](https://docs.midnight.network/api-reference/compact-runtime/interfaces/WitnessContext) , part of the input definition of all circuits * Built-in functions: * Hashing/commitment * [transientHash](https://docs.midnight.network/api-reference/compact-runtime/functions/transientHash) * [transientCommit](https://docs.midnight.network/api-reference/compact-runtime/functions/transientCommit) * [persistentHash](https://docs.midnight.network/api-reference/compact-runtime/functions/persistentHash) * [persistentCommit](https://docs.midnight.network/api-reference/compact-runtime/functions/persistentCommit) * [degradeToTransient](https://docs.midnight.network/api-reference/compact-runtime/functions/degradeToTransient) * Elliptic curve * [ecAdd](https://docs.midnight.network/api-reference/compact-runtime/functions/ecAdd) * [ecMul](https://docs.midnight.network/api-reference/compact-runtime/functions/ecMul) * [ecMulGenerator](https://docs.midnight.network/api-reference/compact-runtime/functions/ecMulGenerator) * [hashToCurve](https://docs.midnight.network/api-reference/compact-runtime/functions/hashToCurve) * [ContractState](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState) , encapsulating the entirety of a smart contract's on-chain state * [StateValue](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue) , encoding data a contract maintains on-chain * [QueryContext](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext) , providing an annotated view into the contract state, against which on-chain VM programs can be run * [CompactType](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) , providing a runtime representation of basic Compact datatypes * Various TypeScript types matching same-named Compact types --- # NetworkId | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/enumerations/NetworkId#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.9.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / NetworkId Enumeration: NetworkId ====================== The network currently being targeted Enumeration Members[​](https://docs.midnight.network/api-reference/compact-runtime/enumerations/NetworkId#enumeration-members "Direct link to Enumeration Members") -------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### DevNet[​](https://docs.midnight.network/api-reference/compact-runtime/enumerations/NetworkId#devnet "Direct link to DevNet") DevNet: 1; A developer network, not guaranteed to be persistent * * * ### MainNet[​](https://docs.midnight.network/api-reference/compact-runtime/enumerations/NetworkId#mainnet "Direct link to MainNet") MainNet: 3; The Midnight mainnet * * * ### TestNet[​](https://docs.midnight.network/api-reference/compact-runtime/enumerations/NetworkId#testnet "Direct link to TestNet") TestNet: 2; A persistent testnet * * * ### Undeployed[​](https://docs.midnight.network/api-reference/compact-runtime/enumerations/NetworkId#undeployed "Direct link to Undeployed") Undeployed: 0; A local test network * [Enumeration Members](https://docs.midnight.network/api-reference/compact-runtime/enumerations/NetworkId#enumeration-members) * [DevNet](https://docs.midnight.network/api-reference/compact-runtime/enumerations/NetworkId#devnet) * [MainNet](https://docs.midnight.network/api-reference/compact-runtime/enumerations/NetworkId#mainnet) * [TestNet](https://docs.midnight.network/api-reference/compact-runtime/enumerations/NetworkId#testnet) * [Undeployed](https://docs.midnight.network/api-reference/compact-runtime/enumerations/NetworkId#undeployed) --- # ChargedState | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/ChargedState#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / ChargedState Class: ChargedState =================== Represents a [StateValue](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue) with storage annotations. These track the state usage that has been charged for so far. Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ChargedState#constructors "Direct link to Constructors") --------------------------------------------------------------------------------------------------------------------------------------------- ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ChargedState#constructor "Direct link to Constructor") new ChargedState(state): ChargedState; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ChargedState#parameters "Direct link to Parameters") ##### state[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ChargedState#state "Direct link to state") [`StateValue`](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ChargedState#returns "Direct link to Returns") `ChargedState` Properties[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ChargedState#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------- ### state[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ChargedState#state-1 "Direct link to state") readonly state: StateValue; Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ChargedState#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------------ ### toString()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ChargedState#tostring "Direct link to toString()") toString(compact?): string; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ChargedState#parameters-1 "Direct link to Parameters") ##### compact?[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ChargedState#compact "Direct link to compact?") `boolean` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ChargedState#returns-1 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/ChargedState#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/ChargedState#constructor) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/classes/ChargedState#properties) * [state](https://docs.midnight.network/api-reference/compact-runtime/classes/ChargedState#state-1) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/ChargedState#methods) * [toString()](https://docs.midnight.network/api-reference/compact-runtime/classes/ChargedState#tostring) --- # CompactTypeBoolean | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.9.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactTypeBoolean Class: CompactTypeBoolean ========================= Runtime type of the builtin `Boolean` type Implements[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#implements "Direct link to Implements") --------------------------------------------------------------------------------------------------------------------------------------------- * [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) <`boolean`\> Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#constructors "Direct link to Constructors") --------------------------------------------------------------------------------------------------------------------------------------------------- ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#constructor "Direct link to Constructor") new CompactTypeBoolean(): CompactTypeBoolean; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#returns "Direct link to Returns") `CompactTypeBoolean` Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------------------ ### alignment()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#alignment "Direct link to alignment()") alignment(): Alignment; The field-aligned binary alignment of this type. #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#returns-1 "Direct link to Returns") [`Alignment`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#implementation-of "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`alignment`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#alignment) * * * ### fromValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#fromvalue "Direct link to fromValue()") fromValue(value): boolean; Converts this type's field-aligned binary representation to its TypeScript representation destructively; (partially) consuming the input, and ignoring superflous data for chaining. #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#parameters "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#value "Direct link to value") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#returns-2 "Direct link to Returns") `boolean` #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#implementation-of-1 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`fromValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#fromvalue) * * * ### toValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#tovalue "Direct link to toValue()") toValue(value): Value; Converts this type's TypeScript representation to its field-aligned binary representation #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#parameters-1 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#value-1 "Direct link to value") `boolean` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#returns-3 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#implementation-of-2 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`toValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#tovalue) * [Implements](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#implements) * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#constructor) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#methods) * [alignment()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#alignment) * [fromValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#fromvalue) * [toValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBoolean#tovalue) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/web-3#__docusaurus_skipToContent_fallback) This past week, I started the SheFi course—a program designed to help women dive deeper into Web3 and decentralized finance. One of the first topics it covered was Ethereum: what it is, why it matters, and how it fits into the broader decentralized ecosystem. To build on what I learned there, I read two excellent overviews: [“A Beginner’s Guide to Ethereum” from Coinbase](https://medium.com/the-coinbase-blog/a-beginners-guide-to-ethereum-46dd486ceecf) and [“Getting Up to Speed on Ethereum” by Matt](https://medium.com/@oneofthemanymatts/getting-up-to-speed-on-ethereum-63ed28821bbe) . Both helped frame Ethereum not just as a cryptocurrency, but as a foundational platform for Web3 applications. Here’s what stood out and why Ethereum remains vital in a rapidly evolving cryptocurrency ecosystem. Ethereum in a Nutshell[​](https://docs.midnight.network/blog/tags/web-3#ethereum-in-a-nutshell "Direct link to Ethereum in a Nutshell") ---------------------------------------------------------------------------------------------------------------------------------------- Ethereum is a decentralized computing platform. Think of it like a global computer that anyone can access, but no single person or organization controls it. This is possible because Ethereum is powered by a blockchain—a network of nodes around the world that maintain and validate a shared record of activity. What makes Ethereum special is that it doesn’t just store transactions; it can also run applications. These apps are powered by smart contracts, which are programs deployed to the blockchain that execute exactly as written. The Ethereum network is designed to be open, programmable, and permissionless. That means anyone can build on it, and no one needs approval to use it. This structure has enabled Ethereum to become the foundation for a wide range of decentralized applications (dApps), including financial tools such as lending protocols and stablecoins, as well as NFT marketplaces and decentralized identity systems. Why Ethereum Matters[​](https://docs.midnight.network/blog/tags/web-3#why-ethereum-matters "Direct link to Why Ethereum Matters") ---------------------------------------------------------------------------------------------------------------------------------- Ethereum matters because it transforms the internet from a read-write platform into a read-write-execute environment. That is, it enables not just the sharing of information, but also the execution of logic—without relying on centralized intermediaries. This shift opens the door to creating systems that are more transparent, resilient, and accessible. One of Ethereum’s most significant breakthroughs is that it allows developers to write and deploy their own logic onto the network through smart contracts. These contracts can define rules, manage value, and interact with other contracts—all while being trustless and tamper-proof. Once deployed, smart contracts can’t be changed or censored, which means users can interact with them without worrying about backend changes or manipulation. Ether: The Fuel of the Ethereum Network[​](https://docs.midnight.network/blog/tags/web-3#ether-the-fuel-of-the-ethereum-network "Direct link to Ether: The Fuel of the Ethereum Network") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Ether (ETH) is the native currency of Ethereum. While many people think of ETH primarily as a cryptocurrency—something you can buy, sell, or hold—its most important role as the fuel for computation. Every operation on the Ethereum network costs gas, and ETH is what you use to pay for it. This is a crucial aspect of Ethereum’s security and incentive structure, ensuring that resources are utilized responsibly and the network remains resilient to spam. When you send a transaction, deploy a smart contract, or interact with a dApp, you’re paying for the network to process that request. The more complex the operation, the more gas it consumes. Gas prices fluctuate based on network demand, and users can choose how much to pay to incentivize faster confirmation. This dynamic creates a market for block space, encouraging developers to write more efficient code. The Power of Smart Contracts[​](https://docs.midnight.network/blog/tags/web-3#the-power-of-smart-contracts "Direct link to The Power of Smart Contracts") ---------------------------------------------------------------------------------------------------------------------------------------------------------- Smart contracts are at the heart of what makes Ethereum powerful. These are self-executing programs that live on the blockchain and enforce rules automatically. You don’t need to trust a company or a person; you can trust the code. Smart contracts enable a wide range of use cases, including lending platforms like Aave, decentralized exchanges like Uniswap, and even games like Axie Infinity. Once a smart contract is deployed, it’s public and verifiable. Anyone can inspect the code, interact with it, and build on top of it. This openness fosters a culture of composability—developers can plug into existing contracts, remix them, or build entirely new systems that work together. This is why Ethereum is often referred to as a “LEGO set for financial and digital tools.” Ethereum Today and Tomorrow[​](https://docs.midnight.network/blog/tags/web-3#ethereum-today-and-tomorrow "Direct link to Ethereum Today and Tomorrow") ------------------------------------------------------------------------------------------------------------------------------------------------------- Ethereum has come a long way since its launch in 2015. It’s no longer just a niche experiment; it’s the most widely used smart contract platform in the world. However, with that growth has come challenges. Network congestion and high gas fees have made it difficult for some users to interact with dApps affordably. To address these issues, Ethereum has undergone significant upgrades, most notably the transition from proof-of-work to proof-of-stake, known as “The Merge.” Proof-of-stake is a consensus mechanism that allows Ethereum to secure the network using validators who lock up ETH rather than relying on energy-intensive mining. This shift has dramatically reduced Ethereum’s energy usage and paved the way for future scaling efforts, such as sharding and rollups. Rollups are a technique for batching many transactions into a single proof, which can then be submitted to the Ethereum mainnet. This helps scale the network without sacrificing security or decentralization. The Ethereum ecosystem is also growing through layer 2 networks, which are built on top of Ethereum and handle transactions off-chain while still relying on Ethereum for settlement and security. Projects like Arbitrum, Optimism, and zkSync are working to make Ethereum faster and cheaper for everyday users. How Ethereum Connects with Midnight[​](https://docs.midnight.network/blog/tags/web-3#how-ethereum-connects-with-midnight "Direct link to How Ethereum Connects with Midnight") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- While Ethereum serves as the foundational smart contract platform for much of Web3, Midnight is designed to complement and extend its capabilities—especially in terms of privacy. In practical terms, this means that developers who are comfortable with the Ethereum ecosystem —its wallets, development environments, and smart contract models—can interact with Midnight using similar patterns. For example, Midnight supports a Solidity-like programming approach through its Compact smart contract language, which compiles to verifiable circuits that enforce privacy constraints. This allows developers to build private versions of applications, such as voting systems, token transfers, and identity verification, that would typically be public on the Ethereum blockchain. Ethereum offers programmability and decentralization, but by default, all on-chain transactions are transparent. Midnight fills in the missing privacy layer. You could imagine a workflow where public assets and smart contracts live on Ethereum, but sensitive data or confidential logic is handled by Midnight—bridging the two networks for richer, privacy-preserving applications. Together, Ethereum and Midnight can be seen as complementary parts of a broader decentralized stack: Ethereum provides openness and composability, while Midnight adds selective disclosure and private computation, enabling developers to build secure and compliant applications in ways that Ethereum alone can’t. Conclusion[​](https://docs.midnight.network/blog/tags/web-3#conclusion "Direct link to Conclusion") ---------------------------------------------------------------------------------------------------- Ethereum isn’t just a cryptocurrency—it’s a platform for building a new kind of internet. By combining programmable logic with decentralized infrastructure, Ethereum enables applications that are open, transparent, and user-owned. It’s the foundation of decentralized finance (DeFi), non-fungible tokens (NFTs), and numerous experiments in online interaction. For me, starting with SheFi and reading through these resources helped ground my understanding of what Ethereum is and why it matters. It’s not just about buying coins—it’s about reshaping how we think about trust, ownership, and value in a digital world. I’ll be back next week as I continue diving into the core building blocks of Web3. If you’re just starting out too, I highly recommend giving [Coinbase’s primer](https://medium.com/the-coinbase-blog/a-beginners-guide-to-ethereum-46dd486ceecf) and [Matt’s breakdown](https://medium.com/@oneofthemanymatts/getting-up-to-speed-on-ethereum-63ed28821bbe) a read. Midnight's Developer Relations team is actively shaping how developers learn, build, and experiment with privacy-first apps. In this post, we take a closer look at how DevRel is lowering the barrier to entry for new builders, supporting open-source tools, and helping the community navigate the unique challenges of developing on a privacy-preserving blockchain. Zero-knowledge proofs let you prove you know something without revealing what you know. Here's how this cryptographic breakthrough is revolutionizing privacy in Web3 applications. As I continue my journey through the world of Web3, I’ve been digging into the building blocks that make privacy-first platforms like Midnight possible (you can catch up on previous posts in the Midnight Dev Diaries!). This week, I focused on two foundational pieces that go hand in hand: smart contracts on Midnight and the Compact language that powers them. Smart contracts aren’t new to blockchain, but Midnight’s approach is unique. Instead of executing code directly on-chain, Midnight uses smart contracts to define rules that are enforced off-chain through zero-knowledge proofs. At the center of this system is [Compact](https://docs.midnight.network/develop/reference/compact/lang-ref) —a purpose-built language designed to make writing these privacy-preserving contracts both secure and practical. To better understand how this works in practice, I also worked through [Module 2 of the Midnight Developer Academy](https://docs.midnight.network/academy/module-2) , which covers key concepts such as contract structure, circuit types, and the relationship between the contract and the external logic that executes it. In this post, I’ll break down what makes smart contracts on Midnight different, how Compact is structured, and how the two work together to enable provable logic without exposing sensitive data. What Is a Smart Contract on Midnight?[​](https://docs.midnight.network/blog/tags/web-3#what-is-a-smart-contract-on-midnight "Direct link to What Is a Smart Contract on Midnight?") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ At a high level, a smart contract is an autonomous program stored on the blockchain. It defines rules for interaction, checks that those rules are met, and records results—all without needing a trusted third party to enforce them. But Midnight isn’t just any blockchain. It’s a privacy-first platform built with compliance in mind, and that means its smart contracts need to do more than just run logic. They need to protect private data, enable selective disclosure, and uphold security and trust even in adversarial environments. That’s where Compact comes in—a custom domain-specific language explicitly designed to write smart contracts on Midnight. Instead of executing logic directly on-chain like many traditional smart contracts, Compact contracts define the logic to be proven, not the execution environment itself. The contract encodes the rules that must be followed, which are then used as the foundation for a zero-knowledge proof. The actual execution—like processing a transaction, generating a credential, or submitting a vote—happens externally, often in a DApp, backend service, or API. That external system runs the necessary logic and **proves** it followed the contract’s rules by generating a cryptographic proof. The blockchain doesn’t need to know the details—it just verifies that the proof is valid. This separation is what makes Midnight’s model both scalable and privacy-preserving. In other words: the contract sets the rules, your app runs the logic, and the blockchain verifies the outcome, without ever seeing the sensitive inputs. What Is Compact?[​](https://docs.midnight.network/blog/tags/web-3#what-is-compact "Direct link to What Is Compact?") --------------------------------------------------------------------------------------------------------------------- Compact is a statically typed, privacy-focused smart contract language tailored to the unique goals of the Midnight network. If you've worked with JavaScript or TypeScript before, you'll find Compact refreshingly approachable. It’s a domain-specific language (DSL) designed to define zero-knowledge proof logic using statically typed circuits that map to off-chain computations. But don’t let the simple syntax fool you—Compact is engineered for privacy-preserving computation using zero-knowledge proofs (ZKPs) under the hood. (For a more technical deep dive into compact, check out part 1 of Kevin Millikin's Compact Deep Dive [here](https://docs.midnight.network/blog/compact) !) A Compact contract is made up of three core components: * **Ledger**: The public, on-chain state of the contract. * **Circuits**: Off-chain logic that can manipulate data, produce proofs, and interact with the ledger. * **Witnesses**: Privately held data, only known to the entity executing the contract. Compact also supports [explicit disclosure](https://docs.midnight.network/develop/reference/compact/explicit_disclosure#conclusion) , meaning developers can define exactly what data gets revealed (and to whom). This provides fine-grained control over what is visible on-chain and what remains private, essential for use cases such as private asset transfers, age-gated access, or confidential voting. Circuits and Privacy[​](https://docs.midnight.network/blog/tags/web-3#circuits-and-privacy "Direct link to Circuits and Privacy") ---------------------------------------------------------------------------------------------------------------------------------- One of the most essential takeaways from Module 2 of the Midnight Developer Academy is how circuits work. In Compact, circuits are the functions that users or systems can call to trigger actions. But unlike Web2 APIs or EVM contract functions, these circuits don’t execute logic directly on the blockchain. Instead, they run off-chain and generate zero-knowledge proofs that the logic was followed. In practice, that means: * The contract logic is public. * The data used during execution is private. * The outcome of the logic (e.g., “the rules were followed”) is publicly verifiable using a proof. This is where Midnight’s model shows its strength—users can prove they followed the rules without revealing the exact data that triggered the result. Think “I proved I’m eligible to vote” without revealing who I am or what I voted for. From Theory to Practice[​](https://docs.midnight.network/blog/tags/web-3#from-theory-to-practice "Direct link to From Theory to Practice") ------------------------------------------------------------------------------------------------------------------------------------------- In traditional smart contract platforms, everything you do is public by default: data, logic, inputs, outputs. That’s useful for transparency, but it's not always practical, especially for sensitive use cases like health data, financial records, or identity verification. Midnight flips that default. Privacy is built in, and developers opt into disclosure only when it’s needed. Some examples of what you might build with Compact on Midnight: * A voting system where only the outcome is public. * An access control system that verifies user attributes without revealing identities. * A token transfer app that hides amounts or senders while still allowing public verification. Conclusion[​](https://docs.midnight.network/blog/tags/web-3#conclusion "Direct link to Conclusion") ---------------------------------------------------------------------------------------------------- Smart contracts are the foundation of decentralized applications—but at Midnight, they’re built for a privacy-first future. Instead of executing every piece of logic on-chain, Midnight separates the contract's logic from its execution. With Compact, developers define the rules of a zero-knowledge proof system, enabling applications to prove facts without exposing sensitive data. It’s a practical shift toward secure, scalable, and user-protective Web3 design. At Midnight, this isn’t just a theoretical improvement—it’s core to how the platform operates. Compact smart contracts let developers write verifiable, auditable logic while keeping inputs and execution off-chain. Combined with ZKPs and shielded transactions, they create an infrastructure that supports real-world use cases without compromising on privacy or decentralization. If you're learning how to build smart contracts in Web3—or just curious how these pieces fit together—I highly recommend diving into [Module 2 of the Midnight Developer Academy](https://docs.midnight.network/academy/module-2) and reviewing the [Compact Language Reference](https://docs.midnight.network/develop/reference/compact/lang-ref) . These resources break down the concepts step by step and show how Midnight’s architecture turns advanced cryptography into practical developer tools. I’ll be back next week with more insights as I continue to unpack the pieces that make privacy-first systems work in the decentralized world. As I delve deeper into the world of Web3, I've been working my way through foundational concepts to have a better understanding of the industry (check out my last five posts on the [Midnight Dev Diaries](https://docs.midnight.network/blog) !). This week, I dove into one of the most practical and privacy-focused ideas I’ve encountered so far: **selective disclosure**. Selective disclosure is more than just a technical feature—it’s the working expression of a broader idea known as **rational privacy**. It allows individuals to prove or reveal only what’s necessary in a given interaction, keeping everything else private. In an ecosystem where trust must be earned without a central authority, this ability to protect personal data while still meeting legal or operational requirements is critical. This post examines how selective disclosure operates, its benefits, and how platforms like Midnight are implementing it through privacy-first smart contracts. What Is Selective Disclosure?[​](https://docs.midnight.network/blog/tags/web-3#what-is-selective-disclosure "Direct link to What Is Selective Disclosure?") ------------------------------------------------------------------------------------------------------------------------------------------------------------ In the Web3 world, privacy doesn’t mean keeping everything secret—it means sharing only what’s necessary. [**Selective disclosure**](https://www.identity.com/what-is-selective-disclosure/) is a privacy-preserving technique that enables individuals to disclose specific information for a given interaction while keeping all other personal data confidential. This approach is a practical expression of a broader concept known as [**rational privacy**](https://midnight.network/blog/midnight-at-consensus-2025-building-the-future-of-rational-privacy) . Rational privacy is the idea that privacy shouldn’t be absolute or all-or-nothing—it should be contextual. It recognizes that in many real-world scenarios, users want to share _some_ data to gain access to services or meet legal obligations, but they shouldn't be forced to give up all privacy and security in the process. It’s about striking a balance between personal control, usability, and regulatory compliance. Selective disclosure is the technical implementation of rational privacy. It gives users and developers the cryptographic tools to protect sensitive information by default, while still enabling the right level of transparency when it’s required. This makes it especially relevant for public blockchain networks, where data is immutable and visible by design. A typical example of selective disclosure in action is the use of Verifiable Credentials (VCs). VCs allow users to prove attributes—like age, residency, or educational background—without revealing the entire credential. This aligns with the principles of data minimization and privacy by design, ensuring individuals remain in control of their information. This balance between usability and privacy is what makes selective disclosure so powerful—and so relevant for real-world blockchain applications. But beyond the technical implementation, it's worth asking: what are the practical benefits of using selective disclosure in the first place? Benefits of Selective Disclosure[​](https://docs.midnight.network/blog/tags/web-3#benefits-of-selective-disclosure "Direct link to Benefits of Selective Disclosure") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- When integrated thoughtfully, selective disclosure brings both technical and human-centric advantages to decentralized systems. It enables individuals and organizations to meet privacy expectations and compliance standards without sacrificing functionality. Implementing selective disclosure offers several advantages: * **Enhanced Privacy**: Selective disclosure enables users to share only the data necessary for a specific interaction, rather than disclosing full credentials or identity documents. This dramatically reduces the surface area for privacy breaches and surveillance. Whether you’re accessing a service, submitting a form, or interacting with a smart contract, your unnecessary personal data stays out of view. * **Data Minimization and Compliance**: This principle, core to privacy laws such as GDPR and HIPAA, requires that only the minimum amount of personal data necessary for a task is collected or processed. Selective disclosure naturally enforces this, making it easier for developers and organizations to design privacy-respecting systems by default. * **User Empowerment and Control**: In traditional systems, users often hand over their entire dataset for one small verification (e.g., uploading an entire ID just to prove their age). Selective disclosure flips that dynamic, giving users the power to control what they share, when, and with whom. This supports a more user-centric data model, where individuals become the custodians of their credentials. * **Reduced Risk of Data Misuse**: The less information that’s exposed, the lower the risk of that data being lost, stolen, or misused. Selective disclosure reduces the need for centralized data storage (e.g., big ID databases), limiting attack vectors for fraud and identity theft. Even if a transaction or credential presentation is intercepted, only the minimum disclosed attribute is visible, keeping the rest safe. * **Lower Liability and Operational Overhead for Businesses:** Many organizations would prefer not to collect or store sensitive user data due to the associated risks, regulatory requirements, and administrative burdens. Selective disclosure offers a path forward, enabling users to demonstrate eligibility or compliance without requiring businesses to retain or manage that data. This can reduce costs, simplify operations, and improve overall data security posture. While selective disclosure introduces a powerful model for user-centric privacy, it also comes with its own set of technical and usability challenges. Understanding these limitations is essential for builders and organizations aiming to adopt it responsibly. Potential Drawbacks[​](https://docs.midnight.network/blog/tags/web-3#potential-drawbacks "Direct link to Potential Drawbacks") ------------------------------------------------------------------------------------------------------------------------------- While selective disclosure strengthens privacy and control, implementing it in real-world systems isn’t always straightforward. Here are some of the common challenges: * **Complexity in Implementation**: Selective disclosure relies on advanced cryptographic techniques, often zero-knowledge proofs or similar privacy-preserving protocols. These require careful design, precise execution, and deep security expertise. For developers new to Web3 or cryptography, like myself, the learning curve can be steep, and mistakes in implementation could compromise the intended privacy protections. * **Verification Difficulties**: When only a fragment of a credential or statement is revealed, verifying its authenticity can become more complicated. Systems must be designed to ensure that partial disclosures can be trusted without needing access to the complete original data. This often requires additional metadata or proofs to be included, which can increase the overall complexity of the system and potentially slow down the verification process. * **Interoperability Challenges**: Not all decentralized identity systems follow the same formats or standards. As a result, credentials issued by one platform may not be easily verifiable on another, especially when using advanced features like selective disclosure. Without widely adopted protocols and infrastructure, cross-platform compatibility can be limited, reducing the broader utility of selectively disclosed data. While these challenges are real, they’re not insurmountable. Much of the current work in privacy-preserving blockchain development, including projects like Midnight, focuses on making selective disclosure more practical, developer-friendly, and interoperable across various ecosystems. Use Cases of Selective Disclosure[​](https://docs.midnight.network/blog/tags/web-3#use-cases-of-selective-disclosure "Direct link to Use Cases of Selective Disclosure") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Selective disclosure has powerful, real-world applications wherever individuals or organizations need to prove something without oversharing. It’s beneficial in systems that handle sensitive data but also require compliance, trust, and transparency. Here are a few domains where it shines: * **Digital Identity Verification**: Imagine proving you're over 18 to access a service—without uploading your driver's license or disclosing your full birthdate and address. Selective disclosure lets you present only the relevant fact (e.g., “over 18”) as a verifiable statement, not the whole credential. * **Financial Transactions**: Financial platforms often need to confirm identity or transaction legitimacy (for KYC/AML compliance), but users shouldn’t have to share their entire financial history or wallet activity. Selective disclosure enables sharing only what’s legally necessary—no more, no less. * **Healthcare**: Patients may need to prove their vaccination status or medical eligibility without disclosing their entire health record. Selective disclosure lets them share only the required attribute (e.g., “vaccinated for X”) while keeping the rest private. * **Access Control**: Whether entering a venue or accessing online services, users may be granted or denied access based on attributes like membership, role, or credentials. Selective disclosure can enforce this access logic without revealing unnecessary identifying information. ### Selective Disclosure in the Midnight Network[​](https://docs.midnight.network/blog/tags/web-3#selective-disclosure-in-the-midnight-network "Direct link to Selective Disclosure in the Midnight Network") At Midnight, selective disclosure isn’t just a privacy feature—it’s a core design principle grounded in rational privacy. Rational privacy recognizes that while sensitive data must be protected, real-world applications also require controlled visibility for regulatory, legal, or operational reasons. Take financial transactions, for example. A decentralized financial platform built on Midnight may want to keep user balances, transfers, and transaction histories private. However, under anti-money laundering (AML) or know-your-customer (KYC) regulations, certain information may need to be revealed—but only to authorized parties, and only under specific legal conditions. This is where selective disclosure and zero-knowledge proofs come together. Using Midnight's Compact smart contract language, developers can build logic that proves a transaction is valid (e.g., below a certain threshold, or compliant with regulatory filters) without revealing the full transaction details. Meanwhile, if a regulatory audit is triggered, users or auditors could selectively disclose the required pieces of information—nothing more. In this way, Midnight enables builders to create applications that respect individual privacy _and_ comply with regulatory requirements. It’s a practical application of selective disclosure that mirrors how real-world trust operates: share only what’s needed, only when it’s needed, and only with the right people. Conclusion[​](https://docs.midnight.network/blog/tags/web-3#conclusion "Direct link to Conclusion") ---------------------------------------------------------------------------------------------------- Selective disclosure offers a flexible and powerful approach to privacy—one that meets people where they are, allowing them to control their information. It enables individuals to share just enough information to satisfy requirements, without exposing more than necessary. Whether you're verifying an identity, proving a credential, or complying with financial regulations, selective disclosure makes privacy practical and effective. At Midnight, this concept becomes more than theoretical. It’s embedded into the platform’s architecture through Compact smart contracts and zero-knowledge proofs, allowing builders to create systems that balance user protection with real-world needs. It’s rational privacy in action. If you're exploring how to build for privacy in Web3—or just learning how these systems work—I encourage you to check out the [Midnight docs](https://docs.midnight.network/) and [Academy](https://docs.midnight.network/academy) for more examples and technical insight, as well as a detailed list of further reading about selective disclosure below: * [What Is Selective Disclosure? – Identity.com](https://www.identity.com/what-is-selective-disclosure/) * [Selective Disclosure Guide – Dock.io](https://www.dock.io/post/selective-disclosure) * [A Refresher on Selective Disclosure and Anti-Fraud Rules – Frost Brown Todd](https://frostbrowntodd.com/a-refresher-on-selective-disclosure-and-anti-fraud-rules/) * [Midnight Academy Module 3 – Midnight Docs](https://docs.midnight.network/academy/module-3) * [Explicit Disclosure Reference – Midnight Docs](https://docs.midnight.network/develop/reference/compact/explicit_disclosure) * [Digital Assets Use Cases – Midnight Docs](https://docs.midnight.network/learn/introduction/use-cases/digital-assets) And, as always, if you’ve come across any great learning resources on privacy or identity in Web3, I’d love to see them—drop a comment or reply with your favorites! I'll be back next week with more insights as I continue unpacking the key building blocks that make decentralized systems work. As I continue my Web3 learning journey, I've mostly been working through [Cardano Academy](https://cardanofoundation.org/academy) and [Midnight Academy](https://docs.midnight.network/academy/) and documenting my findings in the [Midnight Dev Diaries](https://docs.midnight.network/blog) . But this week, I decided to branch out and explore a broader range of beginner-friendly resources across the ecosystem. That led me to two foundational concepts that kept coming up: Merkle Trees and Decentralized Autonomous Organizations (DAOs). These two topics sit at the heart of blockchain's promise—ensuring transparency, verifying data integrity, and enabling decentralized governance. I've broken down the key takeaways below, and if you're curious to go deeper, check out the list of helpful resources I've included at the end. Merkle Trees: Ensuring Data Integrity[​](https://docs.midnight.network/blog/tags/web-3#merkle-trees-ensuring-data-integrity "Direct link to Merkle Trees: Ensuring Data Integrity") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ A Merkle Tree, also known as a hash tree, is a data structure that enables efficient and secure verification of large data sets. At its core, it is a special kind of [binary tree](https://www.geeksforgeeks.org/binary-tree-data-structure/) —a structure many Web2 developers will recognize. In a binary tree, each node has at most two children. What makes Merkle Trees different is that instead of storing values directly, they store hashes. These hashes represent data blocks and provide a compact, tamper-evident summary of all the data in the tree. Merkle Trees are crucial in blockchain because they allow a large set of data (like thousands of transactions) to be verified efficiently and securely. Instead of needing to check every transaction, you only need a small subset of hashes (called a Merkle proof) to confirm that a transaction is part of a block. Here's a simplified breakdown of how a Merkle Tree is built: 1. Start with data blocks (like transactions in a block). 2. Each data block is hashed individually. These hashes become the leaf nodes. 3. Pairs of leaf hashes are then hashed together to form the next level of the tree. 4. This process continues, combining hashes pairwise and moving up the tree until you're left with a single root hash, often called the Merkle Root. In short, each leaf node contains the hash of a data block, each non-leaf node contains the hash of its child nodes, and the root hash represents the entire data set. Any change to any single data block will change its hash, which then cascades up the tree, altering the Merkle Root. This property is crucial for blockchain systems, where data immutability and integrity are paramount. In practice, Merkle Trees are used in: * Blockchain Transactions: Ensuring that transactions within a block are untampered. * Proof of Reserves: Cryptocurrency exchanges use Merkle Trees to prove they hold sufficient assets to cover user deposits without revealing individual account balances. DAOs: Redefining Organizational Governance[​](https://docs.midnight.network/blog/tags/web-3#daos-redefining-organizational-governance "Direct link to DAOs: Redefining Organizational Governance") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Decentralized Autonomous Organizations (DAOs) are organizations governed by smart contracts on a blockchain, eliminating the need for centralized leadership. They replace traditional top-down leadership with transparent, community-driven governance, all enforced through code—specifically, smart contracts. In a DAO, rules and operations are programmed upfront and stored on-chain. That means anyone can inspect how decisions are made, how funds are allocated, and how proposals are handled. Everything is transparent and auditable by default. Instead of a single CEO or board, decisions are made collectively by the community. Token holders can vote on proposals, and the outcome reflects the weight of their stake in the project. This collective decision-making process is what makes DAOs decentralized by design. And because those rules are enforced automatically by smart contracts, DAOs can operate autonomously without relying on manual intervention or centralized gatekeepers. Once a proposal passes, the smart contract executes the decision just as it was coded—no waiting for someone to push a button. However, DAOs also face challenges, including: * Security Risks: Vulnerabilities in smart contracts can be exploited. * Governance Issues: Low voter participation and token concentration can lead to centralization. DAOs have been utilized in various domains, such as: * Investment Funds: Pooling resources to invest in projects collectively. * Charitable Organizations: Deciding on fund allocation through member voting. * Protocol Governance: Managing and updating blockchain protocols. ### How DAO Voting Works (The Simple Version)[​](https://docs.midnight.network/blog/tags/web-3#how-dao-voting-works-the-simple-version "Direct link to How DAO Voting Works (The Simple Version)") Most DAOs use token-based voting to reach decisions: 1. Members hold a governance token, which gives them the right to vote. 2. A proposal is submitted (for example, "Fund a new development project"). 3. Token holders vote for or against the proposal. 4. If a certain threshold is reached (like a quorum or majority), the proposal is accepted and automatically executed by smart contracts. Beyond on-chain voting, many DAOs utilize off-chain governance platforms, such as Snapshot (widely used for token-weighted voting), Aragon Voice, Tally (commonly paired with Governor contracts), or Coordinape (used for decentralized grants and peer voting). These tools offer flexibility, reduce gas costs, and enable more experimental governance setups. The more tokens you hold, the more voting power you wield. This is similar to how shareholders vote in corporations, but the process is entirely on-chain, without intermediaries. Some DAOs use [quadratic voting](https://blog.colony.io/what-is-quadratic-voting-a-guide-to-dao-decision-making/) or other mechanisms to prevent whales (large holders) from dominating the process, but the core idea remains the same: the community drives the roadmap. Interplay Between Merkle Trees and DAOs[​](https://docs.midnight.network/blog/tags/web-3#interplay-between-merkle-trees-and-daos "Direct link to Interplay Between Merkle Trees and DAOs") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- While Merkle Trees and DAOs serve different purposes in the blockchain world—one focused on data integrity, the other on governance—they complement each other in powerful ways. Together, DAOs can remain secure, transparent, and efficient even as they scale. For example, instead of storing a complete list of eligible voters, a DAO can publish a Merkle Root representing that list. Individual voters then submit a short cryptographic proof (a Merkle proof) to confirm they're included. This keeps voting lightweight, private, and verifiable. The same method can be used to verify grant recipients or airdrop eligibility—ensuring integrity while saving space and gas costs. Merkle Trees also act as a bridge between off-chain and on-chain activity. Whether it's tracking voting done through Snapshot or verifying community identities, these proofs give DAOs a scalable way to maintain trust and transparency—even as they grow. Merkle Trees provide DAOs with the cryptographic foundation to scale governance without sacrificing transparency or efficiency. Whether it's verifying voter eligibility, proving fund distribution, or bridging off-chain data to on-chain actions, Merkle Trees help DAOs maintain trust and accountability as they grow. It's a powerful example of how foundational blockchain structures support and enhance decentralized decision-making. Conclusion[​](https://docs.midnight.network/blog/tags/web-3#conclusion "Direct link to Conclusion") ---------------------------------------------------------------------------------------------------- Together, Merkle Trees and DAOs demonstrate how blockchain technology strikes a balance between technical efficiency and community empowerment. Merkle Trees ensure that large sets of data—like transactions, votes, or recipient lists, can be verified quickly and securely. At the same time, DAOs introduce a way for communities to govern decentralized projects in a transparent and fair manner. When combined, they offer a practical solution for scaling trust without sacrificing decentralization. Whether you're verifying a vote, distributing funds, or proving membership, these tools help build the infrastructure that makes Web3 more than just a technological shift—it becomes a new model for how people coordinate, decide, and build together. Exploring beyond the Cardano and Midnight Academies for the first time in this journey provided me with a broader understanding of how these technologies are explained and applied across the space. If you're learning along with me or want to dig deeper into any of the topics covered, here are some of the materials I found especially helpful: * [Video: Merkle Trees Explained – Simply Explained](https://www.youtube.com/watch?v=3AcQyTs_Es4) * [Introduction to Merkle Trees – Geeks for Geeks](https://www.geeksforgeeks.org/introduction-to-merkle-tree/) * [What Are DAOs – LimeChain Blog](https://limechain.tech/blog/what-are-daos) * [Blockchain Transparency: Merkle Trees & Proof of Reserves – Moralis](https://academy.moralis.io/blog/blockchain-transparency-exploring-merkle-trees-and-proof-of-reserves) * [Everything You Need to Know About Merkle Trees – Bitpanda Academy](https://www.bitpanda.com/academy/en/lessons/everything-you-need-to-know-about-merkle-trees/) * [Introduction to DAOs – Chainalysis](https://www.chainalysis.com/blog/introduction-to-decentralized-autonomous-organizations-daos/) And if you’ve come across other great resources while learning Web3 basics, I’d love to hear them—drop a comment or reply with your favorites! You can also check out the [Midnight docs](https://docs.midnight.network/) for more technical deep dives and real-world use cases. Stay tuned for next week's exploration into other core components of the decentralized world. Explore how blockchain platforms have evolved from Bitcoin to Midnight and why tokens are essential to powering decentralized ecosystems. Explore how public key encryption and Practical Byzantine Fault Tolerance form the cryptographic and consensus backbone of secure, decentralized blockchain networks like Midnight. Two foundational cryptographic tools—hash functions and digital signatures—ensure data integrity, authenticity, and trust in decentralized Web3 systems like Midnight. Journey into Web3, unpack key blockchain concepts like decentralization, consensus, and how they shape platforms like Midnight. --- # CompactTypeCurvePoint | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.9.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactTypeCurvePoint Class: CompactTypeCurvePoint ============================ Runtime type of [CurvePoint](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CurvePoint) Implements[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#implements "Direct link to Implements") ------------------------------------------------------------------------------------------------------------------------------------------------ * [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) <[`CurvePoint`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CurvePoint) \> Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------------------ ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#constructor "Direct link to Constructor") new CompactTypeCurvePoint(): CompactTypeCurvePoint; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#returns "Direct link to Returns") `CompactTypeCurvePoint` Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#methods "Direct link to Methods") --------------------------------------------------------------------------------------------------------------------------------------- ### alignment()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#alignment "Direct link to alignment()") alignment(): Alignment; The field-aligned binary alignment of this type. #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#returns-1 "Direct link to Returns") [`Alignment`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#implementation-of "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`alignment`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#alignment) * * * ### fromValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#fromvalue "Direct link to fromValue()") fromValue(value): CurvePoint; Converts this type's field-aligned binary representation to its TypeScript representation destructively; (partially) consuming the input, and ignoring superflous data for chaining. #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#parameters "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#value "Direct link to value") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#returns-2 "Direct link to Returns") [`CurvePoint`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CurvePoint) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#implementation-of-1 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`fromValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#fromvalue) * * * ### toValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#tovalue "Direct link to toValue()") toValue(value): Value; Converts this type's TypeScript representation to its field-aligned binary representation #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#parameters-1 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#value-1 "Direct link to value") [`CurvePoint`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CurvePoint) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#returns-3 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#implementation-of-2 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`toValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#tovalue) * [Implements](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#implements) * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#constructor) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#methods) * [alignment()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#alignment) * [fromValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#fromvalue) * [toValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeCurvePoint#tovalue) --- # CompactTypeEnum | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactTypeEnum Class: CompactTypeEnum ====================== Runtime type of an enum with a given number of entries Implements[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#implements "Direct link to Implements") ------------------------------------------------------------------------------------------------------------------------------------------ * [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) <`number`\> Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------------ ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#constructor "Direct link to Constructor") new CompactTypeEnum(maxValue, length): CompactTypeEnum; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#parameters "Direct link to Parameters") ##### maxValue[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#maxvalue "Direct link to maxValue") `number` ##### length[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#length "Direct link to length") `number` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#returns "Direct link to Returns") `CompactTypeEnum` Properties[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------ ### length[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#length-1 "Direct link to length") readonly length: number; * * * ### maxValue[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#maxvalue-1 "Direct link to maxValue") readonly maxValue: number; Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#methods "Direct link to Methods") --------------------------------------------------------------------------------------------------------------------------------- ### alignment()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#alignment "Direct link to alignment()") alignment(): Alignment; The field-aligned binary alignment of this type. #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#returns-1 "Direct link to Returns") [`Alignment`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#implementation-of "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`alignment`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#alignment) * * * ### fromValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#fromvalue "Direct link to fromValue()") fromValue(value): number; Converts this type's field-aligned binary representation to its TypeScript representation destructively; (partially) consuming the input, and ignoring superflous data for chaining. #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#parameters-1 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#value "Direct link to value") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#returns-2 "Direct link to Returns") `number` #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#implementation-of-1 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`fromValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#fromvalue) * * * ### toValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#tovalue "Direct link to toValue()") toValue(value): Value; Converts this type's TypeScript representation to its field-aligned binary representation #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#parameters-2 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#value-1 "Direct link to value") `number` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#returns-3 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#implementation-of-2 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`toValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#tovalue) * [Implements](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#implements) * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#constructor) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#properties) * [length](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#length-1) * [maxValue](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#maxvalue-1) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#methods) * [alignment()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#alignment) * [fromValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#fromvalue) * [toValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeEnum#tovalue) --- # CompactTypeBytes | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactTypeBytes Class: CompactTypeBytes ======================= Runtime type of the builtin `Bytes` types Implements[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#implements "Direct link to Implements") ------------------------------------------------------------------------------------------------------------------------------------------- * [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) <`Uint8Array`\> Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------------- ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#constructor "Direct link to Constructor") new CompactTypeBytes(length): CompactTypeBytes; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#parameters "Direct link to Parameters") ##### length[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#length "Direct link to length") `number` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#returns "Direct link to Returns") `CompactTypeBytes` Properties[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------- ### length[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#length-1 "Direct link to length") readonly length: number; Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------------------- ### alignment()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#alignment "Direct link to alignment()") alignment(): Alignment; The field-aligned binary alignment of this type. #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#returns-1 "Direct link to Returns") [`Alignment`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#implementation-of "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`alignment`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#alignment) * * * ### fromValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#fromvalue "Direct link to fromValue()") fromValue(value): Uint8Array; Converts this type's field-aligned binary representation to its TypeScript representation destructively; (partially) consuming the input, and ignoring superflous data for chaining. #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#parameters-1 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#value "Direct link to value") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#returns-2 "Direct link to Returns") `Uint8Array` #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#implementation-of-1 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`fromValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#fromvalue) * * * ### toValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#tovalue "Direct link to toValue()") toValue(value): Value; Converts this type's TypeScript representation to its field-aligned binary representation #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#parameters-2 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#value-1 "Direct link to value") `Uint8Array` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#returns-3 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#implementation-of-2 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`toValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#tovalue) * [Implements](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#implements) * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#constructor) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#properties) * [length](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#length-1) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#methods) * [alignment()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#alignment) * [fromValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#fromvalue) * [toValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeBytes#tovalue) --- # CompactTypeField | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.9.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactTypeField Class: CompactTypeField ======================= Runtime type of the builtin `Field` type Implements[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#implements "Direct link to Implements") ------------------------------------------------------------------------------------------------------------------------------------------- * [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) <`bigint`\> Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------------- ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#constructor "Direct link to Constructor") new CompactTypeField(): CompactTypeField; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#returns "Direct link to Returns") `CompactTypeField` Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------------------- ### alignment()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#alignment "Direct link to alignment()") alignment(): Alignment; The field-aligned binary alignment of this type. #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#returns-1 "Direct link to Returns") [`Alignment`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#implementation-of "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`alignment`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#alignment) * * * ### fromValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#fromvalue "Direct link to fromValue()") fromValue(value): bigint; Converts this type's field-aligned binary representation to its TypeScript representation destructively; (partially) consuming the input, and ignoring superflous data for chaining. #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#parameters "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#value "Direct link to value") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#returns-2 "Direct link to Returns") `bigint` #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#implementation-of-1 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`fromValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#fromvalue) * * * ### toValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#tovalue "Direct link to toValue()") toValue(value): Value; Converts this type's TypeScript representation to its field-aligned binary representation #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#parameters-1 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#value-1 "Direct link to value") `bigint` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#returns-3 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#implementation-of-2 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`toValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#tovalue) * [Implements](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#implements) * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#constructor) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#methods) * [alignment()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#alignment) * [fromValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#fromvalue) * [toValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeField#tovalue) --- # CompactTypeMerkleTreeDigest | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.9.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactTypeMerkleTreeDigest Class: CompactTypeMerkleTreeDigest ================================== Runtime type of [MerkleTreeDigest](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreeDigest) Implements[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#implements "Direct link to Implements") ------------------------------------------------------------------------------------------------------------------------------------------------------ * [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) <[`MerkleTreeDigest`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreeDigest) \> Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------------------------ ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#constructor "Direct link to Constructor") new CompactTypeMerkleTreeDigest(): CompactTypeMerkleTreeDigest; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#returns "Direct link to Returns") `CompactTypeMerkleTreeDigest` Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#methods "Direct link to Methods") --------------------------------------------------------------------------------------------------------------------------------------------- ### alignment()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#alignment "Direct link to alignment()") alignment(): Alignment; The field-aligned binary alignment of this type. #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#returns-1 "Direct link to Returns") [`Alignment`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#implementation-of "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`alignment`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#alignment) * * * ### fromValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#fromvalue "Direct link to fromValue()") fromValue(value): MerkleTreeDigest; Converts this type's field-aligned binary representation to its TypeScript representation destructively; (partially) consuming the input, and ignoring superflous data for chaining. #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#parameters "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#value "Direct link to value") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#returns-2 "Direct link to Returns") [`MerkleTreeDigest`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreeDigest) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#implementation-of-1 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`fromValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#fromvalue) * * * ### toValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#tovalue "Direct link to toValue()") toValue(value): Value; Converts this type's TypeScript representation to its field-aligned binary representation #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#parameters-1 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#value-1 "Direct link to value") [`MerkleTreeDigest`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreeDigest) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#returns-3 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#implementation-of-2 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`toValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#tovalue) * [Implements](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#implements) * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#constructor) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#methods) * [alignment()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#alignment) * [fromValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#fromvalue) * [toValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreeDigest#tovalue) --- # CompactTypeMerkleTreePath | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactTypeMerkleTreePath Class: CompactTypeMerkleTreePath
=================================== Runtime type of [MerkleTreePath](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePath) Type Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#type-parameters "Direct link to Type Parameters") ------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### A[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#a "Direct link to A") `A` Implements[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#implements "Direct link to Implements") ---------------------------------------------------------------------------------------------------------------------------------------------------- * [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) <[`MerkleTreePath`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePath) <`A`\>> Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------------------------------- ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#constructor "Direct link to Constructor") new CompactTypeMerkleTreePath(n, leaf): CompactTypeMerkleTreePath; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#parameters "Direct link to Parameters") ##### n[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#n "Direct link to n") `number` ##### leaf[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#leaf "Direct link to leaf") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) <`A`\> #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#returns "Direct link to Returns") `CompactTypeMerkleTreePath`<`A`\> Properties[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------------------------- ### leaf[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#leaf-1 "Direct link to leaf") readonly leaf: CompactType; * * * ### path[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#path "Direct link to path") readonly path: CompactTypeVector; Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------------------------- ### alignment()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#alignment "Direct link to alignment()") alignment(): Alignment; The field-aligned binary alignment of this type. #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#returns-1 "Direct link to Returns") [`Alignment`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#implementation-of "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`alignment`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#alignment) * * * ### fromValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#fromvalue "Direct link to fromValue()") fromValue(value): MerkleTreePath; Converts this type's field-aligned binary representation to its TypeScript representation destructively; (partially) consuming the input, and ignoring superflous data for chaining. #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#parameters-1 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#value "Direct link to value") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#returns-2 "Direct link to Returns") [`MerkleTreePath`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePath) <`A`\> #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#implementation-of-1 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`fromValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#fromvalue) * * * ### toValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#tovalue "Direct link to toValue()") toValue(value): Value; Converts this type's TypeScript representation to its field-aligned binary representation #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#parameters-2 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#value-1 "Direct link to value") [`MerkleTreePath`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePath) <`A`\> #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#returns-3 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#implementation-of-2 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`toValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#tovalue) * [Type Parameters](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#type-parameters) * [A](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#a) * [Implements](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#implements) * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#constructor) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#properties) * [leaf](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#leaf-1) * [path](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#path) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#methods) * [alignment()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#alignment) * [fromValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#fromvalue) * [toValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePath#tovalue) --- # CompactError | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactError Class: CompactError =================== An error originating from code generated by the Compact compiler Extends[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#extends "Direct link to Extends") ------------------------------------------------------------------------------------------------------------------------------ * `Error` Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#constructors "Direct link to Constructors") --------------------------------------------------------------------------------------------------------------------------------------------- ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#constructor "Direct link to Constructor") new CompactError(msg): CompactError; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#parameters "Direct link to Parameters") ##### msg[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#msg "Direct link to msg") `string` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#returns "Direct link to Returns") `CompactError` #### Overrides[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#overrides "Direct link to Overrides") Error.constructor Properties[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------- ### message[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#message "Direct link to message") message: string; #### Inherited from[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#inherited-from "Direct link to Inherited from") Error.message * * * ### name[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#name "Direct link to name") name: string; #### Inherited from[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#inherited-from-1 "Direct link to Inherited from") Error.name * * * ### stack?[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#stack "Direct link to stack?") optional stack: string; #### Inherited from[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#inherited-from-2 "Direct link to Inherited from") Error.stack * * * ### stackTraceLimit[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#stacktracelimit "Direct link to stackTraceLimit") static stackTraceLimit: number; The `Error.stackTraceLimit` property specifies the number of stack frames collected by a stack trace (whether generated by `new Error().stack` or `Error.captureStackTrace(obj)`). The default value is `10` but may be set to any valid JavaScript number. Changes will affect any stack trace captured _after_ the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. #### Inherited from[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#inherited-from-3 "Direct link to Inherited from") Error.stackTraceLimit Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------------ ### captureStackTrace()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#capturestacktrace "Direct link to captureStackTrace()") static captureStackTrace(targetObject, constructorOpt?): void; Creates a `.stack` property on `targetObject`, which when accessed returns a string representing the location in the code at which `Error.captureStackTrace()` was called. const myObject = {};Error.captureStackTrace(myObject);myObject.stack; // Similar to `new Error().stack` The first line of the trace will be prefixed with `${myObject.name}: ${myObject.message}`. The optional `constructorOpt` argument accepts a function. If given, all frames above `constructorOpt`, including `constructorOpt`, will be omitted from the generated stack trace. The `constructorOpt` argument is useful for hiding implementation details of error generation from the user. For instance: function a() { b();}function b() { c();}function c() { // Create an error without stack trace to avoid calculating the stack trace twice. const { stackTraceLimit } = Error; Error.stackTraceLimit = 0; const error = new Error(); Error.stackTraceLimit = stackTraceLimit; // Capture the stack trace above function b Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace throw error;}a(); #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#parameters-1 "Direct link to Parameters") ##### targetObject[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#targetobject "Direct link to targetObject") `object` ##### constructorOpt?[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#constructoropt "Direct link to constructorOpt?") `Function` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#returns-1 "Direct link to Returns") `void` #### Inherited from[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#inherited-from-4 "Direct link to Inherited from") Error.captureStackTrace * * * ### prepareStackTrace()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#preparestacktrace "Direct link to prepareStackTrace()") static prepareStackTrace(err, stackTraces): any; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#parameters-2 "Direct link to Parameters") ##### err[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#err "Direct link to err") `Error` ##### stackTraces[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#stacktraces "Direct link to stackTraces") `CallSite`\[\] #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#returns-2 "Direct link to Returns") `any` #### See[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#see "Direct link to See") [https://v8.dev/docs/stack-trace-api#customizing-stack-traces](https://v8.dev/docs/stack-trace-api#customizing-stack-traces) #### Inherited from[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#inherited-from-5 "Direct link to Inherited from") Error.prepareStackTrace * [Extends](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#extends) * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#constructor) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#properties) * [message](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#message) * [name](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#name) * [stack?](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#stack) * [stackTraceLimit](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#stacktracelimit) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#methods) * [captureStackTrace()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#capturestacktrace) * [prepareStackTrace()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactError#preparestacktrace) --- # ContractMaintenanceAuthority | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / ContractMaintenanceAuthority Class: ContractMaintenanceAuthority =================================== A committee permitted to make changes to this contract. If a threshold of the public keys in this committee sign off, they can change the rules of this contract, or recompile it for a new version. If the threshold is greater than the number of committee members, it is impossible for them to sign anything. Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------------------------- ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#constructor "Direct link to Constructor") new ContractMaintenanceAuthority( committee, threshold, counter?): ContractMaintenanceAuthority; Constructs a new authority from its components If not supplied, `counter` will default to `0n`. Values should be non-negative, and at most 2^32 - 1. At deployment, `counter` must be `0n`, and any subsequent update should set counter to exactly one greater than the current value. #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#parameters "Direct link to Parameters") ##### committee[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#committee "Direct link to committee") `string`\[\] ##### threshold[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#threshold "Direct link to threshold") `number` ##### counter?[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#counter "Direct link to counter?") `bigint` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#returns "Direct link to Returns") `ContractMaintenanceAuthority` Properties[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------------------- ### committee[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#committee-1 "Direct link to committee") readonly committee: string[]; The committee public keys * * * ### counter[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#counter-1 "Direct link to counter") readonly counter: bigint; The replay protection counter * * * ### threshold[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#threshold-1 "Direct link to threshold") readonly threshold: number; How many keys must sign rule changes Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#serialize "Direct link to serialize()") serialize(): Uint8Array; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#tostring "Direct link to toString()") toString(compact?): string; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#parameters-1 "Direct link to Parameters") ##### compact?[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#compact "Direct link to compact?") `boolean` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#deserialize "Direct link to deserialize()") static deserialize(raw): ContractState; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#parameters-2 "Direct link to Parameters") ##### raw[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#raw "Direct link to raw") `Uint8Array` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#returns-3 "Direct link to Returns") [`ContractState`](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState) * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#constructor) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#properties) * [committee](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#committee-1) * [counter](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#counter-1) * [threshold](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#threshold-1) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#methods) * [serialize()](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#serialize) * [toString()](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#tostring) * [deserialize()](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractMaintenanceAuthority#deserialize) --- # CompactTypeOpaqueString | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.9.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactTypeOpaqueString Class: CompactTypeOpaqueString ============================== Runtime type of `Opaque["string"]` Implements[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#implements "Direct link to Implements") -------------------------------------------------------------------------------------------------------------------------------------------------- * [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) <`string`\> Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#constructors "Direct link to Constructors") -------------------------------------------------------------------------------------------------------------------------------------------------------- ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#constructor "Direct link to Constructor") new CompactTypeOpaqueString(): CompactTypeOpaqueString; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#returns "Direct link to Returns") `CompactTypeOpaqueString` Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#methods "Direct link to Methods") ----------------------------------------------------------------------------------------------------------------------------------------- ### alignment()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#alignment "Direct link to alignment()") alignment(): Alignment; The field-aligned binary alignment of this type. #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#returns-1 "Direct link to Returns") [`Alignment`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#implementation-of "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`alignment`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#alignment) * * * ### fromValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#fromvalue "Direct link to fromValue()") fromValue(value): string; Converts this type's field-aligned binary representation to its TypeScript representation destructively; (partially) consuming the input, and ignoring superflous data for chaining. #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#parameters "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#value "Direct link to value") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#returns-2 "Direct link to Returns") `string` #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#implementation-of-1 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`fromValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#fromvalue) * * * ### toValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#tovalue "Direct link to toValue()") toValue(value): Value; Converts this type's TypeScript representation to its field-aligned binary representation #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#parameters-1 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#value-1 "Direct link to value") `string` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#returns-3 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#implementation-of-2 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`toValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#tovalue) * [Implements](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#implements) * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#constructor) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#methods) * [alignment()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#alignment) * [fromValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#fromvalue) * [toValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueString#tovalue) --- # CompactTypeMerkleTreePathEntry | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.9.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactTypeMerkleTreePathEntry Class: CompactTypeMerkleTreePathEntry ===================================== Runtime type of [MerkleTreePathEntry](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePathEntry) Implements[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#implements "Direct link to Implements") --------------------------------------------------------------------------------------------------------------------------------------------------------- * [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) <[`MerkleTreePathEntry`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePathEntry) \> Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#constructors "Direct link to Constructors") --------------------------------------------------------------------------------------------------------------------------------------------------------------- ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#constructor "Direct link to Constructor") new CompactTypeMerkleTreePathEntry(): CompactTypeMerkleTreePathEntry; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#returns "Direct link to Returns") `CompactTypeMerkleTreePathEntry` Properties[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------------------------- ### bool[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#bool "Direct link to bool") readonly bool: CompactTypeBoolean; * * * ### digest[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#digest "Direct link to digest") readonly digest: CompactTypeMerkleTreeDigest; Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------------------------------ ### alignment()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#alignment "Direct link to alignment()") alignment(): Alignment; The field-aligned binary alignment of this type. #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#returns-1 "Direct link to Returns") [`Alignment`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#implementation-of "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`alignment`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#alignment) * * * ### fromValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#fromvalue "Direct link to fromValue()") fromValue(value): MerkleTreePathEntry; Converts this type's field-aligned binary representation to its TypeScript representation destructively; (partially) consuming the input, and ignoring superflous data for chaining. #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#parameters "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#value "Direct link to value") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#returns-2 "Direct link to Returns") [`MerkleTreePathEntry`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePathEntry) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#implementation-of-1 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`fromValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#fromvalue) * * * ### toValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#tovalue "Direct link to toValue()") toValue(value): Value; Converts this type's TypeScript representation to its field-aligned binary representation #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#parameters-1 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#value-1 "Direct link to value") [`MerkleTreePathEntry`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePathEntry) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#returns-3 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#implementation-of-2 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`toValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#tovalue) * [Implements](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#implements) * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#constructor) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#properties) * [bool](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#bool) * [digest](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#digest) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#methods) * [alignment()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#alignment) * [fromValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#fromvalue) * [toValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeMerkleTreePathEntry#tovalue) --- # CompactTypeOpaqueUint8Array | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.9.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactTypeOpaqueUint8Array Class: CompactTypeOpaqueUint8Array ================================== Runtime type of `Opaque["Uint8Array"]` Implements[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#implements "Direct link to Implements") ------------------------------------------------------------------------------------------------------------------------------------------------------ * [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) <`Uint8Array`\> Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------------------------ ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#constructor "Direct link to Constructor") new CompactTypeOpaqueUint8Array(): CompactTypeOpaqueUint8Array; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#returns "Direct link to Returns") `CompactTypeOpaqueUint8Array` Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#methods "Direct link to Methods") --------------------------------------------------------------------------------------------------------------------------------------------- ### alignment()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#alignment "Direct link to alignment()") alignment(): Alignment; The field-aligned binary alignment of this type. #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#returns-1 "Direct link to Returns") [`Alignment`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#implementation-of "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`alignment`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#alignment) * * * ### fromValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#fromvalue "Direct link to fromValue()") fromValue(value): Uint8Array; Converts this type's field-aligned binary representation to its TypeScript representation destructively; (partially) consuming the input, and ignoring superflous data for chaining. #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#parameters "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#value "Direct link to value") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#returns-2 "Direct link to Returns") `Uint8Array` #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#implementation-of-1 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`fromValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#fromvalue) * * * ### toValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#tovalue "Direct link to toValue()") toValue(value): Value; Converts this type's TypeScript representation to its field-aligned binary representation #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#parameters-1 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#value-1 "Direct link to value") `Uint8Array` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#returns-3 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#implementation-of-2 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`toValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#tovalue) * [Implements](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#implements) * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#constructor) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#methods) * [alignment()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#alignment) * [fromValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#fromvalue) * [toValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeOpaqueUint8Array#tovalue) --- # CostModel | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/CostModel#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CostModel Class: CostModel ================ A cost model for calculating transaction fees Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CostModel#methods "Direct link to Methods") --------------------------------------------------------------------------------------------------------------------------- ### toString()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CostModel#tostring "Direct link to toString()") toString(compact?): string; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CostModel#parameters "Direct link to Parameters") ##### compact?[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CostModel#compact "Direct link to compact?") `boolean` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CostModel#returns "Direct link to Returns") `string` * * * ### initialCostModel()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CostModel#initialcostmodel "Direct link to initialCostModel()") static initialCostModel(): CostModel; The initial cost model of Midnight #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CostModel#returns-1 "Direct link to Returns") `CostModel` * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/CostModel#methods) * [toString()](https://docs.midnight.network/api-reference/compact-runtime/classes/CostModel#tostring) * [initialCostModel()](https://docs.midnight.network/api-reference/compact-runtime/classes/CostModel#initialcostmodel) --- # ContractOperation | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / ContractOperation Class: ContractOperation ======================== An individual operation, or entry point of a contract, consisting primarily of a ZK verifier keys, potentially for different versions of the proving system. Only the latest available version is exposed to this API. Note that the serialized form of the key is checked on initialization Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#constructors "Direct link to Constructors") -------------------------------------------------------------------------------------------------------------------------------------------------- ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#constructor "Direct link to Constructor") new ContractOperation(): ContractOperation; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#returns "Direct link to Returns") `ContractOperation` Properties[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#properties "Direct link to Properties") -------------------------------------------------------------------------------------------------------------------------------------------- ### verifierKey[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#verifierkey "Direct link to verifierKey") verifierKey: Uint8Array; Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#methods "Direct link to Methods") ----------------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#serialize "Direct link to serialize()") serialize(): Uint8Array; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#tostring "Direct link to toString()") toString(compact?): string; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#parameters "Direct link to Parameters") ##### compact?[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#compact "Direct link to compact?") `boolean` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#deserialize "Direct link to deserialize()") static deserialize(raw): ContractOperation; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#parameters-1 "Direct link to Parameters") ##### raw[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#raw "Direct link to raw") `Uint8Array` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#returns-3 "Direct link to Returns") `ContractOperation` * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#constructor) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#properties) * [verifierKey](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#verifierkey) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#methods) * [serialize()](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#serialize) * [toString()](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#tostring) * [deserialize()](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation#deserialize) --- # VmResults | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/VmResults#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / VmResults Class: VmResults ================ Represents the results of a VM call Properties[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmResults#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------ ### events[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmResults#events "Direct link to events") readonly events: GatherResult[]; The events that got emitted by this VM invocation * * * ### gasCost[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmResults#gascost "Direct link to gasCost") readonly gasCost: RunningCost; The computed gas cost of running this VM invocation * * * ### stack[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmResults#stack "Direct link to stack") readonly stack: VmStack; The VM stack at the end of the VM invocation Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmResults#methods "Direct link to Methods") --------------------------------------------------------------------------------------------------------------------------- ### toString()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmResults#tostring "Direct link to toString()") toString(compact?): string; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmResults#parameters "Direct link to Parameters") ##### compact?[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmResults#compact "Direct link to compact?") `boolean` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmResults#returns "Direct link to Returns") `string` * [Properties](https://docs.midnight.network/api-reference/compact-runtime/classes/VmResults#properties) * [events](https://docs.midnight.network/api-reference/compact-runtime/classes/VmResults#events) * [gasCost](https://docs.midnight.network/api-reference/compact-runtime/classes/VmResults#gascost) * [stack](https://docs.midnight.network/api-reference/compact-runtime/classes/VmResults#stack) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/VmResults#methods) * [toString()](https://docs.midnight.network/api-reference/compact-runtime/classes/VmResults#tostring) --- # QueryResults | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryResults#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / QueryResults Class: QueryResults =================== The results of making a query against a specific state or context Properties[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryResults#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------- ### context[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryResults#context "Direct link to context") readonly context: QueryContext; The context state after executing the query. This can be used to execute further queries * * * ### events[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryResults#events "Direct link to events") readonly events: GatherResult[]; Any events/results that occurred during or from the query * * * ### gasCost[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryResults#gascost "Direct link to gasCost") readonly gasCost: RunningCost; The measured cost of executing the query Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryResults#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------------ ### toString()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryResults#tostring "Direct link to toString()") toString(compact?): string; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryResults#parameters "Direct link to Parameters") ##### compact?[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryResults#compact "Direct link to compact?") `boolean` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryResults#returns "Direct link to Returns") `string` * [Properties](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryResults#properties) * [context](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryResults#context) * [events](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryResults#events) * [gasCost](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryResults#gascost) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryResults#methods) * [toString()](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryResults#tostring) --- # StateValue | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / StateValue Class: StateValue ================= Represents the core of a contract's state, and recursively represents each of its components. There are different _classes_ of state values: * `null` * Cells of [AlignedValue](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue) s * Maps from [AlignedValue](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue) s to state values * Bounded Merkle trees containing [AlignedValue](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue) leaves * Short (<= 15 element) arrays of state values State values are _immutable_, any operations that mutate states will return a new state instead. Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------------- ### arrayPush()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#arraypush "Direct link to arrayPush()") arrayPush(value): StateValue; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#parameters "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#value "Direct link to value") `StateValue` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#returns "Direct link to Returns") `StateValue` * * * ### asArray()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#asarray "Direct link to asArray()") asArray(): StateValue[] | undefined; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#returns-1 "Direct link to Returns") `StateValue`\[\] | `undefined` * * * ### asBoundedMerkleTree()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#asboundedmerkletree "Direct link to asBoundedMerkleTree()") asBoundedMerkleTree(): StateBoundedMerkleTree | undefined; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#returns-2 "Direct link to Returns") [`StateBoundedMerkleTree`](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree) | `undefined` * * * ### asCell()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#ascell "Direct link to asCell()") asCell(): AlignedValue; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#returns-3 "Direct link to Returns") [`AlignedValue`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue) * * * ### asMap()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#asmap "Direct link to asMap()") asMap(): StateMap | undefined; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#returns-4 "Direct link to Returns") [`StateMap`](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap) | `undefined` * * * ### encode()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#encode "Direct link to encode()") encode(): EncodedStateValue; **`Internal`** #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#returns-5 "Direct link to Returns") [`EncodedStateValue`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/EncodedStateValue) * * * ### logSize()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#logsize "Direct link to logSize()") logSize(): number; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#returns-6 "Direct link to Returns") `number` * * * ### toString()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#tostring "Direct link to toString()") toString(compact?): string; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#parameters-1 "Direct link to Parameters") ##### compact?[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#compact "Direct link to compact?") `boolean` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#returns-7 "Direct link to Returns") `string` * * * ### type()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#type "Direct link to type()") type(): "cell" | "map" | "array" | "null" | "boundedMerkleTree"; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#returns-8 "Direct link to Returns") `"cell"` | `"map"` | `"array"` | `"null"` | `"boundedMerkleTree"` * * * ### decode()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#decode "Direct link to decode()") static decode(value): StateValue; **`Internal`** #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#parameters-2 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#value-1 "Direct link to value") [`EncodedStateValue`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/EncodedStateValue) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#returns-9 "Direct link to Returns") `StateValue` * * * ### newArray()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#newarray "Direct link to newArray()") static newArray(): StateValue; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#returns-10 "Direct link to Returns") `StateValue` * * * ### newBoundedMerkleTree()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#newboundedmerkletree "Direct link to newBoundedMerkleTree()") static newBoundedMerkleTree(tree): StateValue; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#parameters-3 "Direct link to Parameters") ##### tree[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#tree "Direct link to tree") [`StateBoundedMerkleTree`](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#returns-11 "Direct link to Returns") `StateValue` * * * ### newCell()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#newcell "Direct link to newCell()") static newCell(value): StateValue; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#parameters-4 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#value-2 "Direct link to value") [`AlignedValue`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#returns-12 "Direct link to Returns") `StateValue` * * * ### newMap()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#newmap "Direct link to newMap()") static newMap(map): StateValue; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#parameters-5 "Direct link to Parameters") ##### map[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#map "Direct link to map") [`StateMap`](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#returns-13 "Direct link to Returns") `StateValue` * * * ### newNull()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#newnull "Direct link to newNull()") static newNull(): StateValue; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#returns-14 "Direct link to Returns") `StateValue` * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#methods) * [arrayPush()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#arraypush) * [asArray()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#asarray) * [asBoundedMerkleTree()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#asboundedmerkletree) * [asCell()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#ascell) * [asMap()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#asmap) * [encode()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#encode) * [logSize()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#logsize) * [toString()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#tostring) * [type()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#type) * [decode()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#decode) * [newArray()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#newarray) * [newBoundedMerkleTree()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#newboundedmerkletree) * [newCell()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#newcell) * [newMap()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#newmap) * [newNull()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue#newnull) --- # CompactTypeVector | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactTypeVector Class: CompactTypeVector =========================== Runtime type of the builtin `Vector` types Type Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#type-parameters "Direct link to Type Parameters") ----------------------------------------------------------------------------------------------------------------------------------------------------------- ### A[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#a "Direct link to A") `A` Implements[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#implements "Direct link to Implements") -------------------------------------------------------------------------------------------------------------------------------------------- * [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) <`A`\[\]> Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#constructors "Direct link to Constructors") -------------------------------------------------------------------------------------------------------------------------------------------------- ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#constructor "Direct link to Constructor") new CompactTypeVector(length, type): CompactTypeVector; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#parameters "Direct link to Parameters") ##### length[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#length "Direct link to length") `number` ##### type[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#type "Direct link to type") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) <`A`\> #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#returns "Direct link to Returns") `CompactTypeVector`<`A`\> Properties[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#properties "Direct link to Properties") -------------------------------------------------------------------------------------------------------------------------------------------- ### length[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#length-1 "Direct link to length") readonly length: number; * * * ### type[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#type-1 "Direct link to type") readonly type: CompactType; Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#methods "Direct link to Methods") ----------------------------------------------------------------------------------------------------------------------------------- ### alignment()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#alignment "Direct link to alignment()") alignment(): Alignment; The field-aligned binary alignment of this type. #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#returns-1 "Direct link to Returns") [`Alignment`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#implementation-of "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`alignment`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#alignment) * * * ### fromValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#fromvalue "Direct link to fromValue()") fromValue(value): A[]; Converts this type's field-aligned binary representation to its TypeScript representation destructively; (partially) consuming the input, and ignoring superflous data for chaining. #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#parameters-1 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#value "Direct link to value") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#returns-2 "Direct link to Returns") `A`\[\] #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#implementation-of-1 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`fromValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#fromvalue) * * * ### toValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#tovalue "Direct link to toValue()") toValue(value): Value; Converts this type's TypeScript representation to its field-aligned binary representation #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#parameters-2 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#value-1 "Direct link to value") `A`\[\] #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#returns-3 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#implementation-of-2 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`toValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#tovalue) * [Type Parameters](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#type-parameters) * [A](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#a) * [Implements](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#implements) * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#constructor) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#properties) * [length](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#length-1) * [type](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#type-1) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#methods) * [alignment()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#alignment) * [fromValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#fromvalue) * [toValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeVector#tovalue) --- # StateMap | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / StateMap Class: StateMap =============== Represents a key-value map, where keys are [AlignedValue](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue) s, and values are [StateValue](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue) s. Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#constructors "Direct link to Constructors") ----------------------------------------------------------------------------------------------------------------------------------------- ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#constructor "Direct link to Constructor") new StateMap(): StateMap; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#returns "Direct link to Returns") `StateMap` Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#methods "Direct link to Methods") -------------------------------------------------------------------------------------------------------------------------- ### get()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#get "Direct link to get()") get(key): StateValue | undefined; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#parameters "Direct link to Parameters") ##### key[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#key "Direct link to key") [`AlignedValue`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#returns-1 "Direct link to Returns") [`StateValue`](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue) | `undefined` * * * ### insert()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#insert "Direct link to insert()") insert(key, value): StateMap; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#parameters-1 "Direct link to Parameters") ##### key[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#key-1 "Direct link to key") [`AlignedValue`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue) ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#value "Direct link to value") [`StateValue`](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#returns-2 "Direct link to Returns") `StateMap` * * * ### keys()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#keys "Direct link to keys()") keys(): AlignedValue[]; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#returns-3 "Direct link to Returns") [`AlignedValue`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue) \[\] * * * ### remove()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#remove "Direct link to remove()") remove(key): StateMap; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#parameters-2 "Direct link to Parameters") ##### key[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#key-2 "Direct link to key") [`AlignedValue`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#returns-4 "Direct link to Returns") `StateMap` * * * ### toString()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#tostring "Direct link to toString()") toString(compact?): string; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#parameters-3 "Direct link to Parameters") ##### compact?[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#compact "Direct link to compact?") `boolean` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#returns-5 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#constructor) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#methods) * [get()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#get) * [insert()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#insert) * [keys()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#keys) * [remove()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#remove) * [toString()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateMap#tostring) --- # StateBoundedMerkleTree | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / StateBoundedMerkleTree Class: StateBoundedMerkleTree ============================= Represents a fixed-depth Merkle tree storing hashed data, whose preimages are unknown Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------------------- ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#constructor "Direct link to Constructor") new StateBoundedMerkleTree(height): StateBoundedMerkleTree; Create a blank tree with the given height #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#parameters "Direct link to Parameters") ##### height[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#height "Direct link to height") `number` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#returns "Direct link to Returns") `StateBoundedMerkleTree` Properties[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------------- ### height[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#height-1 "Direct link to height") readonly height: number; Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------------------------- ### collapse()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#collapse "Direct link to collapse()") collapse(start, end): StateBoundedMerkleTree; **`Internal`** Erases all but necessary hashes between, and inclusive of, `start` and `end` inidices #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#parameters-1 "Direct link to Parameters") ##### start[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#start "Direct link to start") `bigint` ##### end[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#end "Direct link to end") `bigint` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#returns-1 "Direct link to Returns") `StateBoundedMerkleTree` #### Throws[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#throws "Direct link to Throws") If the indices are out-of-bounds for the tree, or `end < start` * * * ### findPathForLeaf()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#findpathforleaf "Direct link to findPathForLeaf()") findPathForLeaf(leaf): AlignedValue | undefined; **`Internal`** Internal implementation of the finding path primitive. Returns undefined if the leaf is not in the tree. #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#parameters-2 "Direct link to Parameters") ##### leaf[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#leaf "Direct link to leaf") [`AlignedValue`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#returns-2 "Direct link to Returns") [`AlignedValue`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue) | `undefined` * * * ### pathForLeaf()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#pathforleaf "Direct link to pathForLeaf()") pathForLeaf(index, leaf): AlignedValue; **`Internal`** Internal implementation of the path construction primitive #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#parameters-3 "Direct link to Parameters") ##### index[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#index "Direct link to index") `bigint` ##### leaf[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#leaf-1 "Direct link to leaf") [`AlignedValue`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#returns-3 "Direct link to Returns") [`AlignedValue`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue) #### Throws[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#throws-1 "Direct link to Throws") If the index is out-of-bounds for the tree * * * ### rehash()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#rehash "Direct link to rehash()") rehash(): StateBoundedMerkleTree; Rehashes the tree, updating all internal hashes and ensuring all node hashes are present. Necessary because the onchain runtime does not automatically rehash trees. #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#returns-4 "Direct link to Returns") `StateBoundedMerkleTree` * * * ### root()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#root "Direct link to root()") root(): AlignedValue | undefined; **`Internal`** Internal implementation of the merkle tree root primitive. Returns undefined if the tree has not been fully hashed. #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#returns-5 "Direct link to Returns") [`AlignedValue`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue) | `undefined` * * * ### toString()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#tostring "Direct link to toString()") toString(compact?): string; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#parameters-4 "Direct link to Parameters") ##### compact?[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#compact "Direct link to compact?") `boolean` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#returns-6 "Direct link to Returns") `string` * * * ### update()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#update "Direct link to update()") update(index, leaf): StateBoundedMerkleTree; Inserts a value into the Merkle tree, returning the updated tree #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#parameters-5 "Direct link to Parameters") ##### index[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#index-1 "Direct link to index") `bigint` ##### leaf[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#leaf-2 "Direct link to leaf") [`AlignedValue`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#returns-7 "Direct link to Returns") `StateBoundedMerkleTree` #### Throws[​](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#throws-2 "Direct link to Throws") If the index is out-of-bounds for the tree * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#constructor) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#properties) * [height](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#height-1) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#methods) * [collapse()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#collapse) * [findPathForLeaf()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#findpathforleaf) * [pathForLeaf()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#pathforleaf) * [rehash()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#rehash) * [root()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#root) * [toString()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#tostring) * [update()](https://docs.midnight.network/api-reference/compact-runtime/classes/StateBoundedMerkleTree#update) --- # VmStack | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / VmStack Class: VmStack ============== Represents the state of the VM's stack at a specific point. The stack is an array of [StateValue](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue) s, each of which is also annotated with whether it is "strong" or "weak"; that is, whether it is permitted to be stored on-chain or not. Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------------- ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#constructor "Direct link to Constructor") new VmStack(): VmStack; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#returns "Direct link to Returns") `VmStack` Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------- ### get()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#get "Direct link to get()") get(idx): StateValue | undefined; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#parameters "Direct link to Parameters") ##### idx[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#idx "Direct link to idx") `number` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#returns-1 "Direct link to Returns") [`StateValue`](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue) | `undefined` * * * ### isStrong()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#isstrong "Direct link to isStrong()") isStrong(idx): boolean | undefined; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#parameters-1 "Direct link to Parameters") ##### idx[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#idx-1 "Direct link to idx") `number` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#returns-2 "Direct link to Returns") `boolean` | `undefined` * * * ### length()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#length "Direct link to length()") length(): number; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#returns-3 "Direct link to Returns") `number` * * * ### push()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#push "Direct link to push()") push(value, is_strong): void; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#parameters-2 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#value "Direct link to value") [`StateValue`](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue) ##### is\_strong[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#is_strong "Direct link to is_strong") `boolean` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#returns-4 "Direct link to Returns") `void` * * * ### removeLast()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#removelast "Direct link to removeLast()") removeLast(): void; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#returns-5 "Direct link to Returns") `void` * * * ### toString()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#tostring "Direct link to toString()") toString(compact?): string; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#parameters-3 "Direct link to Parameters") ##### compact?[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#compact "Direct link to compact?") `boolean` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#returns-6 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#constructor) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#methods) * [get()](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#get) * [isStrong()](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#isstrong) * [length()](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#length) * [push()](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#push) * [removeLast()](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#removelast) * [toString()](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack#tostring) --- # CompactTypeUnsignedInteger | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactTypeUnsignedInteger Class: CompactTypeUnsignedInteger ================================= Runtime type of the builtin `Unsigned Integer` types Implements[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#implements "Direct link to Implements") ----------------------------------------------------------------------------------------------------------------------------------------------------- * [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) <`bigint`\> Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#constructors "Direct link to Constructors") ----------------------------------------------------------------------------------------------------------------------------------------------------------- ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#constructor "Direct link to Constructor") new CompactTypeUnsignedInteger(maxValue, length): CompactTypeUnsignedInteger; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#parameters "Direct link to Parameters") ##### maxValue[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#maxvalue "Direct link to maxValue") `bigint` ##### length[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#length "Direct link to length") `number` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#returns "Direct link to Returns") `CompactTypeUnsignedInteger` Properties[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#properties "Direct link to Properties") ----------------------------------------------------------------------------------------------------------------------------------------------------- ### length[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#length-1 "Direct link to length") readonly length: number; * * * ### maxValue[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#maxvalue-1 "Direct link to maxValue") readonly maxValue: bigint; Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#methods "Direct link to Methods") -------------------------------------------------------------------------------------------------------------------------------------------- ### alignment()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#alignment "Direct link to alignment()") alignment(): Alignment; The field-aligned binary alignment of this type. #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#returns-1 "Direct link to Returns") [`Alignment`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#implementation-of "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`alignment`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#alignment) * * * ### fromValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#fromvalue "Direct link to fromValue()") fromValue(value): bigint; Converts this type's field-aligned binary representation to its TypeScript representation destructively; (partially) consuming the input, and ignoring superflous data for chaining. #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#parameters-1 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#value "Direct link to value") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#returns-2 "Direct link to Returns") `bigint` #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#implementation-of-1 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`fromValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#fromvalue) * * * ### toValue()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#tovalue "Direct link to toValue()") toValue(value): Value; Converts this type's TypeScript representation to its field-aligned binary representation #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#parameters-2 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#value-1 "Direct link to value") `bigint` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#returns-3 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Implementation of[​](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#implementation-of-2 "Direct link to Implementation of") [`CompactType`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType) .[`toValue`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#tovalue) * [Implements](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#implements) * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#constructor) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#properties) * [length](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#length-1) * [maxValue](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#maxvalue-1) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#methods) * [alignment()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#alignment) * [fromValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#fromvalue) * [toValue()](https://docs.midnight.network/api-reference/compact-runtime/classes/CompactTypeUnsignedInteger#tovalue) --- # QueryContext | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / QueryContext Class: QueryContext =================== Provides the information needed to fully process a transaction, including information about the rest of the transaction, and the state of the chain at the time of execution. Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#constructors "Direct link to Constructors") --------------------------------------------------------------------------------------------------------------------------------------------- ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#constructor "Direct link to Constructor") new QueryContext(state, address): QueryContext; Construct a basic context from a contract's address and current state value #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#parameters "Direct link to Parameters") ##### state[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#state "Direct link to state") [`ChargedState`](https://docs.midnight.network/api-reference/compact-runtime/classes/ChargedState) ##### address[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#address "Direct link to address") `string` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#returns "Direct link to Returns") `QueryContext` Properties[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------- ### address[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#address-1 "Direct link to address") readonly address: string; The address of the contract * * * ### block[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#block "Direct link to block") block: CallContext; The block-level information accessible to the contract * * * ### comIndices[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#comindices "Direct link to comIndices") readonly comIndices: Map; The commitment indices map accessible to the contract, primarily via [qualify](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#qualify) * * * ### effects[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#effects "Direct link to effects") effects: Effects; The effects that occurred during execution against this context, should match those declared in a [Transcript](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Transcript) * * * ### state[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#state-1 "Direct link to state") readonly state: ChargedState; The current contract state retained in the context Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------------ ### insertCommitment()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#insertcommitment "Direct link to insertCommitment()") insertCommitment(comm, index): QueryContext; Register a given coin commitment as being accessible at a specific index, for use when receiving coins in-contract, and needing to record their index to later spend them #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#parameters-1 "Direct link to Parameters") ##### comm[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#comm "Direct link to comm") `string` ##### index[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#index "Direct link to index") `bigint` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#returns-1 "Direct link to Returns") `QueryContext` * * * ### qualify()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#qualify "Direct link to qualify()") qualify(coin): Value | undefined; **`Internal`** Internal counterpart to [insertCommitment](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#insertcommitment) ; upgrades an encoded [ShieldedCoinInfo](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ShieldedCoinInfo) to an encoded [QualifiedShieldedCoinInfo](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedShieldedCoinInfo) using the inserted commitments #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#parameters-2 "Direct link to Parameters") ##### coin[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#coin "Direct link to coin") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#returns-2 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) | `undefined` * * * ### query()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#query "Direct link to query()") query( ops, cost_model, gas_limit?): QueryResults; Runs a sequence of operations in gather mode, returning the results of the gather. #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#parameters-3 "Direct link to Parameters") ##### ops[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#ops "Direct link to ops") [`Op`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Op) <`null`\>\[\] ##### cost\_model[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#cost_model "Direct link to cost_model") [`CostModel`](https://docs.midnight.network/api-reference/compact-runtime/classes/CostModel) ##### gas\_limit?[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#gas_limit "Direct link to gas_limit?") [`RunningCost`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/RunningCost) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#returns-3 "Direct link to Returns") [`QueryResults`](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryResults) * * * ### runTranscript()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#runtranscript "Direct link to runTranscript()") runTranscript(transcript, cost_model): QueryContext; Runs a transcript in verifying mode against the current query context, outputting a new query context, with the [state](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#state) and [effects](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#effects) from after the execution. #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#parameters-4 "Direct link to Parameters") ##### transcript[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#transcript "Direct link to transcript") [`Transcript`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Transcript) <[`AlignedValue`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue) \> ##### cost\_model[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#cost_model-1 "Direct link to cost_model") [`CostModel`](https://docs.midnight.network/api-reference/compact-runtime/classes/CostModel) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#returns-4 "Direct link to Returns") `QueryContext` * * * ### toString()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#tostring "Direct link to toString()") toString(compact?): string; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#parameters-5 "Direct link to Parameters") ##### compact?[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#compact "Direct link to compact?") `boolean` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#returns-5 "Direct link to Returns") `string` * * * ### toVmStack()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#tovmstack "Direct link to toVmStack()") toVmStack(): VmStack; Converts the QueryContext to [VmStack](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack) . #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#returns-6 "Direct link to Returns") [`VmStack`](https://docs.midnight.network/api-reference/compact-runtime/classes/VmStack) * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#constructor) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#properties) * [address](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#address-1) * [block](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#block) * [comIndices](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#comindices) * [effects](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#effects) * [state](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#state-1) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#methods) * [insertCommitment()](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#insertcommitment) * [qualify()](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#qualify) * [query()](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#query) * [runTranscript()](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#runtranscript) * [toString()](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#tostring) * [toVmStack()](https://docs.midnight.network/api-reference/compact-runtime/classes/QueryContext#tovmstack) --- # ContractState | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / ContractState Class: ContractState ==================== The state of a contract, consisting primarily of the [data](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#data) accessible directly to the contract, and the map of [ContractOperation](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation) s that can be called on it, the keys of which can be accessed with [operations](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#operations) , and the individual operations can be read with [operation](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#operation) and written to with [setOperation](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#setoperation) . Constructors[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------------------- ### Constructor[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#constructor "Direct link to Constructor") new ContractState(): ContractState; Creates a blank contract state #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#returns "Direct link to Returns") `ContractState` Properties[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------------- ### balance[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#balance "Direct link to balance") balance: Map; The public balances held by this contract * * * ### data[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#data "Direct link to data") data: ChargedState; The current value of the primary state of the contract * * * ### maintenanceAuthority[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#maintenanceauthority "Direct link to maintenanceAuthority") maintenanceAuthority: ContractMaintenanceAuthority; The maintenance authority associated with this contract Methods[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------------- ### operation()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#operation "Direct link to operation()") operation(operation): ContractOperation | undefined; Get the operation at a specific entry point name #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#parameters "Direct link to Parameters") ##### operation[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#operation-1 "Direct link to operation") `string` | `Uint8Array`<`ArrayBufferLike`\> #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#returns-1 "Direct link to Returns") [`ContractOperation`](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation) | `undefined` * * * ### operations()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#operations "Direct link to operations()") operations(): (string | Uint8Array)[]; Return a list of the entry points currently registered on this contract #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#returns-2 "Direct link to Returns") (`string` | `Uint8Array`<`ArrayBufferLike`\>)\[\] * * * ### query()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#query "Direct link to query()") query(query, cost_model): GatherResult[]; Runs a series of operations against the current state, and returns the results #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#parameters-1 "Direct link to Parameters") ##### query[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#query-1 "Direct link to query") [`Op`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Op) <`null`\>\[\] ##### cost\_model[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#cost_model "Direct link to cost_model") [`CostModel`](https://docs.midnight.network/api-reference/compact-runtime/classes/CostModel) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#returns-3 "Direct link to Returns") [`GatherResult`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/GatherResult) \[\] * * * ### serialize()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#serialize "Direct link to serialize()") serialize(): Uint8Array; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#returns-4 "Direct link to Returns") `Uint8Array` * * * ### setOperation()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#setoperation "Direct link to setOperation()") setOperation(operation, value): void; Set a specific entry point name to contain a given operation #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#parameters-2 "Direct link to Parameters") ##### operation[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#operation-2 "Direct link to operation") `string` | `Uint8Array`<`ArrayBufferLike`\> ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#value "Direct link to value") [`ContractOperation`](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractOperation) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#returns-5 "Direct link to Returns") `void` * * * ### toString()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#tostring "Direct link to toString()") toString(compact?): string; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#parameters-3 "Direct link to Parameters") ##### compact?[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#compact "Direct link to compact?") `boolean` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#returns-6 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#deserialize "Direct link to deserialize()") static deserialize(raw): ContractState; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#parameters-4 "Direct link to Parameters") ##### raw[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#raw "Direct link to raw") `Uint8Array` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#returns-7 "Direct link to Returns") `ContractState` * [Constructors](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#constructors) * [Constructor](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#constructor) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#properties) * [balance](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#balance) * [data](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#data) * [maintenanceAuthority](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#maintenanceauthority) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#methods) * [operation()](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#operation) * [operations()](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#operations) * [query()](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#query) * [serialize()](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#serialize) * [setOperation()](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#setoperation) * [toString()](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#tostring) * [deserialize()](https://docs.midnight.network/api-reference/compact-runtime/classes/ContractState#deserialize) --- # ErrorCodes | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/dapp-connector/variables/ErrorCodes#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/dapp-connector-api v3.0.0**](https://docs.midnight.network/api-reference/dapp-connector) * * * [@midnight-ntwrk/dapp-connector-api](https://docs.midnight.network/api-reference/dapp-connector/globals) / ErrorCodes Variable: ErrorCodes ==================== > `const` **ErrorCodes**: `object` The following error codes can be thrown by the dapp connector. Type declaration[​](https://docs.midnight.network/api-reference/dapp-connector/variables/ErrorCodes#type-declaration "Direct link to Type declaration") -------------------------------------------------------------------------------------------------------------------------------------------------------- ### InternalError[​](https://docs.midnight.network/api-reference/dapp-connector/variables/ErrorCodes#internalerror "Direct link to InternalError") > `readonly` **InternalError**: `"InternalError"` = `'InternalError'` The dapp connector wasn't able to process the request ### InvalidRequest[​](https://docs.midnight.network/api-reference/dapp-connector/variables/ErrorCodes#invalidrequest "Direct link to InvalidRequest") > `readonly` **InvalidRequest**: `"InvalidRequest"` = `'InvalidRequest'` Can be thrown in various circumstances, e.g. one being a malformed transaction ### Rejected[​](https://docs.midnight.network/api-reference/dapp-connector/variables/ErrorCodes#rejected "Direct link to Rejected") > `readonly` **Rejected**: `"Rejected"` = `'Rejected'` The user rejected the request * [Type declaration](https://docs.midnight.network/api-reference/dapp-connector/variables/ErrorCodes#type-declaration) * [InternalError](https://docs.midnight.network/api-reference/dapp-connector/variables/ErrorCodes#internalerror) * [InvalidRequest](https://docs.midnight.network/api-reference/dapp-connector/variables/ErrorCodes#invalidrequest) * [Rejected](https://docs.midnight.network/api-reference/dapp-connector/variables/ErrorCodes#rejected) --- # APIError | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/dapp-connector-api v3.0.0**](https://docs.midnight.network/api-reference/dapp-connector) * * * [@midnight-ntwrk/dapp-connector-api](https://docs.midnight.network/api-reference/dapp-connector/globals) / APIError Class: APIError =============== Whenever there's a function called that returns a promise, an error with the shape can be thrown. Extends[​](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError#extends "Direct link to Extends") ------------------------------------------------------------------------------------------------------------------------- * `CustomError` Constructors[​](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------------- ### new APIError()[​](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError#new-apierror "Direct link to new APIError()") > **new APIError**(`code`, `reason`): [`APIError`](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError) #### Parameters[​](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError#parameters "Direct link to Parameters") ##### code[​](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError#code "Direct link to code") [`ErrorCode`](https://docs.midnight.network/api-reference/dapp-connector/type-aliases/ErrorCode) ##### reason[​](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError#reason "Direct link to reason") `string` #### Returns[​](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError#returns "Direct link to Returns") [`APIError`](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError) #### Overrides[​](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError#overrides "Direct link to Overrides") `CustomError.constructor` Properties[​](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------- ### code[​](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError#code-1 "Direct link to code") > **code**: [`ErrorCode`](https://docs.midnight.network/api-reference/dapp-connector/type-aliases/ErrorCode) The code of the error that's thrown * * * ### reason[​](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError#reason-1 "Direct link to reason") > **reason**: `string` The reason the error is thrown * [Extends](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError#extends) * [Constructors](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError#constructors) * [new APIError()](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError#new-apierror) * [Properties](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError#properties) * [code](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError#code-1) * [reason](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError#reason-1) --- # ErrorCode | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/dapp-connector/type-aliases/ErrorCode#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/dapp-connector-api v3.0.0**](https://docs.midnight.network/api-reference/dapp-connector) * * * [@midnight-ntwrk/dapp-connector-api](https://docs.midnight.network/api-reference/dapp-connector/globals) / ErrorCode Type Alias: ErrorCode ===================== > **ErrorCode**: _typeof_ [`ErrorCodes`](https://docs.midnight.network/api-reference/dapp-connector/variables/ErrorCodes) > \[keyof _typeof_ [`ErrorCodes`](https://docs.midnight.network/api-reference/dapp-connector/variables/ErrorCodes)\ > \] ErrorCode type definition --- # globals | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/dapp-connector/globals#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/dapp-connector-api v3.0.0**](https://docs.midnight.network/api-reference/dapp-connector) * * * @midnight-ntwrk/dapp-connector-api v3.0.0 ========================================= Classes[​](https://docs.midnight.network/api-reference/dapp-connector/globals#classes "Direct link to Classes") ---------------------------------------------------------------------------------------------------------------- * [APIError](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError) Interfaces[​](https://docs.midnight.network/api-reference/dapp-connector/globals#interfaces "Direct link to Interfaces") ------------------------------------------------------------------------------------------------------------------------- * [DAppConnectorAPI](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorAPI) * [DAppConnectorWalletAPI](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI) * [DAppConnectorWalletState](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState) * [ServiceUriConfig](https://docs.midnight.network/api-reference/dapp-connector/interfaces/ServiceUriConfig) Type Aliases[​](https://docs.midnight.network/api-reference/dapp-connector/globals#type-aliases "Direct link to Type Aliases") ------------------------------------------------------------------------------------------------------------------------------- * [ErrorCode](https://docs.midnight.network/api-reference/dapp-connector/type-aliases/ErrorCode) Variables[​](https://docs.midnight.network/api-reference/dapp-connector/globals#variables "Direct link to Variables") ---------------------------------------------------------------------------------------------------------------------- * [ErrorCodes](https://docs.midnight.network/api-reference/dapp-connector/variables/ErrorCodes) * [Classes](https://docs.midnight.network/api-reference/dapp-connector/globals#classes) * [Interfaces](https://docs.midnight.network/api-reference/dapp-connector/globals#interfaces) * [Type Aliases](https://docs.midnight.network/api-reference/dapp-connector/globals#type-aliases) * [Variables](https://docs.midnight.network/api-reference/dapp-connector/globals#variables) --- # ServiceUriConfig | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/dapp-connector/interfaces/ServiceUriConfig#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/dapp-connector-api v3.0.0**](https://docs.midnight.network/api-reference/dapp-connector) * * * [@midnight-ntwrk/dapp-connector-api](https://docs.midnight.network/api-reference/dapp-connector/globals) / ServiceUriConfig Interface: ServiceUriConfig =========================== The services configuration Properties[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/ServiceUriConfig#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------------- ### indexerUri[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/ServiceUriConfig#indexeruri "Direct link to indexerUri") > **indexerUri**: `string` Indexer URI * * * ### indexerWsUri[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/ServiceUriConfig#indexerwsuri "Direct link to indexerWsUri") > **indexerWsUri**: `string` Indexer WebSocket URI * * * ### proverServerUri[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/ServiceUriConfig#proverserveruri "Direct link to proverServerUri") > **proverServerUri**: `string` Prover Server URI * * * ### substrateNodeUri[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/ServiceUriConfig#substratenodeuri "Direct link to substrateNodeUri") > **substrateNodeUri**: `string` Substrate URI * [Properties](https://docs.midnight.network/api-reference/dapp-connector/interfaces/ServiceUriConfig#properties) * [indexerUri](https://docs.midnight.network/api-reference/dapp-connector/interfaces/ServiceUriConfig#indexeruri) * [indexerWsUri](https://docs.midnight.network/api-reference/dapp-connector/interfaces/ServiceUriConfig#indexerwsuri) * [proverServerUri](https://docs.midnight.network/api-reference/dapp-connector/interfaces/ServiceUriConfig#proverserveruri) * [substrateNodeUri](https://docs.midnight.network/api-reference/dapp-connector/interfaces/ServiceUriConfig#substratenodeuri) --- # DAppConnectorAPI | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorAPI#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/dapp-connector-api v3.0.0**](https://docs.midnight.network/api-reference/dapp-connector) * * * [@midnight-ntwrk/dapp-connector-api](https://docs.midnight.network/api-reference/dapp-connector/globals) / DAppConnectorAPI Interface: DAppConnectorAPI =========================== DApp Connector API Definition When errors occur in functions returning a promise, they should be thrown in the form of an [APIError](https://docs.midnight.network/api-reference/dapp-connector/classes/APIError) . Properties[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorAPI#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------------- ### apiVersion[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorAPI#apiversion "Direct link to apiVersion") > **apiVersion**: `string` Semver string. DApps are encouraged to check the compatibility whenever this changes. * * * ### enable()[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorAPI#enable "Direct link to enable()") > **enable**: () => `Promise`<[`DAppConnectorWalletAPI`](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI) > \> Request access to the wallet, returns the wallet api on approval #### Returns[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorAPI#returns "Direct link to Returns") `Promise`<[`DAppConnectorWalletAPI`](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI) \> * * * ### isEnabled()[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorAPI#isenabled "Direct link to isEnabled()") > **isEnabled**: () => `Promise`<`boolean`\> Check if the wallet has authorized the dapp #### Returns[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorAPI#returns-1 "Direct link to Returns") `Promise`<`boolean`\> * * * ### name[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorAPI#name "Direct link to name") > **name**: `string` The name of the wallet * * * ### serviceUriConfig()[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorAPI#serviceuriconfig "Direct link to serviceUriConfig()") > **serviceUriConfig**: () => `Promise`<[`ServiceUriConfig`](https://docs.midnight.network/api-reference/dapp-connector/interfaces/ServiceUriConfig) > \> Request the services (indexer, node, and proof server) URIs. #### Returns[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorAPI#returns-2 "Direct link to Returns") `Promise`<[`ServiceUriConfig`](https://docs.midnight.network/api-reference/dapp-connector/interfaces/ServiceUriConfig) \> * [Properties](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorAPI#properties) * [apiVersion](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorAPI#apiversion) * [enable()](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorAPI#enable) * [isEnabled()](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorAPI#isenabled) * [name](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorAPI#name) * [serviceUriConfig()](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorAPI#serviceuriconfig) --- # DAppConnectorWalletState | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/dapp-connector-api v3.0.0**](https://docs.midnight.network/api-reference/dapp-connector) * * * [@midnight-ntwrk/dapp-connector-api](https://docs.midnight.network/api-reference/dapp-connector/globals) / DAppConnectorWalletState Interface: DAppConnectorWalletState =================================== The shape of the wallet state that must be exposed Properties[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState#properties "Direct link to Properties") ----------------------------------------------------------------------------------------------------------------------------------------------------- ### address[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState#address "Direct link to address") > **address**: `string` The bech32m encoded address * * * ### ~addressLegacy~[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState#addresslegacy "Direct link to addresslegacy") > **addressLegacy**: `string` #### Deprecated[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState#deprecated "Direct link to Deprecated") please use the `address` field instead. The wallet address, which is a concatenation of coinPublicKey and encryptionPublicKey * * * ### coinPublicKey[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState#coinpublickey "Direct link to coinPublicKey") > **coinPublicKey**: `string` The bech32m encoded coin public key * * * ### ~coinPublicKeyLegacy~[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState#coinpublickeylegacy "Direct link to coinpublickeylegacy") > **coinPublicKeyLegacy**: `string` #### Deprecated[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState#deprecated-1 "Direct link to Deprecated") please use the `coinPublicKey` field instead. The hex encoded coin public key * * * ### encryptionPublicKey[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState#encryptionpublickey "Direct link to encryptionPublicKey") > **encryptionPublicKey**: `string` The bech32m encoded encryption public key * * * ### ~encryptionPublicKeyLegacy~[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState#encryptionpublickeylegacy "Direct link to encryptionpublickeylegacy") > **encryptionPublicKeyLegacy**: `string` #### Deprecated[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState#deprecated-2 "Direct link to Deprecated") please use the `encryptionPublicKey` field instead. The hex encoded encryption public key * [Properties](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState#properties) * [address](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState#address) * [~addressLegacy~](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState#addresslegacy) * [coinPublicKey](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState#coinpublickey) * [~coinPublicKeyLegacy~](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState#coinpublickeylegacy) * [encryptionPublicKey](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState#encryptionpublickey) * [~encryptionPublicKeyLegacy~](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState#encryptionpublickeylegacy) --- # DAppConnectorWalletAPI | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/dapp-connector-api v3.0.0**](https://docs.midnight.network/api-reference/dapp-connector) * * * [@midnight-ntwrk/dapp-connector-api](https://docs.midnight.network/api-reference/dapp-connector/globals) / DAppConnectorWalletAPI Interface: DAppConnectorWalletAPI ================================= Shape of the Wallet API in the DApp Connector Properties[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------------------- ### balanceAndProveTransaction()[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#balanceandprovetransaction "Direct link to balanceAndProveTransaction()") > **balanceAndProveTransaction**: (`tx`, `newCoins`) => `Promise`<`Transaction`\> It will try to balance given transaction and prove it #### Parameters[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#parameters "Direct link to Parameters") ##### tx[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#tx "Direct link to tx") `Transaction` Transaction to balance ##### newCoins[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#newcoins "Direct link to newCoins") `CoinInfo`\[\] New coins created by transaction, for which wallet will watch for #### Returns[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#returns "Direct link to Returns") `Promise`<`Transaction`\> Proved transaction or error * * * ### ~balanceTransaction()~[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#balancetransaction "Direct link to balancetransaction") > **balanceTransaction**: (`tx`, `newCoins`) => `Promise`<`BalanceTransactionToProve` | `NothingToProve`\> Balances the provided transaction. #### Parameters[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#parameters-1 "Direct link to Parameters") ##### tx[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#tx-1 "Direct link to tx") `Transaction` Transaction to balance ##### newCoins[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#newcoins-1 "Direct link to newCoins") `CoinInfo`\[\] CoinInfo array of coins created by the transaction, which the wallet will watch for and apply to the state The `newCoins` parameter should be used in cases where a new coin is created (for example, a DApp mints a coin and wants to send it to the wallet). Because of how Midnight works, newly created coins must be explicitly sent to the wallet using this method. This allows the wallet to monitor them and incorporate them into its state. #### Returns[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#returns-1 "Direct link to Returns") `Promise`<`BalanceTransactionToProve` | `NothingToProve`\> BalanceTransactionToProve or NothingToProve recipe (for the already balanced transaction) or error. #### Remarks[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#remarks "Direct link to Remarks") Balancing a transaction means that for any given output and transaction fees, the wallet will take the available coins from the state to cover them. #### Deprecated[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#deprecated "Direct link to Deprecated") Deprecated since version 1.1.0 and will be removed in version 2.0.0. Please use the `balanceAndProveTransaction` method instead. * * * ### ~proveTransaction()~[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#provetransaction "Direct link to provetransaction") > **proveTransaction**: (`recipe`) => `Promise`<`Transaction`\> Calls the proving server with the proving recipe and returns the proven transaction or error. #### Parameters[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#parameters-2 "Direct link to Parameters") ##### recipe[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#recipe "Direct link to recipe") `ProvingRecipe` ProvingRecipe with data to prove #### Returns[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#returns-2 "Direct link to Returns") `Promise`<`Transaction`\> Transaction or error #### Remarks[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#remarks-1 "Direct link to Remarks") * Proof generation takes time and resources, therefore depending on the user's computer specs, this can be an expensive operation * There can be wallet implementations that do not need to support proving, in which case this method should return an error #### Deprecated[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#deprecated-1 "Direct link to Deprecated") Deprecated since version 1.1.0 and will be removed in version 2.0.0. Please use the `balanceAndProveTransaction` method instead. * * * ### state()[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#state "Direct link to state()") > **state**: () => `Promise`<[`DAppConnectorWalletState`](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState) > \> Returns a promise with the exposed wallet state #### Returns[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#returns-3 "Direct link to Returns") `Promise`<[`DAppConnectorWalletState`](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletState) \> * * * ### submitTransaction()[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#submittransaction "Direct link to submitTransaction()") > **submitTransaction**: (`tx`) => `Promise`<`string`\> It will submit given transaction to the node Submits the provided transaction to the node #### Parameters[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#parameters-3 "Direct link to Parameters") ##### tx[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#tx-2 "Direct link to tx") `Transaction` Transaction to submit #### Returns[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#returns-4 "Direct link to Returns") `Promise`<`string`\> TransactionIdentifier - First transaction identifier from identifiers list or error #### Param[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#param "Direct link to Param") Transaction to submit #### Returns[​](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#returns-5 "Direct link to Returns") First transaction identifier from identifiers list or error * [Properties](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#properties) * [balanceAndProveTransaction()](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#balanceandprovetransaction) * [~balanceTransaction()~](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#balancetransaction) * [~proveTransaction()~](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#provetransaction) * [state()](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#state) * [submitTransaction()](https://docs.midnight.network/api-reference/dapp-connector/interfaces/DAppConnectorWalletAPI#submittransaction) --- # NetworkId | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / NetworkId Enumeration: NetworkId ====================== The network currently being targeted Enumeration Members[​](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId#enumeration-members "Direct link to Enumeration Members") ----------------------------------------------------------------------------------------------------------------------------------------------------------- ### DevNet[​](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId#devnet "Direct link to DevNet") DevNet: 1; A developer network, not guaranteed to be persistent * * * ### MainNet[​](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId#mainnet "Direct link to MainNet") MainNet: 3; The Midnight mainnet * * * ### TestNet[​](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId#testnet "Direct link to TestNet") TestNet: 2; A persistent testnet * * * ### Undeployed[​](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId#undeployed "Direct link to Undeployed") Undeployed: 0; A local test network * [Enumeration Members](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId#enumeration-members) * [DevNet](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId#devnet) * [MainNet](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId#mainnet) * [TestNet](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId#testnet) * [Undeployed](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId#undeployed) --- # Midnight DApp connector API | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/dapp-connector#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/dapp-connector-api v4.0.0** * * * This API provides a comprehensive interface for connecting Decentralized Applications (DApps) to Midnight wallets. It defines the methods, data structures, and operations that enable DApps to request wallet information, create transactions, and interact with the Midnight Network. Installation[​](https://docs.midnight.network/api-reference/dapp-connector#installation "Direct link to Installation") ----------------------------------------------------------------------------------------------------------------------- The Midnight DApp connector API is available as an NPM package with the namespace `@midnight-ntwrk/dapp-connector-api`. It can be installed using any node package manager, such as Yarn. To install the package using Yarn, execute the following command: yarn add @midnight-ntwrk/dapp-connector-api Package usage[​](https://docs.midnight.network/api-reference/dapp-connector#package-usage "Direct link to Package usage") -------------------------------------------------------------------------------------------------------------------------- The package provides the type declarations that are documented in the [documentation](https://docs.midnight.network/api-reference/type-aliases/InitialAPI.md) of this package. The DApp connector API should be exposed through the global variable as follows: window.midnight.{someWalletIdString} In this way multiple wallets can inject their API without causing conflicts, and a DApp can select/ask the user to which wallet connection should be established. Initial API data and methods[​](https://docs.midnight.network/api-reference/dapp-connector#initial-api-data-and-methods "Direct link to Initial API data and methods") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | Name | Description | | --- | --- | | **name** | Wallet name, expected to be displayed to the user. | | **icon** | Wallet icon, as an URL, either reference to a hosted resource, or a base64 encoded data URL. | | **apiVersion** | Version of the API implemented by this instance of the API. For example, wallet implementing version 3.1.5 provides apiVersion with value '3.1.5'. This value lets DApps to differentiate between different versions of the API and implement appropriate logic for each version or not use some versions at all. | | **connect** | Connect to wallet, passing the desired network ID as a parameter. Upon successful connection returns a promise with [ConnectedAPI](https://docs.midnight.network/api-reference/type-aliases/ConnectedAPI.md)
. | Connect to a wallet[​](https://docs.midnight.network/api-reference/dapp-connector#connect-to-a-wallet "Direct link to Connect to a wallet") -------------------------------------------------------------------------------------------------------------------------------------------- A DApp needs to select the wallet it wants to connect to and call the `connect(networkId)` method, then wait for the returned promise. The promise may resolve with a significant delay, as most wallets might want to display a dialog asking the user for authorization. try { const desiredNetworkId = 'mainnet' const api = await window.midnight.{selectedWalletId}.connect('mainnet'); // api is available here} catch (error) { console.log('an error occurred', error);} Get information about the wallet before connection[​](https://docs.midnight.network/api-reference/dapp-connector#get-information-about-the-wallet-before-connection "Direct link to Get information about the wallet before connection") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Before establishing a connection, you can access basic wallet information such as the wallet name, icon, and API version. ### Name and icon[​](https://docs.midnight.network/api-reference/dapp-connector#name-and-icon "Direct link to Name and icon") To get the name and icon of the wallet, use the `name` and `icon` properties in the implemented DApp connector API: const name = window.midnight.{walletName}.name;const iconURL = window.midnight.{walletName}.icon;console.log('Wallet name', name);console.log('Wallet icon URL', iconURL); Both fields are meant to be displayed to the user to help with wallet selection. To prevent XSS vulnerabilities, the DApp must ensure proper escaping. For example, display the icon only through an `img` tag and display the name using a `Text` node. ### Get API version[​](https://docs.midnight.network/api-reference/dapp-connector#get-api-version "Direct link to Get API version") To get the API version, use the `apiVersion` property as follows: const apiVersion = window.midnight.{walletName}.apiVersion;console.log('API version', apiVersion); The DApp needs to verify whether the version reported by the wallet matches the DApp's expectations. Use a semver check to validate compatibility. Query wallet state and initiate transactions[​](https://docs.midnight.network/api-reference/dapp-connector#query-wallet-state-and-initiate-transactions "Direct link to Query wallet state and initiate transactions") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Once connected, the DApp can issue many different requests to the wallet as defined by the [ConnectedAPI](https://docs.midnight.network/api-reference/type-aliases/ConnectedAPI.md) type. The most important operations are: * Query the wallet for information, like balances or addresses. * Query the wallet for configuration, so that the DApp can connect to the same instance of Indexer, Midnight Node, or Proof Server. * Ask the wallet to make a transfer, balance a transaction, make an unbalanced intent (for example, for a swap), or sign data. * Ask the wallet to submit a transaction. ### Get the configuration[​](https://docs.midnight.network/api-reference/dapp-connector#get-the-configuration "Direct link to Get the configuration") Midnight wallet users can configure the node, indexer, and proving server URIs in the wallet settings. DApps are expected to follow these configurations to respect user preferences. This is important from a privacy standpoint. The returned object has the following properties: | Name | Description | | --- | --- | | **indexerUri** | Indexer HTTP URI | | **indexerWsUri** | Indexer WebSocket URI | | **proverServerUri** | Prover Server URI | | **substrateNodeUri** | Substrate URI | | **networkId** | Network ID connected to - present here mostly for completeness and to allow the DApp to validate it is connected to the network it wishes to. | To get the service URI config, use the API as follows: try { const connected = await window.midnight.{selectedWalletId}.connect(); const serviceUriConfig = await connected.getConfiguration(); console.log('serviceUriConfig', serviceUriConfig);} catch (error) { console.log('an error occurred', error);} ### Read wallet information[​](https://docs.midnight.network/api-reference/dapp-connector#read-wallet-information "Direct link to Read wallet information") Several methods are available for querying wallet state. The most important ones are `getShieldedBalances`, `getUnshieldedBalances`, `getDustBalance`, `getShieldedAddresses`, `getUnshieldedAddress`, and `getDustAddress`. Keys and addresses are provided in Bech32m format. Shielded and unshielded balances return a record whose keys are token types. try { const connected = await window.midnight.{selectedWalletId}.connect(); const addressesAndBalances = { shieldedBalances: await connected.getShieldedBalances(), unshieldedBalances: await connected.getUnshieldedBalances(), dustBalance: await connected.getDustBalance(), shieldedAddresses: await connected.getShieldedAddresses(), unshieldedAddress: await connected.getUnshieldedAddress(), dustAddress: await connected.getDustAddress(), } console.log('addressesAndBalances', addressesAndBalances);} catch (error) { console.log('an error occurred', error);} ### Initiate a payment[​](https://docs.midnight.network/api-reference/dapp-connector#initiate-a-payment "Direct link to Initiate a payment") If a DApp needs to initiate a payment, `makeTransfer` is the right method to use. It takes an array of outputs that need to be present in the final transaction. For more details, see the [InitActions type documentation](https://docs.midnight.network/api-reference/type-aliases/InitActions.md) . import {nativeToken} from '@midnight-ntwrk/ledger'try { const connected = await window.midnight.{selectedWalletId}.connect(); const transaction = await connected.makeTransfer([{ kind: 'unshielded', tokenType: nativeToken().raw, value: 10n**6n, recipient: 'mn_addr1abcdef.....' }]);} catch (error) { console.log('an error occurred', error);} ### Balance a transaction[​](https://docs.midnight.network/api-reference/dapp-connector#balance-a-transaction "Direct link to Balance a transaction") To balance a transaction, begin by creating a transaction in your DApp. For transaction creation, see the [Wallet Developer Guide](https://docs.midnight.network/sdks/official/wallet-developer-guide) . This method is particularly useful for DApps calling contracts. It's the best way to use native tokens in a DApp or make the user pay the fees for a contract call. Depending on the use case and state of the transaction to be balanced, there are two methods available: `balanceSealedTransaction` and `balanceUnsealedTransaction`. They indicate different methods the wallet will use to deserialize the transaction and try to balance it. A transaction that is the result of a contract call will most likely need a call to `balanceUnsealedTransaction`. Completing a swap (for example, initiated by a `makeIntent` call) will require a call to `balanceSealedTransaction`. try { // assuming we have a transaction at hand here const transaction; const result = await connected.balanceUnsealedTransaction(transaction); const resultTransaction = result.tx;} catch (error) { console.log('an error occurred', error);} ### Submit a transaction[​](https://docs.midnight.network/api-reference/dapp-connector#submit-a-transaction "Direct link to Submit a transaction") With the balanced and proven transaction from above, you can now submit it. try { const submittedTransaction = await connected.submitTransaction(resultTransaction);} catch (error) { console.log('an error occurred', error);} Examples[​](https://docs.midnight.network/api-reference/dapp-connector#examples "Direct link to Examples") ----------------------------------------------------------------------------------------------------------- The following examples demonstrate common usage patterns for the DApp connector API. ### Connect[​](https://docs.midnight.network/api-reference/dapp-connector#connect "Direct link to Connect") This example shows how to connect to a compatible wallet on a specific network. It filters wallets by API version, prompts the user to select one, and establishes a connection. import { NetworkId } from '@midnight-ntwrk/midnight-js-network-id';declare function semverMatch(version, expectedRange);declare function askUserToSelect(wallets: InitialAPI[]): Promise;async function connect(): Promise { const networkId = NetworkId('preprod'); const compatibleWallets = Object.values(window.midnight ?? {}) .filter((wallet) => semverMatch(wallet.apiVersion, '^1.0')); const selectedWallet = await askUserToSelect(compatibleWallets); const connectedWallet = await selectedWallet.connect(networkId); const connectionStatus = await connectedWallet.getConnectionStatus(); assert(connectionStatus.networkId === networkId); return connectedWallet;} ### Initiate a Night payment to an address[​](https://docs.midnight.network/api-reference/dapp-connector#initiate-a-night-payment-to-an-address "Direct link to Initiate a Night payment to an address") This example demonstrates how to initiate a transfer of 10 Night tokens to a specific unshielded address. The transaction is created using `makeTransfer` and then submitted to the network. import { nativeToken } from '@midnight-ntwrk/ledger-v7';const connectedWallet = await connect();const tx = await connectedWallet.makeTransfer([{ kind: "unshielded", type: nativeToken().raw, value: 10_000_000, //10 Night recipient: "mn_addr1asujt0dayj4pelgq97wv75hjhscqv9epmzzpapkf8sy8c87jhh9s6e0fs3"}]);await connectedWallet.submitTransaction(tx); ### Initiate and complement a swap of Night into a shielded token[​](https://docs.midnight.network/api-reference/dapp-connector#initiate-and-complement-a-swap-of-night-into-a-shielded-token "Direct link to Initiate and complement a swap of Night into a shielded token") This example shows a two-party swap where Party #1 creates an unbalanced transaction offering 10 Night tokens, and Party #2 completes it by providing 50,000 Foo tokens. The transaction is balanced and submitted by Party #2. // Party #1import { nativeToken } from '@midnight-ntwrk/ledger-v7';declare function getFooTokenType(): TokenType;const connectedWallet = await connect();const shieldedAddress = (await connectedWallet.getShieldedAddresses()).shieldedAddress;// This call will create a transaction with inputs and outputs structured so that there is:// - surplus of 10 Night (inputs cover 10 Night, there might be some change output of Night created)// - shortage of 50_000 Foo tokens (there is an output for 50_000 Foo tokens, but no inputs)const tx = await connectedWallet.makeIntent([{ kind: "unshielded", type: nativeToken().raw, value: 10_000_000, //10 Night}], [{ kind: "shielded", type: getFooTokenType(), value: 50_000, recipient: shieldedAddress}]);// Here, the `tx` can be submitted to some service, so that it becomes available to the other party// Party #2const tx = await fetchTransactionToMatch();const connectedWallet = await connect();// Then party #2 provides the 50_000 Foo tokens and creates self outputs for the surplus of 10 Nightconst balancedTx = await connectedWallet.balanceSealedTransaction(tx);await connectedWallet.submitTransaction(balancedTx); ### Delegate proving[​](https://docs.midnight.network/api-reference/dapp-connector#delegate-proving "Direct link to Delegate proving") This example demonstrates how to delegate Zero Knowledge (ZK) proof generation to the wallet's proving provider. It prepares an unproven transaction, generates the proof, balances the transaction, and submits it. import { FetchZkConfigProvider } from '@midnight-ntwrk/midnight-js-fetch-zk-config-provider';import { Transaction } from '@midnight-ntwrk/ledger-v7';const keyMaterialProvider = new FetchZkConfigProvider('https://example.com');const connectedAPI = await connect();const provingProvider = connectedAPI.getProvingProvider(keyMaterialProvider);// Let's prepare the transaction and their inputsconst costModel = await fetchCostModel(); // For example, from Indexer, using `Block.ledgerParameters`: https://github.com/midnightntwrk/midnight-indexer/blob/main/indexer-api/graphql/schema-v3.graphql#L36const unprovedTx = prepareUnprovenTransaction(costModel); // For example, make a contract call// Now the proving itself:const provenTx = await unprovenTx.prove(provingProvider, costModel);// Now the transaction can be, for instance, balanced (to pay fees) and submitted:const finalTx = await connectedAPI.balanceUnsealedTransaction(provenTx);await connectedAPI.submitTransaction(finalTx); Reference[​](https://docs.midnight.network/api-reference/dapp-connector#reference "Direct link to Reference") -------------------------------------------------------------------------------------------------------------- For the complete technical specification of the DApp Connector API, see the [DApp Connector API Specification](https://github.com/midnightntwrk/midnight-dapp-connector-api/blob/main/docs/api/_media/SPECIFICATION.md) on GitHub. * [Installation](https://docs.midnight.network/api-reference/dapp-connector#installation) * [Package usage](https://docs.midnight.network/api-reference/dapp-connector#package-usage) * [Initial API data and methods](https://docs.midnight.network/api-reference/dapp-connector#initial-api-data-and-methods) * [Connect to a wallet](https://docs.midnight.network/api-reference/dapp-connector#connect-to-a-wallet) * [Get information about the wallet before connection](https://docs.midnight.network/api-reference/dapp-connector#get-information-about-the-wallet-before-connection) * [Name and icon](https://docs.midnight.network/api-reference/dapp-connector#name-and-icon) * [Get API version](https://docs.midnight.network/api-reference/dapp-connector#get-api-version) * [Query wallet state and initiate transactions](https://docs.midnight.network/api-reference/dapp-connector#query-wallet-state-and-initiate-transactions) * [Get the configuration](https://docs.midnight.network/api-reference/dapp-connector#get-the-configuration) * [Read wallet information](https://docs.midnight.network/api-reference/dapp-connector#read-wallet-information) * [Initiate a payment](https://docs.midnight.network/api-reference/dapp-connector#initiate-a-payment) * [Balance a transaction](https://docs.midnight.network/api-reference/dapp-connector#balance-a-transaction) * [Submit a transaction](https://docs.midnight.network/api-reference/dapp-connector#submit-a-transaction) * [Examples](https://docs.midnight.network/api-reference/dapp-connector#examples) * [Connect](https://docs.midnight.network/api-reference/dapp-connector#connect) * [Initiate a Night payment to an address](https://docs.midnight.network/api-reference/dapp-connector#initiate-a-night-payment-to-an-address) * [Initiate and complement a swap of Night into a shielded token](https://docs.midnight.network/api-reference/dapp-connector#initiate-and-complement-a-swap-of-night-into-a-shielded-token) * [Delegate proving](https://docs.midnight.network/api-reference/dapp-connector#delegate-proving) * [Reference](https://docs.midnight.network/api-reference/dapp-connector#reference) --- # Midnight.js API | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/midnight-js#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **Midnight.js API Reference v2.0.2** * * * Midnight.js =========== Midnight.js is a Typescript-based application development framework for the Midnight blockchain. Analogous to [Web3.js](https://web3js.org/) for Ethereum, or [polkadot.js](https://polkadot.js.org/) for Polkadot, it contains utilities for: * Creating and submitting transactions * Interacting with wallets * Querying for block and state information * Subscribing to chain events Due to the privacy-preservation properties of the Midnight system, Midnight.js also contains a number of utilities that are unique to it: * Executing smart contracts locally * Incorporating private state into contract execution * Persisting, querying, and updating private state * Creating and verifying zero-knowledge proofs Package structure[​](https://docs.midnight.network/api-reference/midnight-js#package-structure "Direct link to Package structure") ----------------------------------------------------------------------------------------------------------------------------------- * `types` - Contains types and interfaces common to all other packages. * `contracts` - Contains utilities for interacting with Midnight smart contracts. * `indexer-public-data-provider` - Contains a cross-environment implementation of a Midnight indexer client. * `node-zk-config-provider` - Contains a file system based Node.js utility for retrieving zero-knowledge artifacts. * `fetch-zk-config-provider` - Contains a [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) based cross-environment utility for retrieving zero-knowledge artifacts. * `network-id` - Contains utilities for setting the network id used by `ledger`, `zswap`, and `compact-runtime` dependencies. * `http-client-proof-provider` - Contains a cross-environment implementation of a proof-server client. * `level-private-state-provider` - Contains a cross-environment implementation of a persistent private state store based on [Level](https://github.com/Level/level) . * [Package structure](https://docs.midnight.network/api-reference/midnight-js#package-structure) --- # Midnight Indexer API Documentation v1 | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/midnight-indexer#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ The Midnight Indexer API exposes a GraphQL API that enables clients to query and subscribe to blockchain data—blocks, transactions, contracts, and wallet-related events—indexed from the Midnight blockchain. These capabilities facilitate both historical lookups and real-time monitoring. **Disclaimer:** The examples provided here are illustrative and may need updating if the API changes. Always consider [midnight-indexer-api-schema](https://github.com/midnightntwrk/midnight-indexer/blob/main/indexer-api/graphql/schema-v1.graphql) as the primary source of truth. Adjust queries as necessary to match the latest schema. GraphQL Schema[​](https://docs.midnight.network/api-reference/midnight-indexer#graphql-schema "Direct link to GraphQL Schema") ------------------------------------------------------------------------------------------------------------------------------- The GraphQL schema is defined in [midnight-indexer-api-schema](https://github.com/midnightntwrk/midnight-indexer/blob/main/indexer-api/graphql/schema-v1.graphql) . It specifies all queries, mutations, subscriptions, and their types, including arguments and return structures. Overview of Operations[​](https://docs.midnight.network/api-reference/midnight-indexer#overview-of-operations "Direct link to Overview of Operations") ------------------------------------------------------------------------------------------------------------------------------------------------------- * **Queries**: Fetch blocks, transactions, and contract actions. Examples: * Retrieve the latest block or a specific block by hash or height. * Look up transactions by their hash or identifier. * Inspect the current state of a contract action at a given block or transaction offset. * **Mutations**: Manage wallet sessions. * `connect(viewingKey: ViewingKey!)`: Creates a session associated with a viewing key. * `disconnect(sessionId: HexEncoded!)`: Ends a previously established session. * **Subscriptions**: Receive real-time updates. * `blocks`: Stream newly indexed blocks. * `contractActions(address, offset)`: Stream contract actions. * `wallet(sessionId, ...)`: Stream wallet updates, including relevant transactions and optional progress updates. API Endpoints[​](https://docs.midnight.network/api-reference/midnight-indexer#api-endpoints "Direct link to API Endpoints") ---------------------------------------------------------------------------------------------------------------------------- **HTTP (Queries & Mutations):** POST https://:/api/v1/graphqlContent-Type: application/json **WebSocket (Subscriptions):** wss://:/api/v1/graphql/wsSec-WebSocket-Protocol: graphql-transport-ws Core Scalars[​](https://docs.midnight.network/api-reference/midnight-indexer#core-scalars "Direct link to Core Scalars") ------------------------------------------------------------------------------------------------------------------------- * `HexEncoded`: Hex-encoded bytes (for hashes, addresses, session IDs). * `ViewingKey`: A viewing key in hex or Bech32 format for wallet sessions. * `ApplyStage`: Enumerated stages of transaction application. This scalar represents the outcome of transaction processing on the chain ("Success", "PartialSuccess" or "Failure"). * `Unit`: An empty return type for mutations that do not return data. Example Queries and Mutations[​](https://docs.midnight.network/api-reference/midnight-indexer#example-queries-and-mutations "Direct link to Example Queries and Mutations") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- **Note:** These are examples only. Refer to the schema file to confirm exact field names and structures. ### block(offset: BlockOffset): Block[​](https://docs.midnight.network/api-reference/midnight-indexer#blockoffset-blockoffset-block "Direct link to block(offset: BlockOffset): Block") **Parameters** (BlockOffset is a oneOf): * `hash: HexEncoded` – The block hash. * `height: Int` – The block height (number). If no offset is provided, the latest block is returned. **Example:** Query by height: query { block(offset: { height: 3 }) { hash height protocolVersion timestamp parent { hash } transactions { hash applyStage } }} ### transactions(offset: TransactionOffset!): \[Transaction!\]![​](https://docs.midnight.network/api-reference/midnight-indexer#transactionsoffset-transactionoffset-transaction "Direct link to transactions(offset: TransactionOffset!): [Transaction!]!") Fetch transactions by hash or by identifier using a TransactionOffset object. The offset must include either a hash or an identifier, but not both. Returns an array since a hash may map to multiple related actions. **Example:** query { transactions(offset: { hash: "3031323..." }) { hash protocolVersion merkleTreeRoot block { height hash } identifiers raw contractActions { __typename ... on ContractDeploy { address state chainState } ... on ContractCall { address state entryPoint chainState } ... on ContractUpdate { address state chainState } } }} ### contractAction(address: HexEncoded!, offset: ContractActionOffset): ContractAction[​](https://docs.midnight.network/api-reference/midnight-indexer#contractactionaddress-hexencoded-offset-contractactionoffset-contractaction "Direct link to contractAction(address: HexEncoded!, offset: ContractActionOffset): ContractAction") Retrieve the latest known contract action at a given offset (by block or transaction). If no offset is provided, returns the latest state. **Example (latest):** query { contractAction(address: "3031323...") { __typename address state chainState }} **Example (by block height):** query { contractAction( address: "3031323...", offset: { blockOffset: { height: 10 } } ) { __typename address state chainState }} Contract Action Types[​](https://docs.midnight.network/api-reference/midnight-indexer#contract-action-types "Direct link to Contract Action Types") ---------------------------------------------------------------------------------------------------------------------------------------------------- All ContractAction types (ContractDeploy, ContractCall, ContractUpdate) implement the ContractAction interface with these common fields: * `address`: The contract address (HexEncoded) * `state`: The contract state (HexEncoded) * `chainState`: The chain state at this action (HexEncoded) * `transaction`: The transaction that contains this action Contract actions can be one of three types: * **ContractDeploy**: Initial contract deployment * **ContractCall**: Invocation of a contract's entry point * **ContractUpdate**: State update to an existing contract Each type implements the ContractAction interface but may have additional fields. For example, ContractCall includes an `entryPoint` field and a reference to its associated `deploy`. Mutations[​](https://docs.midnight.network/api-reference/midnight-indexer#mutations "Direct link to Mutations") ---------------------------------------------------------------------------------------------------------------- Mutations allow the client to connect a wallet (establishing a session) and disconnect it. ### connect(viewingKey: ViewingKey!): HexEncoded![​](https://docs.midnight.network/api-reference/midnight-indexer#connectviewingkey-viewingkey-hexencoded "Direct link to connect(viewingKey: ViewingKey!): HexEncoded!") Establishes a session for a given wallet viewing key in **either** bech32m or hex format. Returns the session ID. **Viewing Key Format Support** * **Bech32m** (preferred): A base-32 encoded format with a human-readable prefix, e.g., `mn_shield-esk_dev1...` * **Hex** (fallback): A hex-encoded string representing the key bytes. **Example:** mutation { # Provide the bech32m format: connect(viewingKey: "mn_shield-esk1abcdef...") } **Response:** { "data": { "connect": "sessionIdHere" }} ### disconnect(sessionId: HexEncoded!): Unit![​](https://docs.midnight.network/api-reference/midnight-indexer#disconnectsessionid-hexencoded-unit "Direct link to disconnect(sessionId: HexEncoded!): Unit!") Ends an existing session. **Example:** Use this `sessionId` for wallet subscriptions. When done: mutation { disconnect(sessionId: "sessionIdHere")} Subscriptions: Real-time Updates[​](https://docs.midnight.network/api-reference/midnight-indexer#subscriptions-real-time-updates "Direct link to Subscriptions: Real-time Updates") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Subscriptions use a WebSocket connection following the [GraphQL over WebSocket](https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md) protocol. After connecting and sending a `connection_init` message, the client can start subscription operations. ### Blocks Subscription[​](https://docs.midnight.network/api-reference/midnight-indexer#blocks-subscription "Direct link to Blocks Subscription") `blocks(offset: BlockOffset): Block!` Subscribe to new blocks. The `offset` parameter lets you start receiving from a given block (by height or hash). If omitted, starts from the latest block. **Example:** { "id": "1", "type": "start", "payload": { "query": "subscription { blocks(offset: { height: 10 }) { hash height timestamp transactions { hash } } }" }} When a new block is indexed, the client receives a `next` message. ### Contracts Subscription[​](https://docs.midnight.network/api-reference/midnight-indexer#contracts-subscription "Direct link to Contracts Subscription") `contractActions(address: HexEncoded!, offset: BlockOffset): ContractAction!` Subscribes to contract actions for a particular address. New contract actions (calls, updates) are pushed as they occur. **Example:** { "id": "2", "type": "start", "payload": { "query": "subscription { contractActions(address:\"3031323...\", offset: { height: 1 }) { __typename address state } }" }} ### Wallet Subscription[​](https://docs.midnight.network/api-reference/midnight-indexer#wallet-subscription "Direct link to Wallet Subscription") `wallet(sessionId: HexEncoded!, index: Int, sendProgressUpdates: Boolean): WalletSyncEvent!` Subscribes to wallet updates. This includes relevant transactions and possibly Merkle tree updates, as well as `ProgressUpdate` events if `sendProgressUpdates` is set to `true`, which is also the default. The `index` parameter can be used to resume from a certain point. Adjust `index` and `offset` arguments as needed. **Example:** { "id": "3", "type": "start", "payload": { "query": "subscription { wallet(sessionId: \"1CYq6ZsLmn\", index: 100) { __typename ... on ViewingUpdate { index update { __typename ... on RelevantTransaction { transaction { hash } } } } ... on ProgressUpdate { highestIndex highestRelevantIndex highestRelevantWalletIndex } } }" }} **Responses** may vary depending on what is happening in the chain: * A `ViewingUpdate` with new relevant transactions or a collapsed Merkle tree update. * A `ProgressUpdate` providing synchronization progress with fields like `highestIndex`, `highestRelevantIndex`, and `highestRelevantWalletIndex`. Query Limits Configuration[​](https://docs.midnight.network/api-reference/midnight-indexer#query-limits-configuration "Direct link to Query Limits Configuration") ------------------------------------------------------------------------------------------------------------------------------------------------------------------- The server may apply limitations to queries (e.g. `max-depth`, `max-fields`, `timeout`, and complexity cost). Requests that violate these limits return errors indicating the reason (too many fields, too deep, too costly, or timed out). **Example error:** { "data": null, "errors": [ { "message": "Query has too many fields: 20. Max fields: 10." } ]} Authentication[​](https://docs.midnight.network/api-reference/midnight-indexer#authentication "Direct link to Authentication") ------------------------------------------------------------------------------------------------------------------------------- * Wallet subscription requires a `sessionId` from the `connect` mutation. ### Regenerating the Schema[​](https://docs.midnight.network/api-reference/midnight-indexer#regenerating-the-schema "Direct link to Regenerating the Schema") If you modify the code defining the GraphQL schema, regenerate it: just generate-indexer-api-schema This ensures the schema file stays aligned with code changes. Conclusion[​](https://docs.midnight.network/api-reference/midnight-indexer#conclusion "Direct link to Conclusion") ------------------------------------------------------------------------------------------------------------------- This document offers a few hand-picked examples and an overview of available operations. For the most accurate and comprehensive reference, consult the schema file. As the API evolves, remember to validate these examples against the schema and update them as needed. * [GraphQL Schema](https://docs.midnight.network/api-reference/midnight-indexer#graphql-schema) * [Overview of Operations](https://docs.midnight.network/api-reference/midnight-indexer#overview-of-operations) * [API Endpoints](https://docs.midnight.network/api-reference/midnight-indexer#api-endpoints) * [Core Scalars](https://docs.midnight.network/api-reference/midnight-indexer#core-scalars) * [Example Queries and Mutations](https://docs.midnight.network/api-reference/midnight-indexer#example-queries-and-mutations) * [block(offset: BlockOffset): Block](https://docs.midnight.network/api-reference/midnight-indexer#blockoffset-blockoffset-block) * [transactions(offset: TransactionOffset!): \[Transaction!\]!](https://docs.midnight.network/api-reference/midnight-indexer#transactionsoffset-transactionoffset-transaction) * [contractAction(address: HexEncoded!, offset: ContractActionOffset): ContractAction](https://docs.midnight.network/api-reference/midnight-indexer#contractactionaddress-hexencoded-offset-contractactionoffset-contractaction) * [Contract Action Types](https://docs.midnight.network/api-reference/midnight-indexer#contract-action-types) * [Mutations](https://docs.midnight.network/api-reference/midnight-indexer#mutations) * [connect(viewingKey: ViewingKey!): HexEncoded!](https://docs.midnight.network/api-reference/midnight-indexer#connectviewingkey-viewingkey-hexencoded) * [disconnect(sessionId: HexEncoded!): Unit!](https://docs.midnight.network/api-reference/midnight-indexer#disconnectsessionid-hexencoded-unit) * [Subscriptions: Real-time Updates](https://docs.midnight.network/api-reference/midnight-indexer#subscriptions-real-time-updates) * [Blocks Subscription](https://docs.midnight.network/api-reference/midnight-indexer#blocks-subscription) * [Contracts Subscription](https://docs.midnight.network/api-reference/midnight-indexer#contracts-subscription) * [Wallet Subscription](https://docs.midnight.network/api-reference/midnight-indexer#wallet-subscription) * [Query Limits Configuration](https://docs.midnight.network/api-reference/midnight-indexer#query-limits-configuration) * [Authentication](https://docs.midnight.network/api-reference/midnight-indexer#authentication) * [Regenerating the Schema](https://docs.midnight.network/api-reference/midnight-indexer#regenerating-the-schema) * [Conclusion](https://docs.midnight.network/api-reference/midnight-indexer#conclusion) --- # Midnight Dev Diaries [Skip to main content](https://docs.midnight.network/blog/tags/compact#__docusaurus_skipToContent_fallback) AI coding assistants like Claude, GitHub Copilot, and Cursor have transformed how developers write code. But they have a fundamental limitation: they only know what was in their training data. Compact, Midnight's smart contract language, isn't in that training data. When you ask an AI assistant to write a Compact contract, it hallucinates. It invents syntax that doesn't exist, references functions that were never defined, and produces code that fails at compile time. Midnight MCP solves this problem. What is MCP?[​](https://docs.midnight.network/blog/tags/compact#what-is-mcp "Direct link to What is MCP?") ----------------------------------------------------------------------------------------------------------- The _Model Context Protocol_ (MCP) is an open standard that allows AI assistants to access external tools and data sources. Instead of relying solely on training data, an AI assistant with MCP can query live documentation, search codebases, and call APIs. Midnight MCP is an MCP server purpose-built for Midnight development. It gives AI assistants: * **Indexed knowledge** of 102 Midnight repositories * **Real compiler validation** before showing you code * **Semantic search** across documentation and examples * **Version-aware syntax references** for Compact When you ask Claude to write a Compact contract, it queries Midnight MCP for the correct syntax, generates the code, validates it against the real compiler, and only shows you working code. The problem with AI-generated Compact code[​](https://docs.midnight.network/blog/tags/compact#the-problem-with-ai-generated-compact-code "Direct link to The problem with AI-generated Compact code") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Consider this prompt: "Write a simple counter contract in Compact" Without Midnight MCP, an AI assistant might generate: contract Counter { state count: Int = 0; function increment(): Void { count = count + 1; }} This looks plausible. It's also completely wrong: * Compact uses `ledger` for state, not `state`. * There is no `Int` type in Compact. It uses `Uint<32>`, `Field`, and other specific types. * `Void` doesn't exist. Compact uses `[]` for the unit type. * State mutations require witness functions, not direct assignment. The AI hallucinated a language that resembles Solidity but isn't Compact. A developer unfamiliar with Compact might spend hours debugging code that was never valid. Install Midnight MCP[​](https://docs.midnight.network/blog/tags/compact#install-midnight-mcp "Direct link to Install Midnight MCP") ------------------------------------------------------------------------------------------------------------------------------------ Midnight MCP requires no API keys and installs in under 60 seconds. Add the appropriate configuration to your AI assistant based on the tool you use. ### Claude Desktop[​](https://docs.midnight.network/blog/tags/compact#claude-desktop "Direct link to Claude Desktop") On macOS, edit `~/Library/Application Support/Claude/claude_desktop_config.json`. Add the following configuration to enable Midnight MCP: { "mcpServers": { "midnight": { "command": "npx", "args": ["-y", "midnight-mcp@latest"] } }} ### Cursor[​](https://docs.midnight.network/blog/tags/compact#cursor "Direct link to Cursor") Create or edit `.cursor/mcp.json` in your project root. You can also configure it globally at `~/.cursor/mcp.json` on macOS/Linux or `%USERPROFILE%\.cursor\mcp.json` on Windows. Add the following configuration: { "mcpServers": { "midnight": { "command": "npx", "args": ["-y", "midnight-mcp@latest"] } }} ### VS Code with GitHub Copilot[​](https://docs.midnight.network/blog/tags/compact#vs-code-with-github-copilot "Direct link to VS Code with GitHub Copilot") Create or edit `.vscode/mcp.json` in your project. Add the following configuration to connect Copilot to Midnight MCP: { "servers": { "midnight": { "command": "npx", "args": ["-y", "midnight-mcp@latest"] } }} After adding the configuration, restart your AI assistant. You now have access to [29 Midnight-specific tools](https://docs.midnight.network/blog/tags/compact#29-tools-for-midnight-development) . How Midnight MCP works[​](https://docs.midnight.network/blog/tags/compact#how-midnight-mcp-works "Direct link to How Midnight MCP works") ------------------------------------------------------------------------------------------------------------------------------------------ Midnight MCP operates as a local server that connects your AI assistant to Midnight's ecosystem. ![Midnight MCP Architecture](https://docs.midnight.network/assets/images/mcp-flow-6300d117555db9ec395e0f419d22de5d.png) When you ask for a Compact contract: 1. The AI assistant calls `midnight-get-latest-syntax` to retrieve current Compact syntax. 2. It generates code using the correct patterns. 3. It calls `midnight-compile-contract` to validate against the real compiler. 4. If compilation fails, it reads the error, fixes the code, and retries. 5. You receive verified, working code. This compile-validate-fix loop happens automatically. You never see the broken intermediate versions. Real compiler integration[​](https://docs.midnight.network/blog/tags/compact#real-compiler-integration "Direct link to Real compiler integration") --------------------------------------------------------------------------------------------------------------------------------------------------- Most code-generation tools rely on pattern matching and hope. Midnight MCP validates code against the actual Compact compiler hosted. The compiler catches errors that static analysis cannot, including: * **Type mismatches**: Using `Field` where `Uint<64>` is expected * **Sealed field violations**: Attempting to access sealed state incorrectly * **Disclose rule errors**: Missing or malformed privacy annotations * **Unbound identifiers**: References to undefined variables or types When the compiler returns an error, the response includes the exact line number and column: success: falsemessage: "Line 12:8 - unbound identifier 'totalSupply'"errorDetails: line: 12 column: 8 errorType: error The AI assistant uses this information to fix the code and try again. ### Graceful fallback[​](https://docs.midnight.network/blog/tags/compact#graceful-fallback "Direct link to Graceful fallback") If the hosted compiler is unavailable, Midnight MCP falls back to static analysis. The response indicates which validation method was used: validationType: "compiler" # Real compiler validationvalidationType: "static-analysis-fallback" # Compiler unavailable You always receive validation. The tool never fails silently. Semantic search across 102 repositories[​](https://docs.midnight.network/blog/tags/compact#semantic-search-across-102-repositories "Direct link to Semantic search across 102 repositories") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Today, Midnight MCP indexes every non-archived repository in the Midnight ecosystem: * All 88 repositories from `midnightntwrk`. * 14 community and partner repositories, including OpenZeppelin contracts and hackathon winners. The search is semantic, not keyword-based. For example, a prompt like "find code that handles shielded transactions" returns relevant results even if those exact words don't appear in the code. Prompt: "How do I implement a token with transfer limits?"midnight-search-compact returns:- Token contract examples from midnight-examples- Rate limiting patterns from community repos- Relevant documentation sections 29 tools for Midnight development[​](https://docs.midnight.network/blog/tags/compact#29-tools-for-midnight-development "Direct link to 29 tools for Midnight development") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Midnight MCP provides 29 tools organized by function. ### Search tools[​](https://docs.midnight.network/blog/tags/compact#search-tools "Direct link to Search tools") Use these tools to find code, documentation, and examples across the Midnight ecosystem. | Tool | Purpose | | --- | --- | | `midnight-search-compact` | Search Compact language code across indexed repos | | `midnight-search-docs` | Search official Midnight documentation | | `midnight-search-typescript` | Search TypeScript SDK implementations | | `midnight-fetch-docs` | Fetch live documentation from docs.midnight.network | ### Analysis tools[​](https://docs.midnight.network/blog/tags/compact#analysis-tools "Direct link to Analysis tools") Use these tools to validate, analyze, and review Compact contracts. | Tool | Purpose | | --- | --- | | `midnight-compile-contract` | Validate code against the real Compact compiler | | `midnight-analyze-contract` | Run 15 static security checks | | `midnight-review-contract` | AI-powered security review | | `midnight-extract-contract-structure` | Parse contract structure and exports | ### Generation tools[​](https://docs.midnight.network/blog/tags/compact#generation-tools "Direct link to Generation tools") Use these tools to create new contracts and documentation. | Tool | Purpose | | --- | --- | | `midnight-generate-contract` | Generate contracts from natural language descriptions | | `midnight-document-contract` | Generate documentation in Markdown or JSDoc format | ### Repository tools[​](https://docs.midnight.network/blog/tags/compact#repository-tools "Direct link to Repository tools") Use these tools to access files and syntax references from Midnight repositories. | Tool | Purpose | | --- | --- | | `midnight-get-file` | Retrieve files from any indexed Midnight repository | | `midnight-get-file-at-version` | Get file content at a specific version | | `midnight-compare-syntax` | Compare syntax between Compact versions | | `midnight-get-latest-syntax` | Current Compact syntax reference | | `midnight-get-repo-context` | Everything needed to start coding (compound tool) | | `midnight-list-examples` | List available example contracts | ### Version management tools[​](https://docs.midnight.network/blog/tags/compact#version-management-tools "Direct link to Version management tools") Use these tools to manage upgrades and track changes between Compact versions. | Tool | Purpose | | --- | --- | | `midnight-upgrade-check` | Full upgrade analysis (compound tool) | | `midnight-check-breaking-changes` | Identify breaking changes between versions | | `midnight-get-migration-guide` | Step-by-step migration instructions | Resources and prompts[​](https://docs.midnight.network/blog/tags/compact#resources-and-prompts "Direct link to Resources and prompts") --------------------------------------------------------------------------------------------------------------------------------------- Beyond tools, Midnight MCP provides nine built-in resources and five interactive prompts. _Resources_ are always-available references that provide quick access to syntax and examples: midnight://syntax/latest Current Compact syntaxmidnight://examples/counter Counter contract examplemidnight://examples/token Token contract examplemidnight://docs/compact Compact language reference _Prompts_ are templates for common tasks that guide you through specific workflows: create-compact-contract Start a new contractdebug-compact-error Fix compilation errorssecurity-review Full security auditcompare-compact-versions Migration assistance Architecture[​](https://docs.midnight.network/blog/tags/compact#architecture "Direct link to Architecture") ------------------------------------------------------------------------------------------------------------ Midnight MCP is built for reliability: * **Token efficiency**: Outputs YAML by default (20-30% fewer tokens than JSON) * **Compound tools**: Single calls that combine multiple operations * **Graceful degradation**: Falls back to cached data when services are unavailable * **Progress notifications**: Real-time updates during long operations The codebase is fully tested with 206 tests across 10 test suites. What's next[​](https://docs.midnight.network/blog/tags/compact#whats-next "Direct link to What's next") -------------------------------------------------------------------------------------------------------- Midnight MCP is open source and actively developed. The roadmap includes: * **Full ZK circuit output parsing** from compiler results. * **Contract deployment** directly from AI chat. * **TypeScript SDK integration** for automatic prover code generation. * **Local devnet interaction** for querying balances and submitting transactions. Learn more[​](https://docs.midnight.network/blog/tags/compact#learn-more "Direct link to Learn more") ------------------------------------------------------------------------------------------------------ Explore the source code and contribute: → [GitHub repository](https://github.com/Olanetsoft/midnight-mcp) → [npm package](https://npmjs.com/package/midnight-mcp) → [API documentation](https://github.com/Olanetsoft/midnight-mcp/blob/main/docs/API.md) _Midnight MCP is a community project. Contributions, issues, and feature requests are welcome._ This blog post is the third part of the Compact Deep Dive series, which explores how Compact contracts work on the Midnight network. Each article focuses on a different technical topic and can be read on its own, but together they provide a fuller picture of how Compact functions in practice. The first two parts can be found here: * [Part 1: Top-level Contract Structure](https://docs.midnight.network/blog/compact) * [Part 2: Circuits and Witnesses](https://docs.midnight.network/blog/compact-2) This article looks at the on-chain runtime and how public ledger state updates happen in your DApp. The Bulletin Board's `post` Circuit =================================== In the previous parts we used the Bulletin Board example DApp to take a look at contract structure and the implementation of circuits and witnesses. We saw that a contract's exported circuits, such as `post` from the Bulletin Board example, had an outer "wrapper" that called the actual implementation. We will now take a look at that actual implementation. Recall the Compact implementation of `post`: export circuit post(newMessage: Opaque<"string">): [] { assert(state == State.VACANT, "Attempted to post to an occupied board"); poster = disclose(publicKey(localSecretKey(), instance as Field as Bytes<32>)); message = disclose(some>(newMessage)); state = State.OCCUPIED;} It reads the `state` field from the contract's public ledger state and asserts that the bulletin board is vacant. Then it calls the witness `localSecretKey` and uses the return value to derive `poster`, a commitment to the post's author. Finally, it updates three ledger fields (`poster`, `message`, and `state`). We compiled the contract with version 0.25.0 of the Compact compiler. Note that this is a different version than the one used in parts one and two of this series. If you use a different version, the implementation details might be different. The implementation of `post` is in a JavaScript function called `_post_0`. Every line of this function has something new to learn about the way that Compact works, so we will go line by line through it. The first line of this function corresponds to the first line of the Compact circuit: _post_0(context, partialProofData, newMessage_0) { __compactRuntime.assert( _descriptor_0.fromValue( Contract._query( context, partialProofData, [ { dup: { n: 0 } }, { idx: { cached: false, pushPath: false, path: [ { tag: 'value', value: { value: _descriptor_9.toValue(0n), alignment: _descriptor_9.alignment() } }] } }, { popeq: { cached: false, result: undefined } }]).value) === 0, 'Attempted to post to an occupied board'); (Here and below we have reformatted the JavaScript code to fit better on screen. The only change is the indentation.) We will read this line of JavaScript from the inside out. The very first subexpression evaluated in the Compact `post` circuit is simply `state`, which is a read of the ledger's `state` field. This also must be the first thing evaluated in the JavaScript implementation. It is implemented by a call to a compiler-generated static method `_query` on the `Contract` class. (We will take a closer look at `Contract._query` in the next article in this series.) Recall what is happening when `_post_0` is executed in your DApp. The JavaScript code is running locally on a user's machine, with full access to private data from the witnesses it uses. After running the code, the proof server will be used to construct a zero-knowledge (ZK) proof that it did run that code. Then, a transaction will be submitted to the Midnight chain. If the chain verifies the proof, the public ledger state updates specified by the circuit implementation will be performed. The Midnight node uses the [Impact VM](https://docs.midnight.network/develop/how-midnight-works/impact) , a stack-based virtual machine, to perform public ledger state updates. This machine executes a program in a bytecode language called **Impact**. We use the same Impact VM to perform updates to a local copy of the public state when we are running your DApp's code locally before submitting a transaction. The On-Chain Runtime and the Impact VM ====================================== The Compact runtime package includes an embedded version of the on-chain runtime. This is the exact same Rust code that is used to implement the Midnight ledger on the Midnight network nodes. For the Compact runtime, it is compiled to WebAssembly and imported as the [on-chain runtime](https://docs.midnight.network/develop/reference/midnight-api/onchain-runtime/) package. You can actually use this package directly in your DApp, though much of it is re-exported by the higher-level Compact runtime. Sometimes the Compact runtime provides wrapped versions that have a higher-level API (specifically, using JavaScript representations instead of the ledger's native binary representation). note If you use the on-chain runtime package directly in your DApp, it is very important to remember that you are working with a snapshot of the public state. This snapshot was obtained from a Midnight indexer, but while your DApp is running, the chain itself is progressing with other transactions for the same contract. That's part of what it means for a DApp to be "decentralized". The Impact VM performs public ledger state updates, immediately in your DApp's copy and later (when the transaction is run) on chain. There are a host of reasons to use the exact same VM: * Transaction semantics will be identical. * It saves engineering work to implement it (and update it and maintain it) once. * We will need the Impact program to compute fees for the transaction. * The ZK proof will be about this **specific** Impact program. The Impact VM is a stack-based machine. Transactions operate on a stack of values, which are encoded in the ledger's binary representation. The transaction always starts with three values on the stack: 1. First (at the base of the stack), a **context** object for the transaction. 2. Second, an **effects** object collecting actions performed by the transaction. 3. Third, the contract's public state. When a transaction completes, these three values are left on the stack in the same order. Values on the VM's stack are immutable. For instance, a state update is accomplished by **replacing** the state third on the stack with a new one (rather than **mutating** the existing state value). The third argument to `Contract._query` is an array of `Op`s which are JavaScript representations of Impact VM instructions. `Op` is a type [defined](https://docs.midnight.network/develop/reference/midnight-api/onchain-runtime/type-aliases/Op) in the on-chain runtime. Transactions will use a [binary encoding](https://docs.midnight.network/develop/how-midnight-works/impact#programs) of these instructions. The array of instructions is a partial Impact program. A whole program will be built up for the transaction, usually with multiple calls to `Contract._query`. Ledger Read Operations ====================== The Impact code for the ledger read of the field `state` from above was: [ { dup: { n: 0 } }, { idx: { cached: false, pushPath: false, path: [ { tag: 'value', value: { value: _descriptor_9.toValue(0n), alignment: _descriptor_9.alignment() } }] } }, { popeq: { cached: false, result: undefined } }] The first instruction is `dup 0`. Instructions will find their inputs on the Impact VM's stack. They can also have operands which are encoded as part of the instruction, such as the zero in `dup 0`. The `dup N` instruction **duplicates** a value on the stack. The value is found _N_ elements below the top of the stack, so _N_\=0 is the top of the stack. Since this is the first Impact instruction in a `post` transaction, that will be the public ledger state value. Before `dup 0`, the Impact VM's stack had `` in order from the base to the top of the stack. `ledger0` is the initial ledger state of this transaction. After `dup 0`, it will have `` with two copies of the ledger state on top of the stack. This allows subsequent instructions which consume values to execute without losing the public ledger state. The second instruction is `idx [0]`. This instruction **indexes** into the top value on the stack, extracting a subpart of it. It removes the top value on the stack and replaces it with the extracted subpart. The instruction's operand is a path, a sequence of ledger-encoded values (or a special tag `stack`). The two different encodings of values, and the descriptors that convert between them, were described in [Part 2](https://docs.midnight.network/blog/compact-2#descriptors) . Here the instruction uses `_descriptor_9`: const _descriptor_9 = new __compactRuntime.CompactTypeUnsignedInteger(255n, 1); This is an instance of [`CompactTypeUnsignedInteger`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/classes/CompactTypeUnsignedInteger) from the Compact runtime. It takes a maximum value and a size in bytes. So this is the descriptor for a one byte unsigned integer with a maximum value of 255 (that is, just an unsigned byte). The value `0n` is the public ledger state index that the Compact compiler has assigned to the `state` field. Impact has four different indexing instructions: `idx`, `idxc` (cached), `idxp` (push path), and `idxpc` (push path, cached). In the JavaScript representation of instructions, we simply use a pair of boolean properties giving the same four variants. `cached` is true when the value being accessed has already been accessed (that is, read or written) in the same transaction. It can potentially be used for assigning different fees for cached and uncached accesses. In this case, we have not accessed the `state` ledger field yet in the transaction. `pushPath` is a variant that leaves a path in place on the stack for a subsequent write operation. Before `idx [0]`, the VM's stack had ``. After `idx [0]`, it will have `` (where `ledger0` is the entire public ledger state and `state` is the value of the field with that name). The third instruction is `popeq`. This instruction **pops** the top value from the VM's stack. The Impact VM can run in two different modes. It runs in **gathering** mode when it runs locally in a DApp. It runs in **verifying** mode when it executes a contract's public ledger state updates on chain. In gathering mode the popped value is collected (it's used by `Contract._query` as the result of this ledger read). In verifying mode the VM will ensure that the popped value is equal to the instruction's operand. Here we are running in gathering mode, so the instruction's `result` operand is the JavaScript `undefined` value. Before `popeq`, the VM's stack had ``. After `popeq`, it will have ``. These three simple VM instructions implement a top-level ledger read. Assert in Circuits ================== The `post` circuit asserts that the bulletin board's state is vacant. This is implemented by the JavaScript code from above (with the Impact instructions elided): __compactRuntime.assert( _descriptor_0.fromValue( Contract._query( context, partialProofData, /* Impact code */).value) === 0, 'Attempted to post to an occupied board'); `Contract._query` returns an object with a ledger-encoded result. `_descriptor_0` is the descriptor for the the `State` enumeration type, so `_descriptor_0.fromValue` is used to convert it to one of the enumeration values `VACANT=0` or `OCCUPIED=1`. This value is compared via JavaScript's strict equality operator to the vacant value (zero). The assertion itself is implemented by a call to the Compact runtime's `assert` function. If the condition is not true, this will cause the DApp's `post` transaction to fail without ever reaching the Midnight chain. Provided that the assertion succeeds when running the DApp locally, the ZK proof will prove that it suceeded. When the proof is verified on chain, the Midnight network will then know that this assertion was true. The on-chain Impact program will not directly assert this property (that `state` was `State.VACANT`). However, when the `popeq` instruction is run in verifying mode, it will have an operand that indicates the actual value that was popped locally in the DApp. So specifically, if the DApp successfully built a `post` transaction, that instruction will be `popeq 0`. This is subtly different from asserting that the `state` field was 0. If the `assert` were removed from the Compact program and the ledger field read remained, then the Impact program run on chain could have either `popeq 0` or `popeq 1` depending on the actual value that was read by the DApp. Circuit and Witness Calls ========================= The second line of the Compact `post` circuit is: poster = disclose(publicKey(localSecretKey(), instance as Field as Bytes<32>)); This is a write to the ledger's `poster` field. The right-hand side of the write operation is implemented by the JavaScript code: const tmp_0 = this._publicKey_0( this._localSecretKey_0(context, partialProofData), __compactRuntime.convert_bigint_to_Uint8Array( 32, _descriptor_1.fromValue( Contract._query( context, partialProofData, [ { dup: { n: 0 } }, { idx: { cached: false, pushPath: false, path: [ { tag: 'value', value: { value: _descriptor_9.toValue(2n), alignment: _descriptor_9.alignment() } }] } }, { popeq: { cached: true, result: undefined } }]).value))); The compiler has named this value `tmp_0` so it can refer to it later. The call to the witness `localSecretKey` has been compiled into a call to the `_localSecretKey_0` method of the contract. Recall from [Part 2](https://docs.midnight.network/blog/compact-2#witnesses) that this method is a wrapper around the DApp-provided witness implementation. The wrapper performs some type checks on the witness return value, and it records that return value as one of the transaction's private inputs. The Impact code above implements the read of the ledger's `instance` field. It is nearly the same as the code for the read of `state`. The difference is that the Compact compiler has assigned `instance` to index 2. The field `instance` has a `Counter` ledger type. Reading it in Compact [gives a `Uint<64>`](https://docs.midnight.network/develop/reference/compact/ledger-adt#read-1) . The ledger representation of this value is converted to the JavaScript representation (`bigint`) using `_descriptor_1`: const _descriptor_1 = new __compactRuntime.CompactTypeUnsignedInteger(18446744073709551615n, 8); The maximum value here is the maximum unsigned 64-bit integer and the size in bytes is 8. Type Casts in Compact ===================== The Compact code has a sequence of type casts `instance as Field as Bytes<32>`. `instance` is a `Counter`, reading it from the ledger gives a Compact value with type `Uint<64>`. This cannot be directly cast to `Bytes<32>` so the contract uses an intermediate cast to `Field`. There are three distinct kinds of type casts in Compact: upcasts, downcasts, and so-called "cross casts". An upcast is from a type to one of its supertypes. Such a cast will change the static type as seen by the compiler, but it will have no effect at runtime. For example, casting from `Uint<64>` to `Field` is an upcast. That cast was performed statically (that is, by the compiler) but there is no JavaScript code here to implement it. A downcast is from a type to one of its subtypes. Such a cast will not normally change a value's representation, but it will require a runtime check in the compiler-generated JavaScript code. A cross cast is from a type to an unrelated type (with respect to subtyping). For example, casting a `Field` to `Bytes<32>` is a cross cast. These type casts will normally require a representation change. The Compact runtime function [`convert_bigint_to_Uint8Array`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/functions/convert_bigint_to_Uint8Array) performs the representation change in this case. Then there was a call in Compact to the circuit `publicKey`. Here we see that the call goes directly to the JavaScript implementation method `_publicKey_0`, and not to the exported circuit's `publicKey` wrapper. Recall from [Part 2](https://docs.midnight.network/blog/compact-2#what-are-wrappers-for) that the circuit wrapper performed some runtime type checks that we do not need when we call from Compact to Compact (the Compact type system guarantees that these checks aren't needed). More importantly, a circuit's wrapper established a fresh proof data object for a transaction. Since the call to `publicKey` is part of the `post` transaction that the DApp is building, it should reuse the existing proof data. Notice that the `disclose` operator in Compact doesn't do anything at all at runtime. `disclose` was necessary because a value computed from the witness `localSecretKey` was exposed on chain. This is an instruction to the Compact compiler to allow this value to be exposed, but it has no runtime effect. Ledger Writes ============= The right-hand side value named `tmp_0` in JavaScript should be written to the ledger field `poster`. The code to do that is in the next line of JavaScript code: Contract._query( context, partialProofData, [ { push: { storage: false, value: __compactRuntime.StateValue.newCell( { value: _descriptor_9.toValue(3n), alignment: _descriptor_9.alignment() }).encode() } }, { push: { storage: true, value: __compactRuntime.StateValue.newCell( { value: _descriptor_2.toValue(tmp_0), alignment: _descriptor_2.alignment() }).encode() } }, { ins: { cached: false, n: 1 } }]); This is again implemented by a partial Impact program. The Impact code above implements a ledger cell write (in contrast to the read we saw above). The first instruction is `push 3`. Impact's `push` instruction is the dual to the `pop` instruction. Impact has two different variants: `push` and `pushs`. In the JavaScript representation of Impact instructions, they are distinguished by a boolean `storage` property. `storage` is false to indicate that the value is kept solely in the Impact VM's memory and will not be written to the ledger. The second instruction is `pushs tmp_0`. The instruction is `pushs` because `storage` is true (this value will be written to the ledger). The instruction's operand will be the actual `Bytes<32>` value of `tmp_0`. As you would expect, `_descriptor_2` is the descriptor for `Bytes<32>`, used to convert the JavaScript value to a ledger value: const _descriptor_2 = new __compactRuntime.CompactTypeBytes(32); Before executing these two instructions, the Impact VM's stack had ``. After executing these two instructions, it will have ``. The next instruction is `ins 1` which **inserts** into a value on the VM's stack. Impact's `ins` instruction is the dual to the `idx` instruction we saw used for ledger reads. The value to insert is on top of the stack (that is, the `Bytes<32>` value of `tmp_0`). Underneath that is a path consisting of _N_ elements, where _N_ is the operand of the `ins` instruction. In this case, the path has length 1, so it is the singleton sequence `[3]`. This is the index the Compact compiler has assigned to the top-level ledger field `poster`. The insert instruction removes the value under the path (namely, the public ledger state) and replaces it with a new copy of that value with the location denoted by the path updated to have the new value. Before `ins 1`, the Impact VM's stack had ``. After `ins 1`, it will have `` where `ledger1` is a new public ledger state representing the write to `poster`. The remainder of `_post_0` has two more ledger writes and a return of the Compact empty tuple represented by the JavaScript empty array: const tmp_1 = this._some_0(newMessage_0);Contract._query( context, partialProofData, [ { push: { storage: false, value: __compactRuntime.StateValue.newCell( { value: _descriptor_9.toValue(1n), alignment: _descriptor_9.alignment() }).encode() } }, { push: { storage: true, value: __compactRuntime.StateValue.newCell( { value: _descriptor_5.toValue(tmp_1), alignment: _descriptor_5.alignment() }).encode() } }, { ins: { cached: false, n: 1 } }]);Contract._query( context, partialProofData, [ { push: { storage: false, value: __compactRuntime.StateValue.newCell( { value: _descriptor_9.toValue(0n), alignment: _descriptor_9.alignment() }).encode() } }, { push: { storage: true, value: __compactRuntime.StateValue.newCell( { value: _descriptor_0.toValue(1), alignment: _descriptor_0.alignment() }).encode() } }, { ins: { cached: false, n: 1 } }]);return []; Take a look and see if you can see how the code above works. `publicKey` =========== There is one more way that the on-chain runtime is used by Compact. If we take a look at the implementation of the `publicKey` circuit (the actual implementation, not the wrapper for the exported circuit): _publicKey_0(sk_0, instance_0) { return this._persistentHash_0([new Uint8Array([98, 98, 111, 97, 114, 100, 58, 112, 107, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), instance_0, sk_0]);} We see that the padded string literal has been compiled to an explicit `Uint8Array`. We also see a call to a `_persistentHash_0` method, which is the Compact standard library's [`persistentHash` circuit](https://docs.midnight.network/develop/reference/compact/compact-std-library/exports#persistenthash) . The compiler has included a JavaScript implementation of this circuit: _persistentHash_0(value_0) { const result_0 = __compactRuntime.persistentHash(_descriptor_7, value_0); return result_0;} This is a call to the Compact runtime's [`persistentHash` function](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/functions/persistentHash) . This function in the Compact runtime is a thin wrapper around the on-chain runtime's own [`persistentHash`](https://docs.midnight.network/develop/reference/midnight-api/onchain-runtime/functions/persistentHash) . The difference is that the on-chain runtime's version operates on the ledger encoding of values, and the Compact runtime's version uses the descriptor it is passed to do the relevant conversion. So this is the final capability of the on-chain runtime that we will look at here: it contains implementations of functions like `persistentHash` that are shared between the DApp and the Midnight node. In the next article in this series, we will look at how partial Impact programs get collected together and how the compiler-generated JavaScript code produces so-called public inputs and public outputs for the ZK proof that will be generated. Introduction to the FungibleToken contract on Midnight[​](https://docs.midnight.network/blog/tags/compact#introduction-to-the-fungibletoken-contract-on-midnight "Direct link to Introduction to the FungibleToken contract on Midnight") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ **Midnight** is a privacy-first blockchain designed to bring _privacy_ to decentralized applications. It achieves this through [zero-knowledge proofs, programmable data protection, and developer-friendly tools](https://docs.midnight.network/develop/how-midnight-works/) like **Compact**, a TypeScript-based DSL (Domain-Specific Language) for writing privacy-aware smart contracts. [**OpenZeppelin**](https://docs.openzeppelin.com/) is renowned in the Ethereum ecosystem for its battle-tested smart contract libraries, which have secured trillions in on-chain value. Recently, [OpenZeppelin partnered with Midnight](https://midnight.network/blog/openzeppelin-joins-forces-with-midnight-to-shape-the-future-of-privacy-preserving-smart) to bring comparable tooling to the Compact ecosystem, adapting familiar standards like ERC-20 into privacy-preserving variants. In the Ethereum world, the **ERC-20** standard defines a fungible token with public ledger functions like `balanceOf`, `transfer`, `approve`, etc. It exposes transaction data transparently and lacks built-in privacy. The **FungibleToken** contract on Midnight draws inspiration from this, but operates within Midnight’s zero-knowledge, selective-disclosure framework. Fungible tokens are a cornerstone of the blockchain ecosystem, representing digital assets that are interchangeable – much like traditional currency. On various blockchains, these tokens power a wide array of applications, from facilitating seamless transactions and enabling decentralized finance (DeFi) protocols to representing ownership in digital communities and driving the mechanics of in-game economies. Unlike unique non-fungible tokens (NFTs), the value of one fungible token is identical to another of the same type, making them ideal for use cases requiring divisibility and ease of exchange. Their widespread adoption underscores their importance in building liquid and interconnected digital economies. In this article, you'll learn about the core features of the contract, including how it manages ledger state variables, its key entry points and circuits for operations like minting, burning, and transferring tokens, and the essential safety and utility functions provided by the **Utils** and **Initializable** modules. By understanding how these components fit together, you’ll gain insight into how the **FungibleToken** contract balances fungibility, usability, and privacy, providing an essential building block for privacy-preserving DeFi, identity, and tokenized assets on Midnight. * * * Features of the FungibleToken Contract[​](https://docs.midnight.network/blog/tags/compact#features-of-the-fungibletoken-contract "Direct link to Features of the FungibleToken Contract") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ The FungibleToken contract on Midnight utilizes ledger state variables to keep track of balances, allowances, total supply, name, symbol, and decimals. Its functionality is exposed through "circuits" (entry points) like `Mint`, `Burn`, `Transfer`, `Approve`, `TransferFrom`, and `Initialize`, all of which enforce specific zero-knowledge validated transitions and maintain the integrity of the token's state. ### Ledger State Variables[​](https://docs.midnight.network/blog/tags/compact#ledger-state-variables "Direct link to Ledger State Variables") In Compact, the contract defines a structured **state** storing token balances and allowances—similar to ERC-20. The `_balances` map keeps track of the users’ token balances and is updated when a transfer occurs. The `_allowances` map keeps track of the permission given to specific users to spend tokens on behalf of another user: export ledger _balances: Map, Uint<128>>;export ledger _allowances: Map, Map, Uint<128>>>; These values live in the contract's ledger and are updated through transactions sent to the contract. There are other values in the ledger that are set when the contract is deployed: export ledger _totalSupply: Uint<128>;export sealed ledger _name: Opaque<"string">;export sealed ledger _symbol: Opaque<"string">;export sealed ledger _decimals: Uint<8>; These values provide different information about the token managed by the contract, its total supply, its name, its symbol, and its decimal (for display). ### Entry Points and Circuits[​](https://docs.midnight.network/blog/tags/compact#entry-points-and-circuits "Direct link to Entry Points and Circuits") In Compact, entry points are defined as **circuits** (akin to Solidity functions), each modelling a zero-knowledge validated transition. The difference between a circuit entry point and a circuit is that the entry point is callable via a transaction, while the non-entry point circuit is internal. Core circuits include: * **`Mint` / `Burn`** (to mint new tokens or burn existing tokens). * **`Transfer`**: to move tokens between addresses. * **`Approve`**, **`TransferFrom`**: standard ERC-20-style delegation mechanisms. * **`Initialize`**: via the **Initializable** module for contract setup. Each circuit enforces necessary constraints — for example, ensuring sufficient balance, managing allowance decrements, and preserving total supply. In the next step of the contract lifecycle, the different metadata stored in the ledger of the contract are safely initialized. Initialization and Metadata\*\*[​](https://docs.midnight.network/blog/tags/compact#initialization-and-metadata "Direct link to Initialization and Metadata**") --------------------------------------------------------------------------------------------------------------------------------------------------------------- The following circuits define the essential setup and retrieval logic for the fungible token metadata and users’ balances, enforcing correct initialization. * **`initialize(name_, symbol_, decimals_)`** One-time setup. Calls `Initializable_initialize()`, then stores the (disclosed) name, symbol, and decimals. Every other public circuit asserts that the contract is initialized first. * **`name()` / `symbol()` / `decimals()` / `totalSupply()`** Simple getters that first assert initialized, then return the sealed (read only) ledger values. * **`balanceOf(account)`** Safe map lookup that returns `0` if the account isn’t present (to prevent contract failure if the key is absent). * * * The Transfer Family[​](https://docs.midnight.network/blog/tags/compact#the-transfer-family "Direct link to The Transfer Family") --------------------------------------------------------------------------------------------------------------------------------- The `FungibleToken` contract's **transfer** circuits manage token movement. Key circuits include: `transfer` for safe user-initiated transfers, `_unsafeTransfer` for internal token movement, `_transfer` for administrative transfers, `_unsafeUncheckedTransfer` for low-level token movement, and `_update` as the central accounting function for all token operations. These are split into **safe** and **unsafe** variants because **sending to contract addresses is currently disallowed** (until contract-to-contract interactions are supported). “Safe” circuits enforce that policy; “unsafe” ones let you bypass it—explicitly marked as dangerous in comments. * **`transfer(to, value)` → `Boolean`** Safe user-initiated transfer: rejects if `to` is a `ContractAddress`. Internally, it just forwards to the unsafe variant after the check. * **`_unsafeTransfer(to, value)` → `Boolean`** Owner is the caller (`left(ownPublicKey())`). Moves value using the unchecked internal mover, then returns `true`. * **`_transfer(from, to, value)` → `[]`** Admin/extension hook that moves tokens **from an arbitrary `from`** (not necessarily the caller). Still enforces the “no contracts as `to`” rule and then uses the same mover underneath. * **`_unsafeUncheckedTransfer(from, to, value)` → `[]`** The low-level mover checks that neither side is the zero/burn address and then delegates the actual accounting to `_update`. * **`_update(from, to, value)` → `[]`** **Central accounting function** used by all mint/burn/transfer paths. It’s an internal circuit; it cannot be called via a transaction. * If `from` is zero, the **mint** circuit is called, it asserts no `uint128` overflow, and increases `_totalSupply`. * Else, it deducts from `from` balance (or reverts on insufficient funds). * If `to` is zero, the **burn** circuit is called, and it decreases `_totalSupply`. * Else, it adds to `to` balance. This single function guarantees the invariants for every movement of value. The "transfer family" circuits ensure secure token movement, with "safe" variants disallowing transfers to contract addresses and "unsafe" variants providing lower-level control. This leads us to explore how allowances function, enabling delegated token spending. * * * Allowances (approve / spend / transferFrom)[​](https://docs.midnight.network/blog/tags/compact#allowances-approve--spend--transferfrom "Direct link to Allowances (approve / spend / transferFrom)") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- This section details the allowance mechanisms within the FungibleToken contract, which enable users to delegate spending permissions to other addresses. These circuits facilitate secure, approved transfers on behalf of an owner without directly exposing their private keys. * **`allowance(owner, spender)`** Read the nested `_allowances` map, returning `0` when keys are missing (no revert). * **`approve(spender, value)` → `Boolean`** The owner is the caller. Forwards to `_approve(owner, spender, value)` and returns `true`. * **`transferFrom(from, to, value)` → `Boolean`** Safe delegated transfer: enforces the “no contract receiver” rule, then defers to `_unsafeTransferFrom`. * **`_unsafeTransferFrom(from, to, value)` → `Boolean`** The spender is the caller. First spends allowance via `_spendAllowance(from, spender, value)`, then moves value using `_unsafeUncheckedTransfer`. Returns `true`. * **`_approve(owner, spender, value)` → `[]`** It ensures that both the owner and the spender are valid, creates the owner’s entry in the map if needed, and then writes the allowance. (This mirrors OZ’s ERC-20 pattern of public `approve()` → internal `_approve()`.) * **`_spendAllowance(owner, spender, value)` → `[]`** It deducts from the allowance unless it’s “infinite.” The implementation treats **`MAX_UINT128`** as infinite: if `currentAllowance == MAX`, it doesn’t decrement; otherwise, it asserts `currentAllowance ≥ value` and writes back `currentAllowance - value`. This is important because it supports “no-friction approvals” by letting apps set MAX once. So, we just covered how allowances let people delegate token spending—basically, giving others permission to move their tokens. Up next, we'll dive into how we create and delete tokens in the contract. * * * Minting and Burning[​](https://docs.midnight.network/blog/tags/compact#minting-and-burning "Direct link to Minting and Burning") --------------------------------------------------------------------------------------------------------------------------------- Here's how the FungibleToken contract handles making and destroying tokens. We'll dive into the `_mint` and `_burn` functions, showing what they do and how they link up with the main accounting system. * **`_mint(account, value)`** (safe) → `[]` It forbids minting **to** a contract address (same contract-to-contract restriction), then forwards to `_unsafeMint`. * **`_unsafeMint(account, value)`** → `[]` It validates the receiver’s address, then calls `_update(burnAddress(), account, value)`—i.e., mint is modelled as a transfer **from** the burn/zero address. * **`_burn(account, value)`** → `[]` It validates the sender’s address, then calls `_update(account, burnAddress(), value)`—i.e., burn is a transfer **to** the burn/zero address. _Note:_ The actual notion of “zero/burn” address is standardized in the Utils module; you can also see helpers like `Utils_isKeyOrAddressZero` and `Utils_isContractAddress`. Because mint and burn also route through `_update`, **total supply is adjusted in exactly one place,** and the same safety checks apply across all flows (including the `uint128` overflow check on mint). The mint and burn circuits, by using the `_update` function, make sure the total supply adjustments are always consistent and that all token flows get the same safety checks. Now, let's dive into the extra safety and utility stuff that the `Utils` and `Initializable` modules bring to the table. * * * Safety and Utility Glue (from `Utils` and `Initializable`)[​](https://docs.midnight.network/blog/tags/compact#safety-and-utility-glue-from-utils-and-initializable "Direct link to safety-and-utility-glue-from-utils-and-initializable") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ This section explores how the `Utils` and `Initializable` modules provide essential safeguards and helpful functionalities. These components are vital for ensuring the contract's integrity and enabling secure, well-managed operations. * **Initialization guards**: The `Initializable_initialize` and `Initializable_assertInitialized` functions serve as crucial initialization guards within the `Initializable` contract. These safeguards ensure that a contract's state is properly set up only once and that subsequent operations only proceed if the contract has been correctly initialized. Every circuit that interacts with or modifies the contract's state is designed to invoke the `assert` function, reinforcing the integrity of the initialization process. * **Address helpers**: * `Utils_isContractAddress(either)` distinguishes user keys from contract addresses. * `Utils_isKeyOrAddressZero(either)` detects the zero/burn address used in `_update`, `_unsafeUncheckedTransfer`, etc. These support the temporary “no contract receiver” policy and zero-address checks. The **Utils** and **Initializable** modules provide crucial safety and utility functions, ensuring the contract's proper setup and secure operation. Now, let's look at how all these different parts of the **FungibleToken** contract work together. * * * How the Pieces Fit Together[​](https://docs.midnight.network/blog/tags/compact#how-the-pieces-fit-together "Direct link to How the Pieces Fit Together") --------------------------------------------------------------------------------------------------------------------------------------------------------- This part shows how everything in the FungibleToken contract is hooked up. Whether it's you sending tokens, someone else doing it for you, or tokens being created or destroyed, it all funnels through a few key functions and ultimately lands in the main `_update` function to keep track of everything. * User transfer: `transfer` → _(safe check)_ → `_unsafeTransfer` → `_unsafeUncheckedTransfer` → `_update` (balances/supply) * Delegated transfer: `transferFrom` → _(safe check)_ → `_unsafeTransferFrom` → `_spendAllowance` → `_unsafeUncheckedTransfer` → `_update` * Mint/Burn: `_mint/_unsafeMint` or `_burn` → `_update` (with zero/burn address on one side) This section illustrates how various token operations, from user transfers to minting and burning, ultimately funnel through the central `_update` function for consistent accounting. Now, let's summarize the key takeaways of the **FungibleToken** contract on Midnight. * * * Conclusion[​](https://docs.midnight.network/blog/tags/compact#conclusion "Direct link to Conclusion") ------------------------------------------------------------------------------------------------------ The **FungibleToken** Compact contract on Midnight is a privacy-aware reimagining of the ERC-20 standard. It maintains the familiar token interfaces—balances, transfers, approvals—but encodes them as ZK-validated circuits within Compact, enabling private, verifiable execution. The contract’s state and logic are shielded by design, exposing only proofs rather than raw data to the blockchain. The ERC-20 standard revolutionized the crypto landscape by providing a common framework for creating and managing digital assets, fostering interoperability, and accelerating the growth of decentralized applications. For Midnight, an ERC-20-based token is crucial as it leverages this established standard while integrating ZK-privacy, offering a familiar yet enhanced experience for developers and users seeking both functionality and confidentiality. This model contrasts sharply with ERC-20 on Ethereum, where all token movements and balances are fully transparent. Here, Midnight allows selective disclosure: users and applications choose what to reveal. The **FungibleToken** contract thus balances fungibility, usability, and privacy—providing an essential building block for privacy-preserving DeFi, identity, and tokenized assets on Midnight. * * * Links[​](https://docs.midnight.network/blog/tags/compact#links "Direct link to Links") --------------------------------------------------------------------------------------- Delve deeper into the code, contracts, and comprehensive documentation to enhance your understanding and development skills. These resources are invaluable for building robust and innovative solutions. * FungibleToken contract: [FungibleToken.compact on Github](https://github.com/OpenZeppelin/compact-contracts/blob/main/contracts/fungibleToken/src/FungibleToken.compact) * OpenZeppelin documentation: [docs.openzeppelin.com](https://docs.openzeppelin.com/contracts-compact/0.0.1/fungibletoken) * ERC20 standard: [ethereum.org](https://ethereum.org/en/developers/docs/standards/tokens/erc-20/) * Midnight docs: [Midnight Developer Documentation](https://docs.midnight.network/) * Do you have any questions?: [Midnight Forum](https://forum.midnight.network/) After participating in three hackathons this year, I thought I had a good idea of what to expect. Then came the fourth. It began like the others: an idea, a challenge, a blank terminal screen. But this one took an unexpected turn, one I didn't see coming. I had recently left my software engineering role to explore zero-knowledge protocols, an area in which I didn’t have much experience. It was a risk, but one I felt I had to take. I chose to pursue this path not only because zero-knowledge cryptography is built on one of the most elegant branches of mathematics, but also I believe privacy on the blockchain or on the internet is fundamental and should never be an afterthought. One day, my mentor casually mentioned the [African Blockchain Championship](https://www.africanblockchamp.com/) and suggested I look into the Zero-Knowledge track. That small nudge became a turning point. That’s when I discovered [Midnight](https://midnight.network/) ! Meet Midnight: Privacy on the Blockchain ======================================== Midnight is a zero-knowledge proof-based privacy chain developed by Input Output, the parent company of Cardano. As a partner chain of Cardano, it aims to bring rational privacy through zero-knowledge technology to the broader ecosystem. They weren’t just building another blockchain—they were laying the foundation for private, decentralized computation. After diving into the documentation and setting up the tools, everything was finally in place. All that remained… was to begin. Only later did I realize: this wasn’t just the start of another hackathon—it was the beginning of something much bigger. Building on Midnight ==================== Hacking on Midnight was challenging, as building in a testnet environment requires constant learning and adaptation to major changes. Within just a few weeks, significant network updates rendered the existing examples incompatible with the latest SDK versions. As a result, an example had to be cloned and debugged line by line. The example repository was dense, filled with layers of files and directories, and figuring out where to start was a challenge in itself. Fortunately, Midnight’s smart contract language, [Compact](https://docs.midnight.network/develop/reference/compact/) , shares a syntax similar to TypeScript, which eased the learning curve. I pushed forward, determined to build something meaningful and make my mark—but in the end, my attempt fell short. With midterm exams approaching and the hackathon submission deadline close by, I had to make a difficult decision. I decided not to submit a project to the African Blockchain Championship hackathon. Still, a quiet sense of regret lingered. I couldn’t help but wonder: what if I had just pushed a _little_ harder? The Extended Deadline ===================== About a week later, I received an email from the ABC team announcing that the hackathon deadline had been extended. I was thrilled, and I promised myself I’d give it everything this time. It wasn’t long before I was back at it. A few weeks had passed since I’d last touched the project, and during that time, both the network and SDKs had been updated. I gathered my gear, updated my environment, and set out with renewed determination to finally build something solid. I wrote my contract and began debugging, but each change introduced a new layer of complexity. Every update required changes across multiple files. It was frustrating, exhausting, but strangely thrilling. I began thinking of ways to simplify the chaos, to make the process less painful, more intuitive. That’s when I started creating small scripts to streamline the workflow. Earlier that month, I had joined the [Midnight Discord](https://discord.com/invite/midnightnetwork) to ask questions. One week, I jumped on a Discord community call, and to my surprise, I learned about an ongoing Midnight tooling hackathon that was happening asynchronously. Right then, it clicked: _this_ was the hackathon I was meant to be part of from the start. From Personal Tool to Shared Project ==================================== What started as a personal tool suddenly took on a bigger purpose. The hackathon provided me with the opportunity to share my work with others and contribute to shaping the future of smart contract development on Midnight. I took a little detour from my original hackathon submission—promising myself I’d return to it—and began refining the tool, aiming not just to build something functional, but something genuinely useful for newcomers to the ecosystem. Scaffold Midnight & Create Midnight App[​](https://docs.midnight.network/blog/tags/compact#scaffold-midnight--create-midnight-app "Direct link to Scaffold Midnight & Create Midnight App") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- That’s how [**Scaffold Midnight**](http://github.com/kaleababayneh/scaffold-midnight) was born, a cloneable GitHub starter template. But I didn’t stop there. I realized it would be even more useful as an npm library, something developers could install with all dependencies bundled and start using right away. So, I polished the project and released the first version as [**create-midnight-app**](https://www.npmjs.com/package/create-midnight-app) . But I didn’t want to stop at solving just one problem. Every issue I fixed revealed another. Through multiple iterations, I kept refining the library. It’s now at version 2.1.7, and I’m actively working to make it compatible with the latest release of Compact. It’s far from perfect, and that’s what makes it exciting. Every day, I wake up with a new idea, a new feature to add, or a better way to improve the developer experience! ![Create Midnight App](https://ibin.co/8rMdmI75JRDl.png) At its core, **create-midnight-app** is a scaffolding npm library for Midnight that automates the entire setup process. Developers can focus solely on writing their Compact contracts; the tool takes care of the rest. It handles wallet creation, faucet requests, balance checks, API configuration, CLI updates, and even function and file change imports are updated automatically. It reduces initial application setup time from over half an hour to just a few minutes. I had several euphoric moments while working on this project, but one instance in particular, stands out. One feature I was eager to build was a way for developers to request testnet tokens without ever leaving their code editor. The simplest idea was to send a request from the terminal directly to the official [Midnight faucet](https://docs.midnight.network/blog/tags/%20https://midnight.network/test-faucet) . But there was a catch—the site is protected by [Cloudflare Turnstile](https://www.cloudflare.com/application-services/products/turnstile/) , which blocks automated requests to prevent spam and abuse. As a hacker, I started looking for a workaround. After some Googling and tips from friends, I tested several paid tools that claimed to bypass CAPTCHA protections. I spent an entire afternoon trying them, but none worked reliably. That’s when I remembered the genesis wallet, whose private key is publicly available. So, I implemented a workaround: instead of calling the faucet, I simulated a faucet transaction by transferring tokens directly from the genesis wallet to the user’s wallet. It’s not a long-term solution, and I know it won’t scale—but for now, it works and helps streamline the developer experience. Submission and Recognition ========================== I finally submitted my project, and the judges’ reactions were incredibly [encouraging](https://youtu.be/xrCEBIBqS-Y?t=4453) —it gave me a renewed sense of inspiration. With that momentum, I turned my focus back to my original hackathon: the African Blockchain Championship. For this challenge, I built an anonymous, censorship-resistant voting platform. In many African countries—across 34 nations—roughly 30–40% of citizens no longer view voting as a fair or trustworthy process (Afrobarometer, 2023). That’s why anonymous voting isn’t just a feature—it’s a necessity. My project, [**Privote**](https://github.com/kaleababayneh/zkvote-midnight) , aims to address this critical issue by leveraging zero-knowledge technology to protect voter identity and integrity. As the submission deadline approached, I ran into a major hurdle: integrating the wallet into the frontend. I reached out to one of the Developer Relations Engineers, who kindly shared some example code. Unfortunately, I couldn’t get it working in time. With the clock ticking, I had to improvise. I quickly built a custom Chrome extension that enabled wallet interaction—running through the terminal on the backend—just in time for submission. While the current version still has some privacy limitations, the smart contract compiles successfully, and users can interact with it on the Midnight testnet—offering a real glimpse of what decentralized, anonymous voting could look like in practice. ![Private Hackathon](https://ibin.co/8rMho4816dhp.png) The Midnight Community ====================== Even though there aren’t many resources available yet, the Midnight community more than makes up for it. Almost every question asked on Discord gets a response. It’s a space where people genuinely support each other—even during hackathons, when we’re technically competing and have little incentive to help other teams. In fact, during the hackathon, I often found myself answering questions in the Telegram group. I even hosted a workshop at the ABC hackathon on how to use **Create Midnight App**, helping others get started quickly and navigate the ecosystem more easily. I also want to take a moment to thank the Midnight team for the recognition they gave me—it truly meant a lot. Beyond placing first in the CLI track, the support and appreciation I received from the community were genuinely heartwarming. I even had the chance to join a community call—not just as a participant this time, but as a [speaker](https://x.com/MidnightNtwrk/status/1942969613496758398) —to share my journey and the lessons I’d learned along the way. Why Now is the Time to Build on Midnight ======================================== And for you—my readers—this is honestly the best time to get involved in the Midnight ecosystem. There’s _almost always_ a hackathon happening (seriously, it's kind of wild!). Right now, they’re even running a [mini DApp hackathon](https://midnight.network/hackathon/midnight-mini-dapp-hackathon) . It’s an excellent opportunity to learn, build, and get your project noticed. ![Midnight Dapp Hackathon](https://ibin.co/8rMcCFquPRqS.png) As for me, I’m currently building something new for the hackathon. While I enjoy working on projects, I’ve found even more fulfillment in developing infrastructure tools. I have a long-term goal of building a web-based Midnight playground where anyone can start writing Compact code and begin interacting with the Midnight testnet without needing to install anything. I hope to continue collaborating with the Midnight team and growing my skills—especially in zero-knowledge protocols—as I continue this journey. We are proud to announce the launch of the Compact developer tools! Today we are launching `compact`, a command-line tool that is used for installing the Compact toolchain (e.g., the compiler), keeping it up to date, and invoking the toolchain tools themselves. The developer tools are now the "official" supported way to install and update the toolchain and to invoke other Compact tooling such as the Compact compiler. To avoid confusion, we will make a careful distinction between the "Compact toolchain" and the "Compact developer tools". The toolchain contains the compiler and will eventually contain other tooling that is specific to a particular version of the Compact language. The developer tools include the updater tools and will eventually support other tools that work consistently across different versions of the language. In the initial release, the Compact developer tools are primarily used to manage the installation of a Compact toolchain, but they will support additional tooling in the future. There is no new release of the Compact toolchain yet, but you can already start using the new developer tools to install and invoke the current version of the compiler. The Old Toolchain Installation Method ===================================== Before this new release, installing the Compact toolchain was a manual and tedious process: 1. Developers had to download a ZIP file for a specific compiler version and platform architecture 2. They then had to extract it to a directory included in their PATH 3. On macOS, they would have to give permission to run the two different binaries (the compiler and the ZK-key generator). This process would have to be repeated each time there was a new Compact toolchain release. Keeping multiple versions installed at once was also cumbersome and hard to manage. The New Toolchain Installation Method ===================================== The new way to install the Compact toolchain starts with a one-time installation of the `compact` command-line tool. Once installed, the developer tools can update themselves automatically. To install, run the following command: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/midnightntwrk/compact/releases/latest/download/compact-installer.sh | sh This command will download and run a shell script. It will instruct you how to add the binary directory it uses to your `PATH` environment variable. Once you've done this, the `compact` command line tool is available to use. This tool has a number of useful subcommands that can be invoked. For instance, to **update** the toolchain to the latest version, you will run the command: compact update The output will look something like this (on an Apple Silicon macOS machine, for instance): compact: aarch64-darwin -- 0.24.0 -- installedcompact: aarch64-darwin -- 0.24.0 -- default. This subcommand will switch to the latest version of the toolchain available for your architecture. As of today, this is version 0.24.0 which is reported by the tool. The `compact` tool will download the toolchain artifacts if necessary (you will see a progress meter while it downloads). If you have already downloaded the artifacts, the tool will simply switch the default version to be the latest version. When there is a new Compact toolchain release, such as 0.25.0, you will use the same subcommand as above to update to that new version. You can **check** if there is a new version available using the `check` subcommand like this: compact check If there is a new version available, you will see something like: compact: aarch64-darwin -- Update Available -- 0.24.0compact: Latest version available: 0.25.0. This is reporting that you are on version 0.24.0 and that 0.25.0 is available. note You will not actually see this output until there is a new version available. Instead, you will see that you are on the latest version: compact: aarch64-darwin -- Up to date -- 0.24.0 Switching Toolchain Versions ============================ You can also "update" to any other available toolchain, including previous ones. You can **list** all the versions available with the command: compact list The output will look something like this: compact: available versions→ 0.24.0 - x86_macos, aarch64_macos, x86_linux 0.23.0 - aarch64_macos, x86_linux 0.22.0 - x86_macos, x86_linux This is showing the different versions, and which platforms they are available for. The arrow indicates the current default version, 0.24.0 in this case. This default is whichever you have currently set as the default (via `compact update`). You can pass the flag `--installed` (or `-i`) to `compact list` to see the versions that are actually downloaded locally: compact list --installed The output will probably look like this: compact: installed versions→ 0.24.0 The update subcommand can be used with a specific version to switch to that version. For example: $ compact update 0.23.0compact: aarch64-darwin -- 0.23.0 -- installedcompact: aarch64-darwin -- 0.23.0 -- default.$ compact list --installedcompact: installed versions 0.24.0→ 0.23.0 note If you are on an Intel x86 macOS computer, you will not be able to update to version 0.23.0 because it was not available for that architecture. You can try the same commands above with version 0.22.0 instead. You can now switch back to the latest version with `compact update` or `compact update 0.24.0`. This time, nothing will be downloaded because that version is already installed locally. Invoking the Compiler ===================== In addition to keeping the toolchain updated, the `compact` tool will also be the official supported way to invoke all the toolchain tools themselves. For the time being, the only such tool is the compiler, but we will be building out more tools in the future. The compiler can be invoked with the `compile` subcommand: compact compile This will use the current default version of the toolchain (the one indicated by the arrow in `compact list`). note If you are using macOS, you no longer have to explicitly give permission to run the compiler and ZK-key generation binaries. You can override the default to use a specific (already installed) version by including the version number after a plus (`+`) sign like: compact compile +0.23.0 Looking ahead, we plan to remove the `compactc` executable. Going forward, `compact compile` will become the standard way to invoke the Compact compiler. Built-in Help ============= The `compact` tool and all of its subcommands have detailed help pages provided by the tools themselves. You can see these in two different ways, either using the `help` subcommand or by using the `--help` flag. For the Compact tool itself, you can invoke `compact help` or `compact --help` and you will see the exact same help page. This page shows all the subcommands (`compile` is currently listed at the bottom of the page). It also shows common command line options. For a specific subcommand, such as `update`, you can see detailed help either via `compact help update` or `compact update --help`. You can use the help pages to find all the subcommands and their options. note Because of the way that the tools are currently implemented, you cannot get compiler help via `compact help compile`. Instead, you will have to use `compact compile --help`. Versions ======== The developer tools are separately versioned from the toolchain (i.e., compiler) itself. This is because the tools are capable of managing multiple versions of the toolchain. You can see the version of the developer tools with `compact --version`. That should currently be 0.1.0. You can also see the version of subcommands like `compact update --version`. Currently, built-in subcommands (that is, ones implemented by the developer tools, not the toolchain) all have the same version as the developer tools. You can find the version of the toolchain with `compact list -i` or `compact check` (though the latter will make an Internet check to see if there is a new version). You can also find it from the compiler via `compact compile --version`. This should currently be 0.24.0 if you are on the latest version. As before, the Compact language itself is versioned separately from the toolchain. You can find this from the compiler via `compact compile --language-version`. Keeping the Developer Tools Up to Date ====================================== Once they are installed, the developer tools are capable of keeping themselves up to date. You can check for updates with `compact self check`, and you can update to the latest version of the tool with `compact self update`. We have not provided a way to go back to a previous version of the developer tools themselves, because you generally won't need to do that. You don't necessarily have to update the developer tools themselves all the time, either. You **will** however want to update the developer tools themselves when we make more developer tools available. For example, a future release will include a Compact formatter available via a `compact format` subcommand. You will need to update the developer tools themselves to get access to the formatter tool. We will always announce such updates in the release notes for both the toolchain and the developer tools. How it Works ============ The tool is currently a simple one, but its architecture is flexible and it will eventually support many more different developer tools. If you look at the help pages, you will see that the tools take a `--directory` command-line flag which tells them where to find the toolchain. By default this will be the directory `.compact` in your home directory. If you look in that directory, you will see two subdirectories: `bin` and `versions`. The `versions` subdirectory contains separate subdirectories for each installed version, which contain the toolchain artifacts for that version. The `bin` subdirectory represents the default version, which is just a symbolic link to one of the installed versions. The command line tool is capable of checking for updates and downloading and unzipping toolchain artifacts if necessary. Switching between installed versions just changes the `bin` symbolic link to point to a different installed toolchain. Invoking the toolchain itself just invokes the corresponding default executables in the `bin` directory, or for a specific version if necessary. This blog post is part of the Compact Deep Dive series, which explores how Compact contracts work on the Midnight network. Each article focuses on a different technical topic and can be read on its own, but together they provide a fuller picture of how Compact functions in practice. [Compact Deep Dive - Part 1](https://docs.midnight.network/blog/compact) looked at the TypeScript API of the Compact compiler-generated contract implementation. If you haven’t read it yet, we encourage you to start there. This article looks at how circuits and witnesses are actually implemented in JavaScript code generated by the Compact compiler. In part 1, we used the Bulletin Board tutorial contract as an example. We compiled it with the Compact compiler and started looking at the files generated by the compiler. We used Compact toolchain version 0.24.0. Recall the caveat from part 1 that the generated code is an implementation detail of the platform. We freely change it, so it can be different when different versions of the compiler are used. Circuits[​](https://docs.midnight.network/blog/tags/compact#circuits "Direct link to Circuits") ------------------------------------------------------------------------------------------------ We looked at the bulletin board contract’s `post` circuit. The compiler generated a TypeScript declaration file that includes a declaration for the circuit: post(context: __compactRuntime.CircuitContext, newMessage_0: string): __compactRuntime.CircuitResults; Recall that the types [`CircuitContext`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/interfaces/CircuitContext) and [`CircuitResults`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/interfaces/CircuitResults) came from the Compact runtime used by the compiler. In the file `index.cjs` the compiler has generated a JavaScript implementation of this circuit. You will find this in the `contract` subdirectory of the compiler output directory you gave on the `compact` command line when compiling the contract’s Compact source code. The implementation is installed as a property on the `circuits` object of the contract in class `Contract`’s constructor. The entirety of the code is here (we will drill down into this in the rest of this section): this.circuits = { post: (...args_1) => { if (args_1.length !== 2) throw new __compactRuntime.CompactError(`post: expected 2 arguments (as invoked from Typescript), received ${args_1.length}`); const contextOrig_0 = args_1[0]; const newMessage_0 = args_1[1]; if (!(typeof(contextOrig_0) === 'object' && contextOrig_0.originalState != undefined && contextOrig_0.transactionContext != undefined)) __compactRuntime.type_error('post', 'argument 1 (as invoked from Typescript)', 'bboard.compact line 26 char 1', 'CircuitContext', contextOrig_0) const context = { ...contextOrig_0 }; const partialProofData = { input: { value: _descriptor_4.toValue(newMessage_0), alignment: _descriptor_4.alignment() }, output: undefined, publicTranscript: [], privateTranscriptOutputs: [] }; const result_0 = this.#_post_0(context, partialProofData, newMessage_0); partialProofData.output = { value: [], alignment: [] }; return { result: result_0, context: context, proofData: partialProofData }; }, ### Runtime Type Checks[​](https://docs.midnight.network/blog/tags/compact#runtime-type-checks "Direct link to Runtime Type Checks") The first part of this implementation is so-called “boilerplate” code that is generated by the compiler for every circuit. Every circuit has essentially the same code, differing only slightly depending on the number and names of the arguments, file names, and source code positions. Let’s focus on that code first: if (args_1.length !== 2) throw new __compactRuntime.CompactError(`post: expected 2 arguments (as invoked from Typescript), received ${args_1.length}`);const contextOrig_0 = args_1[0];const newMessage_0 = args_1[1];if (!(typeof(contextOrig_0) === 'object' && contextOrig_0.originalState != undefined && contextOrig_0.transactionContext != undefined)) __compactRuntime.type_error('post', 'argument 1 (as invoked from Typescript)', 'bboard.compact line 26 char 1', 'CircuitContext', contextOrig_0)const context = { ...contextOrig_0 }; There are some runtime type checks here. First, we check that the actual number of arguments passed matches the expected number. In this case, that’s two (the second one is the circuit’s parameter `newMessage` and the first one is the `CircuitContext` parameter inserted by the compiler). If not, we’ll throw an exception. This is one way that Compact differs from TypeScript. The JavaScript code produced by the TypeScript compiler does not check argument counts or types at run time because it assumes that the calling code has also passed the TypeScript type checker. Because the correctness of your contracts will depend on it, we do not assume that. Instead, the generated JavaScript code will perform the appropriate checks at run time. A `const` binding is used to give the first argument a name based on `contextOrig` (always) and the second argument is named based on whatever name we used in the Compact source code. The suffixes like `_0` added on variable names is the way that the compiler ensures that it always generates unique names. Then we have some runtime type checks that the first argument actually satisfies the interface for `CircuitContext` defined in the Compact runtime. Finally, we copy the original `CircuitContext` and name it `context`. We do this so that we can mutate the copy without changing the original one that was passed to us. ### Proof Data[​](https://docs.midnight.network/blog/tags/compact#proof-data "Direct link to Proof Data") The big-picture view of a `post` transaction is that it runs the JavaScript implementation of the circuit, with full access to the private state provided by its witnesses. Then we ask the proof server to generate a zero-knowledge (ZK) proof that the circuit ran as expected. Specifically, we prove that we know the private data required to produce the observed on-chain behavior—without revealing that private data. In order to do that, we have to collect some information about running the circuit in the so-called “proof data”. We next initialize that data: const partialProofData = { input: { value: _descriptor_4.toValue(newMessage_0), alignment: _descriptor_4.alignment() }, output: undefined, publicTranscript: [], privateTranscriptOutputs: []}; This is a JavaScript value that satisfies the TypeScript interface [`ProofData`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/interfaces/ProofData) from the Compact runtime. To understand this, we need to look inside of the definition. That definition (from the version of the Compact runtime used by the Compact compiler version 0.24.0) is: interface ProofData { input: AlignedValue; output: AlignedValue; privateTranscriptOutputs: AlignedValue[]; publicTranscript: Op[];} This is called `partialProofData` because it will not necessarily contain **all** the proof data that we need. When we run the JavaScript code for the circuit off chain, some conditional branches will be skipped. In these cases, the proof will require 'dummy' data to fill in for branches that were not taken. We’ll explore that in more detail later in the series. The initial value is kind of like the boilerplate we saw before. The properties `input`, `output`, and `publicTranscript` have default initial values. The initial value of `input` depends on the number and types of the parameters to the circuit in Compact: From the TypeScript declaration of ProofData, we can see that `input` has type `AlignedValue`. This is the type alias [`AlignedValue`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/type-aliases/AlignedValue) from the Compact runtime. And from the TypeScript declaration for that we can see that it has a pair of properties, `alignment` and `value`. ### Descriptors[​](https://docs.midnight.network/blog/tags/compact#descriptors "Direct link to Descriptors") To fully understand this, let’s take a look at the Compact runtime TypeScript declaration of AlignedValue: type AlignedValue = { alignment: Alignment; value: Value;}; We’ll gloss over `Alignment`, but it’s instructive to see what [`Value`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/type-aliases/Value) is: type Value = Uint8Array[]; So an aligned value is an alignment tag of some kind and a value which is an array of `Uint8Arrays`. This is the ledger’s encoding of Compact values in the on-chain runtime. That’s a different encoding from the JavaScript encoding of the same value. We have two different representations for the same values. One is native JavaScript objects. The other is a binary encoding, used in the on-chain runtime. To convert between these two representations, we use so-called “descriptors”. They are the JavaScript representation of Compact types. More specifically, they are objects implementing the [`CompactType`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/interfaces/CompactType) interface. They have three methods: `toValue` to convert from a JavaScript value to an on-chain value, `fromValue` to convert from an on-chain value to a JavaScript value, and `alignment` to return the alignment of the on-chain value. The code for the `ProofData`’s input (representing the `post` circuit’s `newMessage` argument) was: input: { value: _descriptor_4.toValue(newMessage_0), alignment: _descriptor_4.alignment()}, The compiler generates top-level `const` bindings in JavaScript for a number of descriptors that it has used in the generated JavaScript code. If we look at `_descriptor_4` in `index.cjs` we see: const _descriptor_4 = new __compactRuntime.CompactTypeOpaqueString(); It’s an instance of a descriptor for a Compact value of type `Opaque<"string">`. The Compact runtime defines descriptor classes for all the Compact types, such as [`CompactTypeOpaqueString`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/classes/CompactTypeOpaqueString) . The JavaScript representation of the Compact type `Opaque<"string">` is as a JavaScript string and the ledger representation is as a (tagged) single-element array consisting of the JavaScript string’s UTF-8 encoding. The proof data we will build up while executing the circuit contains ledger representations of values, so we use the descriptor’s `toValue` method to convert the `newMessage` parameter to that representation. ### Wrapping it Up[​](https://docs.midnight.network/blog/tags/compact#wrapping-it-up "Direct link to Wrapping it Up") Finally, we have a last little bit of code: const result_0 = this.#_post_0(context, partialProofData, newMessage_0);partialProofData.output = { value: [], alignment: [] };return { result: result_0, context: context, proofData: partialProofData }; This calls a method on the contract named `#_post_0`, which contains the **actual** implementation of the `post` circuit. What we’ve been looking at (the `post` method) is a mostly boilerplate wrapper around this implementation. The implementation method takes the context and passes along the arguments, along with the proof data object we’ve constructed for it. Then after it returns, we will set the `output` property of the proof data. The way that’s set depends on the return type of the Compact circuit. In this case it was the Compact type `[]`, so that’s relatively uninteresting. If you take a look at the `takeDown` circuit in the same contract, you will see the slightly more interesting: partialProofData.output = { value: _descriptor_4.toValue(result_0), alignment: _descriptor_4.alignment() }; Remember that `_descriptor_4` was the one for the Compact type `Opaque<"string">`, and the proof data has ledger values. The circuit implementation in JavaScript will return a JavaScript value, so we need to encode it into the ledger’s representation using `toValue` and `alignment`. And finally, we return the result of the circuit invocation. Recall that this was a [`CircuitResults`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/interfaces/CircuitResults) (where `T` is the contract’s private state type). That interface is in the Compact runtime and it looks like: interface CircuitResults { context: CircuitContext; proofData: ProofData; result: U;} We will look more closely into the actual circuit implementation `#_post_0` in the next article in this series. ### What are Wrappers For?[​](https://docs.midnight.network/blog/tags/compact#what-are-wrappers-for "Direct link to What are Wrappers For?") Why do we wrap the implementation in this way? There are a couple of reasons. First, the mostly boilerplate code we have been looking at is used when we call the circuit from JavaScript code in our DApp. So it needs to have the extra runtime checks that we see for safety. But when we call the circuit from another Compact circuit, we do not need these type checks. The Compact type system guarantees that we don’t need extra runtime checks, so we can directly call the implementation function (such as `#_post_0`). And second, when we call a Compact circuit from another one, that is considered part of the same transaction that we are constructing. So in that case, we don’t want to construct a fresh `ProofData` object to pass in, and we don’t want to box up the results in a `CircuitResults` object. We only need to do that at the outermost circuit call, coming from the DApp’s JavaScript code. Witnesses[​](https://docs.midnight.network/blog/tags/compact#witnesses "Direct link to Witnesses") --------------------------------------------------------------------------------------------------- Let’s take a quick look at the implementation of witnesses. Our contract has one, and we expect it to be passed in when we construct the contract. The constructor for class `Contract` has some runtime type checking code for that: constructor(...args_0) { if (args_0.length !== 1) throw new __compactRuntime.CompactError(`Contract constructor: expected 1 argument, received ${args_0.length}`); const witnesses_0 = args_0[0]; if (typeof(witnesses_0) !== 'object') throw new __compactRuntime.CompactError('first (witnesses) argument to Contract constructor is not an object'); if (typeof(witnesses_0.localSecretKey) !== 'function') throw new __compactRuntime.CompactError('first (witnesses) argument to Contract constructor does not contain a function-valued field named localSecretKey'); this.witnesses = witnesses_0; Then, probably more interesting, the witnesses are also wrapped. The contract has a method for each witness, like: #_localSecretKey_0(context, partialProofData) { const witnessContext_0 = __compactRuntime.witnessContext(ledger(context.transactionContext.state), context.currentPrivateState, context.transactionContext.address); const [nextPrivateState_0, result_0] = this.witnesses.localSecretKey(witnessContext_0); context.currentPrivateState = nextPrivateState_0; if (!(result_0.buffer instanceof ArrayBuffer && result_0.BYTES_PER_ELEMENT === 1 && result_0.length === 32)) __compactRuntime.type_error('localSecretKey', 'return value', 'bboard.compact line 24 char 1', 'Bytes<32>', result_0) partialProofData.privateTranscriptOutputs.push({ value: _descriptor_2.toValue(result_0), alignment: _descriptor_2.alignment() }); return result_0;} The circuit wrapper `post` was used when we called the circuit from JavaScript code, and bypassed (by directly calling the implementation `#_post_0`) when we called it from Compact code. For witnesses, the situation is reversed. You can call your witnesses (like `witnesses.localSecretKey`) all you want from JavaScript code and we don’t care and won’t even observe it. But if you call them from a Compact circuit, we will need to know about it, so we’ll call a wrapper (like `localSecretKey_0`). Your witness implementation expects to have a `WitnessContext` argument passed to it, so here we’ll construct one to pass in. It contains the ledger, current private state, and the contract’s address. We get the JavaScript representation of the public ledger state using the compiler-generated `ledger` function that we looked at in part 1 of this series. Then we actually invoke your witness implementation, getting the result and a new private state. We mutate the context to update the private state (remember, we copied the original context before invoking a circuit implementation so it was safe to mutate the copied context). Next, we have runtime type checks after the witness returns. This is for the same reason that we check arguments coming in to circuits from JavaScript: we don’t control the witness implementation and we need to make sure that the return value is as expected for the circuit. Compact’s type safety depends on these runtime checks. Finally, we record the witness’s return value in the proof data's private transcript that we are building while running the outermost Compact circuit call. This is private data and so for the ZK proof we construct the proof server will need to know it (so the proof server can prove that it knows the private data). In the next article in this series, "Compact Deep Dive Part 3: The On-Chain Runtime", we will take a closer look at the actual implementation of the `post` circuit from the bulletin board contract and see how it uses the on-chain runtime. This post is part of the Compact Deep Dive series, which explores how Compact contracts work on the Midnight network. Each article focuses on a different technical topic and can be read on its own, but together they provide a fuller picture of how Compact functions in practice. The articles assume that you are familiar with Compact to the level of detail covered in the [developer tutorial](https://docs.midnight.network/develop/tutorial/) . Some posts in this series take a deep technical dive into the implementation details of ZK proofs and the Midnight on-chain runtime. These insights reflect the current architecture, but since they describe low-level mechanics, they may change as the platform evolves. One caveat to keep in mind is that almost everything here should be considered an implementation detail. That means that the details are not stable, and they can and will change as we see fit. Overview of the Bulletin Board Contract[​](https://docs.midnight.network/blog/tags/compact#overview-of-the-bulletin-board-contract "Direct link to Overview of the Bulletin Board Contract") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- We'll use our old favorite, [Bulletin Board](https://docs.midnight.network/develop/tutorial/creating/bboard-contract#compiling-the-contract) as an example. We're compiling this with Compact toolchain version 0.24.0. The Compact language is a moving target as we introduce and change features, so this code may not compile with any Compact toolchain version other than 0.24.0. note All the code in this section is Compact code pragma language_version 0.16;import CompactStandardLibrary;export enum State { VACANT, OCCUPIED}export ledger state: State;export ledger message: Maybe>;export ledger instance: Counter;export ledger poster: Bytes<32>;constructor() { state = State.VACANT; message = none>(); instance.increment(1);}witness localSecretKey(): Bytes<32>;export circuit post(newMessage: Opaque<"string">): [] { assert(state == State.VACANT, "Attempted to post to an occupied board"); poster = disclose(publicKey(localSecretKey(), instance as Field as Bytes<32>)); message = disclose(some>(newMessage)); state = State.OCCUPIED;}export circuit takeDown(): Opaque<"string"> { assert(state == State.OCCUPIED, "Attempted to take down post from an empty board"); assert(poster == publicKey(localSecretKey(), instance as Field as Bytes<32>), "Attempted to take down post, but not the current poster"); const formerMsg = message.value; state = State.VACANT; instance.increment(1); message = none>(); return formerMsg;}export circuit publicKey(sk: Bytes<32>, instance: Bytes<32>): Bytes<32> { return persistentHash>>([pad(32, "bboard:pk:"), instance, sk]);} We’ll focus on the `post` circuit. First, let’s refresh your memory about the basics of the contract. It declares a Compact `enum` type for the bulletin board’s state, and it declares some ledger fields. Three of them are mutable ledger cells and one of them is a `Counter`: export enum State { VACANT, OCCUPIED}export ledger state: State;export ledger message: Maybe>;export ledger instance: Counter;export ledger poster: Bytes<32>; There is a witness that has access to private state. This is a foreign function implemented in JavaScript or TypeScript. It looks up the user’s secret key somehow and returns it. The `post` circuit makes sure that the bulletin board is in the `VACANT` state and, if so, uses the witness to get the secret key and updates the three cells in the ledger: witness localSecretKey(): Bytes<32>;export circuit post(newMessage: Opaque<"string">): [] { assert(state == State.VACANT, "Attempted to post to an occupied board"); poster = disclose(publicKey(localSecretKey(), instance as Field as Bytes<32>)); message = disclose(some>(newMessage)); state = State.OCCUPIED;} There is also a helper circuit called `publicKey`, which is used by both the `post` and `takeDown` circuits. Declaring `publicKey` as exported has two effects: * It makes the circuit callable from TypeScript or JavaScript. * It makes it a contract entry point, allowing `publicKey` transactions to be submitted to the Midnight blockchain. export circuit publicKey(sk: Bytes<32>, instance: Bytes<32>): Bytes<32> { return persistentHash>>([pad(32, "bboard:pk:"), instance, sk]);} A Look Under the Hood[​](https://docs.midnight.network/blog/tags/compact#a-look-under-the-hood "Direct link to A Look Under the Hood") --------------------------------------------------------------------------------------------------------------------------------------- Presuming `compact` is in your path, you can compile the Bulletin Board contract directly. If the code is in a file named `bboard.compact`, change to the directory where that file is located. Then run `compact compile`, passing the source file and an output directory: $ compact compile bboard.compact bboard-outCompact version: 0.24.0Compiling 2 circuits: circuit "post" (k=14, rows=10070) circuit "takeDown" (k=14, rows=10087) Overall progress [====================] 2/2 Let’s take a look at what the compiler has generated: $ ls bboard-outcompiler contract keys zkir There are four subdirectories. `compiler` has some metadata about the contract that will be used by composable contracts, which we can just ignore for now. `keys` and `zkir` are related to the ZK proofs which we will talk about in a later article. The compiler has translated the contract code into a JavaScript implementation, which is in the contract subdirectory. We’ll focus on that first. $ ls bboard-out/contractindex.cjs index.cjs.map index.d.cts There are three files here. `index.cjs` is the JavaScript implementation of the contract. (It is JavaScript source code, the `.cjs` extension means that it uses the CommonJS module system.) There is a source map file `index.cjs.map` that can be used for debugging. It connects the JavaScript implementation in `index.cjs` back to the original Compact source code that was in `bboard.compact`. Finally, there is a TypeScript declaration file `index.d.cts` for the JavaScript implementation. This allows the JavaScript code in `index.cjs` to be called from TypeScript (and importantly, type checked by the TypeScript compiler). We have chosen this strategy (a JavaScript implementation with a TypeScript declaration file, instead of a pure TypeScript implementation) for a couple of reasons. First, it lets us generate runtime checks in the JavaScript code for things that wouldn’t be checked by TypeScript’s type system. And second, we can generate a source map for debugging that maps the implementation back to the Compact source code. The source map you would get from the TypeScript compiler would only connect the TypeScript compiler generated JavaScript code back to Compact compiler generated TypeScript, not all the way back to the original Compact source code. TypeScript Declaration[​](https://docs.midnight.network/blog/tags/compact#typescript-declaration "Direct link to TypeScript Declaration") ------------------------------------------------------------------------------------------------------------------------------------------ Now, let’s take a first look at the structure of the contract’s implementation by looking inside the TypeScript declaration file `index.d.cts`. We will walk through this file, though not necessarily in order. Before reading further, we encourage you to compile the code to generate this file and take a look at it yourself. Remember, this was generated with Compact toolchain version 0.24.0. If you try the same thing with a different version, you might see different implementation details. ### The Compact Runtime[​](https://docs.midnight.network/blog/tags/compact#the-compact-runtime "Direct link to The Compact Runtime") note All the code in this section is written in TypeScript. The very first thing you will see is: import type * as __compactRuntime from '@midnight-ntwrk/compact-runtime'; This imports the Node.js package `@midnight-ntwrk/compact-runtime` which is an API used by the Compact compiler’s generated JavaScript code. Separating it out like this decouples the runtime from the compiler implementation, and it means that the generated JavaScript code can be smaller. We’ll see later that the Compact runtime is quite complex (it re-exports a large part of the on-chain runtime which is implemented in Rust and compiled to WebAssembly). You can even import this package in your DApp to have your own access to Compact runtime types and functions if necessary. The API documentation for the Compact runtime is available in the [Midnight documentation](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/) . ### Compact `enum` Types[​](https://docs.midnight.network/blog/tags/compact#compact-enum-types "Direct link to compact-enum-types") The bulletin board contract declared a Compact `enum` type for the bulletin board’s state (vacant or occupied). This type was exported (via the `export` keyword) which makes it available to a DApp’s TypeScript or JavaScript implementation, so there is a declaration in the TypeScript declaration file: export enum State { VACANT = 0, OCCUPIED = 1 } If this `enum` type was not exported in Compact, we would not see this declaration. Then, whenever this type appeared in the contract’s API (like in a circuit parameter or in the ledger) we would instead see the the underlying TypeScript representation type `number`. (Try it and see! Remove the `export` keyword for the `enum` in the Compact contract. Note that if you merely want to look at the generated TypeScript or JavaScript contract code you can skip ZK key generation by passing the command-line flag `--skip-zk` to the Compact compiler. This will run much faster.) ### The Compact Ledger[​](https://docs.midnight.network/blog/tags/compact#the-compact-ledger "Direct link to The Compact Ledger") In Compact, the contract’s public state is established by ledger declarations. The compiler collects all of these and exposes them to the DApp in the form of a ledger type: export type Ledger = { readonly state: State; readonly message: { is_some: boolean, value: string }; readonly instance: bigint; readonly poster: Uint8Array;} It has read-only properties for all the ledger fields. They are read-only in TypeScript, because **updating** the ledger actually requires a transaction to be submitted to the chain. A DApp, however, can freely read them from (a snapshot of) the public ledger state. We mentioned before that `State` appears in this API because we exported the Compact `enum` type `State`. Notice that the Compact standard library type `Maybe` does not appear in this API. Instead, the ledger field `message` has the underlying TypeScript type. That’s because we didn’t export the standard library’s `Maybe` type. We could do that with `export { Maybe }` at the top level of our Compact contract, and then we would instead see: export type Maybe
= { is_some: boolean; value: a };export type Ledger = { readonly state: State; readonly message: Maybe; readonly instance: bigint; readonly poster: Uint8Array;} There is also a declaration of a function that gives us (a read-only snapshot of) the public ledger state, returning a TypeScript value of type `Ledger` as declared above: export declare function ledger(state: __compactRuntime.StateValue): Ledger; This function takes a value of the Compact runtime’s type [`StateValue`](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/classes/StateValue) . We will see in Part 2 of this series how this function is used to pass a `Ledger` to witnesses. ### Compact Circuits[​](https://docs.midnight.network/blog/tags/compact#compact-circuits "Direct link to Compact Circuits") Our contract had three exported circuits. By exporting them, they are made available to be called by the DApp’s TypeScript or JavaScript code, and they form the contract’s entry points. We can see declarations for them in the TypeScript declaration file, in two different places: export type ImpureCircuits = { post(context: __compactRuntime.CircuitContext, newMessage_0: string): __compactRuntime.CircuitResults; takeDown(context: __compactRuntime.CircuitContext): __compactRuntime.CircuitResults;}export type PureCircuits = { publicKey(sk_0: Uint8Array, instance_0: Uint8Array): Uint8Array;}export type Circuits = { post(context: __compactRuntime.CircuitContext, newMessage_0: string): __compactRuntime.CircuitResults; takeDown(context: __compactRuntime.CircuitContext): __compactRuntime.CircuitResults; publicKey(context: __compactRuntime.CircuitContext, sk_0: Uint8Array, instance_0: Uint8Array): __compactRuntime.CircuitResults;} The `post` and `takeDown` circuits are _impure_. In Compact, this basically means that they access (even if only by reading) the public state and/or they invoke witnesses. They are declared in the type `ImpureCircuits`. The generic type parameter `T` here is the type of the contract's private state. The Compact compiler doesn't know what that type is (nor does it need to); it's up to the DApp developer to fill that in. Recall the Compact signature of the `post` circuit was `circuit post(new_message: Opaque<"string">): []`. We can see that the TypeScript API for this circuit is predictably derived from the Compact signature, with a few differences. First, the circuit takes an extra first argument of type `CircuitContext`. This is an interface declared in the [Compact runtime](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/interfaces/CircuitContext) . It contains an encapsulation of the contract's on-chain and private state, some separate Zswap state, and a representation of what the on-chain context would be if the circuit were actually executing on chain (though note, this JavaScript code is **not** what's executed on chain). Second, we can see that the Compact type `Opaque<"string">` is represented by the TypeScript type `string`. One goal of Compact is that the TypeScript representation of Compact types is always predictable. And third, we can see that the return type (in Compact it was `[]`) is actually `CircuitResults`. This is another interface declared in the [Compact runtime](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/interfaces/CircuitResults) . It has the actual return value with TypeScript type `[]`, as well as some proof data required to construct the ZK proof and a new `CircuitContext` representing the public and private state after running the circuit. We won’t focus on `takeDown` here, but you can see that its signature is similarly and predictably derived from the signature of the circuit in Compact. The helper circuit `publicKey` is _pure_. This means that it does not access the public state or invoke witnesses (i.e., it's not impure). It is declared in the type `PureCircuits`. Pure circuits are ones that can run without an instance of the contract. Specifically, they do not need access to the ledger state and they do not have access to private state. You can see that here, because the extra first `CircuitContext` argument is missing, and the return value is a bare TypeScript type rather than a `CircuitResult`. The type `PureCircuits` is not generic, there is no type parameter `T` needed to represent the type of the private state. Finally, these declarations are repeated in the type `Circuits`. The declarations of `post` and `takeDown` are exactly the same as before, but the declaration of `publicKey` has the signature of an impure circuit. This is so that the DApp can make a `publicKey` transaction, without having to worry about the details of whether it's pure or not. There are implementations of these circuits in the compiler-generated JavaScript code for the contract, which we will look at in the next article in this series. ### Compact Witnesses[​](https://docs.midnight.network/blog/tags/compact#compact-witnesses "Direct link to Compact Witnesses") We had a single witness declaration in our contract, which is also reflected in the contract’s TypeScript API: export type Witnesses = { localSecretKey(context: __compactRuntime.WitnessContext): [T, Uint8Array];} The witness’s signature is also predictably derived from the Compact witness declaration. It has an extra first argument of type `WitnessContext`. This interface is declared in the [Compact runtime](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime/interfaces/WitnessContext) . It contains a snapshot of the public ledger state, the contract’s private state of type `T`, and the contract’s address. The witness returns a tuple (a two-element TypeScript array) consisting of a new private state of type `T` and the Compact return value. The Compact type `Bytes<32>` is represented by the underlying TypeScript type Uint8Array. The DApp implementation is responsible for providing a witness with this signature when constructing the contract. ### The Contract Type[​](https://docs.midnight.network/blog/tags/compact#the-contract-type "Direct link to The Contract Type") Finally, there is a declaration of the contract type: export declare class Contract = Witnesses> { witnesses: W; circuits: Circuits; impureCircuits: ImpureCircuits; constructor(witnesses: W); initialState(context: __compactRuntime.ConstructorContext): __compactRuntime.ConstructorResult;}export declare const pureCircuits: PureCircuits; It is parameterized over the private state type and the witness type, and it has witnesses, circuits, impure circuits, a constructor, and an initial state all using the type declarations seen above. The pure circuits are a top-level TypeScript value (rather than a contract property), representing the fact that they do not need an instance of the contract. The contract itself is implemented by the compiler-generated JavaScript code in `index.cjs`. In the next article in this series, "Compact Deep Dive – Part 2: Circuits and Witnesses", we’ll begin examining how circuits and witnesses are implemented in the generated code. Compact makes on-chain logic efficient and secure—while division isn't yet supported, you can use vector subtraction or off-chain computation with witness verification. --- # NetworkId | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/enumerations/NetworkId#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / NetworkId Enumeration: NetworkId ====================== The network currently being targeted Enumeration Members[​](https://docs.midnight.network/api-reference/onchain-runtime/enumerations/NetworkId#enumeration-members "Direct link to Enumeration Members") -------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### DevNet[​](https://docs.midnight.network/api-reference/onchain-runtime/enumerations/NetworkId#devnet "Direct link to DevNet") DevNet: 1; A developer network, not guaranteed to be persistent * * * ### MainNet[​](https://docs.midnight.network/api-reference/onchain-runtime/enumerations/NetworkId#mainnet "Direct link to MainNet") MainNet: 3; The Midnight mainnet * * * ### TestNet[​](https://docs.midnight.network/api-reference/onchain-runtime/enumerations/NetworkId#testnet "Direct link to TestNet") TestNet: 2; A persistent testnet * * * ### Undeployed[​](https://docs.midnight.network/api-reference/onchain-runtime/enumerations/NetworkId#undeployed "Direct link to Undeployed") Undeployed: 0; A local test network * [Enumeration Members](https://docs.midnight.network/api-reference/onchain-runtime/enumerations/NetworkId#enumeration-members) * [DevNet](https://docs.midnight.network/api-reference/onchain-runtime/enumerations/NetworkId#devnet) * [MainNet](https://docs.midnight.network/api-reference/onchain-runtime/enumerations/NetworkId#mainnet) * [TestNet](https://docs.midnight.network/api-reference/onchain-runtime/enumerations/NetworkId#testnet) * [Undeployed](https://docs.midnight.network/api-reference/onchain-runtime/enumerations/NetworkId#undeployed) --- # ConstructorContext | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorContext#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / ConstructorContext Interface: ConstructorContext ================================= Passed to the constructor of a contract. Used to compute the contract's initial ledger state. Type Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorContext#type-parameters "Direct link to Type Parameters") --------------------------------------------------------------------------------------------------------------------------------------------------------------- ### PS[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorContext#ps "Direct link to PS") `PS` = `any` Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorContext#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------------ ### initialPrivateState[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorContext#initialprivatestate "Direct link to initialPrivateState") initialPrivateState: PS; The private state we would like to use to execute the contract's constructor. * * * ### initialZswapLocalState[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorContext#initialzswaplocalstate "Direct link to initialZswapLocalState") initialZswapLocalState: EncodedZswapLocalState; An initial (usually empty) Zswap local state to use to execute the contract's constructor. * [Type Parameters](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorContext#type-parameters) * [PS](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorContext#ps) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorContext#properties) * [initialPrivateState](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorContext#initialprivatestate) * [initialZswapLocalState](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorContext#initialzswaplocalstate) --- # CircuitContext | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitContext#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CircuitContext Interface: CircuitContext ============================= The external information accessible from within a Compact circuit call Type Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitContext#type-parameters "Direct link to Type Parameters") ----------------------------------------------------------------------------------------------------------------------------------------------------------- ### PS[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitContext#ps "Direct link to PS") `PS` = `any` Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitContext#properties "Direct link to Properties") -------------------------------------------------------------------------------------------------------------------------------------------- ### costModel[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitContext#costmodel "Direct link to costModel") costModel: CostModel; The cost model to use for the execution. * * * ### currentPrivateState[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitContext#currentprivatestate "Direct link to currentPrivateState") currentPrivateState: PS; The current private state for the contract. * * * ### currentQueryContext[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitContext#currentquerycontext "Direct link to currentQueryContext") currentQueryContext: QueryContext; The current on-chain context the transaction is evolving. * * * ### currentZswapLocalState[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitContext#currentzswaplocalstate "Direct link to currentZswapLocalState") currentZswapLocalState: EncodedZswapLocalState; The current Zswap local state. Tracks inputs and outputs produced during circuit execution. * * * ### gasLimit?[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitContext#gaslimit "Direct link to gasLimit?") optional gasLimit: RunningCost; The gas limit for this circuit. * [Type Parameters](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitContext#type-parameters) * [PS](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitContext#ps) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitContext#properties) * [costModel](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitContext#costmodel) * [currentPrivateState](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitContext#currentprivatestate) * [currentQueryContext](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitContext#currentquerycontext) * [currentZswapLocalState](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitContext#currentzswaplocalstate) * [gasLimit?](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitContext#gaslimit) --- # CircuitResults | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitResults#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CircuitResults Interface: CircuitResults ================================ The results of the call to a Compact circuit Type Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitResults#type-parameters "Direct link to Type Parameters") ----------------------------------------------------------------------------------------------------------------------------------------------------------- ### PS[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitResults#ps "Direct link to PS") `PS` = `any` ### R[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitResults#r "Direct link to R") `R` = `any` Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitResults#properties "Direct link to Properties") -------------------------------------------------------------------------------------------------------------------------------------------- ### context[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitResults#context "Direct link to context") context: CircuitContext; The updated context after the circuit execution, that can be used to inform further runs * * * ### gasCost[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitResults#gascost "Direct link to gasCost") gasCost: RunningCost; The gas consumption of the circuit execution * * * ### proofData[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitResults#proofdata "Direct link to proofData") proofData: ProofData; The data required to prove this circuit run * * * ### result[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitResults#result "Direct link to result") result: R; The primary result, as returned from Compact * [Type Parameters](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitResults#type-parameters) * [PS](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitResults#ps) * [R](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitResults#r) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitResults#properties) * [context](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitResults#context) * [gasCost](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitResults#gascost) * [proofData](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitResults#proofdata) * [result](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CircuitResults#result) --- # Authentication | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/overview/authentication#__docusaurus_skipToContent_fallback) Explore with… ▾ The Midnight APIs have authentication methods to prevent abuse and ensure fair use. --- # Rate limits | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/overview/rate-limits#__docusaurus_skipToContent_fallback) Explore with… ▾ The Midnight APIs have rate limits to prevent abuse and ensure fair use. --- # Error codes | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/overview/error-codes#__docusaurus_skipToContent_fallback) Explore with… ▾ The Midnight APIs have error codes to help you debug and fix issues. --- # On-Chain runtime API | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • Readme | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * Midnight Onchain Runtime TypeScript API ======================================= This API provides a TypeScript interface to Midnight's onchain runtime, including the execution of VM instructions, and the primitives required to successfully use them. Key parts of this API are: * [ContractState](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState) , encapsulating the entirety of a smart contract's on-chain state * [StateValue](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue) , encoding data a contract maintains on-chain * [QueryContext](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext) , providing an annotated view into the contract state, against which on-chain VM programs can be run * [Op](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Op) , providing the TypeScript encoding of on-chain VM programs * [AlignedValue](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) , the "base" value type that encodes all user data stored on-chain --- # ConstructorResult | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorResult#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / ConstructorResult Interface: ConstructorResult ================================ The result of executing a contract constructor. Type Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorResult#type-parameters "Direct link to Type Parameters") -------------------------------------------------------------------------------------------------------------------------------------------------------------- ### PS[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorResult#ps "Direct link to PS") `PS` = `any` Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorResult#properties "Direct link to Properties") ----------------------------------------------------------------------------------------------------------------------------------------------- ### currentContractState[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorResult#currentcontractstate "Direct link to currentContractState") currentContractState: ContractState; The contract's initial ledger (public state). * * * ### currentPrivateState[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorResult#currentprivatestate "Direct link to currentPrivateState") currentPrivateState: PS; The contract's initial private state. Potentially different from the private state passed in [ConstructorContext](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorContext) . * * * ### currentZswapLocalState[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorResult#currentzswaplocalstate "Direct link to currentZswapLocalState") currentZswapLocalState: EncodedZswapLocalState; The contract's initial Zswap local state. Potentially includes outputs created in the contract's constructor. * [Type Parameters](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorResult#type-parameters) * [PS](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorResult#ps) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorResult#properties) * [currentContractState](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorResult#currentcontractstate) * [currentPrivateState](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorResult#currentprivatestate) * [currentZswapLocalState](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ConstructorResult#currentzswaplocalstate) --- # CurvePoint | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CurvePoint#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.9.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CurvePoint Interface: CurvePoint ===================== A point in the embedded elliptic curve. TypeScript representation of the Compact type of the same name Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CurvePoint#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------------- ### x[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CurvePoint#x "Direct link to x") readonly x: bigint; * * * ### y[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CurvePoint#y "Direct link to y") readonly y: bigint; * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CurvePoint#properties) * [x](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CurvePoint#x) * [y](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CurvePoint#y) --- # EncodedQualifiedShieldedCoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedShieldedCoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / EncodedQualifiedShieldedCoinInfo Interface: EncodedQualifiedShieldedCoinInfo =========================================== A QualifiedCoinInfo with its fields encoded as byte strings. This representation is used internally by the contract executable. Extends[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedShieldedCoinInfo#extends "Direct link to Extends") ----------------------------------------------------------------------------------------------------------------------------------------------------- * [`EncodedShieldedCoinInfo`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedShieldedCoinInfo) Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedShieldedCoinInfo#properties "Direct link to Properties") -------------------------------------------------------------------------------------------------------------------------------------------------------------- ### color[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedShieldedCoinInfo#color "Direct link to color") readonly color: Uint8Array; The coin's type, identifying the currency it represents. #### Inherited from[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedShieldedCoinInfo#inherited-from "Direct link to Inherited from") [`EncodedShieldedCoinInfo`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedShieldedCoinInfo) .[`color`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedShieldedCoinInfo#color) * * * ### mt\_index[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedShieldedCoinInfo#mt_index "Direct link to mt_index") readonly mt_index: bigint; The coin's location in the chain's Merkle tree of coin commitments. Bounded to be a non-negative 64-bit integer. * * * ### nonce[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedShieldedCoinInfo#nonce "Direct link to nonce") readonly nonce: Uint8Array; The coin's randomness, preventing it from colliding with other coins. #### Inherited from[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedShieldedCoinInfo#inherited-from-1 "Direct link to Inherited from") [`EncodedShieldedCoinInfo`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedShieldedCoinInfo) .[`nonce`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedShieldedCoinInfo#nonce) * * * ### value[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedShieldedCoinInfo#value "Direct link to value") readonly value: bigint; The coin's value, in atomic units dependent on the currency. Bounded to be a non-negative 64-bit integer. #### Inherited from[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedShieldedCoinInfo#inherited-from-2 "Direct link to Inherited from") [`EncodedShieldedCoinInfo`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedShieldedCoinInfo) .[`value`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedShieldedCoinInfo#value) * [Extends](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedShieldedCoinInfo#extends) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedShieldedCoinInfo#properties) * [color](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedShieldedCoinInfo#color) * [mt\_index](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedShieldedCoinInfo#mt_index) * [nonce](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedShieldedCoinInfo#nonce) * [value](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedShieldedCoinInfo#value) --- # EncodedCoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedCoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.9.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / EncodedCoinInfo Interface: EncodedCoinInfo ========================== A [CoinInfo](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CoinInfo) with its fields encoded as byte strings. This representation is used internally by the contract executable. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedCoinInfo#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------------- ### color[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedCoinInfo#color "Direct link to color") readonly color: Uint8Array; The coin's type, identifying the currency it represents. * * * ### nonce[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedCoinInfo#nonce "Direct link to nonce") readonly nonce: Uint8Array; The coin's randomness, preventing it from colliding with other coins. * * * ### value[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedCoinInfo#value "Direct link to value") readonly value: bigint; The coin's value, in atomic units dependent on the currency. Bounded to be a non-negative 64-bit integer. * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedCoinInfo#properties) * [color](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedCoinInfo#color) * [nonce](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedCoinInfo#nonce) * [value](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedCoinInfo#value) --- # MerkleTreePathEntry | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePathEntry#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / MerkleTreePathEntry Interface: MerkleTreePathEntry ============================== An entry in a Merkle path. TypeScript representation of the Compact type of the same name. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePathEntry#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------------- ### goes\_left[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePathEntry#goes_left "Direct link to goes_left") readonly goes_left: boolean; * * * ### sibling[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePathEntry#sibling "Direct link to sibling") readonly sibling: MerkleTreeDigest; * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePathEntry#properties) * [goes\_left](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePathEntry#goes_left) * [sibling](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePathEntry#sibling) --- # MerkleTreePath | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePath#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / MerkleTreePath Interface: MerkleTreePath ============================ A path demonstrating inclusion in a Merkle tree. TypeScript representation of the Compact type of the same name. Type Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePath#type-parameters "Direct link to Type Parameters") ----------------------------------------------------------------------------------------------------------------------------------------------------------- ### A[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePath#a "Direct link to A") `A` Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePath#properties "Direct link to Properties") -------------------------------------------------------------------------------------------------------------------------------------------- ### leaf[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePath#leaf "Direct link to leaf") readonly leaf: A; * * * ### path[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePath#path "Direct link to path") readonly path: MerkleTreePathEntry[]; * [Type Parameters](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePath#type-parameters) * [A](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePath#a) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePath#properties) * [leaf](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePath#leaf) * [path](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePath#path) --- # MerkleTreeDigest | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreeDigest#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / MerkleTreeDigest Interface: MerkleTreeDigest =========================== The hash value of a Merkle tree. TypeScript representation of the Compact type of the same name Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreeDigest#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------------------- ### field[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreeDigest#field "Direct link to field") readonly field: bigint; * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreeDigest#properties) * [field](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreeDigest#field) --- # NativePoint | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/NativePoint#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / NativePoint Interface: NativePoint ====================== A point in the embedded elliptic curve. TypeScript representation of the Compact type of the same name Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/NativePoint#properties "Direct link to Properties") ----------------------------------------------------------------------------------------------------------------------------------------- ### x[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/NativePoint#x "Direct link to x") readonly x: bigint; * * * ### y[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/NativePoint#y "Direct link to y") readonly y: bigint; * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/NativePoint#properties) * [x](https://docs.midnight.network/api-reference/compact-runtime/interfaces/NativePoint#x) * [y](https://docs.midnight.network/api-reference/compact-runtime/interfaces/NativePoint#y) --- # EncodedRecipient | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedRecipient#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / EncodedRecipient Interface: EncodedRecipient =========================== A [Recipient](https://docs.midnight.network/api-reference/compact-runtime/interfaces/Recipient) with its fields encoded as byte strings. This representation is used internally by the contract executable. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedRecipient#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------------------- ### is\_left[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedRecipient#is_left "Direct link to is_left") readonly is_left: boolean; Whether the recipient is a user or a contract. * * * ### left[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedRecipient#left "Direct link to left") readonly left: EncodedCoinPublicKey; The recipient's public key, if the recipient is a user. * * * ### right[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedRecipient#right "Direct link to right") readonly right: EncodedContractAddress; The recipient's contract address, if the recipient is a contract. * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedRecipient#properties) * [is\_left](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedRecipient#is_left) * [left](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedRecipient#left) * [right](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedRecipient#right) --- # EncodedZswapLocalState | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedZswapLocalState#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / EncodedZswapLocalState Interface: EncodedZswapLocalState ================================= Tracks the coins consumed and produced throughout circuit execution. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedZswapLocalState#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------------------------- ### coinPublicKey[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedZswapLocalState#coinpublickey "Direct link to coinPublicKey") coinPublicKey: EncodedCoinPublicKey; The Zswap coin public key of the user executing the circuit. * * * ### currentIndex[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedZswapLocalState#currentindex "Direct link to currentIndex") currentIndex: bigint; The Merkle tree index of the next coin produced. * * * ### inputs[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedZswapLocalState#inputs "Direct link to inputs") inputs: EncodedQualifiedShieldedCoinInfo[]; The coins consumed as inputs to the circuit. * * * ### outputs[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedZswapLocalState#outputs "Direct link to outputs") outputs: { coinInfo: EncodedShieldedCoinInfo; recipient: EncodedRecipient;}[]; The coins produced as outputs from the circuit. #### coinInfo[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedZswapLocalState#coininfo "Direct link to coinInfo") coinInfo: EncodedShieldedCoinInfo; #### recipient[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedZswapLocalState#recipient "Direct link to recipient") recipient: EncodedRecipient; * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedZswapLocalState#properties) * [coinPublicKey](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedZswapLocalState#coinpublickey) * [currentIndex](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedZswapLocalState#currentindex) * [inputs](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedZswapLocalState#inputs) * [outputs](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedZswapLocalState#outputs) --- # midnight-js-fetch-zk-config-provider | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-fetch-zk-config-provider#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**Midnight.js API Reference v2.0.2**](https://docs.midnight.network/api-reference/midnight-js) * * * [Midnight.js API Reference](https://docs.midnight.network/api-reference/midnight-js/packages) / @midnight-ntwrk/midnight-js-fetch-zk-config-provider @midnight-ntwrk/midnight-js-fetch-zk-config-provider ==================================================== Classes[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-fetch-zk-config-provider#classes "Direct link to Classes") ---------------------------------------------------------------------------------------------------------------------------------------------------------- * [FetchZkConfigProvider](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-fetch-zk-config-provider/classes/FetchZkConfigProvider) * [Classes](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-fetch-zk-config-provider#classes) --- # EncodedQualifiedCoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedCoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.9.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / EncodedQualifiedCoinInfo Interface: EncodedQualifiedCoinInfo =================================== A [QualifiedCoinInfo](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedCoinInfo) with its fields encoded as byte strings. This representation is used internally by the contract executable. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedCoinInfo#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------------------ ### color[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedCoinInfo#color "Direct link to color") readonly color: Uint8Array; The coin's type, identifying the currency it represents. * * * ### mt\_index[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedCoinInfo#mt_index "Direct link to mt_index") readonly mt_index: bigint; The coin's location in the chain's Merkle tree of coin commitments. Bounded to be a non-negative 64-bit integer. * * * ### nonce[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedCoinInfo#nonce "Direct link to nonce") readonly nonce: Uint8Array; The coin's randomness, preventing it from colliding with other coins. * * * ### value[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedCoinInfo#value "Direct link to value") readonly value: bigint; The coin's value, in atomic units dependent on the currency. Bounded to be a non-negative 64-bit integer. * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedCoinInfo#properties) * [color](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedCoinInfo#color) * [mt\_index](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedCoinInfo#mt_index) * [nonce](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedCoinInfo#nonce) * [value](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedCoinInfo#value) --- # EncodedContractAddress | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedContractAddress#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / EncodedContractAddress Interface: EncodedContractAddress ================================= A [ContractAddress](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ContractAddress) encoded as a byte string. This representation is used internally by the contract executable. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedContractAddress#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------------------------- ### bytes[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedContractAddress#bytes "Direct link to bytes") readonly bytes: Uint8Array; The contract address's bytes. * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedContractAddress#properties) * [bytes](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedContractAddress#bytes) --- # midnight-js-logger-provider | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-logger-provider#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**Midnight.js API Reference v2.0.2**](https://docs.midnight.network/api-reference/midnight-js) * * * [Midnight.js API Reference](https://docs.midnight.network/api-reference/midnight-js/packages) / @midnight-ntwrk/midnight-js-logger-provider @midnight-ntwrk/midnight-js-logger-provider =========================================== Classes[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-logger-provider#classes "Direct link to Classes") ------------------------------------------------------------------------------------------------------------------------------------------------- * [LoggerProvider](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-logger-provider/classes/LoggerProvider) * [Classes](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-logger-provider#classes) --- # midnight-js-http-client-proof-provider | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-http-client-proof-provider#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**Midnight.js API Reference v2.0.2**](https://docs.midnight.network/api-reference/midnight-js) * * * [Midnight.js API Reference](https://docs.midnight.network/api-reference/midnight-js/packages) / @midnight-ntwrk/midnight-js-http-client-proof-provider @midnight-ntwrk/midnight-js-http-client-proof-provider ====================================================== Variables[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-http-client-proof-provider#variables "Direct link to Variables") ------------------------------------------------------------------------------------------------------------------------------------------------------------------ * [DEFAULT\_CONFIG](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-http-client-proof-provider/variables/DEFAULT_CONFIG) Functions[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-http-client-proof-provider#functions "Direct link to Functions") ------------------------------------------------------------------------------------------------------------------------------------------------------------------ * [httpClientProofProvider](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-http-client-proof-provider/functions/httpClientProofProvider) * [serializePayload](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-http-client-proof-provider/functions/serializePayload) * [serializeZKConfig](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-http-client-proof-provider/functions/serializeZKConfig) * [Variables](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-http-client-proof-provider#variables) * [Functions](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-http-client-proof-provider#functions) --- # PartialProofData | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/PartialProofData#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / PartialProofData Interface: PartialProofData =========================== Encapsulates the data required to produce a zero-knowledge proof except the circuit output Extended by[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/PartialProofData#extended-by "Direct link to Extended by") ------------------------------------------------------------------------------------------------------------------------------------------------- * [`ProofData`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ProofData) Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/PartialProofData#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------------------- ### input[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/PartialProofData#input "Direct link to input") input: AlignedValue; The inputs to a circuit * * * ### privateTranscriptOutputs[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/PartialProofData#privatetranscriptoutputs "Direct link to privateTranscriptOutputs") privateTranscriptOutputs: AlignedValue[]; The transcript of the witness call outputs * * * ### publicTranscript[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/PartialProofData#publictranscript "Direct link to publicTranscript") publicTranscript: Op[]; The public transcript of operations * [Extended by](https://docs.midnight.network/api-reference/compact-runtime/interfaces/PartialProofData#extended-by) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/PartialProofData#properties) * [input](https://docs.midnight.network/api-reference/compact-runtime/interfaces/PartialProofData#input) * [privateTranscriptOutputs](https://docs.midnight.network/api-reference/compact-runtime/interfaces/PartialProofData#privatetranscriptoutputs) * [publicTranscript](https://docs.midnight.network/api-reference/compact-runtime/interfaces/PartialProofData#publictranscript) --- # midnight-js-level-private-state-provider | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-level-private-state-provider#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**Midnight.js API Reference v2.0.2**](https://docs.midnight.network/api-reference/midnight-js) * * * [Midnight.js API Reference](https://docs.midnight.network/api-reference/midnight-js/packages) / @midnight-ntwrk/midnight-js-level-private-state-provider @midnight-ntwrk/midnight-js-level-private-state-provider ======================================================== Interfaces[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-level-private-state-provider#interfaces "Direct link to Interfaces") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- * [LevelPrivateStateProviderConfig](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-level-private-state-provider/interfaces/LevelPrivateStateProviderConfig) Variables[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-level-private-state-provider#variables "Direct link to Variables") -------------------------------------------------------------------------------------------------------------------------------------------------------------------- * [DEFAULT\_CONFIG](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-level-private-state-provider/variables/DEFAULT_CONFIG) Functions[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-level-private-state-provider#functions "Direct link to Functions") -------------------------------------------------------------------------------------------------------------------------------------------------------------------- * [levelPrivateStateProvider](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-level-private-state-provider/functions/levelPrivateStateProvider) * [Interfaces](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-level-private-state-provider#interfaces) * [Variables](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-level-private-state-provider#variables) * [Functions](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-level-private-state-provider#functions) --- # midnight-js-node-zk-config-provider | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-node-zk-config-provider#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**Midnight.js API Reference v2.0.2**](https://docs.midnight.network/api-reference/midnight-js) * * * [Midnight.js API Reference](https://docs.midnight.network/api-reference/midnight-js/packages) / @midnight-ntwrk/midnight-js-node-zk-config-provider @midnight-ntwrk/midnight-js-node-zk-config-provider =================================================== Classes[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-node-zk-config-provider#classes "Direct link to Classes") --------------------------------------------------------------------------------------------------------------------------------------------------------- * [NodeZkConfigProvider](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-node-zk-config-provider/classes/NodeZkConfigProvider) * [Classes](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-node-zk-config-provider#classes) --- # packages | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/midnight-js/packages#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**Midnight.js API Reference v2.0.2**](https://docs.midnight.network/api-reference/midnight-js) * * * Midnight.js API Reference v2.0.2 ================================ Packages[​](https://docs.midnight.network/api-reference/midnight-js/packages#packages "Direct link to Packages") ----------------------------------------------------------------------------------------------------------------- * [@midnight-ntwrk/midnight-js-contracts - v2.0.2](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts) * [@midnight-ntwrk/midnight-js-fetch-zk-config-provider - v2.0.2](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-fetch-zk-config-provider) * [@midnight-ntwrk/midnight-js-http-client-proof-provider - v2.0.2](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-http-client-proof-provider) * [@midnight-ntwrk/midnight-js-indexer-public-data-provider - v2.0.2](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-indexer-public-data-provider) * [@midnight-ntwrk/midnight-js-level-private-state-provider - v2.0.2](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-level-private-state-provider) * [@midnight-ntwrk/midnight-js-logger-provider - v2.0.2](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-logger-provider) * [@midnight-ntwrk/midnight-js-network-id - v2.0.2](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-network-id) * [@midnight-ntwrk/midnight-js-node-zk-config-provider - v2.0.2](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-node-zk-config-provider) * [@midnight-ntwrk/midnight-js-testing - v2.0.2](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing) * [@midnight-ntwrk/midnight-js-types - v2.0.2](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types) * [@midnight-ntwrk/midnight-js-utils - v2.0.2](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-utils) * [Packages](https://docs.midnight.network/api-reference/midnight-js/packages#packages) --- # midnight-js-indexer-public-data-provider | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-indexer-public-data-provider#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**Midnight.js API Reference v2.0.2**](https://docs.midnight.network/api-reference/midnight-js) * * * [Midnight.js API Reference](https://docs.midnight.network/api-reference/midnight-js/packages) / @midnight-ntwrk/midnight-js-indexer-public-data-provider @midnight-ntwrk/midnight-js-indexer-public-data-provider ======================================================== Classes[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-indexer-public-data-provider#classes "Direct link to Classes") -------------------------------------------------------------------------------------------------------------------------------------------------------------- * [IndexerFormattedError](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-indexer-public-data-provider/classes/IndexerFormattedError) Functions[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-indexer-public-data-provider#functions "Direct link to Functions") -------------------------------------------------------------------------------------------------------------------------------------------------------------------- * [indexerPublicDataProvider](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-indexer-public-data-provider/functions/indexerPublicDataProvider) * [Classes](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-indexer-public-data-provider#classes) * [Functions](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-indexer-public-data-provider#functions) --- # CompactType | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactType Interface: CompactType ========================= A runtime representation of a type in Compact Type Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#type-parameters "Direct link to Type Parameters") -------------------------------------------------------------------------------------------------------------------------------------------------------- ### A[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#a "Direct link to A") `A` Methods[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#methods "Direct link to Methods") -------------------------------------------------------------------------------------------------------------------------------- ### alignment()[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#alignment "Direct link to alignment()") alignment(): Alignment; The field-aligned binary alignment of this type. #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#returns "Direct link to Returns") [`Alignment`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) * * * ### fromValue()[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#fromvalue "Direct link to fromValue()") fromValue(value): A; Converts this type's field-aligned binary representation to its TypeScript representation destructively; (partially) consuming the input, and ignoring superflous data for chaining. #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#parameters "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#value "Direct link to value") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#returns-1 "Direct link to Returns") `A` * * * ### toValue()[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#tovalue "Direct link to toValue()") toValue(value): Value; Converts this type's TypeScript representation to its field-aligned binary representation #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#parameters-1 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#value-1 "Direct link to value") `A` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#returns-2 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) * [Type Parameters](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#type-parameters) * [A](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#a) * [Methods](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#methods) * [alignment()](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#alignment) * [fromValue()](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#fromvalue) * [toValue()](https://docs.midnight.network/api-reference/compact-runtime/interfaces/CompactType#tovalue) --- # EncodedCoinPublicKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedCoinPublicKey#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / EncodedCoinPublicKey Interface: EncodedCoinPublicKey =============================== A [CoinPublicKey](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CoinPublicKey) encoded as a byte string. This representation is used internally by the contract executable. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedCoinPublicKey#properties "Direct link to Properties") -------------------------------------------------------------------------------------------------------------------------------------------------- ### bytes[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedCoinPublicKey#bytes "Direct link to bytes") readonly bytes: Uint8Array; The coin public key's bytes. * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedCoinPublicKey#properties) * [bytes](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedCoinPublicKey#bytes) --- # Recipient | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/Recipient#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / Recipient Interface: Recipient ==================== The recipient of a coin produced by a circuit. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/Recipient#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------- ### is\_left[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/Recipient#is_left "Direct link to is_left") readonly is_left: boolean; Whether the recipient is a user or a contract. * * * ### left[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/Recipient#left "Direct link to left") readonly left: string; The recipient's public key, if the recipient is a user. * * * ### right[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/Recipient#right "Direct link to right") readonly right: string; The recipient's contract address, if the recipient is a contract. * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/Recipient#properties) * [is\_left](https://docs.midnight.network/api-reference/compact-runtime/interfaces/Recipient#is_left) * [left](https://docs.midnight.network/api-reference/compact-runtime/interfaces/Recipient#left) * [right](https://docs.midnight.network/api-reference/compact-runtime/interfaces/Recipient#right) --- # WitnessContext | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/WitnessContext#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / WitnessContext Interface: WitnessContext ================================ The external information accessible from within a Compact witness call Type Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/WitnessContext#type-parameters "Direct link to Type Parameters") ----------------------------------------------------------------------------------------------------------------------------------------------------------- ### L[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/WitnessContext#l "Direct link to L") `L` = `any` ### PS[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/WitnessContext#ps "Direct link to PS") `PS` = `any` Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/WitnessContext#properties "Direct link to Properties") -------------------------------------------------------------------------------------------------------------------------------------------- ### contractAddress[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/WitnessContext#contractaddress "Direct link to contractAddress") readonly contractAddress: string; The address of the contract being called * * * ### ledger[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/WitnessContext#ledger "Direct link to ledger") readonly ledger: L; The projected ledger state, if the transaction were to run against the ledger state as you locally see it currently * * * ### privateState[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/WitnessContext#privatestate "Direct link to privateState") readonly privateState: PS; The current private state for the contract * [Type Parameters](https://docs.midnight.network/api-reference/compact-runtime/interfaces/WitnessContext#type-parameters) * [L](https://docs.midnight.network/api-reference/compact-runtime/interfaces/WitnessContext#l) * [PS](https://docs.midnight.network/api-reference/compact-runtime/interfaces/WitnessContext#ps) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/WitnessContext#properties) * [contractAddress](https://docs.midnight.network/api-reference/compact-runtime/interfaces/WitnessContext#contractaddress) * [ledger](https://docs.midnight.network/api-reference/compact-runtime/interfaces/WitnessContext#ledger) * [privateState](https://docs.midnight.network/api-reference/compact-runtime/interfaces/WitnessContext#privatestate) --- # EncodedShieldedCoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedShieldedCoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / EncodedShieldedCoinInfo Interface: EncodedShieldedCoinInfo ================================== A [ShieldedCoinInfo](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ShieldedCoinInfo) with its fields encoded as byte strings. This representation is used internally by the contract executable. Extended by[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedShieldedCoinInfo#extended-by "Direct link to Extended by") -------------------------------------------------------------------------------------------------------------------------------------------------------- * [`EncodedQualifiedShieldedCoinInfo`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedQualifiedShieldedCoinInfo) Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedShieldedCoinInfo#properties "Direct link to Properties") ----------------------------------------------------------------------------------------------------------------------------------------------------- ### color[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedShieldedCoinInfo#color "Direct link to color") readonly color: Uint8Array; The coin's type, identifying the currency it represents. * * * ### nonce[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedShieldedCoinInfo#nonce "Direct link to nonce") readonly nonce: Uint8Array; The coin's randomness, preventing it from colliding with other coins. * * * ### value[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedShieldedCoinInfo#value "Direct link to value") readonly value: bigint; The coin's value, in atomic units dependent on the currency. Bounded to be a non-negative 64-bit integer. * [Extended by](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedShieldedCoinInfo#extended-by) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedShieldedCoinInfo#properties) * [color](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedShieldedCoinInfo#color) * [nonce](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedShieldedCoinInfo#nonce) * [value](https://docs.midnight.network/api-reference/compact-runtime/interfaces/EncodedShieldedCoinInfo#value) --- # ZswapLocalState | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ZswapLocalState#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / ZswapLocalState Interface: ZswapLocalState ========================== Tracks the coins consumed and produced throughout circuit execution. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ZswapLocalState#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------------- ### coinPublicKey[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ZswapLocalState#coinpublickey "Direct link to coinPublicKey") coinPublicKey: string; The Zswap coin public key of the user executing the circuit. * * * ### currentIndex[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ZswapLocalState#currentindex "Direct link to currentIndex") currentIndex: bigint; The Merkle tree index of the next coin produced. * * * ### inputs[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ZswapLocalState#inputs "Direct link to inputs") inputs: QualifiedShieldedCoinInfo[]; The coins consumed as inputs to the circuit. * * * ### outputs[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ZswapLocalState#outputs "Direct link to outputs") outputs: { coinInfo: ShieldedCoinInfo; recipient: Recipient;}[]; The coins produced as outputs from the circuit. #### coinInfo[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ZswapLocalState#coininfo "Direct link to coinInfo") coinInfo: ShieldedCoinInfo; #### recipient[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ZswapLocalState#recipient "Direct link to recipient") recipient: Recipient; * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ZswapLocalState#properties) * [coinPublicKey](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ZswapLocalState#coinpublickey) * [currentIndex](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ZswapLocalState#currentindex) * [inputs](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ZswapLocalState#inputs) * [outputs](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ZswapLocalState#outputs) --- # Ledger API | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • Readme | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * Ledger TypeScript API ===================== This document outlines the flow of transaction assembly and usage with the ledger TS API. Network ID[​](https://docs.midnight.network/api-reference/ledger#network-id "Direct link to Network ID") --------------------------------------------------------------------------------------------------------- Prior to any interaction, setNetworkId should be used to set the [NetworkId](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) to target the correct network. Proof stages[​](https://docs.midnight.network/api-reference/ledger#proof-stages "Direct link to Proof stages") --------------------------------------------------------------------------------------------------------------- Most transaction components will be in one of three stages: `X`, `UnprovenX`, or `ProofErasedX`. The `UnprovenX` stage is _always_ the first one. It is possible to transition to the `X` stage by proving an `UnprovenTransaction` through the proof server. For testing, and where proofs aren't necessary, the `ProofErasedX` stage is used, which can be reached via `eraseProof[s]` from the other two stages. Transaction structure[​](https://docs.midnight.network/api-reference/ledger#transaction-structure "Direct link to Transaction structure") ------------------------------------------------------------------------------------------------------------------------------------------ A [Transaction](https://docs.midnight.network/api-reference/ledger/classes/Transaction) runs in two phases: a _guaranteed_ phase, handling fee payments and fast-to-verify operations, and a _fallible_ phase, handling operations which may fail atomically, separately from the guaranteed phase. It therefore contains: * A "guaranteed" [Offer](https://docs.midnight.network/api-reference/ledger/classes/Offer) * Optionally, a "fallible" [Offer](https://docs.midnight.network/api-reference/ledger/classes/Offer) * Optionally, a sequence of [ContractCall](https://docs.midnight.network/api-reference/ledger/classes/ContractCall) s or [ContractDeploy](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy) s. It also contains additional cryptographic glue that will be omitted in this document. ### Zswap[​](https://docs.midnight.network/api-reference/ledger#zswap "Direct link to Zswap") A Zswap [Offer](https://docs.midnight.network/api-reference/ledger/classes/Offer) consists of: * A set of [Input](https://docs.midnight.network/api-reference/ledger/classes/Input) s, burning coins. * A set of [Output](https://docs.midnight.network/api-reference/ledger/classes/Output) s, creating coins. * A set of [Transient](https://docs.midnight.network/api-reference/ledger/classes/Transient) s, indicating a coin that is created and burnt in the same transaction. * A mapping from [TokenType](https://docs.midnight.network/api-reference/ledger/type-aliases/TokenType) s to offer balance, positive when there are more inputs than outputs and vice versa. [Input](https://docs.midnight.network/api-reference/ledger/classes/Input) s can be created either from a [QualifiedCoinInfo](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo) and a contract address, if the coin is contract-owned, or from a [QualifiedCoinInfo](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo) and a ZswapLocalState, if it is user-owned. Similarly, [Output](https://docs.midnight.network/api-reference/ledger/classes/Output) s can be created from a [CoinInfo](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo) and a contract address for contract-owned coins, or from a [CoinInfo](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo) and a user's public key(s), if it is user-owned. A [Transient](https://docs.midnight.network/api-reference/ledger/classes/Transient) is created similarly to a [Input](https://docs.midnight.network/api-reference/ledger/classes/Input) , but directly converts an existing [Output](https://docs.midnight.network/api-reference/ledger/classes/Output) . A [QualifiedCoinInfo](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo) is a [CoinInfo](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo) with an index into the Merkle tree of coin commitments that can be used to find the relevant coin to spend, while a [CoinInfo](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo) consists of a coins [TokenType](https://docs.midnight.network/api-reference/ledger/type-aliases/TokenType) , value, and a nonce. ### Calls[​](https://docs.midnight.network/api-reference/ledger#calls "Direct link to Calls") A [ContractDeploy](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy) consists of an initial contract state, and a nonce. A [ContractCall](https://docs.midnight.network/api-reference/ledger/classes/ContractCall) consists of a contract's address, the entry point used on this contract, a guaranteed and a fallible public oracle transcript, a communication commitment, and a proof. [ContractCall](https://docs.midnight.network/api-reference/ledger/classes/ContractCall) s are constructed via [ContractCallPrototype](https://docs.midnight.network/api-reference/ledger/classes/ContractCallPrototype) s, which consist of the following raw pieces of data: * The contract address * The contract's entry point * The contract operation expected (that is, the verifier key and transcript shape expected to be at this contract address and entry point) * The guaranteed transcript (as produced by the generated JS code) * The fallible transcript (as produced by the generated JS code) * The outputs of the private oracle calls (As a FAB [AlignedValue](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) s) * The input(s) to the call, concatenated together (As a FAB [AlignedValue](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) ) * The output(s) to the call, concatenated together (As a FAB [AlignedValue](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) ) * The communications commitment randomness (As a hex-encoded field element string) * A unique identifier for the ZK circuit used (used by the proof server to index for the prover key) NOTE: currently the JS code only generates a single transcript. We probably just want a canonical way to split this into guaranteed/fallible? A ContractCalls object is assembed, and [ContractCallPrototype](https://docs.midnight.network/api-reference/ledger/classes/ContractCallPrototype) s / [ContractDeploy](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy) s are added to this directly. This can then be inserted into an [UnprovenTransaction](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction) . State Structure[​](https://docs.midnight.network/api-reference/ledger#state-structure "Direct link to State Structure") ------------------------------------------------------------------------------------------------------------------------ The [LedgerState](https://docs.midnight.network/api-reference/ledger/classes/LedgerState) is the primary entry point for Midnight's ledger state, and it consists of a [ZswapChainState](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState) , as well as a mapping from [ContractAddress](https://docs.midnight.network/api-reference/ledger/type-aliases/ContractAddress) es to [ContractState](https://docs.midnight.network/api-reference/ledger/classes/ContractState) s. States are immutable, and applying transactions always produce new outputs states. * [Network ID](https://docs.midnight.network/api-reference/ledger#network-id) * [Proof stages](https://docs.midnight.network/api-reference/ledger#proof-stages) * [Transaction structure](https://docs.midnight.network/api-reference/ledger#transaction-structure) * [Zswap](https://docs.midnight.network/api-reference/ledger#zswap) * [Calls](https://docs.midnight.network/api-reference/ledger#calls) * [State Structure](https://docs.midnight.network/api-reference/ledger#state-structure) --- # midnight-js-utils | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-utils#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**Midnight.js API Reference v2.0.2**](https://docs.midnight.network/api-reference/midnight-js) * * * [Midnight.js API Reference](https://docs.midnight.network/api-reference/midnight-js/packages) / @midnight-ntwrk/midnight-js-utils @midnight-ntwrk/midnight-js-utils ================================= Type Aliases[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-utils#type-aliases "Direct link to Type Aliases") ------------------------------------------------------------------------------------------------------------------------------------------------------ * [ParsedHexString](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-utils/type-aliases/ParsedHexString) Functions[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-utils#functions "Direct link to Functions") --------------------------------------------------------------------------------------------------------------------------------------------- * [assertDefined](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-utils/functions/assertDefined) * [assertIsContractAddress](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-utils/functions/assertIsContractAddress) * [assertIsHex](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-utils/functions/assertIsHex) * [assertUndefined](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-utils/functions/assertUndefined) * [fromHex](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-utils/functions/fromHex) * [isHex](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-utils/functions/isHex) * [parseCoinPublicKeyToHex](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-utils/functions/parseCoinPublicKeyToHex) * [parseEncPublicKeyToHex](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-utils/functions/parseEncPublicKeyToHex) * [parseHex](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-utils/functions/parseHex) * [toHex](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-utils/functions/toHex) * [Type Aliases](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-utils#type-aliases) * [Functions](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-utils#functions) --- # midnight-js-network-id | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-network-id#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**Midnight.js API Reference v2.0.2**](https://docs.midnight.network/api-reference/midnight-js) * * * [Midnight.js API Reference](https://docs.midnight.network/api-reference/midnight-js/packages) / @midnight-ntwrk/midnight-js-network-id @midnight-ntwrk/midnight-js-network-id ====================================== Enumerations[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-network-id#enumerations "Direct link to Enumerations") ----------------------------------------------------------------------------------------------------------------------------------------------------------- * [NetworkId](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-network-id/enumerations/NetworkId) Classes[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-network-id#classes "Direct link to Classes") -------------------------------------------------------------------------------------------------------------------------------------------- * [NetworkIdTypeError](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-network-id/classes/NetworkIdTypeError) Functions[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-network-id#functions "Direct link to Functions") -------------------------------------------------------------------------------------------------------------------------------------------------- * [getLedgerNetworkId](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-network-id/functions/getLedgerNetworkId) * [getNetworkId](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-network-id/functions/getNetworkId) * [getRuntimeNetworkId](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-network-id/functions/getRuntimeNetworkId) * [getZswapNetworkId](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-network-id/functions/getZswapNetworkId) * [networkIdToHex](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-network-id/functions/networkIdToHex) * [setNetworkId](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-network-id/functions/setNetworkId) * [stringToNetworkId](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-network-id/functions/stringToNetworkId) * [Enumerations](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-network-id#enumerations) * [Classes](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-network-id#classes) * [Functions](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-network-id#functions) --- # midnight-js-contract | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**Midnight.js API Reference v2.0.2**](https://docs.midnight.network/api-reference/midnight-js) * * * [Midnight.js API Reference](https://docs.midnight.network/api-reference/midnight-js/packages) / @midnight-ntwrk/midnight-js-contracts @midnight-ntwrk/midnight-js-contracts ===================================== Classes[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts#classes "Direct link to Classes") ------------------------------------------------------------------------------------------------------------------------------------------- * [CallTxFailedError](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/classes/CallTxFailedError) * [ContractTypeError](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/classes/ContractTypeError) * [DeployTxFailedError](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/classes/DeployTxFailedError) * [IncompleteCallTxPrivateStateConfig](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/classes/IncompleteCallTxPrivateStateConfig) * [IncompleteFindContractPrivateStateConfig](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/classes/IncompleteFindContractPrivateStateConfig) * [InsertVerifierKeyTxFailedError](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/classes/InsertVerifierKeyTxFailedError) * [RemoveVerifierKeyTxFailedError](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/classes/RemoveVerifierKeyTxFailedError) * [ReplaceMaintenanceAuthorityTxFailedError](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/classes/ReplaceMaintenanceAuthorityTxFailedError) * [TxFailedError](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/classes/TxFailedError) Type Aliases[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts#type-aliases "Direct link to Type Aliases") ---------------------------------------------------------------------------------------------------------------------------------------------------------- * [CallOptions](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/CallOptions) * [CallOptionsBase](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/CallOptionsBase) * [CallOptionsProviderDataDependencies](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/CallOptionsProviderDataDependencies) * [CallOptionsWithArguments](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/CallOptionsWithArguments) * [CallOptionsWithPrivateState](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/CallOptionsWithPrivateState) * [CallOptionsWithProviderDataDependencies](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/CallOptionsWithProviderDataDependencies) * [CallResult](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/CallResult) * [CallResultPrivate](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/CallResultPrivate) * [CallResultPublic](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/CallResultPublic) * [CallTxOptions](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/CallTxOptions) * [CallTxOptionsBase](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/CallTxOptionsBase) * [CallTxOptionsWithPrivateStateId](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/CallTxOptionsWithPrivateStateId) * [CircuitCallTxInterface](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/CircuitCallTxInterface) * [CircuitMaintenanceTxInterface](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/CircuitMaintenanceTxInterface) * [CircuitMaintenanceTxInterfaces](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/CircuitMaintenanceTxInterfaces) * [ContractConstructorOptions](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/ContractConstructorOptions) * [ContractConstructorOptionsBase](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/ContractConstructorOptionsBase) * [ContractConstructorOptionsProviderDataDependencies](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/ContractConstructorOptionsProviderDataDependencies) * [ContractConstructorOptionsWithArguments](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/ContractConstructorOptionsWithArguments) * [ContractConstructorOptionsWithPrivateState](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/ContractConstructorOptionsWithPrivateState) * [ContractConstructorOptionsWithProviderDataDependencies](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/ContractConstructorOptionsWithProviderDataDependencies) * [ContractConstructorResult](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/ContractConstructorResult) * [ContractMaintenanceTxInterface](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/ContractMaintenanceTxInterface) * [ContractProviders](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/ContractProviders) * [ContractStates](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/ContractStates) * [DeployContractOptions](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/DeployContractOptions) * [DeployContractOptionsBase](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/DeployContractOptionsBase) * [DeployContractOptionsWithPrivateState](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/DeployContractOptionsWithPrivateState) * [DeployedContract](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/DeployedContract) * [DeployTxOptions](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/DeployTxOptions) * [DeployTxOptionsBase](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/DeployTxOptionsBase) * [DeployTxOptionsWithPrivateState](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/DeployTxOptionsWithPrivateState) * [DeployTxOptionsWithPrivateStateId](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/DeployTxOptionsWithPrivateStateId) * [FinalizedCallTxData](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/FinalizedCallTxData) * [FinalizedDeployTxData](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/FinalizedDeployTxData) * [FinalizedDeployTxDataBase](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/FinalizedDeployTxDataBase) * [FindDeployedContractOptions](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/FindDeployedContractOptions) * [FindDeployedContractOptionsBase](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/FindDeployedContractOptionsBase) * [FindDeployedContractOptionsExistingPrivateState](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/FindDeployedContractOptionsExistingPrivateState) * [FindDeployedContractOptionsStorePrivateState](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/FindDeployedContractOptionsStorePrivateState) * [FoundContract](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/FoundContract) * [PartitionedTranscript](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/PartitionedTranscript) * [PublicContractStates](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/PublicContractStates) * [SubmitTxOptions](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/SubmitTxOptions) * [SubmitTxProviders](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/SubmitTxProviders) * [UnprovenCallTxProvidersBase](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/UnprovenCallTxProvidersBase) * [UnprovenCallTxProvidersWithPrivateState](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/UnprovenCallTxProvidersWithPrivateState) * [UnprovenDeployTxOptions](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/UnprovenDeployTxOptions) * [UnprovenDeployTxProviders](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/UnprovenDeployTxProviders) * [UnsubmittedCallTxData](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/UnsubmittedCallTxData) * [UnsubmittedDeployTxData](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/UnsubmittedDeployTxData) * [UnsubmittedDeployTxDataBase](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/UnsubmittedDeployTxDataBase) * [UnsubmittedDeployTxPrivateData](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/UnsubmittedDeployTxPrivateData) * [UnsubmittedDeployTxPublicData](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/UnsubmittedDeployTxPublicData) * [UnsubmittedTxData](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/type-aliases/UnsubmittedTxData) Functions[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts#functions "Direct link to Functions") ------------------------------------------------------------------------------------------------------------------------------------------------- * [call](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/call) * [callContractConstructor](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/callContractConstructor) * [createCallTxOptions](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/createCallTxOptions) * [createCircuitCallTxInterface](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/createCircuitCallTxInterface) * [createCircuitMaintenanceTxInterface](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/createCircuitMaintenanceTxInterface) * [createCircuitMaintenanceTxInterfaces](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/createCircuitMaintenanceTxInterfaces) * [createContractMaintenanceTxInterface](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/createContractMaintenanceTxInterface) * [createUnprovenCallTx](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/createUnprovenCallTx) * [createUnprovenCallTxFromInitialStates](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/createUnprovenCallTxFromInitialStates) * [createUnprovenDeployTx](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/createUnprovenDeployTx) * [createUnprovenDeployTxFromVerifierKeys](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/createUnprovenDeployTxFromVerifierKeys) * [deployContract](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/deployContract) * [findDeployedContract](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/findDeployedContract) * [getPublicStates](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/getPublicStates) * [getStates](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/getStates) * [submitCallTx](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/submitCallTx) * [submitDeployTx](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/submitDeployTx) * [submitInsertVerifierKeyTx](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/submitInsertVerifierKeyTx) * [submitRemoveVerifierKeyTx](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/submitRemoveVerifierKeyTx) * [submitReplaceAuthorityTx](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/submitReplaceAuthorityTx) * [submitTx](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/submitTx) * [verifierKeysEqual](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/verifierKeysEqual) * [verifyContractState](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts/functions/verifyContractState) * [Classes](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts#classes) * [Type Aliases](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts#type-aliases) * [Functions](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-contracts#functions) --- # ProofData | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ProofData#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / ProofData Interface: ProofData ==================== Encapsulates the data required to produce a zero-knowledge proof Extends[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ProofData#extends "Direct link to Extends") ------------------------------------------------------------------------------------------------------------------------------ * [`PartialProofData`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/PartialProofData) Properties[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ProofData#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------- ### input[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ProofData#input "Direct link to input") input: AlignedValue; The inputs to a circuit #### Inherited from[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ProofData#inherited-from "Direct link to Inherited from") [`PartialProofData`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/PartialProofData) .[`input`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/PartialProofData#input) * * * ### output[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ProofData#output "Direct link to output") output: AlignedValue; The outputs from a circuit * * * ### privateTranscriptOutputs[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ProofData#privatetranscriptoutputs "Direct link to privateTranscriptOutputs") privateTranscriptOutputs: AlignedValue[]; The transcript of the witness call outputs #### Inherited from[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ProofData#inherited-from-1 "Direct link to Inherited from") [`PartialProofData`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/PartialProofData) .[`privateTranscriptOutputs`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/PartialProofData#privatetranscriptoutputs) * * * ### publicTranscript[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ProofData#publictranscript "Direct link to publicTranscript") publicTranscript: Op[]; The public transcript of operations #### Inherited from[​](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ProofData#inherited-from-2 "Direct link to Inherited from") [`PartialProofData`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/PartialProofData) .[`publicTranscript`](https://docs.midnight.network/api-reference/compact-runtime/interfaces/PartialProofData#publictranscript) * [Extends](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ProofData#extends) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ProofData#properties) * [input](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ProofData#input) * [output](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ProofData#output) * [privateTranscriptOutputs](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ProofData#privatetranscriptoutputs) * [publicTranscript](https://docs.midnight.network/api-reference/compact-runtime/interfaces/ProofData#publictranscript) --- # midnight-js-types | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**Midnight.js API Reference v2.0.2**](https://docs.midnight.network/api-reference/midnight-js) * * * [Midnight.js API Reference](https://docs.midnight.network/api-reference/midnight-js/packages) / @midnight-ntwrk/midnight-js-types @midnight-ntwrk/midnight-js-types ================================= Enumerations[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types#enumerations "Direct link to Enumerations") ------------------------------------------------------------------------------------------------------------------------------------------------------ * [LogLevel](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/enumerations/LogLevel) Classes[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types#classes "Direct link to Classes") --------------------------------------------------------------------------------------------------------------------------------------- * [InvalidProtocolSchemeError](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/classes/InvalidProtocolSchemeError) * [ZKConfigProvider](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/classes/ZKConfigProvider) Interfaces[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types#interfaces "Direct link to Interfaces") ------------------------------------------------------------------------------------------------------------------------------------------------ * [Contract](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/interfaces/Contract) * [FinalizedTxData](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/interfaces/FinalizedTxData) * [LoggerProvider](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/interfaces/LoggerProvider) * [MidnightProvider](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/interfaces/MidnightProvider) * [MidnightProviders](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/interfaces/MidnightProviders) * [PrivateStateProvider](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/interfaces/PrivateStateProvider) * [ProofProvider](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/interfaces/ProofProvider) * [ProveTxConfig](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/interfaces/ProveTxConfig) * [PublicDataProvider](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/interfaces/PublicDataProvider) * [WalletProvider](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/interfaces/WalletProvider) * [ZKConfig](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/interfaces/ZKConfig) Type Aliases[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types#type-aliases "Direct link to Type Aliases") ------------------------------------------------------------------------------------------------------------------------------------------------------ * [All](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/All) * [BalancedTransaction](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/BalancedTransaction) * [BlockHashConfig](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/BlockHashConfig) * [BlockHeightConfig](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/BlockHeightConfig) * [CircuitParameters](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/CircuitParameters) * [CircuitReturnType](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/CircuitReturnType) * [ContractStateObservableConfig](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/ContractStateObservableConfig) * [ImpureCircuit](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/ImpureCircuit) * [ImpureCircuitId](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/ImpureCircuitId) * [ImpureCircuits](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/ImpureCircuits) * [InitialStateParameters](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/InitialStateParameters) * [Latest](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/Latest) * [PrivateState](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/PrivateState) * [PrivateStateId](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/PrivateStateId) * [ProverKey](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/ProverKey) * [TxIdConfig](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/TxIdConfig) * [TxStatus](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/TxStatus) * [UnbalancedTransaction](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/UnbalancedTransaction) * [VerifierKey](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/VerifierKey) * [Witness](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/Witness) * [Witnesses](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/Witnesses) * [ZKIR](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/type-aliases/ZKIR) Variables[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types#variables "Direct link to Variables") --------------------------------------------------------------------------------------------------------------------------------------------- * [FailEntirely](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/variables/FailEntirely) * [FailFallible](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/variables/FailFallible) * [SucceedEntirely](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/variables/SucceedEntirely) Functions[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types#functions "Direct link to Functions") --------------------------------------------------------------------------------------------------------------------------------------------- * [createBalancedTx](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/functions/createBalancedTx) * [createProverKey](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/functions/createProverKey) * [createUnbalancedTx](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/functions/createUnbalancedTx) * [createVerifierKey](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/functions/createVerifierKey) * [createZKIR](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/functions/createZKIR) * [getImpureCircuitIds](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types/functions/getImpureCircuitIds) * [Enumerations](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types#enumerations) * [Classes](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types#classes) * [Interfaces](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types#interfaces) * [Type Aliases](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types#type-aliases) * [Variables](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types#variables) * [Functions](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-types#functions) --- # Wallet API | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • Readme | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * Midnight Wallet API =================== This API provides a comprehensive interface for wallet operations, defining the structure of the wallet state, the methods for interacting with it, and the types and variables used within. It is implemented by the `@midnight-ntwrk/wallet` package. See the [Midnight wallet developer guide](https://docs.midnight.network/develop/guides/wallet-dev-guide) for implementation and usage information. --- # Bytes32Descriptor | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/Bytes32Descriptor#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / Bytes32Descriptor Variable: Bytes32Descriptor =========================== const Bytes32Descriptor: CompactTypeBytes; The following are type descriptors used to implement createCoinCommitment. They are not intended for direct consumption. --- # midnight-js-testing | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**Midnight.js API Reference v2.0.2**](https://docs.midnight.network/api-reference/midnight-js) * * * [Midnight.js API Reference](https://docs.midnight.network/api-reference/midnight-js/packages) / @midnight-ntwrk/midnight-js-testing What is this? ============= A comprehensive testing solution for your Midnight.JS applications, providing seamless integration with various test environments. This package was created for the [Midnight network](https://midnight.network/) . Please visit the [Midnight Developer Hub](https://midnight.network/developer-hub) to learn more. Use only in Midnight test environments ====================================== Image exclusively for Midnight test environments use. Agree to Terms ============== By downloading and using this image, you agree to [Midnight’s Terms and Conditions](https://midnight.network/static/terms.pdf) , which includes the [Privacy Policy](https://midnight.network/static/privacy-policy.pdf) . License ======= The software provided herein is licensed under the [Apache License V2.0](http://www.apache.org/licenses/LICENSE-2.0) . Table of Contents[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#table-of-contents "Direct link to Table of Contents") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1. [Installation](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#installation) 2. [Getting Started](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#getting-started) 3. [Features](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#Features) 4. [Limitations](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#Limitations) 5. [Examples of Usage](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#Examples-of-Usage) * * * Installation[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#installation "Direct link to Installation") -------------------------------------------------------------------------------------------------------------------------------------------------------- Before using the testing library, ensure you have the following prerequisites: 1. Node.js and yarn installed 2. Docker Desktop (optional for local dockerized tests) 3. Midnight.JS project set up Install the testing library by running the following command in your terminal: yarn add -D @midnight-ntwrk/midnight-js-testing Getting Started[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#getting-started "Direct link to Getting Started") ----------------------------------------------------------------------------------------------------------------------------------------------------------------- To use the testing library, create a new file called `midnight.test.js` in the `__tests__` directory of your project. In this file, import the necessary dependencies: import { getTestEnvironment } from '@midnight-ntwrk/midnight-js-testing';beforeAll(async () => { testEnvironment = getTestEnvironment(logger); environmentConfiguration = await testEnvironment.start(); walletProvider = await testEnvironment.getMidnightWalletProvider();});afterAll(async () => { await testEnvironment.shutdown();}); * * * Features[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#features "Direct link to Features") -------------------------------------------------------------------------------------------------------------------------------------------- Set of functions that simplify testing of DApps in Midnight * [x] Standard Dockerized environment setup - both live and local * [x] Predefined Midnight environments configuration * [x] Proof server control * [x] Wallets management * [x] Fund wallets * [x] Check system health * * * Environment variables[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#environment-variables "Direct link to Environment variables") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### Environment selection:[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#environment-selection "Direct link to Environment selection:") * MN\_TEST\_ENVIRONMENT controls the environment to be used for testing. It can take one of these values: * undeployed * devnet * testnet * env-var-remote If **MN\_TEST\_ENVIRONMENT** is not set, the default value will be `undeployed`. If **MN\_TEST\_ENVIRONMENT** is set to `undeployed`, the testing environment will be deployed locally using Docker. If **MN\_TEST\_ENVIRONMENT** is set to `devnet`,`testnet, env-var-remote` the testing environment will the corresponding live network, with proof server setup using predefined NETWORK\_ID. If **MN\_TEST\_ENVIRONMENT** is set to `env-var-remote`, below environment variables must be set: * _MN\_TEST\_NETWORK\_ID_ - Proof server NETWORK\_ID * _MN\_TEST\_INDEXER_ - Indexer URL * _MN\_TEST\_INDEXER\_WS_ - Indexer WebSocket URL * _MN\_TEST\_NODE_ - Node URL * _MN\_TEST\_FAUCET_ - Faucet URL ### Wallet setup:[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#wallet-setup "Direct link to Wallet setup:") * MN\_TEST\_WALLET\_SEED can be used to set a specific seed phrase for the wallet. If not set, a random seed phrase will be used. * * * Limitations[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#limitations "Direct link to Limitations") ----------------------------------------------------------------------------------------------------------------------------------------------------- * Localnet wallets limit count is 4 * * * Examples of Usage[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#examples-of-usage "Direct link to Examples of Usage") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### 1\. Selecting Different Environments[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#1-selecting-different-environments "Direct link to 1. Selecting Different Environments") You can control the test environment using the `MN_TEST_ENVIRONMENT` environment variable. Here's how you can set it: const testEnvironment = getTestEnvironment(logger);environmentConfiguration = await testEnvironment.start(); # Example: Set the environment variable before initializing the test environmentMN_TEST_ENVIRONMENT='devnet'; yarn test This allows you to easily switch between predefined environments like `devnet`, `testnet`, and others. Default (undefined) value is `undeployed` which will deploy the testing environment locally using Docker. * * * ### 2\. Creating and Managing Wallets[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#2-creating-and-managing-wallets "Direct link to 2. Creating and Managing Wallets") Here's an example of creating wallets in your test environment: // Example: Create multiple wallets in a test environmentconst testEnvironment = getTestEnvironment(logger);await testEnvironment.start();// Create 2 walletsconst wallets = await testEnvironment.startMidnightWalletProviders(2);// Verify wallet propertiesexpect(wallets).toHaveLength(2);wallets.forEach(async (wallet) => { expect(wallet.coinPublicKey).not.toBeUndefined();});// Shutdown the environment after testingawait testEnvironment.shutdown(); This demonstrates how to create wallets and verify their properties, such as the `coinPublicKey`. * * * ### 3\. Setting Wallet Seeds[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#3-setting-wallet-seeds "Direct link to 3. Setting Wallet Seeds") If you need to use specific wallet seeds for testing, you can do the following: // Example: Create a wallet with a predefined seed phraseconst wallet = await testEnvironment.getMidnightWalletProvider();expect(wallet.coinPublicKey).not.toBeUndefined(); # Example: Set the environment variable before initializing the test environmentMN_TEST_WALLET_SEED='00000000000000000000000000000042'; yarn test This allows you to test specific scenarios using known wallet seeds. * * * ### 4\. Handling Environment Configuration[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#4-handling-environment-configuration "Direct link to 4. Handling Environment Configuration") You can also customize the test environment configuration by modifying the `defaultContainersConfiguration` object: import { defaultContainersConfiguration, getContainersConfiguration, setContainersConfiguration} from '../configuration';// Example: Modify default environment configuration before startingconst config: ContainersConfiguration = { ...defaultContainersConfiguration, proofServer: { ...defaultContainersConfiguration.proofServer, fileName: 'proof-server.yml' }};setContainersConfiguration(config); This gives developers flexibility in configuring the test environment according to their needs. * * * ### 5\. Error Handling[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#5-error-handling "Direct link to 5. Error Handling") Here's an example of handling errors when setting up wallets: // Example: Test for maximum wallet limit exceededprocess.env.MN_TEST_ENVIRONMENT = undefined; // Use local environmentconst testEnvironment = getTestEnvironment(logger);await testEnvironment.start();try { await testEnvironment.startMidnightWalletProviders(5); // Assuming max is 4} catch (error) { expect(error.message).toContain('Maximum supported number of wallets for this environment reached');}await testEnvironment.shutdown(); This demonstrates how to handle cases where the wallet limit is exceeded. * * * ### 6\. Advanced Usage with Proof Server[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#6-advanced-usage-with-proof-server "Direct link to 6. Advanced Usage with Proof Server") Here's an example of integrating with the proof server: // Example: Start a proof server with networkd ID = testnet and ID = 123const proofServer = await DynamicProofServerContainer.start(logger, '123', 'testnet');//stop the proof serverawait proofServer.stop(); This shows how to integrate with and customize the proof server for testing. * * * ### 7\. Customized test environments[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#7-customized-test-environments "Direct link to 7. Customized test environments") Library is provided with set of predefined environment configurations i.e.: * LocalTestEnvironment * Testnet2TestEnvironment By using `getTestEnvironment(logger);` based on environment variable MN\_TEST\_ENVIRONMENT test environment configuration is provided. However, you can either create your own class defining the environment endpoints or use the below environment variables. Here's an example of fully customized endpoints of the test environment, that you can provide using environment variables: MN_TEST_ENVIRONMENT="env-var-remote" \MN_TEST_NETWORK_ID="undeployed" \MN_TEST_INDEXER="http://localhost:3085/api/" \MN_TEST_INDEXER_WS="ws://localhost:3085/ws/" \MN_TEST_NODE="http://localhost:3086" \yarn test * * * ### 8\. System health check before tests[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#8-system-health-check-before-tests "Direct link to 8. System health check before tests") For the remote test environemnts (testnet-02, ...) simple health check is performed for each of the components to check their state before test. Classes[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#classes "Direct link to Classes") ----------------------------------------------------------------------------------------------------------------------------------------- * [DevnetTestEnvironment](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/classes/DevnetTestEnvironment) * [DynamicProofServerContainer](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/classes/DynamicProofServerContainer) * [EnvVarRemoteTestEnvironment](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/classes/EnvVarRemoteTestEnvironment) * [FaucetClient](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/classes/FaucetClient) * [GzipFile](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/classes/GzipFile) * [IndexerClient](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/classes/IndexerClient) * [LocalTestConfiguration](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/classes/LocalTestConfiguration) * [LocalTestEnvironment](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/classes/LocalTestEnvironment) * [MidnightWalletProvider](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/classes/MidnightWalletProvider) * [NodeClient](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/classes/NodeClient) * [ProofServerClient](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/classes/ProofServerClient) * [QanetTestEnvironment](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/classes/QanetTestEnvironment) * [RemoteTestEnvironment](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/classes/RemoteTestEnvironment) * [StaticProofServerContainer](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/classes/StaticProofServerContainer) * [TestEnvironment](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/classes/TestEnvironment) * [Testnet2TestEnvironment](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/classes/Testnet2TestEnvironment) * [TestnetTestEnvironment](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/classes/TestnetTestEnvironment) * [WalletFactory](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/classes/WalletFactory) * [WalletSaveStateProvider](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/classes/WalletSaveStateProvider) Interfaces[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#interfaces "Direct link to Interfaces") -------------------------------------------------------------------------------------------------------------------------------------------------- * [ContainerEndpoints](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/interfaces/ContainerEndpoints) * [ContainersConfiguration](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/interfaces/ContainersConfiguration) * [ContractConfiguration](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/interfaces/ContractConfiguration) * [EnvironmentConfiguration](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/interfaces/EnvironmentConfiguration) * [LogConfiguration](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/interfaces/LogConfiguration) * [ProofServerContainer](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/interfaces/ProofServerContainer) * [ProofServerContainerConfiguration](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/interfaces/ProofServerContainerConfiguration) * [StandaloneContainerNames](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/interfaces/StandaloneContainerNames) * [StandaloneContainersConfiguration](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/interfaces/StandaloneContainersConfiguration) Type Aliases[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#type-aliases "Direct link to Type Aliases") -------------------------------------------------------------------------------------------------------------------------------------------------------- * [ComponentPortsConfiguration](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/type-aliases/ComponentPortsConfiguration) * [MidnightWallet](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/type-aliases/MidnightWallet) * [SerializedWalletState](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/type-aliases/SerializedWalletState) * [TxOutput](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/type-aliases/TxOutput) Variables[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#variables "Direct link to Variables") ----------------------------------------------------------------------------------------------------------------------------------------------- * [DEFAULT\_WALLET\_LOG\_LEVEL](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/variables/DEFAULT_WALLET_LOG_LEVEL) * [DEFAULT\_WALLET\_STATE\_DIRECTORY](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/variables/DEFAULT_WALLET_STATE_DIRECTORY) * [defaultContainersConfiguration](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/variables/defaultContainersConfiguration) * [latestContainersConfiguration](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/variables/latestContainersConfiguration) * [logger](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/variables/logger) * [MINUTE](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/variables/MINUTE) Functions[​](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#functions "Direct link to Functions") ----------------------------------------------------------------------------------------------------------------------------------------------- * [createDefaultTestLogger](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/createDefaultTestLogger) * [createLogger](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/createLogger) * [createOutputs](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/createOutputs) * [delay](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/delay) * [expectFoundAndDeployedStatesEqual](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/expectFoundAndDeployedStatesEqual) * [expectFoundAndDeployedTxDataEqual](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/expectFoundAndDeployedTxDataEqual) * [expectFoundAndDeployedTxPrivateDataEqual](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/expectFoundAndDeployedTxPrivateDataEqual) * [expectFoundAndDeployedTxPublicDataEqual](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/expectFoundAndDeployedTxPublicDataEqual) * [expectStatesEqual](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/expectStatesEqual) * [expectSuccessfulCallTx](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/expectSuccessfulCallTx) * [expectSuccessfulDeployTx](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/expectSuccessfulDeployTx) * [expectSuccessfulTxData](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/expectSuccessfulTxData) * [extractHostnameAndPort](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/extractHostnameAndPort) * [getContainersConfiguration](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/getContainersConfiguration) * [getInitialState](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/getInitialState) * [getTestEnvironment](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/getTestEnvironment) * [getWalletStateFilename](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/getWalletStateFilename) * [initializeMidnightProviders](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/initializeMidnightProviders) * [inMemoryPrivateStateProvider](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/inMemoryPrivateStateProvider) * [normalizeWalletState](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/normalizeWalletState) * [sendTransactionToAddress](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/sendTransactionToAddress) * [sendTransactionToWallet](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/sendTransactionToWallet) * [setContainersConfiguration](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/setContainersConfiguration) * [stateValueEqual](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/stateValueEqual) * [syncWallet](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/syncWallet) * [txsEqual](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/txsEqual) * [waitForFinalizedBalance](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/waitForFinalizedBalance) * [waitForFullSync](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/waitForFullSync) * [waitForFunds](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/waitForFunds) * [waitForPending](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/waitForPending) * [waitForSyncProgressDefined](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/waitForSyncProgressDefined) * [waitForTxInHistory](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/waitForTxInHistory) * [walletStateWithoutHistoryAndCoins](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing/functions/walletStateWithoutHistoryAndCoins) * [Table of Contents](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#table-of-contents) * [Installation](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#installation) * [Getting Started](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#getting-started) * [Features](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#features) * [Environment variables](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#environment-variables) * [Environment selection:](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#environment-selection) * [Wallet setup:](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#wallet-setup) * [Limitations](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#limitations) * [Examples of Usage](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#examples-of-usage) * [1\. Selecting Different Environments](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#1-selecting-different-environments) * [2\. Creating and Managing Wallets](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#2-creating-and-managing-wallets) * [3\. Setting Wallet Seeds](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#3-setting-wallet-seeds) * [4\. Handling Environment Configuration](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#4-handling-environment-configuration) * [5\. Error Handling](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#5-error-handling) * [6\. Advanced Usage with Proof Server](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#6-advanced-usage-with-proof-server) * [7\. Customized test environments](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#7-customized-test-environments) * [8\. System health check before tests](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#8-system-health-check-before-tests) * [Classes](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#classes) * [Interfaces](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#interfaces) * [Type Aliases](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#type-aliases) * [Variables](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#variables) * [Functions](https://docs.midnight.network/api-reference/midnight-js/@midnight-ntwrk/midnight-js-testing#functions) --- # BooleanDescriptor | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/BooleanDescriptor#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.9.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / BooleanDescriptor Variable: BooleanDescriptor =========================== const BooleanDescriptor: CompactTypeBoolean; --- # CompactTypeField | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/CompactTypeField#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactTypeField Variable: CompactTypeField ========================== const CompactTypeField: CompactType; Runtime type of the builtin `Field` type --- # CompactTypeOpaqueString | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/CompactTypeOpaqueString#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactTypeOpaqueString Variable: CompactTypeOpaqueString ================================= const CompactTypeOpaqueString: CompactType; Runtime type of `Opaque["string"]` --- # TRANSACTION_TO_PROVE | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/variables/TRANSACTION_TO_PROVE#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / TRANSACTION\_TO\_PROVE Variable: TRANSACTION\_TO\_PROVE ================================ const TRANSACTION_TO_PROVE: "TransactionToProve" = 'TransactionToProve'; Proving recipe identifier type for TransactionToProve --- # NOTHING_TO_PROVE | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/variables/NOTHING_TO_PROVE#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / NOTHING\_TO\_PROVE Variable: NOTHING\_TO\_PROVE ============================ const NOTHING_TO_PROVE: "NothingToProve" = 'NothingToProve'; Proving recipe identifier type for NothingToProve --- # Compact runtime API | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/compact-runtime v0.9.0** * * * Compact runtime library ======================= This API provides runtime primitives used by Compact's TypeScript output, both for use by the compiler output directly, and to utilise it or reproduce its behaviour. This API re-exports a number of items from `@midnight-ntwrk/onchain-runtime`, and wraps others in a more TypeScript-friendly API. Key parts of the API are: * setNetworkId, required to ensure the right network is being targeted * [CircuitContext](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/CircuitContext) , and [CircuitResults](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/CircuitResults) part of the input and output definition of all circuits * [WitnessContext](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/WitnessContext) , part of the input definition of all circuits * Built-in functions: * Hashing/commitment * [transientHash](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/transientHash) * [transientCommit](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/transientCommit) * [persistentHash](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/persistentHash) * [persistentCommit](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/persistentCommit) * [degradeToTransient](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/degradeToTransient) * Elliptic curve * [ecAdd](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/ecAdd) * [ecMul](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/ecMul) * [ecMulGenerator](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/ecMulGenerator) * [hashToCurve](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/hashToCurve) * [ContractState](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/ContractState) , encapsulating the entirety of a smart contract's on-chain state * [StateValue](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/StateValue) , encoding data a contract maintains on-chain * [QueryContext](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/QueryContext) , providing an annotated view into the contract state, against which on-chain VM programs can be run * [CompactType](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/CompactType) , providing a runtime representation of basic Compact datatypes * Various TypeScript types matching same-named Compact types --- # CONTRACT_ADDRESS_BYTE_LENGTH | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/CONTRACT_ADDRESS_BYTE_LENGTH#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CONTRACT\_ADDRESS\_BYTE\_LENGTH Variable: CONTRACT\_ADDRESS\_BYTE\_LENGTH ========================================= const CONTRACT_ADDRESS_BYTE_LENGTH: 32 = 32; The expected length (in bytes) of a contract address. --- # MAX_FIELD | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/MAX_FIELD#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / MAX\_FIELD Variable: MAX\_FIELD ==================== const MAX_FIELD: bigint; The maximum value representable in Compact's `Field` type One less than the prime modulus of the proof system's scalar field --- # CompactTypeOpaqueUint8Array | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/CompactTypeOpaqueUint8Array#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactTypeOpaqueUint8Array Variable: CompactTypeOpaqueUint8Array ===================================== const CompactTypeOpaqueUint8Array: CompactType; Runtime type of `Opaque["Uint8Array"]` --- # CompactTypeBoolean | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/CompactTypeBoolean#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactTypeBoolean Variable: CompactTypeBoolean ============================ const CompactTypeBoolean: CompactType; Runtime type of the builtin `Boolean` type --- # HEX_REGEX_NO_PREFIX | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/HEX_REGEX_NO_PREFIX#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / HEX\_REGEX\_NO\_PREFIX Variable: HEX\_REGEX\_NO\_PREFIX ================================ const HEX_REGEX_NO_PREFIX: RegExp; Regex matching hex strings of even length. --- # CompactTypeMerkleTreePathEntry | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/CompactTypeMerkleTreePathEntry#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactTypeMerkleTreePathEntry Variable: CompactTypeMerkleTreePathEntry ======================================== const CompactTypeMerkleTreePathEntry: CompactType; Runtime type of [MerkleTreePathEntry](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreePathEntry) --- # MaxUint8Descriptor | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/MaxUint8Descriptor#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / MaxUint8Descriptor Variable: MaxUint8Descriptor ============================ const MaxUint8Descriptor: CompactTypeUnsignedInteger; --- # versionString | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/versionString#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / versionString Variable: versionString ======================= const versionString: string = "0.14.0"; --- # BALANCE_TRANSACTION_TO_PROVE | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/variables/BALANCE_TRANSACTION_TO_PROVE#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / BALANCE\_TRANSACTION\_TO\_PROVE Variable: BALANCE\_TRANSACTION\_TO\_PROVE ========================================= const BALANCE_TRANSACTION_TO_PROVE: "BalanceTransactionToProve" = 'BalanceTransactionToProve'; Proving recipe identifier type for BalanceTransactionToProve --- # Reference documentation | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/reference#__docusaurus_skipToContent_fallback) Explore with… ▾ This part of the Midnight documentation provides reference materials covering the Compact language, TypeScript APIs, and tools provided by the Midnight team. It includes: * [The Compact language](https://docs.midnight.network/compact) , providing details on using Compact, including a [tutorial on writing smart contracts](https://docs.midnight.network/compact/writing) . * [Midnight APIs](https://docs.midnight.network/develop/reference/midnight-api) , describing the application programming interfaces of various libraries available for Midnight developers. * [Tools](https://docs.midnight.network/develop/reference/tools) , providing usage details for some of the developer tools, including the Visual Studio Code extension for Compact and the manual page for the Compact compiler. --- # CompactTypeNativePoint | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/CompactTypeNativePoint#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactTypeNativePoint Variable: CompactTypeNativePoint ================================ const CompactTypeNativePoint: CompactType; Runtime type of [NativePoint](https://docs.midnight.network/api-reference/compact-runtime/interfaces/NativePoint) --- # CompactTypeMerkleTreeDigest | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/CompactTypeMerkleTreeDigest#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CompactTypeMerkleTreeDigest Variable: CompactTypeMerkleTreeDigest ===================================== const CompactTypeMerkleTreeDigest: CompactType; Runtime type of [MerkleTreeDigest](https://docs.midnight.network/api-reference/compact-runtime/interfaces/MerkleTreeDigest) --- # ContractOperation | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / ContractOperation Class: ContractOperation ======================== An individual operation, or entry point of a contract, consisting primarily of a ZK verifier keys, potentially for different versions of the proving system. Only the latest available version is exposed to this API. Note that the serialized form of the key is checked on initialization Constructors[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#constructors "Direct link to Constructors") -------------------------------------------------------------------------------------------------------------------------------------------------- ### new ContractOperation()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#new-contractoperation "Direct link to new ContractOperation()") new ContractOperation(): ContractOperation #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#returns "Direct link to Returns") [`ContractOperation`](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation) Properties[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#properties "Direct link to Properties") -------------------------------------------------------------------------------------------------------------------------------------------- ### verifierKey[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#verifierkey "Direct link to verifierKey") verifierKey: Uint8Array; Methods[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#methods "Direct link to Methods") ----------------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#serialize "Direct link to serialize()") serialize(networkid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#parameters "Direct link to Parameters") • **networkid**: [`NetworkId`](https://docs.midnight.network/api-reference/onchain-runtime/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#deserialize "Direct link to deserialize()") static deserialize(raw, networkid): ContractOperation #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **networkid**: [`NetworkId`](https://docs.midnight.network/api-reference/onchain-runtime/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#returns-3 "Direct link to Returns") [`ContractOperation`](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation) * [Constructors](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#constructors) * [new ContractOperation()](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#new-contractoperation) * [Properties](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#properties) * [verifierKey](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#verifierkey) * [Methods](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#methods) * [serialize()](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#serialize) * [toString()](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#tostring) * [deserialize()](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation#deserialize) --- # QueryResults | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / QueryResults Class: QueryResults =================== The results of making a query against a specific state or context Constructors[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults#constructors "Direct link to Constructors") --------------------------------------------------------------------------------------------------------------------------------------------- ### new QueryResults()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults#new-queryresults "Direct link to new QueryResults()") private new QueryResults(): QueryResults #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults#returns "Direct link to Returns") [`QueryResults`](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults) Properties[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------- ### context[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults#context "Direct link to context") readonly context: QueryContext; The context state after executing the query. This can be used to execute further queries * * * ### events[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults#events "Direct link to events") readonly events: GatherResult[]; Any events/results that occurred during or from the query * * * ### gasCost[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults#gascost "Direct link to gasCost") readonly gasCost: bigint; The measured cost of executing the query Methods[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------------ ### toString()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults#parameters "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults#returns-1 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults#constructors) * [new QueryResults()](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults#new-queryresults) * [Properties](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults#properties) * [context](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults#context) * [events](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults#events) * [gasCost](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults#gascost) * [Methods](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults#methods) * [toString()](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults#tostring) --- # CostModel | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / CostModel Class: CostModel ================ A cost model for calculating transaction fees Constructors[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------ ### new CostModel()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel#new-costmodel "Direct link to new CostModel()") private new CostModel(): CostModel #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel#returns "Direct link to Returns") [`CostModel`](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel) Methods[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel#methods "Direct link to Methods") --------------------------------------------------------------------------------------------------------------------------- ### toString()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel#parameters "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel#returns-1 "Direct link to Returns") `string` * * * ### dummyCostModel()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel#dummycostmodel "Direct link to dummyCostModel()") static dummyCostModel(): CostModel A cost model for use in non-critical contexts #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel#returns-2 "Direct link to Returns") [`CostModel`](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel) * [Constructors](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel#constructors) * [new CostModel()](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel#new-costmodel) * [Methods](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel#methods) * [toString()](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel#tostring) * [dummyCostModel()](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel#dummycostmodel) --- # StateMap | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / StateMap Class: StateMap =============== Represents a key-value map, where keys are [AlignedValue](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) s, and values are [StateValue](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue) s. Constructors[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#constructors "Direct link to Constructors") ----------------------------------------------------------------------------------------------------------------------------------------- ### new StateMap()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#new-statemap "Direct link to new StateMap()") new StateMap(): StateMap #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#returns "Direct link to Returns") [`StateMap`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap) Methods[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#methods "Direct link to Methods") -------------------------------------------------------------------------------------------------------------------------- ### get()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#get "Direct link to get()") get(key): undefined | StateValue #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#parameters "Direct link to Parameters") • **key**: [`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#returns-1 "Direct link to Returns") `undefined` | [`StateValue`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue) * * * ### insert()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#insert "Direct link to insert()") insert(key, value): StateMap #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#parameters-1 "Direct link to Parameters") • **key**: [`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) • **value**: [`StateValue`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#returns-2 "Direct link to Returns") [`StateMap`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap) * * * ### keys()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#keys "Direct link to keys()") keys(): AlignedValue[] #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#returns-3 "Direct link to Returns") [`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) \[\] * * * ### remove()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#remove "Direct link to remove()") remove(key): StateMap #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#parameters-2 "Direct link to Parameters") • **key**: [`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#returns-4 "Direct link to Returns") [`StateMap`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap) * * * ### toString()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#parameters-3 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#returns-5 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#constructors) * [new StateMap()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#new-statemap) * [Methods](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#methods) * [get()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#get) * [insert()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#insert) * [keys()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#keys) * [remove()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#remove) * [toString()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap#tostring) --- # VmResults | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / VmResults Class: VmResults ================ Represents the results of a VM call Constructors[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------ ### new VmResults()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults#new-vmresults "Direct link to new VmResults()") private new VmResults(): VmResults #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults#returns "Direct link to Returns") [`VmResults`](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults) Properties[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------ ### events[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults#events "Direct link to events") readonly events: GatherResult[]; The events that got emitted by this VM invocation * * * ### gasCost[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults#gascost "Direct link to gasCost") readonly gasCost: bigint; The computed gas cost of running this VM invocation * * * ### stack[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults#stack "Direct link to stack") readonly stack: VmStack; The VM stack at the end of the VM invocation Methods[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults#methods "Direct link to Methods") --------------------------------------------------------------------------------------------------------------------------- ### toString()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults#parameters "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults#returns-1 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults#constructors) * [new VmResults()](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults#new-vmresults) * [Properties](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults#properties) * [events](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults#events) * [gasCost](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults#gascost) * [stack](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults#stack) * [Methods](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults#methods) * [toString()](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults#tostring) --- # VmStack | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / VmStack Class: VmStack ============== Represents the state of the VM's stack at a specific point. The stack is an array of [StateValue](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue) s, each of which is also annotated with whether it is "strong" or "weak"; that is, whether it is permitted to be stored on-chain or not. Constructors[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------------- ### new VmStack()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#new-vmstack "Direct link to new VmStack()") new VmStack(): VmStack #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#returns "Direct link to Returns") [`VmStack`](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack) Methods[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------- ### get()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#get "Direct link to get()") get(idx): undefined | StateValue #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#parameters "Direct link to Parameters") • **idx**: `number` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#returns-1 "Direct link to Returns") `undefined` | [`StateValue`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue) * * * ### isStrong()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#isstrong "Direct link to isStrong()") isStrong(idx): undefined | boolean #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#parameters-1 "Direct link to Parameters") • **idx**: `number` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#returns-2 "Direct link to Returns") `undefined` | `boolean` * * * ### length()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#length "Direct link to length()") length(): number #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#returns-3 "Direct link to Returns") `number` * * * ### push()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#push "Direct link to push()") push(value, is_strong): void #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#parameters-2 "Direct link to Parameters") • **value**: [`StateValue`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue) • **is\_strong**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#returns-4 "Direct link to Returns") `void` * * * ### removeLast()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#removelast "Direct link to removeLast()") removeLast(): void #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#returns-5 "Direct link to Returns") `void` * * * ### toString()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#parameters-3 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#returns-6 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#constructors) * [new VmStack()](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#new-vmstack) * [Methods](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#methods) * [get()](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#get) * [isStrong()](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#isstrong) * [length()](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#length) * [push()](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#push) * [removeLast()](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#removelast) * [toString()](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack#tostring) --- # ContractMaintenanceAuthority | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / ContractMaintenanceAuthority Class: ContractMaintenanceAuthority =================================== A committee permitted to make changes to this contract. If a threshold of the public keys in this committee sign off, they can change the rules of this contract, or recompile it for a new version. If the threshold is greater than the number of committee members, it is impossible for them to sign anything. Constructors[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------------------------- ### new ContractMaintenanceAuthority(committee, threshold, counter)[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#new-contractmaintenanceauthoritycommittee-threshold-counter "Direct link to new ContractMaintenanceAuthority(committee, threshold, counter)") new ContractMaintenanceAuthority( committee, threshold, counter?): ContractMaintenanceAuthority Constructs a new authority from its components If not supplied, `counter` will default to `0n`. Values should be non-negative, and at most 2^32 - 1. At deployment, `counter` must be `0n`, and any subsequent update should set counter to exactly one greater than the current value. #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#parameters "Direct link to Parameters") • **committee**: `string`\[\] • **threshold**: `number` • **counter?**: `bigint` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#returns "Direct link to Returns") [`ContractMaintenanceAuthority`](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority) Properties[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------------------- ### committee[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#committee "Direct link to committee") readonly committee: string[]; The committee public keys * * * ### counter[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#counter "Direct link to counter") readonly counter: bigint; The replay protection counter * * * ### threshold[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#threshold "Direct link to threshold") readonly threshold: number; How many keys must sign rule changes Methods[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#serialize "Direct link to serialize()") serialize(networkid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#parameters-1 "Direct link to Parameters") • **networkid**: [`NetworkId`](https://docs.midnight.network/api-reference/onchain-runtime/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#parameters-2 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#deserialize "Direct link to deserialize()") static deserialize(raw, networkid): ContractState #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#parameters-3 "Direct link to Parameters") • **raw**: `Uint8Array` • **networkid**: [`NetworkId`](https://docs.midnight.network/api-reference/onchain-runtime/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#returns-3 "Direct link to Returns") [`ContractState`](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState) * [Constructors](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#constructors) * [new ContractMaintenanceAuthority(committee, threshold, counter)](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#new-contractmaintenanceauthoritycommittee-threshold-counter) * [Properties](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#properties) * [committee](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#committee) * [counter](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#counter) * [threshold](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#threshold) * [Methods](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#methods) * [serialize()](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#serialize) * [toString()](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#tostring) * [deserialize()](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractMaintenanceAuthority#deserialize) --- # CoinInfoDescriptor | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.9.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CoinInfoDescriptor Variable: CoinInfoDescriptor ============================ const CoinInfoDescriptor: { alignment: Alignment; fromValue: { color: Uint8Array; nonce: Uint8Array; value: bigint; }; toValue: Value;}; Type declaration[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#type-declaration "Direct link to Type declaration") ----------------------------------------------------------------------------------------------------------------------------------------------------------------- ### alignment()[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#alignment "Direct link to alignment()") alignment(): Alignment; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#returns "Direct link to Returns") [`Alignment`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) ### fromValue()[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#fromvalue "Direct link to fromValue()") fromValue(value): { color: Uint8Array; nonce: Uint8Array; value: bigint;}; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#parameters "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#value "Direct link to value") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#returns-1 "Direct link to Returns") { color: Uint8Array; nonce: Uint8Array; value: bigint;} ##### color[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#color "Direct link to color") color: Uint8Array; ##### nonce[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#nonce "Direct link to nonce") nonce: Uint8Array; ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#value-1 "Direct link to value") value: bigint; ### toValue()[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#tovalue "Direct link to toValue()") toValue(value): Value; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#parameters-1 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#value-2 "Direct link to value") ###### color[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#color-1 "Direct link to color") `Uint8Array` ###### nonce[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#nonce-1 "Direct link to nonce") `Uint8Array` ###### value[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#value-3 "Direct link to value") `bigint` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#returns-2 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) * [Type declaration](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#type-declaration) * [alignment()](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#alignment) * [fromValue()](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#fromvalue) * [toValue()](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinInfoDescriptor#tovalue) --- # DUMMY_ADDRESS | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/DUMMY_ADDRESS#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / DUMMY\_ADDRESS Variable: ~DUMMY\_ADDRESS~ ========================== const DUMMY_ADDRESS: string; A valid placeholder contract address Deprecated[​](https://docs.midnight.network/api-reference/compact-runtime/variables/DUMMY_ADDRESS#deprecated "Direct link to Deprecated") ------------------------------------------------------------------------------------------------------------------------------------------ Cannot handle NetworkIds, use [dummyContractAddress](https://docs.midnight.network/api-reference/compact-runtime/functions/dummyContractAddress) instead. * [Deprecated](https://docs.midnight.network/api-reference/compact-runtime/variables/DUMMY_ADDRESS#deprecated) --- # README | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/reference/midnight-api/midnight-js#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **Midnight.js API Reference v2.0.2** * * * Midnight.js =========== Midnight.js is a Typescript-based application development framework for the Midnight blockchain. Analogous to [Web3.js](https://web3js.org/) for Ethereum, or [polkadot.js](https://polkadot.js.org/) for Polkadot, it contains utilities for: * Creating and submitting transactions * Interacting with wallets * Querying for block and state information * Subscribing to chain events Due to the privacy-preservation properties of the Midnight system, Midnight.js also contains a number of utilities that are unique to it: * Executing smart contracts locally * Incorporating private state into contract execution * Persisting, querying, and updating private state * Creating and verifying zero-knowledge proofs Package structure[​](https://docs.midnight.network/compact/reference/midnight-api/midnight-js#package-structure "Direct link to Package structure") ---------------------------------------------------------------------------------------------------------------------------------------------------- * `types` - Contains types and interfaces common to all other packages. * `contracts` - Contains utilities for interacting with Midnight smart contracts. * `indexer-public-data-provider` - Contains a cross-environment implementation of a Midnight indexer client. * `node-zk-config-provider` - Contains a file system based Node.js utility for retrieving zero-knowledge artifacts. * `fetch-zk-config-provider` - Contains a [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) based cross-environment utility for retrieving zero-knowledge artifacts. * `network-id` - Contains utilities for setting the network id used by `ledger`, `zswap`, and `compact-runtime` dependencies. * `http-client-proof-provider` - Contains a cross-environment implementation of a proof-server client. * `level-private-state-provider` - Contains a cross-environment implementation of a persistent private state store based on [Level](https://github.com/Level/level) . * [Package structure](https://docs.midnight.network/compact/reference/midnight-api/midnight-js#package-structure) --- # globals | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/globals#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/dapp-connector-api v3.0.0**](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector) * * * @midnight-ntwrk/dapp-connector-api v3.0.0 ========================================= Classes[​](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/globals#classes "Direct link to Classes") --------------------------------------------------------------------------------------------------------------------------------- * [APIError](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/classes/APIError) Interfaces[​](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/globals#interfaces "Direct link to Interfaces") ------------------------------------------------------------------------------------------------------------------------------------------ * [DAppConnectorAPI](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/interfaces/DAppConnectorAPI) * [DAppConnectorWalletAPI](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/interfaces/DAppConnectorWalletAPI) * [DAppConnectorWalletState](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/interfaces/DAppConnectorWalletState) * [ServiceUriConfig](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/interfaces/ServiceUriConfig) Type Aliases[​](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/globals#type-aliases "Direct link to Type Aliases") ------------------------------------------------------------------------------------------------------------------------------------------------ * [ErrorCode](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/type-aliases/ErrorCode) Variables[​](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/globals#variables "Direct link to Variables") --------------------------------------------------------------------------------------------------------------------------------------- * [ErrorCodes](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/variables/ErrorCodes) * [Classes](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/globals#classes) * [Interfaces](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/globals#interfaces) * [Type Aliases](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/globals#type-aliases) * [Variables](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/globals#variables) --- # CoinRecipientDescriptor | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.9.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CoinRecipientDescriptor Variable: CoinRecipientDescriptor ================================= const CoinRecipientDescriptor: { alignment: Alignment; fromValue: { is_left: boolean; left: { bytes: Uint8Array; }; right: { bytes: Uint8Array; }; }; toValue: Value;}; Type declaration[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#type-declaration "Direct link to Type declaration") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### alignment()[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#alignment "Direct link to alignment()") alignment(): Alignment; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#returns "Direct link to Returns") [`Alignment`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) ### fromValue()[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#fromvalue "Direct link to fromValue()") fromValue(value): { is_left: boolean; left: { bytes: Uint8Array; }; right: { bytes: Uint8Array; };}; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#parameters "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#value "Direct link to value") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#returns-1 "Direct link to Returns") { is_left: boolean; left: { bytes: Uint8Array; }; right: { bytes: Uint8Array; };} ##### is\_left[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#is_left "Direct link to is_left") is_left: boolean; ##### left[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#left "Direct link to left") left: { bytes: Uint8Array;}; ###### left.bytes[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#leftbytes "Direct link to left.bytes") bytes: Uint8Array; ##### right[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#right "Direct link to right") right: { bytes: Uint8Array;}; ###### right.bytes[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#rightbytes "Direct link to right.bytes") bytes: Uint8Array; ### toValue()[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#tovalue "Direct link to toValue()") toValue(value): Value; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#parameters-1 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#value-1 "Direct link to value") ###### is\_left[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#is_left-1 "Direct link to is_left") `boolean` ###### left[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#left-1 "Direct link to left") { `bytes`: `Uint8Array`; } ###### left.bytes[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#leftbytes-1 "Direct link to left.bytes") `Uint8Array` ###### right[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#right-1 "Direct link to right") { `bytes`: `Uint8Array`; } ###### right.bytes[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#rightbytes-1 "Direct link to right.bytes") `Uint8Array` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#returns-2 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) * [Type declaration](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#type-declaration) * [alignment()](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#alignment) * [fromValue()](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#fromvalue) * [toValue()](https://docs.midnight.network/api-reference/compact-runtime/variables/CoinRecipientDescriptor#tovalue) --- # StateBoundedMerkleTree | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / StateBoundedMerkleTree Class: StateBoundedMerkleTree ============================= Represents a fixed-depth Merkle tree storing hashed data, whose preimages are unknown Constructors[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------------------- ### new StateBoundedMerkleTree(height)[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#new-stateboundedmerkletreeheight "Direct link to new StateBoundedMerkleTree(height)") new StateBoundedMerkleTree(height): StateBoundedMerkleTree Create a blank tree with the given height #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#parameters "Direct link to Parameters") • **height**: `number` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#returns "Direct link to Returns") [`StateBoundedMerkleTree`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree) Properties[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------------- ### height[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#height "Direct link to height") readonly height: number; Methods[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------------------------- ### collapse()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#collapse "Direct link to collapse()") `Internal` collapse(start, end): StateBoundedMerkleTree Erases all but necessary hashes between, and inclusive of, `start` and `end` inidices #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#parameters-1 "Direct link to Parameters") • **start**: `bigint` • **end**: `bigint` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#returns-1 "Direct link to Returns") [`StateBoundedMerkleTree`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree) #### Throws[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#throws "Direct link to Throws") If the indices are out-of-bounds for the tree, or `end < start` * * * ### findPathForLeaf()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#findpathforleaf "Direct link to findPathForLeaf()") `Internal` findPathForLeaf(leaf): AlignedValue Internal implementation of the finding path primitive #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#parameters-2 "Direct link to Parameters") • **leaf**: [`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#returns-2 "Direct link to Returns") [`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) #### Throws[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#throws-1 "Direct link to Throws") If the leaf is not in the tree * * * ### pathForLeaf()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#pathforleaf "Direct link to pathForLeaf()") `Internal` pathForLeaf(index, leaf): AlignedValue Internal implementation of the path construction primitive #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#parameters-3 "Direct link to Parameters") • **index**: `bigint` • **leaf**: [`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#returns-3 "Direct link to Returns") [`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) #### Throws[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#throws-2 "Direct link to Throws") If the index is out-of-bounds for the tree * * * ### root()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#root "Direct link to root()") `Internal` root(): Value Internal implementation of the merkle tree root primitive #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#returns-4 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) * * * ### toString()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#parameters-4 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#returns-5 "Direct link to Returns") `string` * * * ### update()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#update "Direct link to update()") update(index, leaf): StateBoundedMerkleTree Inserts a value into the Merkle tree, returning the updated tree #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#parameters-5 "Direct link to Parameters") • **index**: `bigint` • **leaf**: [`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#returns-6 "Direct link to Returns") [`StateBoundedMerkleTree`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree) #### Throws[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#throws-3 "Direct link to Throws") If the index is out-of-bounds for the tree * [Constructors](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#constructors) * [new StateBoundedMerkleTree(height)](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#new-stateboundedmerkletreeheight) * [Properties](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#properties) * [height](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#height) * [Methods](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#methods) * [collapse()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#collapse) * [findPathForLeaf()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#findpathforleaf) * [pathForLeaf()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#pathforleaf) * [root()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#root) * [toString()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#tostring) * [update()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree#update) --- # ContractAddressDescriptor | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/ContractAddressDescriptor#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / ContractAddressDescriptor Variable: ContractAddressDescriptor =================================== const ContractAddressDescriptor: { alignment: Alignment; fromValue: { bytes: Uint8Array; }; toValue: Value;}; Type Declaration[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ContractAddressDescriptor#type-declaration "Direct link to Type Declaration") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ### alignment()[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ContractAddressDescriptor#alignment "Direct link to alignment()") alignment(): Alignment; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ContractAddressDescriptor#returns "Direct link to Returns") [`Alignment`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) ### fromValue()[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ContractAddressDescriptor#fromvalue "Direct link to fromValue()") fromValue(value): { bytes: Uint8Array;}; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ContractAddressDescriptor#parameters "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ContractAddressDescriptor#value "Direct link to value") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ContractAddressDescriptor#returns-1 "Direct link to Returns") { bytes: Uint8Array;} ##### bytes[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ContractAddressDescriptor#bytes "Direct link to bytes") bytes: Uint8Array; ### toValue()[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ContractAddressDescriptor#tovalue "Direct link to toValue()") toValue(value): Value; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ContractAddressDescriptor#parameters-1 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ContractAddressDescriptor#value-1 "Direct link to value") ###### bytes[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ContractAddressDescriptor#bytes-1 "Direct link to bytes") `Uint8Array` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ContractAddressDescriptor#returns-2 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) * [Type Declaration](https://docs.midnight.network/api-reference/compact-runtime/variables/ContractAddressDescriptor#type-declaration) * [alignment()](https://docs.midnight.network/api-reference/compact-runtime/variables/ContractAddressDescriptor#alignment) * [fromValue()](https://docs.midnight.network/api-reference/compact-runtime/variables/ContractAddressDescriptor#fromvalue) * [toValue()](https://docs.midnight.network/api-reference/compact-runtime/variables/ContractAddressDescriptor#tovalue) --- # StateValue | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / StateValue Class: StateValue ================= Represents the core of a contract's state, and recursively represents each of its components. There are different _classes_ of state values: * `null` * Cells of [AlignedValue](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) s * Maps from [AlignedValue](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) s to state values * Bounded Merkle trees containing [AlignedValue](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) leaves * Short (<= 15 element) arrays of state values State values are _immutable_, any operations that mutate states will return a new state instead. Constructors[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------- ### new StateValue()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#new-statevalue "Direct link to new StateValue()") private new StateValue(): StateValue #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#returns "Direct link to Returns") [`StateValue`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue) Methods[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------------- ### arrayPush()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#arraypush "Direct link to arrayPush()") arrayPush(value): StateValue #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#parameters "Direct link to Parameters") • **value**: [`StateValue`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#returns-1 "Direct link to Returns") [`StateValue`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue) * * * ### asArray()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#asarray "Direct link to asArray()") asArray(): undefined | StateValue[] #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#returns-2 "Direct link to Returns") `undefined` | [`StateValue`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue) \[\] * * * ### asBoundedMerkleTree()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#asboundedmerkletree "Direct link to asBoundedMerkleTree()") asBoundedMerkleTree(): undefined | StateBoundedMerkleTree #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#returns-3 "Direct link to Returns") `undefined` | [`StateBoundedMerkleTree`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree) * * * ### asCell()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#ascell "Direct link to asCell()") asCell(): AlignedValue #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#returns-4 "Direct link to Returns") [`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) * * * ### asMap()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#asmap "Direct link to asMap()") asMap(): undefined | StateMap #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#returns-5 "Direct link to Returns") `undefined` | [`StateMap`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap) * * * ### encode()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#encode "Direct link to encode()") `Internal` encode(): EncodedStateValue #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#returns-6 "Direct link to Returns") [`EncodedStateValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/EncodedStateValue) * * * ### logSize()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#logsize "Direct link to logSize()") logSize(): number #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#returns-7 "Direct link to Returns") `number` * * * ### toString()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#returns-8 "Direct link to Returns") `string` * * * ### type()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#type "Direct link to type()") type(): | "map" | "null" | "cell" | "array" | "boundedMerkleTree" #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#returns-9 "Direct link to Returns") | `"map"` | `"null"` | `"cell"` | `"array"` | `"boundedMerkleTree"` * * * ### decode()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#decode "Direct link to decode()") `Internal` static decode(value): StateValue #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#parameters-2 "Direct link to Parameters") • **value**: [`EncodedStateValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/EncodedStateValue) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#returns-10 "Direct link to Returns") [`StateValue`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue) * * * ### newArray()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#newarray "Direct link to newArray()") static newArray(): StateValue #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#returns-11 "Direct link to Returns") [`StateValue`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue) * * * ### newBoundedMerkleTree()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#newboundedmerkletree "Direct link to newBoundedMerkleTree()") static newBoundedMerkleTree(tree): StateValue #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#parameters-3 "Direct link to Parameters") • **tree**: [`StateBoundedMerkleTree`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateBoundedMerkleTree) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#returns-12 "Direct link to Returns") [`StateValue`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue) * * * ### newCell()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#newcell "Direct link to newCell()") static newCell(value): StateValue #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#parameters-4 "Direct link to Parameters") • **value**: [`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#returns-13 "Direct link to Returns") [`StateValue`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue) * * * ### newMap()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#newmap "Direct link to newMap()") static newMap(map): StateValue #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#parameters-5 "Direct link to Parameters") • **map**: [`StateMap`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateMap) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#returns-14 "Direct link to Returns") [`StateValue`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue) * * * ### newNull()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#newnull "Direct link to newNull()") static newNull(): StateValue #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#returns-15 "Direct link to Returns") [`StateValue`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue) * [Constructors](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#constructors) * [new StateValue()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#new-statevalue) * [Methods](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#methods) * [arrayPush()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#arraypush) * [asArray()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#asarray) * [asBoundedMerkleTree()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#asboundedmerkletree) * [asCell()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#ascell) * [asMap()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#asmap) * [encode()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#encode) * [logSize()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#logsize) * [toString()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#tostring) * [type()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#type) * [decode()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#decode) * [newArray()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#newarray) * [newBoundedMerkleTree()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#newboundedmerkletree) * [newCell()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#newcell) * [newMap()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#newmap) * [newNull()](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue#newnull) --- # Ledger API | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/reference/midnight-api/ledger#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • Readme | [API](https://docs.midnight.network/compact/reference/midnight-api/ledger/globals) * * * Ledger TypeScript API ===================== This document outlines the flow of transaction assembly and usage with the ledger TS API. Network ID[​](https://docs.midnight.network/compact/reference/midnight-api/ledger#network-id "Direct link to Network ID") -------------------------------------------------------------------------------------------------------------------------- Prior to any interaction, setNetworkId should be used to set the [NetworkId](https://docs.midnight.network/compact/reference/midnight-api/ledger/enumerations/NetworkId) to target the correct network. Proof stages[​](https://docs.midnight.network/compact/reference/midnight-api/ledger#proof-stages "Direct link to Proof stages") -------------------------------------------------------------------------------------------------------------------------------- Most transaction components will be in one of three stages: `X`, `UnprovenX`, or `ProofErasedX`. The `UnprovenX` stage is _always_ the first one. It is possible to transition to the `X` stage by proving an `UnprovenTransaction` through the proof server. For testing, and where proofs aren't necessary, the `ProofErasedX` stage is used, which can be reached via `eraseProof[s]` from the other two stages. Transaction structure[​](https://docs.midnight.network/compact/reference/midnight-api/ledger#transaction-structure "Direct link to Transaction structure") ----------------------------------------------------------------------------------------------------------------------------------------------------------- A [Transaction](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/Transaction) runs in two phases: a _guaranteed_ phase, handling fee payments and fast-to-verify operations, and a _fallible_ phase, handling operations which may fail atomically, separately from the guaranteed phase. It therefore contains: * A "guaranteed" [Offer](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/Offer) * Optionally, a "fallible" [Offer](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/Offer) * Optionally, a sequence of [ContractCall](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ContractCall) s or [ContractDeploy](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ContractDeploy) s. It also contains additional cryptographic glue that will be omitted in this document. ### Zswap[​](https://docs.midnight.network/compact/reference/midnight-api/ledger#zswap "Direct link to Zswap") A Zswap [Offer](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/Offer) consists of: * A set of [Input](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/Input) s, burning coins. * A set of [Output](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/Output) s, creating coins. * A set of [Transient](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/Transient) s, indicating a coin that is created and burnt in the same transaction. * A mapping from [TokenType](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/TokenType) s to offer balance, positive when there are more inputs than outputs and vice versa. [Input](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/Input) s can be created either from a [QualifiedCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/QualifiedCoinInfo) and a contract address, if the coin is contract-owned, or from a [QualifiedCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/QualifiedCoinInfo) and a ZswapLocalState, if it is user-owned. Similarly, [Output](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/Output) s can be created from a [CoinInfo](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/CoinInfo) and a contract address for contract-owned coins, or from a [CoinInfo](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/CoinInfo) and a user's public key(s), if it is user-owned. A [Transient](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/Transient) is created similarly to a [Input](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/Input) , but directly converts an existing [Output](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/Output) . A [QualifiedCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/QualifiedCoinInfo) is a [CoinInfo](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/CoinInfo) with an index into the Merkle tree of coin commitments that can be used to find the relevant coin to spend, while a [CoinInfo](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/CoinInfo) consists of a coins [TokenType](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/TokenType) , value, and a nonce. ### Calls[​](https://docs.midnight.network/compact/reference/midnight-api/ledger#calls "Direct link to Calls") A [ContractDeploy](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ContractDeploy) consists of an initial contract state, and a nonce. A [ContractCall](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ContractCall) consists of a contract's address, the entry point used on this contract, a guaranteed and a fallible public oracle transcript, a communication commitment, and a proof. [ContractCall](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ContractCall) s are constructed via [ContractCallPrototype](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ContractCallPrototype) s, which consist of the following raw pieces of data: * The contract address * The contract's entry point * The contract operation expected (that is, the verifier key and transcript shape expected to be at this contract address and entry point) * The guaranteed transcript (as produced by the generated JS code) * The fallible transcript (as produced by the generated JS code) * The outputs of the private oracle calls (As a FAB [AlignedValue](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/AlignedValue) s) * The input(s) to the call, concatenated together (As a FAB [AlignedValue](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/AlignedValue) ) * The output(s) to the call, concatenated together (As a FAB [AlignedValue](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/AlignedValue) ) * The communications commitment randomness (As a hex-encoded field element string) * A unique identifier for the ZK circuit used (used by the proof server to index for the prover key) NOTE: currently the JS code only generates a single transcript. We probably just want a canonical way to split this into guaranteed/fallible? A ContractCalls object is assembed, and [ContractCallPrototype](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ContractCallPrototype) s / [ContractDeploy](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ContractDeploy) s are added to this directly. This can then be inserted into an [UnprovenTransaction](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/UnprovenTransaction) . State Structure[​](https://docs.midnight.network/compact/reference/midnight-api/ledger#state-structure "Direct link to State Structure") ----------------------------------------------------------------------------------------------------------------------------------------- The [LedgerState](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/LedgerState) is the primary entry point for Midnight's ledger state, and it consists of a [ZswapChainState](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ZswapChainState) , as well as a mapping from [ContractAddress](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/ContractAddress) es to [ContractState](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ContractState) s. States are immutable, and applying transactions always produce new outputs states. * [Network ID](https://docs.midnight.network/compact/reference/midnight-api/ledger#network-id) * [Proof stages](https://docs.midnight.network/compact/reference/midnight-api/ledger#proof-stages) * [Transaction structure](https://docs.midnight.network/compact/reference/midnight-api/ledger#transaction-structure) * [Zswap](https://docs.midnight.network/compact/reference/midnight-api/ledger#zswap) * [Calls](https://docs.midnight.network/compact/reference/midnight-api/ledger#calls) * [State Structure](https://docs.midnight.network/compact/reference/midnight-api/ledger#state-structure) --- # packages | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/reference/midnight-api/midnight-js/packages#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**Midnight.js API Reference v2.0.2**](https://docs.midnight.network/compact/reference/midnight-api/midnight-js) * * * Midnight.js API Reference v2.0.2 ================================ Packages[​](https://docs.midnight.network/compact/reference/midnight-api/midnight-js/packages#packages "Direct link to Packages") ---------------------------------------------------------------------------------------------------------------------------------- * [@midnight-ntwrk/midnight-js-contracts - v2.0.2](https://docs.midnight.network/compact/reference/midnight-api/midnight-js/@midnight-ntwrk/midnight-js-contracts) * [@midnight-ntwrk/midnight-js-fetch-zk-config-provider - v2.0.2](https://docs.midnight.network/compact/reference/midnight-api/midnight-js/@midnight-ntwrk/midnight-js-fetch-zk-config-provider) * [@midnight-ntwrk/midnight-js-http-client-proof-provider - v2.0.2](https://docs.midnight.network/compact/reference/midnight-api/midnight-js/@midnight-ntwrk/midnight-js-http-client-proof-provider) * [@midnight-ntwrk/midnight-js-indexer-public-data-provider - v2.0.2](https://docs.midnight.network/compact/reference/midnight-api/midnight-js/@midnight-ntwrk/midnight-js-indexer-public-data-provider) * [@midnight-ntwrk/midnight-js-level-private-state-provider - v2.0.2](https://docs.midnight.network/compact/reference/midnight-api/midnight-js/@midnight-ntwrk/midnight-js-level-private-state-provider) * [@midnight-ntwrk/midnight-js-logger-provider - v2.0.2](https://docs.midnight.network/compact/reference/midnight-api/midnight-js/@midnight-ntwrk/midnight-js-logger-provider) * [@midnight-ntwrk/midnight-js-network-id - v2.0.2](https://docs.midnight.network/compact/reference/midnight-api/midnight-js/@midnight-ntwrk/midnight-js-network-id) * [@midnight-ntwrk/midnight-js-node-zk-config-provider - v2.0.2](https://docs.midnight.network/compact/reference/midnight-api/midnight-js/@midnight-ntwrk/midnight-js-node-zk-config-provider) * [@midnight-ntwrk/midnight-js-testing - v2.0.2](https://docs.midnight.network/compact/reference/midnight-api/midnight-js/@midnight-ntwrk/midnight-js-testing) * [@midnight-ntwrk/midnight-js-types - v2.0.2](https://docs.midnight.network/compact/reference/midnight-api/midnight-js/@midnight-ntwrk/midnight-js-types) * [@midnight-ntwrk/midnight-js-utils - v2.0.2](https://docs.midnight.network/compact/reference/midnight-api/midnight-js/@midnight-ntwrk/midnight-js-utils) * [Packages](https://docs.midnight.network/compact/reference/midnight-api/midnight-js/packages#packages) --- # globals | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/reference/midnight-api/ledger/globals#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/compact/reference/midnight-api/ledger) | API * * * @midnight-ntwrk/ledger v3.0.2 ============================= Enumerations[​](https://docs.midnight.network/compact/reference/midnight-api/ledger/globals#enumerations "Direct link to Enumerations") ---------------------------------------------------------------------------------------------------------------------------------------- * [NetworkId](https://docs.midnight.network/compact/reference/midnight-api/ledger/enumerations/NetworkId) Classes[​](https://docs.midnight.network/compact/reference/midnight-api/ledger/globals#classes "Direct link to Classes") ------------------------------------------------------------------------------------------------------------------------- * [AuthorizedMint](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/AuthorizedMint) * [ContractCall](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ContractCall) * [ContractCallPrototype](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ContractCallPrototype) * [ContractCallsPrototype](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ContractCallsPrototype) * [ContractDeploy](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ContractDeploy) * [ContractMaintenanceAuthority](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ContractMaintenanceAuthority) * [ContractOperation](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ContractOperation) * [ContractOperationVersion](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ContractOperationVersion) * [ContractOperationVersionedVerifierKey](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ContractOperationVersionedVerifierKey) * [ContractState](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ContractState) * [CostModel](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/CostModel) * [EncryptionSecretKey](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/EncryptionSecretKey) * [Input](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/Input) * [LedgerParameters](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/LedgerParameters) * [LedgerState](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/LedgerState) * [LocalState](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/LocalState) * [MaintenanceUpdate](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/MaintenanceUpdate) * [MerkleTreeCollapsedUpdate](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/MerkleTreeCollapsedUpdate) * [Offer](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/Offer) * [Output](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/Output) * [PreTranscript](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/PreTranscript) * [ProofErasedAuthorizedMint](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ProofErasedAuthorizedMint) * [ProofErasedInput](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ProofErasedInput) * [ProofErasedOffer](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ProofErasedOffer) * [ProofErasedOutput](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ProofErasedOutput) * [ProofErasedTransaction](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ProofErasedTransaction) * [ProofErasedTransient](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ProofErasedTransient) * [QueryContext](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/QueryContext) * [QueryResults](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/QueryResults) * [ReplaceAuthority](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ReplaceAuthority) * [StateBoundedMerkleTree](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/StateBoundedMerkleTree) * [StateMap](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/StateMap) * [StateValue](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/StateValue) * [SystemTransaction](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/SystemTransaction) * [Transaction](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/Transaction) * [TransactionContext](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/TransactionContext) * [TransactionCostModel](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/TransactionCostModel) * [TransactionResult](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/TransactionResult) * [Transient](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/Transient) * [UnprovenAuthorizedMint](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/UnprovenAuthorizedMint) * [UnprovenInput](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/UnprovenInput) * [UnprovenOffer](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/UnprovenOffer) * [UnprovenOutput](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/UnprovenOutput) * [UnprovenTransaction](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/UnprovenTransaction) * [UnprovenTransient](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/UnprovenTransient) * [VerifierKeyInsert](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/VerifierKeyInsert) * [VerifierKeyRemove](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/VerifierKeyRemove) * [VmResults](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/VmResults) * [VmStack](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/VmStack) * [WellFormedStrictness](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/WellFormedStrictness) * [ZswapChainState](https://docs.midnight.network/compact/reference/midnight-api/ledger/classes/ZswapChainState) Type Aliases[​](https://docs.midnight.network/compact/reference/midnight-api/ledger/globals#type-aliases "Direct link to Type Aliases") ---------------------------------------------------------------------------------------------------------------------------------------- * [AlignedValue](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/AlignedValue) * [Alignment](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/Alignment) * [AlignmentAtom](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/AlignmentAtom) * [AlignmentSegment](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/AlignmentSegment) * [BlockContext](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/BlockContext) * [CoinCommitment](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/CoinCommitment) * [CoinInfo](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/CoinInfo) * [CoinPublicKey](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/CoinPublicKey) * [CommunicationCommitment](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/CommunicationCommitment) * [CommunicationCommitmentRand](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/CommunicationCommitmentRand) * [ContractAction](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/ContractAction) * [ContractAddress](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/ContractAddress) * [DomainSeperator](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/DomainSeperator) * [Effects](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/Effects) * [EncPublicKey](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/EncPublicKey) * [EncodedStateValue](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/EncodedStateValue) * [Fr](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/Fr) * [GatherResult](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/GatherResult) * [Key](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/Key) * [Nonce](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/Nonce) * [Nullifier](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/Nullifier) * [Op](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/Op) * [QualifiedCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/QualifiedCoinInfo) * [Signature](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/Signature) * [SignatureVerifyingKey](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/SignatureVerifyingKey) * [SigningKey](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/SigningKey) * [SingleUpdate](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/SingleUpdate) * [TokenType](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/TokenType) * [TransactionHash](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/TransactionHash) * [TransactionId](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/TransactionId) * [Transcript](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/Transcript) * [Value](https://docs.midnight.network/compact/reference/midnight-api/ledger/type-aliases/Value) Functions[​](https://docs.midnight.network/compact/reference/midnight-api/ledger/globals#functions "Direct link to Functions") ------------------------------------------------------------------------------------------------------------------------------- * [bigIntModFr](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/bigIntModFr) * [bigIntToValue](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/bigIntToValue) * [checkProofData](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/checkProofData) * [coinCommitment](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/coinCommitment) * [communicationCommitment](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/communicationCommitment) * [communicationCommitmentRandomness](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/communicationCommitmentRandomness) * [createCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/createCoinInfo) * [decodeCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/decodeCoinInfo) * [decodeCoinPublicKey](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/decodeCoinPublicKey) * [decodeContractAddress](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/decodeContractAddress) * [decodeQualifiedCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/decodeQualifiedCoinInfo) * [decodeTokenType](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/decodeTokenType) * [degradeToTransient](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/degradeToTransient) * [dummyContractAddress](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/dummyContractAddress) * [ecAdd](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/ecAdd) * [ecMul](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/ecMul) * [ecMulGenerator](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/ecMulGenerator) * [encodeCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/encodeCoinInfo) * [encodeCoinPublicKey](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/encodeCoinPublicKey) * [encodeContractAddress](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/encodeContractAddress) * [encodeQualifiedCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/encodeQualifiedCoinInfo) * [encodeTokenType](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/encodeTokenType) * [hashToCurve](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/hashToCurve) * [leafHash](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/leafHash) * [maxAlignedSize](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/maxAlignedSize) * [maxField](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/maxField) * [nativeToken](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/nativeToken) * [partitionTranscripts](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/partitionTranscripts) * [persistentCommit](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/persistentCommit) * [persistentHash](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/persistentHash) * [runProgram](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/runProgram) * [sampleCoinPublicKey](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/sampleCoinPublicKey) * [sampleContractAddress](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/sampleContractAddress) * [sampleSigningKey](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/sampleSigningKey) * [sampleTokenType](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/sampleTokenType) * [signData](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/signData) * [signatureVerifyingKey](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/signatureVerifyingKey) * [tokenType](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/tokenType) * [transientCommit](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/transientCommit) * [transientHash](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/transientHash) * [upgradeFromTransient](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/upgradeFromTransient) * [valueToBigInt](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/valueToBigInt) * [verifySignature](https://docs.midnight.network/compact/reference/midnight-api/ledger/functions/verifySignature) * [Enumerations](https://docs.midnight.network/compact/reference/midnight-api/ledger/globals#enumerations) * [Classes](https://docs.midnight.network/compact/reference/midnight-api/ledger/globals#classes) * [Type Aliases](https://docs.midnight.network/compact/reference/midnight-api/ledger/globals#type-aliases) * [Functions](https://docs.midnight.network/compact/reference/midnight-api/ledger/globals#functions) --- # On-Chain runtime API | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • Readme | [API](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/globals) * * * Midnight Onchain Runtime TypeScript API ======================================= This API provides a TypeScript interface to Midnight's onchain runtime, including the execution of VM instructions, and the primitives required to successfully use them. Key parts of this API are: * [ContractState](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/classes/ContractState) , encapsulating the entirety of a smart contract's on-chain state * [StateValue](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/classes/StateValue) , encoding data a contract maintains on-chain * [QueryContext](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/classes/QueryContext) , providing an annotated view into the contract state, against which on-chain VM programs can be run * [Op](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/Op) , providing the TypeScript encoding of on-chain VM programs * [AlignedValue](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/AlignedValue) , the "base" value type that encodes all user data stored on-chain --- # globals | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/globals#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/compact/reference/midnight-api/wallet-api) | API * * * @midnight-ntwrk/wallet-api v5.0.0 ================================= Interfaces[​](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/globals#interfaces "Direct link to Interfaces") -------------------------------------------------------------------------------------------------------------------------------------- * [Wallet](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/interfaces/Wallet) Type Aliases[​](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/globals#type-aliases "Direct link to Type Aliases") -------------------------------------------------------------------------------------------------------------------------------------------- * [Address](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/type-aliases/Address) * [AddressLegacy](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/type-aliases/AddressLegacy) * [ApplyStage](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/type-aliases/ApplyStage) * [BalanceTransactionToProve](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/type-aliases/BalanceTransactionToProve) * [CoinPublicKey](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/type-aliases/CoinPublicKey) * [CoinPublicKeyLegacy](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/type-aliases/CoinPublicKeyLegacy) * [EncPublicKeyLegacy](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/type-aliases/EncPublicKeyLegacy) * [NothingToProve](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/type-aliases/NothingToProve) * [ProvingRecipe](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/type-aliases/ProvingRecipe) * [SyncLag](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/type-aliases/SyncLag) * [SyncProgress](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/type-aliases/SyncProgress) * [TokenTransfer](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/type-aliases/TokenTransfer) * [TokenType](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/type-aliases/TokenType) * [TransactionHash](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/type-aliases/TransactionHash) * [TransactionHistoryEntry](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/type-aliases/TransactionHistoryEntry) * [TransactionIdentifier](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/type-aliases/TransactionIdentifier) * [TransactionToProve](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/type-aliases/TransactionToProve) * [WalletState](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/type-aliases/WalletState) Variables[​](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/globals#variables "Direct link to Variables") ----------------------------------------------------------------------------------------------------------------------------------- * [BALANCE\_TRANSACTION\_TO\_PROVE](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/variables/BALANCE_TRANSACTION_TO_PROVE) * [NOTHING\_TO\_PROVE](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/variables/NOTHING_TO_PROVE) * [TRANSACTION\_TO\_PROVE](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/variables/TRANSACTION_TO_PROVE) * [Interfaces](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/globals#interfaces) * [Type Aliases](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/globals#type-aliases) * [Variables](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/globals#variables) --- # globals | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/globals#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime) | API * * * @midnight-ntwrk/onchain-runtime v0.2.2 ====================================== Enumerations[​](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/globals#enumerations "Direct link to Enumerations") ------------------------------------------------------------------------------------------------------------------------------------------------- * [NetworkId](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/enumerations/NetworkId) Classes[​](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/globals#classes "Direct link to Classes") ---------------------------------------------------------------------------------------------------------------------------------- * [ContractMaintenanceAuthority](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/classes/ContractMaintenanceAuthority) * [ContractOperation](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/classes/ContractOperation) * [ContractState](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/classes/ContractState) * [CostModel](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/classes/CostModel) * [QueryContext](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/classes/QueryContext) * [QueryResults](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/classes/QueryResults) * [StateBoundedMerkleTree](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/classes/StateBoundedMerkleTree) * [StateMap](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/classes/StateMap) * [StateValue](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/classes/StateValue) * [VmResults](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/classes/VmResults) * [VmStack](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/classes/VmStack) Type Aliases[​](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/globals#type-aliases "Direct link to Type Aliases") ------------------------------------------------------------------------------------------------------------------------------------------------- * [AlignedValue](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/AlignedValue) * [Alignment](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/Alignment) * [AlignmentAtom](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/AlignmentAtom) * [AlignmentSegment](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/AlignmentSegment) * [BlockContext](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/BlockContext) * [CoinCommitment](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/CoinCommitment) * [CoinInfo](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/CoinInfo) * [CoinPublicKey](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/CoinPublicKey) * [ContractAddress](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/ContractAddress) * [DomainSeperator](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/DomainSeperator) * [Effects](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/Effects) * [EncodedStateValue](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/EncodedStateValue) * [Fr](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/Fr) * [GatherResult](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/GatherResult) * [Key](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/Key) * [Nonce](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/Nonce) * [Nullifier](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/Nullifier) * [Op](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/Op) * [QualifiedCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/QualifiedCoinInfo) * [Signature](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/Signature) * [SignatureVerifyingKey](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/SignatureVerifyingKey) * [SigningKey](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/SigningKey) * [TokenType](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/TokenType) * [Transcript](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/Transcript) * [Value](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/type-aliases/Value) Functions[​](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/globals#functions "Direct link to Functions") ---------------------------------------------------------------------------------------------------------------------------------------- * [bigIntModFr](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/bigIntModFr) * [bigIntToValue](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/bigIntToValue) * [checkProofData](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/checkProofData) * [coinCommitment](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/coinCommitment) * [decodeCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/decodeCoinInfo) * [decodeCoinPublicKey](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/decodeCoinPublicKey) * [decodeContractAddress](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/decodeContractAddress) * [decodeQualifiedCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/decodeQualifiedCoinInfo) * [decodeTokenType](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/decodeTokenType) * [degradeToTransient](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/degradeToTransient) * [dummyContractAddress](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/dummyContractAddress) * [ecAdd](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/ecAdd) * [ecMul](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/ecMul) * [ecMulGenerator](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/ecMulGenerator) * [encodeCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/encodeCoinInfo) * [encodeCoinPublicKey](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/encodeCoinPublicKey) * [encodeContractAddress](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/encodeContractAddress) * [encodeQualifiedCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/encodeQualifiedCoinInfo) * [encodeTokenType](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/encodeTokenType) * [hashToCurve](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/hashToCurve) * [leafHash](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/leafHash) * [maxAlignedSize](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/maxAlignedSize) * [maxField](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/maxField) * [persistentCommit](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/persistentCommit) * [persistentHash](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/persistentHash) * [runProgram](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/runProgram) * [sampleContractAddress](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/sampleContractAddress) * [sampleSigningKey](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/sampleSigningKey) * [sampleTokenType](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/sampleTokenType) * [signData](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/signData) * [signatureVerifyingKey](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/signatureVerifyingKey) * [tokenType](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/tokenType) * [transientCommit](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/transientCommit) * [transientHash](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/transientHash) * [upgradeFromTransient](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/upgradeFromTransient) * [valueToBigInt](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/valueToBigInt) * [verifySignature](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/functions/verifySignature) * [Enumerations](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/globals#enumerations) * [Classes](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/globals#classes) * [Type Aliases](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/globals#type-aliases) * [Functions](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime/globals#functions) --- # One doc tagged with "developer-tools" | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/tags/developer-tools#__docusaurus_skipToContent_fallback) [Midnight SDKs\ -------------](https://docs.midnight.network/sdks) Build privacy-preserving decentralized applications with Midnight's comprehensive SDK ecosystem. Whether you're creating smart contracts, wallets, or full-stack DApps, we have the tools you need. --- # ShieldedCoinInfoDescriptor | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / ShieldedCoinInfoDescriptor Variable: ShieldedCoinInfoDescriptor ==================================== const ShieldedCoinInfoDescriptor: { alignment: Alignment; fromValue: { color: Uint8Array; nonce: Uint8Array; value: bigint; }; toValue: Value;}; Type Declaration[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#type-declaration "Direct link to Type Declaration") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### alignment()[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#alignment "Direct link to alignment()") alignment(): Alignment; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#returns "Direct link to Returns") [`Alignment`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) ### fromValue()[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#fromvalue "Direct link to fromValue()") fromValue(value): { color: Uint8Array; nonce: Uint8Array; value: bigint;}; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#parameters "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#value "Direct link to value") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#returns-1 "Direct link to Returns") { color: Uint8Array; nonce: Uint8Array; value: bigint;} ##### color[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#color "Direct link to color") color: Uint8Array; ##### nonce[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#nonce "Direct link to nonce") nonce: Uint8Array; ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#value-1 "Direct link to value") value: bigint; ### toValue()[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#tovalue "Direct link to toValue()") toValue(value): Value; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#parameters-1 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#value-2 "Direct link to value") ###### color[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#color-1 "Direct link to color") `Uint8Array` ###### nonce[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#nonce-1 "Direct link to nonce") `Uint8Array` ###### value[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#value-3 "Direct link to value") `bigint` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#returns-2 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) * [Type Declaration](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#type-declaration) * [alignment()](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#alignment) * [fromValue()](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#fromvalue) * [toValue()](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinInfoDescriptor#tovalue) --- # ShieldedCoinRecipientDescriptor | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / ShieldedCoinRecipientDescriptor Variable: ShieldedCoinRecipientDescriptor ========================================= const ShieldedCoinRecipientDescriptor: { alignment: Alignment; fromValue: { is_left: boolean; left: { bytes: Uint8Array; }; right: { bytes: Uint8Array; }; }; toValue: Value;}; Type Declaration[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#type-declaration "Direct link to Type Declaration") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ### alignment()[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#alignment "Direct link to alignment()") alignment(): Alignment; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#returns "Direct link to Returns") [`Alignment`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) ### fromValue()[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#fromvalue "Direct link to fromValue()") fromValue(value): { is_left: boolean; left: { bytes: Uint8Array; }; right: { bytes: Uint8Array; };}; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#parameters "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#value "Direct link to value") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#returns-1 "Direct link to Returns") { is_left: boolean; left: { bytes: Uint8Array; }; right: { bytes: Uint8Array; };} ##### is\_left[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#is_left "Direct link to is_left") is_left: boolean; ##### left[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#left "Direct link to left") left: { bytes: Uint8Array;}; ###### left.bytes[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#leftbytes "Direct link to left.bytes") bytes: Uint8Array; ##### right[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#right "Direct link to right") right: { bytes: Uint8Array;}; ###### right.bytes[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#rightbytes "Direct link to right.bytes") bytes: Uint8Array; ### toValue()[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#tovalue "Direct link to toValue()") toValue(value): Value; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#parameters-1 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#value-1 "Direct link to value") ###### is\_left[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#is_left-1 "Direct link to is_left") `boolean` ###### left[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#left-1 "Direct link to left") { `bytes`: `Uint8Array`; } ###### left.bytes[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#leftbytes-1 "Direct link to left.bytes") `Uint8Array` ###### right[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#right-1 "Direct link to right") { `bytes`: `Uint8Array`; } ###### right.bytes[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#rightbytes-1 "Direct link to right.bytes") `Uint8Array` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#returns-2 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) * [Type Declaration](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#type-declaration) * [alignment()](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#alignment) * [fromValue()](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#fromvalue) * [toValue()](https://docs.midnight.network/api-reference/compact-runtime/variables/ShieldedCoinRecipientDescriptor#tovalue) --- # ContractState | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / ContractState Class: ContractState ==================== The state of a contract, consisting primarily of the [data](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#data) accessible directly to the contract, and the map of [ContractOperation](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation) s that can be called on it, the keys of which can be accessed with [operations](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#operations) , and the individual operations can be read with [operation](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#operation) and written to with [setOperation](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#setoperation) . Constructors[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------------------- ### new ContractState()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#new-contractstate "Direct link to new ContractState()") new ContractState(): ContractState Creates a blank contract state #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#returns "Direct link to Returns") [`ContractState`](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState) Properties[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------------- ### data[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#data "Direct link to data") data: StateValue; The current value of the primary state of the contract * * * ### maintenanceAuthority[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#maintenanceauthority "Direct link to maintenanceAuthority") maintenanceAuthority: ContractMaintenanceAuthority; The maintenance authority associated with this contract Methods[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------------- ### operation()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#operation "Direct link to operation()") operation(operation): undefined | ContractOperation Get the operation at a specific entry point name #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#parameters "Direct link to Parameters") • **operation**: `string` | `Uint8Array` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#returns-1 "Direct link to Returns") `undefined` | [`ContractOperation`](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation) * * * ### operations()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#operations "Direct link to operations()") operations(): (string | Uint8Array)[] Return a list of the entry points currently registered on this contract #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#returns-2 "Direct link to Returns") (`string` | `Uint8Array`)\[\] * * * ### query()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#query "Direct link to query()") query(query, cost_model): GatherResult[] Runs a series of operations against the current state, and returns the results #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#parameters-1 "Direct link to Parameters") • **query**: [`Op`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Op) <`null`\>\[\] • **cost\_model**: [`CostModel`](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#returns-3 "Direct link to Returns") [`GatherResult`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/GatherResult) \[\] * * * ### serialize()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#serialize "Direct link to serialize()") serialize(networkid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#parameters-2 "Direct link to Parameters") • **networkid**: [`NetworkId`](https://docs.midnight.network/api-reference/onchain-runtime/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#returns-4 "Direct link to Returns") `Uint8Array` * * * ### setOperation()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#setoperation "Direct link to setOperation()") setOperation(operation, value): void Set a specific entry point name to contain a given operation #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#parameters-3 "Direct link to Parameters") • **operation**: `string` | `Uint8Array` • **value**: [`ContractOperation`](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractOperation) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#returns-5 "Direct link to Returns") `void` * * * ### toString()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#parameters-4 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#returns-6 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#deserialize "Direct link to deserialize()") static deserialize(raw, networkid): ContractState #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#parameters-5 "Direct link to Parameters") • **raw**: `Uint8Array` • **networkid**: [`NetworkId`](https://docs.midnight.network/api-reference/onchain-runtime/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#returns-7 "Direct link to Returns") [`ContractState`](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState) * [Constructors](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#constructors) * [new ContractState()](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#new-contractstate) * [Properties](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#properties) * [data](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#data) * [maintenanceAuthority](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#maintenanceauthority) * [Methods](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#methods) * [operation()](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#operation) * [operations()](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#operations) * [query()](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#query) * [serialize()](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#serialize) * [setOperation()](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#setoperation) * [toString()](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#tostring) * [deserialize()](https://docs.midnight.network/api-reference/onchain-runtime/classes/ContractState#deserialize) --- # ZswapCoinPublicKeyDescriptor | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/variables/ZswapCoinPublicKeyDescriptor#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / ZswapCoinPublicKeyDescriptor Variable: ZswapCoinPublicKeyDescriptor ====================================== const ZswapCoinPublicKeyDescriptor: { alignment: Alignment; fromValue: { bytes: Uint8Array; }; toValue: Value;}; Type Declaration[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ZswapCoinPublicKeyDescriptor#type-declaration "Direct link to Type Declaration") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### alignment()[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ZswapCoinPublicKeyDescriptor#alignment "Direct link to alignment()") alignment(): Alignment; #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ZswapCoinPublicKeyDescriptor#returns "Direct link to Returns") [`Alignment`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) ### fromValue()[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ZswapCoinPublicKeyDescriptor#fromvalue "Direct link to fromValue()") fromValue(value): { bytes: Uint8Array;}; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ZswapCoinPublicKeyDescriptor#parameters "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ZswapCoinPublicKeyDescriptor#value "Direct link to value") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ZswapCoinPublicKeyDescriptor#returns-1 "Direct link to Returns") { bytes: Uint8Array;} ##### bytes[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ZswapCoinPublicKeyDescriptor#bytes "Direct link to bytes") bytes: Uint8Array; ### toValue()[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ZswapCoinPublicKeyDescriptor#tovalue "Direct link to toValue()") toValue(value): Value; #### Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ZswapCoinPublicKeyDescriptor#parameters-1 "Direct link to Parameters") ##### value[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ZswapCoinPublicKeyDescriptor#value-1 "Direct link to value") ###### bytes[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ZswapCoinPublicKeyDescriptor#bytes-1 "Direct link to bytes") `Uint8Array` #### Returns[​](https://docs.midnight.network/api-reference/compact-runtime/variables/ZswapCoinPublicKeyDescriptor#returns-2 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value) * [Type Declaration](https://docs.midnight.network/api-reference/compact-runtime/variables/ZswapCoinPublicKeyDescriptor#type-declaration) * [alignment()](https://docs.midnight.network/api-reference/compact-runtime/variables/ZswapCoinPublicKeyDescriptor#alignment) * [fromValue()](https://docs.midnight.network/api-reference/compact-runtime/variables/ZswapCoinPublicKeyDescriptor#fromvalue) * [toValue()](https://docs.midnight.network/api-reference/compact-runtime/variables/ZswapCoinPublicKeyDescriptor#tovalue) --- # The Compact language | Midnight Docs [Skip to main content](https://docs.midnight.network/compact#__docusaurus_skipToContent_fallback) Explore with… ▾ At this point, you should have already seen Compact, our smart contract programming language, in action in the tutorial and some usage hints in the 'how Midnight works' sections. This section will provide a more in-depth breakdown of what makes up a Compact smart contract, starting with a walkthrough of the main parts of a Compact program, followed by a reference for the Compact language and the Compact standard library API reference. The formal grammar for Compact and a specification of the API for `ledger` datatypes are available, as well (both externally generated): * Compact formal grammar * Ledger data types --- # Formal grammar | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/compact-grammar#__docusaurus_skipToContent_fallback) Explore with… ▾ --- # Wallet API | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/reference/midnight-api/wallet-api#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • Readme | [API](https://docs.midnight.network/compact/reference/midnight-api/wallet-api/globals) * * * Midnight Wallet API =================== This API provides a comprehensive interface for wallet operations, defining the structure of the wallet state, the methods for interacting with it, and the types and variables used within. It is implemented by the `@midnight-ntwrk/wallet` package. See the [Midnight wallet developer guide](https://docs.midnight.network/develop/guides/wallet-dev-guide) for implementation and usage information. --- # globals | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/reference/midnight-api/zswap/globals#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/compact/reference/midnight-api/zswap) | API * * * @midnight/zswap v3.0.2 ====================== Enumerations[​](https://docs.midnight.network/compact/reference/midnight-api/zswap/globals#enumerations "Direct link to Enumerations") --------------------------------------------------------------------------------------------------------------------------------------- * [NetworkId](https://docs.midnight.network/compact/reference/midnight-api/zswap/enumerations/NetworkId) Classes[​](https://docs.midnight.network/compact/reference/midnight-api/zswap/globals#classes "Direct link to Classes") ------------------------------------------------------------------------------------------------------------------------ * [AuthorizedMint](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/AuthorizedMint) * [EncryptionSecretKey](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/EncryptionSecretKey) * [Input](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/Input) * [LedgerParameters](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/LedgerParameters) * [LocalState](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/LocalState) * [MerkleTreeCollapsedUpdate](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/MerkleTreeCollapsedUpdate) * [Offer](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/Offer) * [Output](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/Output) * [ProofErasedAuthorizedMint](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/ProofErasedAuthorizedMint) * [ProofErasedInput](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/ProofErasedInput) * [ProofErasedOffer](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/ProofErasedOffer) * [ProofErasedOutput](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/ProofErasedOutput) * [ProofErasedTransaction](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/ProofErasedTransaction) * [ProofErasedTransient](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/ProofErasedTransient) * [SystemTransaction](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/SystemTransaction) * [Transaction](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/Transaction) * [TransactionCostModel](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/TransactionCostModel) * [Transient](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/Transient) * [UnprovenAuthorizedMint](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/UnprovenAuthorizedMint) * [UnprovenInput](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/UnprovenInput) * [UnprovenOffer](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/UnprovenOffer) * [UnprovenOutput](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/UnprovenOutput) * [UnprovenTransaction](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/UnprovenTransaction) * [UnprovenTransient](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/UnprovenTransient) * [ZswapChainState](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/ZswapChainState) Type Aliases[​](https://docs.midnight.network/compact/reference/midnight-api/zswap/globals#type-aliases "Direct link to Type Aliases") --------------------------------------------------------------------------------------------------------------------------------------- * [CoinCommitment](https://docs.midnight.network/compact/reference/midnight-api/zswap/type-aliases/CoinCommitment) * [CoinInfo](https://docs.midnight.network/compact/reference/midnight-api/zswap/type-aliases/CoinInfo) * [CoinPublicKey](https://docs.midnight.network/compact/reference/midnight-api/zswap/type-aliases/CoinPublicKey) * [ContractAddress](https://docs.midnight.network/compact/reference/midnight-api/zswap/type-aliases/ContractAddress) * [EncPublicKey](https://docs.midnight.network/compact/reference/midnight-api/zswap/type-aliases/EncPublicKey) * [Nonce](https://docs.midnight.network/compact/reference/midnight-api/zswap/type-aliases/Nonce) * [Nullifier](https://docs.midnight.network/compact/reference/midnight-api/zswap/type-aliases/Nullifier) * [QualifiedCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/zswap/type-aliases/QualifiedCoinInfo) * [TokenType](https://docs.midnight.network/compact/reference/midnight-api/zswap/type-aliases/TokenType) * [TransactionHash](https://docs.midnight.network/compact/reference/midnight-api/zswap/type-aliases/TransactionHash) * [TransactionId](https://docs.midnight.network/compact/reference/midnight-api/zswap/type-aliases/TransactionId) Functions[​](https://docs.midnight.network/compact/reference/midnight-api/zswap/globals#functions "Direct link to Functions") ------------------------------------------------------------------------------------------------------------------------------ * [createCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/zswap/functions/createCoinInfo) * [nativeToken](https://docs.midnight.network/compact/reference/midnight-api/zswap/functions/nativeToken) * [sampleCoinPublicKey](https://docs.midnight.network/compact/reference/midnight-api/zswap/functions/sampleCoinPublicKey) * [sampleContractAddress](https://docs.midnight.network/compact/reference/midnight-api/zswap/functions/sampleContractAddress) * [sampleTokenType](https://docs.midnight.network/compact/reference/midnight-api/zswap/functions/sampleTokenType) * [Enumerations](https://docs.midnight.network/compact/reference/midnight-api/zswap/globals#enumerations) * [Classes](https://docs.midnight.network/compact/reference/midnight-api/zswap/globals#classes) * [Type Aliases](https://docs.midnight.network/compact/reference/midnight-api/zswap/globals#type-aliases) * [Functions](https://docs.midnight.network/compact/reference/midnight-api/zswap/globals#functions) --- # globals | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/globals#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.9.0**](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime) * * * @midnight-ntwrk/compact-runtime v0.9.0 ====================================== Enumerations[​](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/globals#enumerations "Direct link to Enumerations") ------------------------------------------------------------------------------------------------------------------------------------------------- * [NetworkId](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/enumerations/NetworkId) Classes[​](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/globals#classes "Direct link to Classes") ---------------------------------------------------------------------------------------------------------------------------------- * [CompactError](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/CompactError) * [CompactTypeBoolean](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/CompactTypeBoolean) * [CompactTypeBytes](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/CompactTypeBytes) * [CompactTypeCurvePoint](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/CompactTypeCurvePoint) * [CompactTypeEnum](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/CompactTypeEnum) * [CompactTypeField](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/CompactTypeField) * [CompactTypeMerkleTreeDigest](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/CompactTypeMerkleTreeDigest) * [CompactTypeMerkleTreePath](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/CompactTypeMerkleTreePath) * [CompactTypeMerkleTreePathEntry](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/CompactTypeMerkleTreePathEntry) * [CompactTypeOpaqueString](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/CompactTypeOpaqueString) * [CompactTypeOpaqueUint8Array](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/CompactTypeOpaqueUint8Array) * [CompactTypeUnsignedInteger](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/CompactTypeUnsignedInteger) * [CompactTypeVector](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/CompactTypeVector) * [ContractMaintenanceAuthority](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/ContractMaintenanceAuthority) * [ContractOperation](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/ContractOperation) * [ContractState](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/ContractState) * [CostModel](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/CostModel) * [QueryContext](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/QueryContext) * [QueryResults](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/QueryResults) * [StateBoundedMerkleTree](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/StateBoundedMerkleTree) * [StateMap](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/StateMap) * [StateValue](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/StateValue) * [VmResults](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/VmResults) * [VmStack](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/classes/VmStack) Interfaces[​](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/globals#interfaces "Direct link to Interfaces") ------------------------------------------------------------------------------------------------------------------------------------------- * [CircuitContext](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/CircuitContext) * [CircuitResults](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/CircuitResults) * [CompactType](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/CompactType) * [ConstructorContext](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/ConstructorContext) * [ConstructorResult](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/ConstructorResult) * [CurvePoint](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/CurvePoint) * [EncodedCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/EncodedCoinInfo) * [EncodedCoinPublicKey](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/EncodedCoinPublicKey) * [EncodedContractAddress](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/EncodedContractAddress) * [EncodedQualifiedCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/EncodedQualifiedCoinInfo) * [EncodedRecipient](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/EncodedRecipient) * [EncodedZswapLocalState](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/EncodedZswapLocalState) * [MerkleTreeDigest](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/MerkleTreeDigest) * [MerkleTreePath](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/MerkleTreePath) * [MerkleTreePathEntry](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/MerkleTreePathEntry) * [ProofData](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/ProofData) * [Recipient](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/Recipient) * [WitnessContext](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/WitnessContext) * [ZswapLocalState](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/interfaces/ZswapLocalState) Type Aliases[​](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/globals#type-aliases "Direct link to Type Aliases") ------------------------------------------------------------------------------------------------------------------------------------------------- * [AlignedValue](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/AlignedValue) * [Alignment](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/Alignment) * [AlignmentAtom](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/AlignmentAtom) * [AlignmentSegment](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/AlignmentSegment) * [BlockContext](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/BlockContext) * [CoinCommitment](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/CoinCommitment) * [CoinInfo](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/CoinInfo) * [CoinPublicKey](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/CoinPublicKey) * [ContractAddress](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/ContractAddress) * [ContractReferenceLocations](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/ContractReferenceLocations) * [DomainSeperator](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/DomainSeperator) * [Effects](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/Effects) * [Fr](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/Fr) * [GatherResult](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/GatherResult) * [Key](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/Key) * [Nonce](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/Nonce) * [Nullifier](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/Nullifier) * [Op](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/Op) * [QualifiedCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/QualifiedCoinInfo) * [Signature](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/Signature) * [SignatureVerifyingKey](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/SignatureVerifyingKey) * [SigningKey](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/SigningKey) * [SparseCompactADT](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/SparseCompactADT) * [SparseCompactArrayLikeADT](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/SparseCompactArrayLikeADT) * [SparseCompactCellADT](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/SparseCompactCellADT) * [SparseCompactContractAddress](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/SparseCompactContractAddress) * [SparseCompactListADT](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/SparseCompactListADT) * [SparseCompactMapADT](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/SparseCompactMapADT) * [SparseCompactSetADT](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/SparseCompactSetADT) * [SparseCompactStruct](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/SparseCompactStruct) * [SparseCompactType](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/SparseCompactType) * [SparseCompactValue](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/SparseCompactValue) * [SparseCompactVector](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/SparseCompactVector) * [TokenType](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/TokenType) * [Transcript](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/Transcript) * [Value](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/type-aliases/Value) Variables[​](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/globals#variables "Direct link to Variables") ---------------------------------------------------------------------------------------------------------------------------------------- * [BooleanDescriptor](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/variables/BooleanDescriptor) * [Bytes32Descriptor](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/variables/Bytes32Descriptor) * [CoinInfoDescriptor](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/variables/CoinInfoDescriptor) * [CoinRecipientDescriptor](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/variables/CoinRecipientDescriptor) * [ContractAddressDescriptor](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/variables/ContractAddressDescriptor) * [~DUMMY\_ADDRESS~](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/variables/DUMMY_ADDRESS) * [MAX\_FIELD](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/variables/MAX_FIELD) * [MaxUint8Descriptor](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/variables/MaxUint8Descriptor) * [versionString](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/variables/versionString) * [ZswapCoinPublicKeyDescriptor](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/variables/ZswapCoinPublicKeyDescriptor) Functions[​](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/globals#functions "Direct link to Functions") ---------------------------------------------------------------------------------------------------------------------------------------- * [addField](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/addField) * [alignedConcat](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/alignedConcat) * [assert](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/assert) * [bigIntToValue](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/bigIntToValue) * [checkProofData](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/checkProofData) * [coinCommitment](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/coinCommitment) * [constructorContext](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/constructorContext) * [contractDependencies](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/contractDependencies) * [convertBytesToField](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/convertBytesToField) * [convertBytesToUint](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/convertBytesToUint) * [convertFieldToBytes](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/convertFieldToBytes) * [createZswapInput](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/createZswapInput) * [createZswapOutput](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/createZswapOutput) * [decodeCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/decodeCoinInfo) * [decodeCoinPublicKey](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/decodeCoinPublicKey) * [decodeContractAddress](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/decodeContractAddress) * [decodeQualifiedCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/decodeQualifiedCoinInfo) * [decodeRecipient](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/decodeRecipient) * [decodeTokenType](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/decodeTokenType) * [decodeZswapLocalState](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/decodeZswapLocalState) * [degradeToTransient](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/degradeToTransient) * [dummyContractAddress](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/dummyContractAddress) * [ecAdd](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/ecAdd) * [ecMul](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/ecMul) * [ecMulGenerator](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/ecMulGenerator) * [emptyZswapLocalState](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/emptyZswapLocalState) * [encodeCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/encodeCoinInfo) * [encodeCoinPublicKey](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/encodeCoinPublicKey) * [encodeContractAddress](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/encodeContractAddress) * [encodeQualifiedCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/encodeQualifiedCoinInfo) * [encodeRecipient](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/encodeRecipient) * [encodeTokenType](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/encodeTokenType) * [encodeZswapLocalState](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/encodeZswapLocalState) * [hasCoinCommitment](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/hasCoinCommitment) * [hashToCurve](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/hashToCurve) * [leafHash](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/leafHash) * [maxAlignedSize](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/maxAlignedSize) * [mulField](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/mulField) * [ownPublicKey](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/ownPublicKey) * [persistentCommit](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/persistentCommit) * [persistentHash](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/persistentHash) * [runProgram](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/runProgram) * [sampleContractAddress](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/sampleContractAddress) * [sampleSigningKey](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/sampleSigningKey) * [sampleTokenType](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/sampleTokenType) * [signatureVerifyingKey](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/signatureVerifyingKey) * [signData](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/signData) * [subField](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/subField) * [tokenType](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/tokenType) * [transientCommit](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/transientCommit) * [transientHash](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/transientHash) * [type\_error](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/type_error) * [upgradeFromTransient](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/upgradeFromTransient) * [valueToBigInt](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/valueToBigInt) * [verifySignature](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/verifySignature) * [witnessContext](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/functions/witnessContext) * [Enumerations](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/globals#enumerations) * [Classes](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/globals#classes) * [Interfaces](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/globals#interfaces) * [Type Aliases](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/globals#type-aliases) * [Variables](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/globals#variables) * [Functions](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime/globals#functions) --- # ZSwap API | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/reference/midnight-api/zswap#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • Readme | [API](https://docs.midnight.network/compact/reference/midnight-api/zswap/globals) * * * Zswap TypeScript API ==================== This document outlines the usage of the Zswap TS API Network ID[​](https://docs.midnight.network/compact/reference/midnight-api/zswap#network-id "Direct link to Network ID") ------------------------------------------------------------------------------------------------------------------------- Prior to any interaction, setNetworkId should be used to set the [NetworkId](https://docs.midnight.network/compact/reference/midnight-api/zswap/enumerations/NetworkId) to target the correct network. Proof stages[​](https://docs.midnight.network/compact/reference/midnight-api/zswap#proof-stages "Direct link to Proof stages") ------------------------------------------------------------------------------------------------------------------------------- Most transaction components will be in one of three stages: `X`, `UnprovenX`, or `ProofErasedX`. The `UnprovenX` stage is _always_ the first one. It is possible to transition to the `X` stage by proving an `UnprovenTransaction` through the proof server. For testing, and where proofs aren't necessary, the `ProofErasedX` stage is used, which can be reached via `eraseProof[s]` from the other two stages. Transaction structure[​](https://docs.midnight.network/compact/reference/midnight-api/zswap#transaction-structure "Direct link to Transaction structure") ---------------------------------------------------------------------------------------------------------------------------------------------------------- A [Transaction](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/Transaction) runs in two phases: a _guaranteed_ phase, handling fee payments and fast-to-verify operations, and a _fallible_ phase, handling operations which may fail atomically, separately from the guaranteed phase. It therefore contains: * A "guaranteed" [Offer](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/Offer) * Optionally, a "fallible" [Offer](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/Offer) * Contract call information not accessible to this API It also contains additional cryptographic glue that will be omitted in this document. ### Zswap[​](https://docs.midnight.network/compact/reference/midnight-api/zswap#zswap "Direct link to Zswap") A Zswap [Offer](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/Offer) consists of: * A set of [Input](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/Input) s, burning coins. * A set of [Output](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/Output) s, creating coins. * A set of [Transient](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/Transient) s, indicating a coin that is created and burnt in the same transaction. * A mapping from [TokenType](https://docs.midnight.network/compact/reference/midnight-api/zswap/type-aliases/TokenType) s to offer balance, positive when there are more inputs than outputs and vice versa. [Input](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/Input) s can be created either from a [QualifiedCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/zswap/type-aliases/QualifiedCoinInfo) and a contract address, if the coin is contract-owned, or from a [QualifiedCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/zswap/type-aliases/QualifiedCoinInfo) and a ZswapLocalState, if it is user-owned. Similarly, [Output](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/Output) s can be created from a [CoinInfo](https://docs.midnight.network/compact/reference/midnight-api/zswap/type-aliases/CoinInfo) and a contract address for contract-owned coins, or from a [CoinInfo](https://docs.midnight.network/compact/reference/midnight-api/zswap/type-aliases/CoinInfo) and a user's public key(s), if it is user-owned. A [Transient](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/Transient) is created similarly to a [Input](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/Input) , but directly converts an existing [Output](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/Output) . A [QualifiedCoinInfo](https://docs.midnight.network/compact/reference/midnight-api/zswap/type-aliases/QualifiedCoinInfo) is a [CoinInfo](https://docs.midnight.network/compact/reference/midnight-api/zswap/type-aliases/CoinInfo) with an index into the Merkle tree of coin commitments that can be used to find the relevant coin to spend, while a [CoinInfo](https://docs.midnight.network/compact/reference/midnight-api/zswap/type-aliases/CoinInfo) consists of a coins [TokenType](https://docs.midnight.network/compact/reference/midnight-api/zswap/type-aliases/TokenType) , value, and a nonce. State Structure[​](https://docs.midnight.network/compact/reference/midnight-api/zswap#state-structure "Direct link to State Structure") ---------------------------------------------------------------------------------------------------------------------------------------- [ZswapChainState](https://docs.midnight.network/compact/reference/midnight-api/zswap/classes/ZswapChainState) holds the on-chain state of Zswap, while ZswaplocalState contains the local, wallet state. * [Network ID](https://docs.midnight.network/compact/reference/midnight-api/zswap#network-id) * [Proof stages](https://docs.midnight.network/compact/reference/midnight-api/zswap#proof-stages) * [Transaction structure](https://docs.midnight.network/compact/reference/midnight-api/zswap#transaction-structure) * [Zswap](https://docs.midnight.network/compact/reference/midnight-api/zswap#zswap) * [State Structure](https://docs.midnight.network/compact/reference/midnight-api/zswap#state-structure) --- # Wallet | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / Wallet Interface: Wallet ================= Wallet API Remarks[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#remarks "Direct link to Remarks") ---------------------------------------------------------------------------------------------------------------------- Wallet is a data structure that holds the state of the wallet and provides methods for proving, balancing, and submitting transactions. Methods[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------- ### balanceTransaction()[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#balancetransaction "Direct link to balanceTransaction()") balanceTransaction(tx, newCoins): Promise Balances the provided transaction. #### Parameters[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#parameters "Direct link to Parameters") • **tx**: `Transaction` Transaction to balance • **newCoins**: `CoinInfo`\[\] CoinInfo array of coins created by the transaction, which the wallet will watch for and apply to the state The `newCoins` parameter should be used in cases where a new coin is created (for example, a DApp mints a coin and wants to send it to the wallet). Because of how Midnight works, newly created coins must be explicitly sent to the wallet using this method. This allows the wallet to monitor them and incorporate them into its state. #### Returns[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#returns "Direct link to Returns") `Promise`<[`BalanceTransactionToProve`](https://docs.midnight.network/api-reference/wallet-api/type-aliases/BalanceTransactionToProve) | [`NothingToProve`](https://docs.midnight.network/api-reference/wallet-api/type-aliases/NothingToProve) \> [BalanceTransactionToProve](https://docs.midnight.network/api-reference/wallet-api/type-aliases/BalanceTransactionToProve) or [NothingToProve](https://docs.midnight.network/api-reference/wallet-api/type-aliases/NothingToProve) recipe (for the already balanced transaction) or error. #### Remarks[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#remarks-1 "Direct link to Remarks") Balancing a transaction means that for any given output and transaction fees, the wallet will take the available coins from the state to cover them. * * * ### proveTransaction()[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#provetransaction "Direct link to proveTransaction()") proveTransaction(recipe): Promise Calls the proving server with the proving recipe and returns the proven transaction or error. #### Parameters[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#parameters-1 "Direct link to Parameters") • **recipe**: [`ProvingRecipe`](https://docs.midnight.network/api-reference/wallet-api/type-aliases/ProvingRecipe) [ProvingRecipe](https://docs.midnight.network/api-reference/wallet-api/type-aliases/ProvingRecipe) with data to prove #### Returns[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#returns-1 "Direct link to Returns") `Promise`<`Transaction`\> Transaction or error #### Remarks[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#remarks-2 "Direct link to Remarks") * Proof generation takes time and resources, therefore depending on the user's computer specs, this can be an expensive operation * There can be wallet implementations that do not need to support proving, in which case this method should return an error * * * ### serializeState()[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#serializestate "Direct link to serializeState()") serializeState(): Promise Serializes and returns the current state of the wallet which contains: * The zswap local state * The transaction history * The offset in the blockchain corresponding to this state * The protocol version * The network ID #### Returns[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#returns-2 "Direct link to Returns") `Promise`<`string`\> Serialized [WalletState](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState) in stringified JSON format * * * ### state()[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#state "Direct link to state()") state(): Observable Observable (rx.js) stream of [WalletState](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState) #### Returns[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#returns-3 "Direct link to Returns") `Observable`<[`WalletState`](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState) \> #### Remarks[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#remarks-3 "Direct link to Remarks") Should update every time there's a state update * * * ### submitTransaction()[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#submittransaction "Direct link to submitTransaction()") submitTransaction(tx): Promise Submits the provided transaction to the node #### Parameters[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#parameters-2 "Direct link to Parameters") • **tx**: `Transaction` Transaction to submit #### Returns[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#returns-4 "Direct link to Returns") `Promise`<`string`\> [TransactionIdentifier](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionIdentifier) - First transaction identifier from identifiers list or error * * * ### transferTransaction()[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#transfertransaction "Direct link to transferTransaction()") transferTransaction(outputs): Promise Prepares a transfer transaction #### Parameters[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#parameters-3 "Direct link to Parameters") • **outputs**: [`TokenTransfer`](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TokenTransfer) \[\] An array of [TokenTransfer](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TokenTransfer) a user wants to perform. #### Returns[​](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#returns-5 "Direct link to Returns") `Promise`<[`TransactionToProve`](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionToProve) \> Recipe with [TransactionToProve](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionToProve) or error * [Remarks](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#remarks) * [Methods](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#methods) * [balanceTransaction()](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#balancetransaction) * [proveTransaction()](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#provetransaction) * [serializeState()](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#serializestate) * [state()](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#state) * [submitTransaction()](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#submittransaction) * [transferTransaction()](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet#transfertransaction) --- # NetworkId | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / NetworkId Enumeration: NetworkId ====================== The network currently being targeted Enumeration Members[​](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId#enumeration-members "Direct link to Enumeration Members") ---------------------------------------------------------------------------------------------------------------------------------------------------------- ### DevNet[​](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId#devnet "Direct link to DevNet") DevNet: 1; A developer network, not guaranteed to be persistent * * * ### MainNet[​](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId#mainnet "Direct link to MainNet") MainNet: 3; The Midnight mainnet * * * ### TestNet[​](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId#testnet "Direct link to TestNet") TestNet: 2; A persistent testnet * * * ### Undeployed[​](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId#undeployed "Direct link to Undeployed") Undeployed: 0; A local test network * [Enumeration Members](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId#enumeration-members) * [DevNet](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId#devnet) * [MainNet](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId#mainnet) * [TestNet](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId#testnet) * [Undeployed](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId#undeployed) --- # Opaque data types | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/opaque_data#__docusaurus_skipToContent_fallback) Explore with… ▾ Data types whose representations are visible are called transparent. These expose the inner structure of the data so that operations on the data can be understood. Drawbacks to having transparent data types include lesser type safety (or type soundness) - how a programming language discourages or prevents type errors, such as assigning the wrong type to a variable. Opaque data types present an interface without sharing the actual, concrete data structure. These can only be manipulated by calling subroutines that have access to knowledge about the missing structure. The principle of information hiding, segregating design decisions from the underlying software implementation, results in more resilient code. Implementations can be improved or changed completely without the fragility that comes from inner details being depended upon. Defensively coding the parts most likely to change results in more robust code overall. Midnight opaque data types ========================== Opaque types in Compact are a compact type system feature that allow "foreign" JavaScript data to be stored, passed around, and retrieved on behalf of a DApp (but not inspected by Compact code). Midnight’s Compact language currently supports `Opaque<'string'>` and `Opaque<'Uint8Array'>`. These can be stored in a contract's public state. NOTE: These are opaque only within Compact. They are transparent in a DApp's JavaScript code. Their representation on-chain is **NOT** hidden - `Uint8Array` is represented by the array of bytes and `string` is represented by its UTF-8 encoding. Examples ======== The Bulletin Board example DApp, in the developer tutorial, has an example of opaque data type usage. * The Compact post circuit is a contract entry point that's called from a DApp and passed an `Opaque<'string'>`. Compact code can't look inside this; it does store it in the contract's public state. * Later, the Compact take\_down circuit reads this value and returns it to the JavaScript or TypeScript caller. --- # 2 docs tagged with "developer guide" | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/tags/developer-guide#__docusaurus_skipToContent_fallback) [Midnight wallet - developer guide\ ---------------------------------](https://docs.midnight.network/sdks/official/wallet-developer-guide) Developer guide for the Midnight wallet SDK. [Midnight.js\ -----------](https://docs.midnight.network/sdks/official/midnight-js) Comprehensive TypeScript SDK for building DApps on Midnight Network. --- # DApp connector API | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/dapp-connector-api v3.0.0** * * * Midnight DApp connector API =========================== This API provides a comprehensive interface for the DApp connector operations, defining the structure of the wallet state it exposes, the methods for interacting with it, and the types and variables used within. Installation[​](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#installation "Direct link to Installation") ---------------------------------------------------------------------------------------------------------------------------------------- The Midnight DApp connector API is available as an NPM package with the namespace `@midnight-ntwrk/dapp-connector-api`. It can be installed using any node package manager, such as Yarn. To install the package using Yarn, execute the following command: `yarn add @midnight-ntwrk/dapp-connector-api` Package usage[​](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#package-usage "Direct link to Package usage") ------------------------------------------------------------------------------------------------------------------------------------------- The package provides the type declarations that are documented in the [documentation](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/interfaces/DAppConnectorAPI) of this package. The DApp connector API should be exposed through the global variable as follows: `window.midnight.{walletName}` Available methods[​](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#available-methods "Direct link to Available methods") ------------------------------------------------------------------------------------------------------------------------------------------------------- | Name | Description | | --- | --- | | **apiVersion** | Provides a semver string version of the DApp connector API | | **enable** | Returns a promise with the [DAppConnectorWalletAPI](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/interfaces/DAppConnectorWalletAPI)
or error | | **isEnabled** | Returns a promise with a boolean showing whether the DApp is authorized to access the API or not | | **name** | The name of the wallet that implements the API | | **serviceUriConfig** | Returns a promise with [ServiceUriConfig](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/interfaces/ServiceUriConfig)
or error if the DApp is not authorized. | API usage[​](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#api-usage "Direct link to API usage") ------------------------------------------------------------------------------------------------------------------------------- Authorizing a DApp[​](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#authorizing-a-dapp "Direct link to Authorizing a DApp") ---------------------------------------------------------------------------------------------------------------------------------------------------------- To authorize a DApp, call the `enable()` method and wait for the user to respond to the request. try { const api = await window.midnight.{walletName}.enable(); // api is available here} catch (error) { console.log('an error occurred', error);} Checking if the DApp is authorized[​](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#checking-if-the-dapp-is-authorized "Direct link to Checking if the DApp is authorized") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- To check if the DApp is authorized, use the `isEnabled()` method as follows: try { const isEnabled = await window.midnight.{walletName}.isEnabled();} catch (error) { console.log('an error occurred', error);} Getting information about the DApp connector API[​](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#getting-information-about-the-dapp-connector-api "Direct link to Getting information about the DApp connector API") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### Name[​](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#name "Direct link to Name") To get the name of the wallet, use the `name` property in the implemented DApp connector API: const name = window.midnight.{walletName}.name;console.log('Wallet name', name); ### API version[​](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#api-version "Direct link to API version") To get the API version, use the `apiVersion` property as follows: const apiVersion = window.midnight.{walletName}.apiVersion;console.log('API version', apiVersion); ### Getting the service URI config[​](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#getting-the-service-uri-config "Direct link to Getting the service URI config") Midnight wallet users can configure the node, indexer, and proving server URIs in the wallet settings. To enable DApps to access and utilize these URLs, the following property is exposed: | Name | Description | | --- | --- | | **Node URL** | The node the wallet is pointing to | | **Indexer URL** | The indexer URL the wallet is pointing to | | **Proving Server URL** | The proving server URL the wallet is pointing to | To get the service URI config, use the API as follows: try { const serviceUriConfig = await window.midnight.{walletName}.serviceUriConfig(); console.log('serviceUriConfig', serviceUriConfig);} catch (error) { console.log('an error occurred', error);} **Note:** The DApp must be authorized before calling this method, otherwise it will throw an error. Interacting with the API[​](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#interacting-with-the-api "Direct link to Interacting with the API") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- After calling the `enable()` method and the user approves the authorization request, you will receive an instance of the [DAppConnectorWalletAPI](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/interfaces/DAppConnectorWalletAPI) , which includes the following properties: | Name | Description | Note | | --- | --- | --- | | **balanceAndProveTransaction** | Balances and proves a transaction | \- | | **submitTransaction** | Submits a balanced and proven transaction | \- | | **state** | Returns [DAppConnectorWalletState](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/interfaces/DAppConnectorWalletState)
object | \- | | **balanceTransaction** | Balances a transaction | This method is deprecated and will be removed in version 2.0.0 | | **proveTransaction** | Proves a transaction | This method is deprecated and will be removed in version 2.0.0 | Getting the wallet state[​](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#getting-the-wallet-state "Direct link to Getting the wallet state") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- To get the wallet state, call the `state()` API method, which will return a promise with the [DAppConnectorWalletState](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector/interfaces/DAppConnectorWalletState) object as follows: try { const state = await api.state(); console.log('Wallet state', state);} catch (error) { console.log('an error occurred', error);} Balancing and proving a transaction[​](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#balancing-and-proving-a-transaction "Direct link to Balancing and proving a transaction") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- To balance and prove a transaction, begin by creating a transaction in your DApp. You can [follow the guide on how to create a transaction here](https://docs.midnight.network/develop/guides/wallet-dev-guide#working-with-transactions) . This method accepts the following properties: | Name | Data type | Required? | | --- | --- | --- | | **transaction** | Transaction | Yes | | **newCoins** | CoinInfo\[\] | No | Below, you'll find an example of how to balance and prove a transaction: try { // assuming we have a transaction at hand here const transaction; const balancedAndProvenTransaction = await api.balanceAndProveTransaction(transaction);} catch (error) { console.log('an error occurred', error);} Submitting a transaction[​](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#submitting-a-transaction "Direct link to Submitting a transaction") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- With the balanced and proven transaction from above, you can now submit it. The `submitTransaction()` method accepts the following parameters: | Name | Data type | Required? | | --- | --- | --- | | **transaction** | Transaction | Yes | Below, you'll find an example of how to submit a transaction: try { const submittedTransaction = await api.submitTransaction(balancedAndProvenTransaction);} catch (error) { console.log('an error occurred', error);} Examples[​](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#examples "Direct link to Examples") ---------------------------------------------------------------------------------------------------------------------------- In this section, you'll find examples demonstrating how to fully utilize the DApp connector API. ### Submitting a transaction[​](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#submitting-a-transaction-1 "Direct link to Submitting a transaction") This example demonstrates how to authorize and submit a transaction from a DApp's perspective using the DApp connector API. try { const api = await window.midnight.{walletName}.enable(); // assuming this is a transaction we've already created // [link to create transaction docs is in the "Balancing and proving a transaction" section] const transaction; const balancedAndProvenTransaction = await api.balanceAndProveTransaction(transaction); const submittedTx = await api.submitTransaction(balancedAndProvenTransaction); console.log(submittedTx);} catch (error) { console.log('an error occurred', error);} * [Installation](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#installation) * [Package usage](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#package-usage) * [Available methods](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#available-methods) * [API usage](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#api-usage) * [Authorizing a DApp](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#authorizing-a-dapp) * [Checking if the DApp is authorized](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#checking-if-the-dapp-is-authorized) * [Getting information about the DApp connector API](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#getting-information-about-the-dapp-connector-api) * [Name](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#name) * [API version](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#api-version) * [Getting the service URI config](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#getting-the-service-uri-config) * [Interacting with the API](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#interacting-with-the-api) * [Getting the wallet state](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#getting-the-wallet-state) * [Balancing and proving a transaction](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#balancing-and-proving-a-transaction) * [Submitting a transaction](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#submitting-a-transaction) * [Examples](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#examples) * [Submitting a transaction](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector#submitting-a-transaction-1) --- # One doc tagged with "authentication" | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/tags/authentication#__docusaurus_skipToContent_fallback) [Authentication\ --------------](https://docs.midnight.network/sdks/overview/authentication) Learn about the authentication methods for the Midnight SDKs and client libraries. --- # Compact standard library | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/compact-std-library#__docusaurus_skipToContent_fallback) Explore with… ▾ **CompactStandardLibrary** ∙ [Detailed API reference](https://docs.midnight.network/compact/compact-std-library/exports) This API provides standard types and circuits for use in Compact programs. Key parts of the API are: * Common data types: * [`Maybe`](https://docs.midnight.network/compact/compact-std-library/exports#maybe) * [`Either`](https://docs.midnight.network/compact/compact-std-library/exports#either) * [`CurvePoint`](https://docs.midnight.network/compact/compact-std-library/exports#curvepoint) * [`MerkleTreeDigest`](https://docs.midnight.network/compact/compact-std-library/exports#merkletreedigest) * [`MerkleTreePathEntry`](https://docs.midnight.network/compact/compact-std-library/exports#merkletreepathentry) * [`MerkleTreePath`](https://docs.midnight.network/compact/compact-std-library/exports#merkletreepath) * [`ContractAddress`](https://docs.midnight.network/compact/compact-std-library/exports#contractaddress) * [`ZswapCoinPublicKey`](https://docs.midnight.network/compact/compact-std-library/exports#zswapcoinpublickey) * Coin management data types: * [`CoinInfo`](https://docs.midnight.network/compact/compact-std-library/exports#coininfo) * [`QualifiedCoinInfo`](https://docs.midnight.network/compact/compact-std-library/exports#qualifiedcoininfo) * [`SendResult`](https://docs.midnight.network/compact/compact-std-library/exports#sendresult) * Common functions: * [`some`](https://docs.midnight.network/compact/compact-std-library/exports#some) * [`none`](https://docs.midnight.network/compact/compact-std-library/exports#none) * [`left`](https://docs.midnight.network/compact/compact-std-library/exports#left) * [`right`](https://docs.midnight.network/compact/compact-std-library/exports#right) * Hashing functions: * [`transientHash`](https://docs.midnight.network/compact/compact-std-library/exports#transienthash) * [`transientCommit`](https://docs.midnight.network/compact/compact-std-library/exports#transientcommit) * [`persistentHash`](https://docs.midnight.network/compact/compact-std-library/exports#persistenthash) * [`persistentCommit`](https://docs.midnight.network/compact/compact-std-library/exports#persistentcommit) * [`degradeToTransient`](https://docs.midnight.network/compact/compact-std-library/exports#degradetotransient) * Elliptic curve functions: * [`ecAdd`](https://docs.midnight.network/compact/compact-std-library/exports#ecadd) * [`ecMul`](https://docs.midnight.network/compact/compact-std-library/exports#ecmul) * [`ecMulGenerator`](https://docs.midnight.network/compact/compact-std-library/exports#ecmulgenerator) * [`hashToCurve`](https://docs.midnight.network/compact/compact-std-library/exports#hashtocurve) * [`upgradeFromTransient`](https://docs.midnight.network/compact/compact-std-library/exports#upgradefromtransient) * Merkle tree functions: * [`merkleTreePathRoot`](https://docs.midnight.network/compact/compact-std-library/exports#merkletreepathroot) * [`merkleTreePathRootNoLeafHash`](https://docs.midnight.network/compact/compact-std-library/exports#merkletreepathrootnoleafhash) * Coin management functions * [`tokenType`](https://docs.midnight.network/compact/compact-std-library/exports#tokentype) * [`nativeToken`](https://docs.midnight.network/compact/compact-std-library/exports#nativetoken) * [`ownPublicKey`](https://docs.midnight.network/compact/compact-std-library/exports#ownpublickey) * [`createZswapInput`](https://docs.midnight.network/compact/compact-std-library/exports#createzswapinput) * [`createZswapOutput`](https://docs.midnight.network/compact/compact-std-library/exports#createzswapoutput) * [`mintToken`](https://docs.midnight.network/compact/compact-std-library/exports#minttoken) * [`evolveNonce`](https://docs.midnight.network/compact/compact-std-library/exports#evolvenonce) * [`receive`](https://docs.midnight.network/compact/compact-std-library/exports#receive) * [`send`](https://docs.midnight.network/compact/compact-std-library/exports#send) * [`sendImmediate`](https://docs.midnight.network/compact/compact-std-library/exports#sendimmediate) * [`mergeCoin`](https://docs.midnight.network/compact/compact-std-library/exports#mergecoin) * [`mergeCoinImmediate`](https://docs.midnight.network/compact/compact-std-library/exports#mergecoinimmediate) * [`burnAddress`](https://docs.midnight.network/compact/compact-std-library/exports#burnaddress) * Block time functions: * [`blockTimeLt`](https://docs.midnight.network/compact/compact-std-library/exports#blocktimelt) * [`blockTimeGte`](https://docs.midnight.network/compact/compact-std-library/exports#blocktimegte) * [`blockTimeGt`](https://docs.midnight.network/compact/compact-std-library/exports#blocktimegt) * [`blockTimeLte`](https://docs.midnight.network/compact/compact-std-library/exports#blocktimelte) --- # One doc tagged with "typescript" | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/tags/typescript#__docusaurus_skipToContent_fallback) [Midnight SDKs\ -------------](https://docs.midnight.network/sdks) Build privacy-preserving decentralized applications with Midnight's comprehensive SDK ecosystem. Whether you're creating smart contracts, wallets, or full-stack DApps, we have the tools you need. --- # Midnight APIs | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/reference/midnight-api#__docusaurus_skipToContent_fallback) Explore with… ▾ Collection of Midnight APIs: * [Compact runtime API](https://docs.midnight.network/compact/reference/midnight-api/compact-runtime) * [DApp connector API](https://docs.midnight.network/compact/reference/midnight-api/dapp-connector) * [Ledger API](https://docs.midnight.network/compact/reference/midnight-api/ledger) * [Midnight JS API](https://docs.midnight.network/compact/reference/midnight-api/midnight-js) * [On-Chain runtime API](https://docs.midnight.network/compact/reference/midnight-api/onchain-runtime) * [Midnight Indexer API](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer) * [Wallet API](https://docs.midnight.network/compact/reference/midnight-api/wallet-api) * [ZSwap API](https://docs.midnight.network/compact/reference/midnight-api/zswap) --- # QueryContext | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / QueryContext Class: QueryContext =================== Provides the information needed to fully process a transaction, including information about the rest of the transaction, and the state of the chain at the time of execution. Constructors[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#constructors "Direct link to Constructors") --------------------------------------------------------------------------------------------------------------------------------------------- ### new QueryContext(state, address)[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#new-querycontextstate-address "Direct link to new QueryContext(state, address)") new QueryContext(state, address): QueryContext Construct a basic context from a contract's address and current state value #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#parameters "Direct link to Parameters") • **state**: [`StateValue`](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue) • **address**: `string` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#returns "Direct link to Returns") [`QueryContext`](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext) Properties[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------- ### address[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#address "Direct link to address") readonly address: string; The address of the contract * * * ### block[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#block "Direct link to block") block: BlockContext; The block-level information accessible to the contract * * * ### comIndicies[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#comindicies "Direct link to comIndicies") readonly comIndicies: Map; The commitment indices map accessible to the contract, primarily via [qualify](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#qualify) * * * ### effects[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#effects "Direct link to effects") effects: Effects; The effects that occurred during execution against this context, should match those declared in a [Transcript](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Transcript) * * * ### state[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#state "Direct link to state") readonly state: StateValue; The current contract state retained in the context Methods[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------------ ### insertCommitment()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#insertcommitment "Direct link to insertCommitment()") insertCommitment(comm, index): QueryContext Register a given coin commitment as being accessible at a specific index, for use when receiving coins in-contract, and needing to record their index to later spend them #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#parameters-1 "Direct link to Parameters") • **comm**: `string` • **index**: `bigint` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#returns-1 "Direct link to Returns") [`QueryContext`](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext) * * * ### ~intoTranscript()~[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#intotranscript "Direct link to intotranscript") intoTranscript(program, cost_model): [undefined | Transcript, undefined | Transcript] Finalizes a sequence of operations against their initial context, resulting in a guaranteed and fallible [Transcript](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Transcript) , optimally allocated, and heuristically covered for gas fees. #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#parameters-2 "Direct link to Parameters") • **program**: [`Op`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Op) <[`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) \>\[\] • **cost\_model**: [`CostModel`](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#returns-2 "Direct link to Returns") \[`undefined` | [`Transcript`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Transcript)\ <[`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue)\ \>, `undefined` | [`Transcript`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Transcript)\ <[`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue)\ \>\] #### Deprecated[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#deprecated "Direct link to Deprecated") Please use the ledger's `partitionTranscripts` instead. * * * ### qualify()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#qualify "Direct link to qualify()") `Internal` qualify(coin): undefined | Value Internal counterpart to [insertCommitment](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#insertcommitment) ; upgrades an encoded [CoinInfo](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/CoinInfo) to an encoded [QualifiedCoinInfo](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/QualifiedCoinInfo) using the inserted commitments #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#parameters-3 "Direct link to Parameters") • **coin**: [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#returns-3 "Direct link to Returns") `undefined` | [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) * * * ### query()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#query "Direct link to query()") query( ops, cost_model, gas_limit?): QueryResults Runs a sequence of operations in gather mode, returning the results of the gather. #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#parameters-4 "Direct link to Parameters") • **ops**: [`Op`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Op) <`null`\>\[\] • **cost\_model**: [`CostModel`](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel) • **gas\_limit?**: `bigint` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#returns-4 "Direct link to Returns") [`QueryResults`](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryResults) * * * ### runTranscript()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#runtranscript "Direct link to runTranscript()") runTranscript(transcript, cost_model): QueryContext Runs a transcript in verifying mode against the current query context, outputting a new query context, with the [state](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#state) and [effects](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#effects) from after the execution. #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#parameters-5 "Direct link to Parameters") • **transcript**: [`Transcript`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Transcript) <[`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) \> • **cost\_model**: [`CostModel`](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel) #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#returns-5 "Direct link to Returns") [`QueryContext`](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext) * * * ### toString()[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#parameters-6 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#returns-6 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#constructors) * [new QueryContext(state, address)](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#new-querycontextstate-address) * [Properties](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#properties) * [address](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#address) * [block](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#block) * [comIndicies](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#comindicies) * [effects](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#effects) * [state](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#state) * [Methods](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#methods) * [insertCommitment()](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#insertcommitment) * [~intoTranscript()~](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#intotranscript) * [qualify()](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#qualify) * [query()](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#query) * [runTranscript()](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#runtranscript) * [toString()](https://docs.midnight.network/api-reference/onchain-runtime/classes/QueryContext#tostring) --- # One doc tagged with "midnight.js" | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/tags/midnight-js#__docusaurus_skipToContent_fallback) [Midnight.js\ -----------](https://docs.midnight.network/sdks/official/midnight-js) Comprehensive TypeScript SDK for building DApps on Midnight Network. --- # One doc tagged with "issues" | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/tags/issues#__docusaurus_skipToContent_fallback) [Common SDK integration issues\ -----------------------------](https://docs.midnight.network/sdks/troubleshoot) Troubleshoot common issues when building on Midnight Network. --- # One doc tagged with "rate limits" | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/tags/rate-limits#__docusaurus_skipToContent_fallback) [Rate limits\ -----------](https://docs.midnight.network/sdks/overview/rate-limits) Learn about the rate limits for the Midnight SDKs and client libraries. --- # One doc tagged with "wallet" | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/tags/wallet#__docusaurus_skipToContent_fallback) [Midnight wallet - developer guide\ ---------------------------------](https://docs.midnight.network/sdks/official/wallet-developer-guide) Developer guide for the Midnight wallet SDK. --- # One doc tagged with "error codes" | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/tags/error-codes#__docusaurus_skipToContent_fallback) [List of error codes\ -------------------](https://docs.midnight.network/sdks/error-codes) List of error codes for the Midnight SDKs and client libraries. --- # Midnight Indexer API Documentation v1 | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ The Midnight Indexer API exposes a GraphQL API that enables clients to query and subscribe to blockchain data—blocks, transactions, contracts, and wallet-related events—indexed from the Midnight blockchain. These capabilities facilitate both historical lookups and real-time monitoring. **Disclaimer:** The examples provided here are illustrative and may need updating if the API changes. Always consider [midnight-indexer-api-schema](https://github.com/midnightntwrk/midnight-indexer/blob/main/indexer-api/graphql/schema-v1.graphql) as the primary source of truth. Adjust queries as necessary to match the latest schema. GraphQL Schema[​](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#graphql-schema "Direct link to GraphQL Schema") ------------------------------------------------------------------------------------------------------------------------------------------------ The GraphQL schema is defined in [midnight-indexer-api-schema](https://github.com/midnightntwrk/midnight-indexer/blob/main/indexer-api/graphql/schema-v1.graphql) . It specifies all queries, mutations, subscriptions, and their types, including arguments and return structures. Overview of Operations[​](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#overview-of-operations "Direct link to Overview of Operations") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ * **Queries**: Fetch blocks, transactions, and contract actions. Examples: * Retrieve the latest block or a specific block by hash or height. * Look up transactions by their hash or identifier. * Inspect the current state of a contract action at a given block or transaction offset. * **Mutations**: Manage wallet sessions. * `connect(viewingKey: ViewingKey!)`: Creates a session associated with a viewing key. * `disconnect(sessionId: HexEncoded!)`: Ends a previously established session. * **Subscriptions**: Receive real-time updates. * `blocks`: Stream newly indexed blocks. * `contractActions(address, offset)`: Stream contract actions. * `wallet(sessionId, ...)`: Stream wallet updates, including relevant transactions and optional progress updates. API Endpoints[​](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#api-endpoints "Direct link to API Endpoints") --------------------------------------------------------------------------------------------------------------------------------------------- **HTTP (Queries & Mutations):** POST https://:/api/v1/graphqlContent-Type: application/json **WebSocket (Subscriptions):** wss://:/api/v1/graphql/wsSec-WebSocket-Protocol: graphql-transport-ws Core Scalars[​](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#core-scalars "Direct link to Core Scalars") ------------------------------------------------------------------------------------------------------------------------------------------ * `HexEncoded`: Hex-encoded bytes (for hashes, addresses, session IDs). * `ViewingKey`: A viewing key in hex or Bech32 format for wallet sessions. * `ApplyStage`: Enumerated stages of transaction application. This scalar represents the outcome of transaction processing on the chain ("Success", "PartialSuccess" or "Failure"). * `Unit`: An empty return type for mutations that do not return data. Example Queries and Mutations[​](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#example-queries-and-mutations "Direct link to Example Queries and Mutations") --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- **Note:** These are examples only. Refer to the schema file to confirm exact field names and structures. ### block(offset: BlockOffset): Block[​](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#blockoffset-blockoffset-block "Direct link to block(offset: BlockOffset): Block") **Parameters** (BlockOffset is a oneOf): * `hash: HexEncoded` – The block hash. * `height: Int` – The block height (number). If no offset is provided, the latest block is returned. **Example:** Query by height: query { block(offset: { height: 3 }) { hash height protocolVersion timestamp parent { hash } transactions { hash applyStage } }} ### transactions(offset: TransactionOffset!): \[Transaction!\]![​](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#transactionsoffset-transactionoffset-transaction "Direct link to transactions(offset: TransactionOffset!): [Transaction!]!") Fetch transactions by hash or by identifier using a TransactionOffset object. The offset must include either a hash or an identifier, but not both. Returns an array since a hash may map to multiple related actions. **Example:** query { transactions(offset: { hash: "3031323..." }) { hash protocolVersion merkleTreeRoot block { height hash } identifiers raw contractActions { __typename ... on ContractDeploy { address state chainState } ... on ContractCall { address state entryPoint chainState } ... on ContractUpdate { address state chainState } } }} ### contractAction(address: HexEncoded!, offset: ContractActionOffset): ContractAction[​](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#contractactionaddress-hexencoded-offset-contractactionoffset-contractaction "Direct link to contractAction(address: HexEncoded!, offset: ContractActionOffset): ContractAction") Retrieve the latest known contract action at a given offset (by block or transaction). If no offset is provided, returns the latest state. **Example (latest):** query { contractAction(address: "3031323...") { __typename address state chainState }} **Example (by block height):** query { contractAction( address: "3031323...", offset: { blockOffset: { height: 10 } } ) { __typename address state chainState }} Contract Action Types[​](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#contract-action-types "Direct link to Contract Action Types") --------------------------------------------------------------------------------------------------------------------------------------------------------------------- All ContractAction types (ContractDeploy, ContractCall, ContractUpdate) implement the ContractAction interface with these common fields: * `address`: The contract address (HexEncoded) * `state`: The contract state (HexEncoded) * `chainState`: The chain state at this action (HexEncoded) * `transaction`: The transaction that contains this action Contract actions can be one of three types: * **ContractDeploy**: Initial contract deployment * **ContractCall**: Invocation of a contract's entry point * **ContractUpdate**: State update to an existing contract Each type implements the ContractAction interface but may have additional fields. For example, ContractCall includes an `entryPoint` field and a reference to its associated `deploy`. Mutations[​](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#mutations "Direct link to Mutations") --------------------------------------------------------------------------------------------------------------------------------- Mutations allow the client to connect a wallet (establishing a session) and disconnect it. ### connect(viewingKey: ViewingKey!): HexEncoded![​](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#connectviewingkey-viewingkey-hexencoded "Direct link to connect(viewingKey: ViewingKey!): HexEncoded!") Establishes a session for a given wallet viewing key in **either** bech32m or hex format. Returns the session ID. **Viewing Key Format Support** * **Bech32m** (preferred): A base-32 encoded format with a human-readable prefix, e.g., `mn_shield-esk_dev1...` * **Hex** (fallback): A hex-encoded string representing the key bytes. **Example:** mutation { # Provide the bech32m format: connect(viewingKey: "mn_shield-esk1abcdef...") } **Response:** { "data": { "connect": "sessionIdHere" }} ### disconnect(sessionId: HexEncoded!): Unit![​](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#disconnectsessionid-hexencoded-unit "Direct link to disconnect(sessionId: HexEncoded!): Unit!") Ends an existing session. **Example:** Use this `sessionId` for wallet subscriptions. When done: mutation { disconnect(sessionId: "sessionIdHere")} Subscriptions: Real-time Updates[​](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#subscriptions-real-time-updates "Direct link to Subscriptions: Real-time Updates") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Subscriptions use a WebSocket connection following the [GraphQL over WebSocket](https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md) protocol. After connecting and sending a `connection_init` message, the client can start subscription operations. ### Blocks Subscription[​](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#blocks-subscription "Direct link to Blocks Subscription") `blocks(offset: BlockOffset): Block!` Subscribe to new blocks. The `offset` parameter lets you start receiving from a given block (by height or hash). If omitted, starts from the latest block. **Example:** { "id": "1", "type": "start", "payload": { "query": "subscription { blocks(offset: { height: 10 }) { hash height timestamp transactions { hash } } }" }} When a new block is indexed, the client receives a `next` message. ### Contracts Subscription[​](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#contracts-subscription "Direct link to Contracts Subscription") `contractActions(address: HexEncoded!, offset: BlockOffset): ContractAction!` Subscribes to contract actions for a particular address. New contract actions (calls, updates) are pushed as they occur. **Example:** { "id": "2", "type": "start", "payload": { "query": "subscription { contractActions(address:\"3031323...\", offset: { height: 1 }) { __typename address state } }" }} ### Wallet Subscription[​](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#wallet-subscription "Direct link to Wallet Subscription") `wallet(sessionId: HexEncoded!, index: Int, sendProgressUpdates: Boolean): WalletSyncEvent!` Subscribes to wallet updates. This includes relevant transactions and possibly Merkle tree updates, as well as `ProgressUpdate` events if `sendProgressUpdates` is set to `true`, which is also the default. The `index` parameter can be used to resume from a certain point. Adjust `index` and `offset` arguments as needed. **Example:** { "id": "3", "type": "start", "payload": { "query": "subscription { wallet(sessionId: \"1CYq6ZsLmn\", index: 100) { __typename ... on ViewingUpdate { index update { __typename ... on RelevantTransaction { transaction { hash } } } } ... on ProgressUpdate { highestIndex highestRelevantIndex highestRelevantWalletIndex } } }" }} **Responses** may vary depending on what is happening in the chain: * A `ViewingUpdate` with new relevant transactions or a collapsed Merkle tree update. * A `ProgressUpdate` providing synchronization progress with fields like `highestIndex`, `highestRelevantIndex`, and `highestRelevantWalletIndex`. Query Limits Configuration[​](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#query-limits-configuration "Direct link to Query Limits Configuration") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ The server may apply limitations to queries (e.g. `max-depth`, `max-fields`, `timeout`, and complexity cost). Requests that violate these limits return errors indicating the reason (too many fields, too deep, too costly, or timed out). **Example error:** { "data": null, "errors": [ { "message": "Query has too many fields: 20. Max fields: 10." } ]} Authentication[​](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#authentication "Direct link to Authentication") ------------------------------------------------------------------------------------------------------------------------------------------------ * Wallet subscription requires a `sessionId` from the `connect` mutation. ### Regenerating the Schema[​](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#regenerating-the-schema "Direct link to Regenerating the Schema") If you modify the code defining the GraphQL schema, regenerate it: just generate-indexer-api-schema This ensures the schema file stays aligned with code changes. Conclusion[​](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#conclusion "Direct link to Conclusion") ------------------------------------------------------------------------------------------------------------------------------------ This document offers a few hand-picked examples and an overview of available operations. For the most accurate and comprehensive reference, consult the schema file. As the API evolves, remember to validate these examples against the schema and update them as needed. * [GraphQL Schema](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#graphql-schema) * [Overview of Operations](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#overview-of-operations) * [API Endpoints](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#api-endpoints) * [Core Scalars](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#core-scalars) * [Example Queries and Mutations](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#example-queries-and-mutations) * [block(offset: BlockOffset): Block](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#blockoffset-blockoffset-block) * [transactions(offset: TransactionOffset!): \[Transaction!\]!](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#transactionsoffset-transactionoffset-transaction) * [contractAction(address: HexEncoded!, offset: ContractActionOffset): ContractAction](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#contractactionaddress-hexencoded-offset-contractactionoffset-contractaction) * [Contract Action Types](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#contract-action-types) * [Mutations](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#mutations) * [connect(viewingKey: ViewingKey!): HexEncoded!](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#connectviewingkey-viewingkey-hexencoded) * [disconnect(sessionId: HexEncoded!): Unit!](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#disconnectsessionid-hexencoded-unit) * [Subscriptions: Real-time Updates](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#subscriptions-real-time-updates) * [Blocks Subscription](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#blocks-subscription) * [Contracts Subscription](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#contracts-subscription) * [Wallet Subscription](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#wallet-subscription) * [Query Limits Configuration](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#query-limits-configuration) * [Authentication](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#authentication) * [Regenerating the Schema](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#regenerating-the-schema) * [Conclusion](https://docs.midnight.network/compact/reference/midnight-api/midnight-indexer#conclusion) --- # One doc tagged with "integration" | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/tags/integration#__docusaurus_skipToContent_fallback) [Common SDK integration issues\ -----------------------------](https://docs.midnight.network/sdks/troubleshoot) Troubleshoot common issues when building on Midnight Network. --- # Explicit disclosure | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/explicit_disclosure#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ Introduction[​](https://docs.midnight.network/compact/explicit_disclosure#introduction "Direct link to Introduction") ---------------------------------------------------------------------------------------------------------------------- Midnight supports the development of applications that preserve privacy whenever possible while allowing selective disclosure of private information as necessary. Selective disclosure differs from traditional blockchains, in which everything is public, or strict privacy-preserving blockchains, in which everything is private. Midnight's selective disclosure allows banks, for example, to disclose data required for regulatory purposes while keeping other account information private. The decision to disclose private information, including information derived from private information, must rest with each Midnight DApp because disclosure requirements are inherently situation-specific. However, because private information should be disclosed only as necessary, Midnight's Compact language requires disclosure to be explicitly declared. That is, a Compact program must explicitly declare its intention to disclose data that might be private before storing it in the public ledger, returning it from an exported circuit, or passing it to another contract. This makes privacy the default and disclosure an explicit exception, reducing the risk of accidental disclosure. The contract produced from a Compact program is a zero-knowledge (zk) proof coupled with updates to be made to the public ledger. A zk-proof proves some property about one or more pieces of data, referred to as _witnesses_ or _witness data_, without disclosing anything about the witness data except that the property holds for them. In Compact, witness data comes primarily from external callback functions declared as witnesses in a Compact contract and provided to the contract by a DApp. Witness data can also come into a contract via exported circuit arguments and via the arguments to the contract constructor, if any. Also, any value derived from witness data is also considered to be witness data. Because witness data may contain private information, it should ordinarily be used only for constructing the zk-proof and not disclosed in any way, but exceptions sometimes need to be made. When exceptions are made, the disclosure must be explicitly declared. Explicitly declaring disclosure[​](https://docs.midnight.network/compact/explicit_disclosure#explicitly-declaring-disclosure "Direct link to Explicitly declaring disclosure") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Explicitly declaring intent to disclose witness data in Compact is straightforward, requiring only the addition of a `disclose()` wrapper around any expression whose value may contain witness data to be disclosed, as illustrated by the following trivial program: import CompactStandardLibrary;witness getBalance(): Bytes<32>;export ledger balance: Bytes<32>;export circuit recordRalance(): [] { balance = disclose(getBalance());} Without the `disclose()` wrapper, the compiler rejects the program with an informative error message. For example, attempting to compile this Compact program: import CompactStandardLibrary;witness getBalance(): Bytes<32>;export ledger balance: Bytes<32>;export circuit recordBalance(): [] { balance = getBalance(); // missing disclose() wrapper} causes the compiler to abort with the following error message: Exception: /tmp/q3.compact line 6 char 11: potential witness-value disclosure must be declared but is not: witness value potentially disclosed: the return value of witness getBalance at line 2 char 1 nature of the disclosure: ledger operation might disclose the witness value via this path through the program: the right-hand side of = at line 6 char 11 The error message lists the sources of all witness data disclosed at this point, so the programmer knows that adding a `disclose()` wrapper will declare all of them disclosed. Placing a `disclose()` wrapper does not cause disclosure in itself; in fact, it has no effect other than telling the compiler that it is okay to disclose the value of the wrapped expression. Equivalently, it tells the compiler to pretend that the value of the wrapped expression does not contain witness data whether it actually does or not. Following indirect witness data assignments[​](https://docs.midnight.network/compact/explicit_disclosure#following-indirect-witness-data-assignments "Direct link to Following indirect witness data assignments") ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- In many cases, disclosure is not so direct, yet the requirement to explicitly declare disclosure always holds. For example, obfuscating the disclosure as follows: import CompactStandardLibrary;struct S { x: Field; }witness getBalance(): Bytes<32>;export ledger balance: Bytes<32>;circuit obfuscate(x: Field): Field { // seriously bad obfuscation return x + 73;}export circuit recordBalance(): [] { const s = S { x: getBalance() as Field }; const x = obfuscate(s.x); balance = x as Bytes<32>;} still causes the compiler to abort, with a similar error message: Exception: /tmp/q3.compact line 13 char 11: potential witness-value disclosure must be declared but is not: witness value potentially disclosed: the return value of witness getBalance at line 3 char 1 nature of the disclosure: ledger operation might disclose the result of an addition involving the witness value via this path through the program: the binding of s at line 11 char 3 the argument to obfuscate at line 12 char 13 the computation at line 7 char 10 the binding of x at line 12 char 3 the right-hand side of = at line 13 char 11 In this case, the disclosure, if intentional, can be declared by placing a `disclose()` wrapper around the call to `getBalance()`, around the right-hand-side of the `balance` assignment, or anywhere else along the path from the point of call to the point of disclosure. For example, it could be added to the body of the `obfuscate` circuit around the reference to its argument. import CompactStandardLibrary;struct S { x: Field; }witness getBalance(): Bytes<32>;export ledger balance: Bytes<32>;circuit obfuscate(x: Field): Field { // seriously bad obfuscation return disclose(x) + 73;}export circuit recordBalance(): [] { const s = S { x: getBalance() as Field }; const x = obfuscate(s.x); balance = x as Bytes<32>;} The best practice is most often to put the `disclose()` wrapper as close to the disclosure point as possible to avoid accidental disclosure if the data travels along multiple paths. For a structured value (such as a tuple, vector, or struct), however, the `disclose()` wrapper should be placed only around the portions of the value that are expected to contain witness data to avoid accidental disclosure in the other portions of the value. Also, in the case of a witness that always returns non-private data or private data that has been sufficiently obfuscated via some cryptographically sound mechanism, it makes sense to place the `disclose()` wrapper directly on the call to the witness. Indirect disclosure via conditional expression[​](https://docs.midnight.network/compact/explicit_disclosure#indirect-disclosure-via-conditional-expression "Direct link to Indirect disclosure via conditional expression") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- The preceding example illustrates that subjecting witness data to arithmetic, converting it from one representation to another, and passing it into and out of other circuits does not hide potential disclosure from the compiler. The compiler also detects indirect disclosure via conditional expressions. For example: import CompactStandardLibrary;witness getBalance(): Uint<64>;export circuit balanceExceeds(n: Uint<64>): Boolean { return getBalance() > n;} causes the compiler to abort with the following message: Exception: /tmp/q3.compact line 5 char 3: potential witness-value disclosure must be declared but is not: witness value potentially disclosed: the return value of witness getBalance at line 2 char 1 nature of the disclosure: the value returned from exported circuit balanceExceeds might disclose the result of a comparison involving the witness value via this path through the program: the comparison at line 5 char 10 The message aids the programmer by noting the indirect nature of the disclosure. This example also illustrates that disclosure does not occur just when witness data is stored in the ledger but also when returned from an exported circuit. Safe Compact standard library routines[​](https://docs.midnight.network/compact/explicit_disclosure#safe-compact-standard-library-routines "Direct link to Safe Compact standard library routines") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- The compiler recognizes that certain Compact standard library routines sufficiently disguise witness data so that explicit declaration of disclosure is not required. For an expression `e` whose value contains witness data, the compiler will treat `transientCommit(e)` as if it does not contain witness data, while it will treat `transientHash(e)` as if it does. How explicit disclosure is implemented[​](https://docs.midnight.network/compact/explicit_disclosure#how-explicit-disclosure-is-implemented "Direct link to How explicit disclosure is implemented") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- We refer to the portion of the compiler that detects and reports undeclared disclosure of witness data as the "witness protection program". The witness-protection program is implemented as an _abstract interpreter_, where the abstract values are not actual run-time values but information about witness data that will be contained within the actual run-time values. The abstract interpreter evaluates the program as if the abstract values were actual values. The operations performed by the interpreter are modified, however, to propagate (or not) information about witness data from the operation inputs to the operation outputs. If at some point the interpreter encounters an undeclared disclosure, e.g., a ledger store, of an abstract value containing witness data, the compiler halts and produces an appropriate error message. Conclusion[​](https://docs.midnight.network/compact/explicit_disclosure#conclusion "Direct link to Conclusion") ---------------------------------------------------------------------------------------------------------------- The `disclose()` wrapper in Compact enforces deliberate programming decisions when dealing with potentially sensitive private witness data and data derived from private information. Explicit disclosure requires Compact program assignments to declare an intention to use data that might be private before storing it in the public ledger, returning it from an exported circuit, or passing it to another contract. This makes privacy the default and disclosure an explicit exception, reducing the risk of accidental disclosure. * [Introduction](https://docs.midnight.network/compact/explicit_disclosure#introduction) * [Explicitly declaring disclosure](https://docs.midnight.network/compact/explicit_disclosure#explicitly-declaring-disclosure) * [Following indirect witness data assignments](https://docs.midnight.network/compact/explicit_disclosure#following-indirect-witness-data-assignments) * [Indirect disclosure via conditional expression](https://docs.midnight.network/compact/explicit_disclosure#indirect-disclosure-via-conditional-expression) * [Safe Compact standard library routines](https://docs.midnight.network/compact/explicit_disclosure#safe-compact-standard-library-routines) * [How explicit disclosure is implemented](https://docs.midnight.network/compact/explicit_disclosure#how-explicit-disclosure-is-implemented) * [Conclusion](https://docs.midnight.network/compact/explicit_disclosure#conclusion) --- # ZSwap API | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • Readme | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * Zswap TypeScript API ==================== This document outlines the usage of the Zswap TS API Network ID[​](https://docs.midnight.network/api-reference/zswap#network-id "Direct link to Network ID") -------------------------------------------------------------------------------------------------------- Prior to any interaction, setNetworkId should be used to set the [NetworkId](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) to target the correct network. Proof stages[​](https://docs.midnight.network/api-reference/zswap#proof-stages "Direct link to Proof stages") -------------------------------------------------------------------------------------------------------------- Most transaction components will be in one of three stages: `X`, `UnprovenX`, or `ProofErasedX`. The `UnprovenX` stage is _always_ the first one. It is possible to transition to the `X` stage by proving an `UnprovenTransaction` through the proof server. For testing, and where proofs aren't necessary, the `ProofErasedX` stage is used, which can be reached via `eraseProof[s]` from the other two stages. Transaction structure[​](https://docs.midnight.network/api-reference/zswap#transaction-structure "Direct link to Transaction structure") ----------------------------------------------------------------------------------------------------------------------------------------- A [Transaction](https://docs.midnight.network/api-reference/zswap/classes/Transaction) runs in two phases: a _guaranteed_ phase, handling fee payments and fast-to-verify operations, and a _fallible_ phase, handling operations which may fail atomically, separately from the guaranteed phase. It therefore contains: * A "guaranteed" [Offer](https://docs.midnight.network/api-reference/zswap/classes/Offer) * Optionally, a "fallible" [Offer](https://docs.midnight.network/api-reference/zswap/classes/Offer) * Contract call information not accessible to this API It also contains additional cryptographic glue that will be omitted in this document. ### Zswap[​](https://docs.midnight.network/api-reference/zswap#zswap "Direct link to Zswap") A Zswap [Offer](https://docs.midnight.network/api-reference/zswap/classes/Offer) consists of: * A set of [Input](https://docs.midnight.network/api-reference/zswap/classes/Input) s, burning coins. * A set of [Output](https://docs.midnight.network/api-reference/zswap/classes/Output) s, creating coins. * A set of [Transient](https://docs.midnight.network/api-reference/zswap/classes/Transient) s, indicating a coin that is created and burnt in the same transaction. * A mapping from [TokenType](https://docs.midnight.network/api-reference/zswap/type-aliases/TokenType) s to offer balance, positive when there are more inputs than outputs and vice versa. [Input](https://docs.midnight.network/api-reference/zswap/classes/Input) s can be created either from a [QualifiedCoinInfo](https://docs.midnight.network/api-reference/zswap/type-aliases/QualifiedCoinInfo) and a contract address, if the coin is contract-owned, or from a [QualifiedCoinInfo](https://docs.midnight.network/api-reference/zswap/type-aliases/QualifiedCoinInfo) and a ZswapLocalState, if it is user-owned. Similarly, [Output](https://docs.midnight.network/api-reference/zswap/classes/Output) s can be created from a [CoinInfo](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinInfo) and a contract address for contract-owned coins, or from a [CoinInfo](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinInfo) and a user's public key(s), if it is user-owned. A [Transient](https://docs.midnight.network/api-reference/zswap/classes/Transient) is created similarly to a [Input](https://docs.midnight.network/api-reference/zswap/classes/Input) , but directly converts an existing [Output](https://docs.midnight.network/api-reference/zswap/classes/Output) . A [QualifiedCoinInfo](https://docs.midnight.network/api-reference/zswap/type-aliases/QualifiedCoinInfo) is a [CoinInfo](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinInfo) with an index into the Merkle tree of coin commitments that can be used to find the relevant coin to spend, while a [CoinInfo](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinInfo) consists of a coins [TokenType](https://docs.midnight.network/api-reference/zswap/type-aliases/TokenType) , value, and a nonce. State Structure[​](https://docs.midnight.network/api-reference/zswap#state-structure "Direct link to State Structure") ----------------------------------------------------------------------------------------------------------------------- [ZswapChainState](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState) holds the on-chain state of Zswap, while ZswaplocalState contains the local, wallet state. * [Network ID](https://docs.midnight.network/api-reference/zswap#network-id) * [Proof stages](https://docs.midnight.network/api-reference/zswap#proof-stages) * [Transaction structure](https://docs.midnight.network/api-reference/zswap#transaction-structure) * [Zswap](https://docs.midnight.network/api-reference/zswap#zswap) * [State Structure](https://docs.midnight.network/api-reference/zswap#state-structure) --- # createCoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/functions/createCoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / createCoinInfo Function: createCoinInfo() ========================== createCoinInfo(type_, value): CoinInfo Creates a new [CoinInfo](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinInfo) , sampling a uniform nonce Parameters[​](https://docs.midnight.network/api-reference/zswap/functions/createCoinInfo#parameters "Direct link to Parameters") --------------------------------------------------------------------------------------------------------------------------------- • **type\_**: `string` • **value**: `bigint` Returns[​](https://docs.midnight.network/api-reference/zswap/functions/createCoinInfo#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------ [`CoinInfo`](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinInfo) * [Parameters](https://docs.midnight.network/api-reference/zswap/functions/createCoinInfo#parameters) * [Returns](https://docs.midnight.network/api-reference/zswap/functions/createCoinInfo#returns) --- # nativeToken | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/functions/nativeToken#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / nativeToken Function: nativeToken() ======================= nativeToken(): TokenType The base/system token type Returns[​](https://docs.midnight.network/api-reference/zswap/functions/nativeToken#returns "Direct link to Returns") --------------------------------------------------------------------------------------------------------------------- [`TokenType`](https://docs.midnight.network/api-reference/zswap/type-aliases/TokenType) * [Returns](https://docs.midnight.network/api-reference/zswap/functions/nativeToken#returns) --- # sampleContractAddress | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/functions/sampleContractAddress#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / sampleContractAddress Function: sampleContractAddress() ================================= sampleContractAddress(): ContractAddress Samples a uniform contract address, for use in testing Returns[​](https://docs.midnight.network/api-reference/zswap/functions/sampleContractAddress#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------------- [`ContractAddress`](https://docs.midnight.network/api-reference/zswap/type-aliases/ContractAddress) * [Returns](https://docs.midnight.network/api-reference/zswap/functions/sampleContractAddress#returns) --- # sampleTokenType | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/functions/sampleTokenType#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / sampleTokenType Function: sampleTokenType() =========================== sampleTokenType(): TokenType Samples a uniform token type, for use in testing Returns[​](https://docs.midnight.network/api-reference/zswap/functions/sampleTokenType#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------- [`TokenType`](https://docs.midnight.network/api-reference/zswap/type-aliases/TokenType) * [Returns](https://docs.midnight.network/api-reference/zswap/functions/sampleTokenType#returns) --- # 4 docs tagged with "sdk" | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/tags/sdk#__docusaurus_skipToContent_fallback) [Common SDK integration issues\ -----------------------------](https://docs.midnight.network/sdks/troubleshoot) Troubleshoot common issues when building on Midnight Network. [Midnight SDKs\ -------------](https://docs.midnight.network/sdks) Build privacy-preserving decentralized applications with Midnight's comprehensive SDK ecosystem. Whether you're creating smart contracts, wallets, or full-stack DApps, we have the tools you need. [Midnight wallet - developer guide\ ---------------------------------](https://docs.midnight.network/sdks/official/wallet-developer-guide) Developer guide for the Midnight wallet SDK. [Midnight.js\ -----------](https://docs.midnight.network/sdks/official/midnight-js) Comprehensive TypeScript SDK for building DApps on Midnight Network. --- # sampleCoinPublicKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/functions/sampleCoinPublicKey#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / sampleCoinPublicKey Function: sampleCoinPublicKey() =============================== sampleCoinPublicKey(): CoinPublicKey Samples a dummy user coin public key, for use in testing Returns[​](https://docs.midnight.network/api-reference/zswap/functions/sampleCoinPublicKey#returns "Direct link to Returns") ----------------------------------------------------------------------------------------------------------------------------- [`CoinPublicKey`](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinPublicKey) * [Returns](https://docs.midnight.network/api-reference/zswap/functions/sampleCoinPublicKey#returns) --- # Detailed API reference | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/compact-std-library/exports#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ Structs[​](https://docs.midnight.network/compact/compact-std-library/exports#structs "Direct link to Structs") --------------------------------------------------------------------------------------------------------------- ### `Maybe`[​](https://docs.midnight.network/compact/compact-std-library/exports#maybe "Direct link to maybe") Encapsulates an optionally present value. If `isSome` is `false`, `value` should be `default` by convention. struct Maybe { isSome: Boolean; value: T;} ### `Either`[​](https://docs.midnight.network/compact/compact-std-library/exports#either "Direct link to either") Disjoint union of `A` and `B`. Iff `isLeft` if `true`, `left` should be populated, otherwise `right`. The other should be `default< >` by convention. struct Either { isLeft: Boolean; left: A; right: B;} ### `CurvePoint`[​](https://docs.midnight.network/compact/compact-std-library/exports#curvepoint "Direct link to curvepoint") A point on the proof systems embedded curve, in affine coordinates. Only outputs of elliptic curve operations are actually guaranteed to lie on the curve. struct CurvePoint { x: Field; y: Field;} ### `MerkleTreeDigest`[​](https://docs.midnight.network/compact/compact-std-library/exports#merkletreedigest "Direct link to merkletreedigest") The root hash of a Merkle tree, represented by a single `Field`. struct MerkleTreeDigest { field: Field; } ### `MerkleTreePathEntry`[​](https://docs.midnight.network/compact/compact-std-library/exports#merkletreepathentry "Direct link to merkletreepathentry") An entry in a Merkle tree path, indicating if the path leads left or right, and the root of the sibling node. Primarily used in [`MerkleTreePath`](https://docs.midnight.network/compact/compact-std-library/exports#merkletreepath) struct MerkleTreePathEntry { sibling: MerkleTreeDigest; goesLeft: Boolean;} ### `MerkleTreePath`[​](https://docs.midnight.network/compact/compact-std-library/exports#merkletreepath "Direct link to merkletreepath") A path in a depth `n` Merkle tree, leading to a leaf of type `T`. Primarily used for [`merkleTreePathRoot`](https://docs.midnight.network/compact/compact-std-library/exports#merkletreepathroot) . This can be constructed from `witness`es that use the compiler output's `findPathForLeaf` and `pathForLeaf` functions. struct MerkleTreePath<#n, T> { leaf: T; path: Vector;} ### `ContractAddress`[​](https://docs.midnight.network/compact/compact-std-library/exports#contractaddress "Direct link to contractaddress") The address of a contract, used as a recipient in [`send`](https://docs.midnight.network/compact/compact-std-library/exports#send) , [`sendImmediate`](https://docs.midnight.network/compact/compact-std-library/exports#sendimmediate) , [`createZswapOutput`](https://docs.midnight.network/compact/compact-std-library/exports#createzswapoutput) , and [`mintToken`](https://docs.midnight.network/compact/compact-std-library/exports#minttoken) . struct ContractAddress { bytes: Bytes<32>; } ### `CoinInfo`[​](https://docs.midnight.network/compact/compact-std-library/exports#coininfo "Direct link to coininfo") The description of a newly created shielded coin, used in outputting shielded coins, or spending/receiving shielded coins that originate in the current transaction. `nonce` can be deterministically derived with [`evolveNonce`](https://docs.midnight.network/compact/compact-std-library/exports#evolvenonce) . Used in: * [`receive`](https://docs.midnight.network/compact/compact-std-library/exports#receive) * [`sendImmediate`](https://docs.midnight.network/compact/compact-std-library/exports#sendimmediate) * [`mergeCoin`](https://docs.midnight.network/compact/compact-std-library/exports#mergecoin) * [`mergeCoinImmediate`](https://docs.midnight.network/compact/compact-std-library/exports#mergecoinimmediate) * [`createZswapOutput`](https://docs.midnight.network/compact/compact-std-library/exports#createzswapoutput) struct CoinInfo { nonce: Bytes<32>; color: Bytes<32>; value: Uint<128>;} ### `QualifiedCoinInfo`[​](https://docs.midnight.network/compact/compact-std-library/exports#qualifiedcoininfo "Direct link to qualifiedcoininfo") The description of an existing shielded coin in the ledger, ready to be spent. Used in: * [`send`](https://docs.midnight.network/compact/compact-std-library/exports#send) * [`mergeCoin`](https://docs.midnight.network/compact/compact-std-library/exports#mergecoin) * [`mergeCoinImmediate`](https://docs.midnight.network/compact/compact-std-library/exports#mergecoinimmediate) * [`createZswapInput`](https://docs.midnight.network/compact/compact-std-library/exports#createzswapinput) struct QualifiedCoinInfo { nonce: Bytes<32>; color: Bytes<32>; value: Uint<128>; mtIndex: Uint<64>;} ### `ZswapCoinPublicKey`[​](https://docs.midnight.network/compact/compact-std-library/exports#zswapcoinpublickey "Direct link to zswapcoinpublickey") The public key used to output a [`CoinInfo`](https://docs.midnight.network/compact/compact-std-library/exports#coininfo) to a user, used as a recipient in [`send`](https://docs.midnight.network/compact/compact-std-library/exports#send) , [`sendImmediate`](https://docs.midnight.network/compact/compact-std-library/exports#sendimmediate) , and [`createZswapOutput`](https://docs.midnight.network/compact/compact-std-library/exports#createzswapoutput) . struct ZswapCoinPublicKey { bytes: Bytes<32>; } ### `SendResult`[​](https://docs.midnight.network/compact/compact-std-library/exports#sendresult "Direct link to sendresult") The output of [`send`](https://docs.midnight.network/compact/compact-std-library/exports#send) and [`sendImmediate`](https://docs.midnight.network/compact/compact-std-library/exports#sendimmediate) , detailing the created shielded coin, and the change from spending the input, if applicable. struct SendResult { change: Maybe; sent: CoinInfo;} Circuits[​](https://docs.midnight.network/compact/compact-std-library/exports#circuits "Direct link to Circuits") ------------------------------------------------------------------------------------------------------------------ ### `some`[​](https://docs.midnight.network/compact/compact-std-library/exports#some "Direct link to some") Constructs a [`Maybe`](https://docs.midnight.network/compact/compact-std-library/exports#maybe) containing an element of type `T` circuit some(value: T): Maybe; ### `none`[​](https://docs.midnight.network/compact/compact-std-library/exports#none "Direct link to none") Constructs a [`Maybe`](https://docs.midnight.network/compact/compact-std-library/exports#maybe) containing nothing circuit none(): Maybe; ### `left`[​](https://docs.midnight.network/compact/compact-std-library/exports#left "Direct link to left") Construct an [`Either`](https://docs.midnight.network/compact/compact-std-library/exports#either) containing the `A` item of the disjoint union circuit left(value: A): Either; ### `right`[​](https://docs.midnight.network/compact/compact-std-library/exports#right "Direct link to right") Constructs an [`Either`](https://docs.midnight.network/compact/compact-std-library/exports#either) containing the `B` item of the disjoint union circuit right(value: B): Either; ### `transientHash`[​](https://docs.midnight.network/compact/compact-std-library/exports#transienthash "Direct link to transienthash") Builtin transient hash compression function This function is a circuit-efficient compression function from arbitrary values to field elements, which is not guaranteed to persist between upgrades. It should not be used to derive state data, but can be used for consistency checks. Although this function returns a hash of its inputs, it is not considered sufficient to protect its input from disclosure. If its input contains any value returned from a witness, the program must acknowledge disclosure (via a `disclose` wrapper) if the result can be stored in the public ledger, returned from an exported circuit, or passed to another contract via a cross-contract call. circuit transientHash(value: T): Field; ### `transientCommit`[​](https://docs.midnight.network/compact/compact-std-library/exports#transientcommit "Direct link to transientcommit") Builtin transient commitment function This function is a circuit-efficient commitment function over arbitrary types, and a field element commitment opening, to field elements, which is not guaranteed to persist between upgrades. It should not be used to derive state data, but can be used for consistency checks. Unlike `transientHash`, this function is considered sufficient to protect its input from disclosure, under the assumption that the `rand` argument is sufficiently random. Thus, even if its input contains a value or values returned from one or more witnesses, the program need not acknowledge disclosure (via a `disclose` wrapper) if the result can be stored in the public ledger, returned from an exported circuit, or passed to another contract via a cross-contract call. circuit transientCommit(value: T, rand: Field): Field; ### `persistentHash`[​](https://docs.midnight.network/compact/compact-std-library/exports#persistenthash "Direct link to persistenthash") Builtin persistent hash compression function This function is a non-circuit-optimised compression function from arbitrary values to a 256-bit bytestring. It is guaranteed to persist between upgrades, and to consistently use the SHA-256 compression algorithm. It _should_ be used to derive state data, and not for consistency checks where avoidable. The note about disclosing under `transientHash` also applies to this function. circuit persistentHash(value: T): Bytes<32>; ### `persistentCommit`[​](https://docs.midnight.network/compact/compact-std-library/exports#persistentcommit "Direct link to persistentcommit") Builtin persistent commitment function This function is a non-circuit-optimised commitment function from arbitrary values representable in Compact, and a 256-bit bytestring opening, to a 256-bit bytestring. It is guaranteed to persist between upgrades, and use the SHA-256 compression algorithm. It _should_ be used to derive state data, and not for consistency checks where avoidable. The note about disclosing under `transientCommit` also applies to this function. circuit persistentCommit(value: T, rand: Bytes<32>): Bytes<32>; ### `degradeToTransient`[​](https://docs.midnight.network/compact/compact-std-library/exports#degradetotransient "Direct link to degradetotransient") This function "degrades" the output of a [`persistentHash`](https://docs.midnight.network/compact/compact-std-library/exports#persistenthash) or [`persistentCommit`](https://docs.midnight.network/compact/compact-std-library/exports#persistentcommit) to a field element, which can then be used in [`transientHash`](https://docs.midnight.network/compact/compact-std-library/exports#transienthash) or [`transientCommit`](https://docs.midnight.network/compact/compact-std-library/exports#transientcommit) . circuit degradeToTransient(x: Bytes<32>) : Field; ### `upgradeFromTransient`[​](https://docs.midnight.network/compact/compact-std-library/exports#upgradefromtransient "Direct link to upgradefromtransient") This function "upgrades" a field element to the output of a [`persistentHash`](https://docs.midnight.network/compact/compact-std-library/exports#persistenthash) or [`persistentCommit`](https://docs.midnight.network/compact/compact-std-library/exports#persistentcommit) . circuit upgradeFromTransient(x: Field): Bytes<32>; ### `ecAdd`[​](https://docs.midnight.network/compact/compact-std-library/exports#ecadd "Direct link to ecadd") This function add two elliptic [`CurvePoint`](https://docs.midnight.network/compact/compact-std-library/exports#curvepoint) s (in multiplicative notation) circuit ecAdd(a: CurvePoint, b: CurvePoint): CurvePoint; ### `ecMul`[​](https://docs.midnight.network/compact/compact-std-library/exports#ecmul "Direct link to ecmul") This function multiplies an elliptic [`CurvePoint`](https://docs.midnight.network/compact/compact-std-library/exports#curvepoint) by a scalar (in multiplicative notation) circuit ecMul(a: CurvePoint, b: Field): CurvePoint; ### `ecMulGenerator`[​](https://docs.midnight.network/compact/compact-std-library/exports#ecmulgenerator "Direct link to ecmulgenerator") This function multiplies the primary group generator of the embedded curve by a scalar (in multiplicative notation) circuit ecMulGenerator(b: Field): CurvePoint; ### `hashToCurve`[​](https://docs.midnight.network/compact/compact-std-library/exports#hashtocurve "Direct link to hashtocurve") This function maps arbitrary types to [`CurvePoint`](https://docs.midnight.network/compact/compact-std-library/exports#curvepoint) s. Outputs are guaranteed to have unknown discrete logarithm with respect to the group base, and any other output, but are not guaranteed to be unique (a given input can be proven correct for multiple outputs). Inputs of different types `T` may have the same output, if they have the same field-aligned binary representation. circuit hashToCurve(value: T): CurvePoint; ### `merkleTreePathRoot`[​](https://docs.midnight.network/compact/compact-std-library/exports#merkletreepathroot "Direct link to merkletreepathroot") Derives the Merkle tree root of a [`MerkleTreePath`](https://docs.midnight.network/compact/compact-std-library/exports#merkletreepath) , which should match the root of the tree that this path originated from. circuit merkleTreePathRoot<#n, T>(path: MerkleTreePath): MerkleTreeDigest; ### `merkleTreePathRootNoLeafHash`[​](https://docs.midnight.network/compact/compact-std-library/exports#merkletreepathrootnoleafhash "Direct link to merkletreepathrootnoleafhash") Derives the Merkle tree root of a [`MerkleTreePath`](https://docs.midnight.network/compact/compact-std-library/exports#merkletreepath) , which should match the root of the tree that this path originated from. As opposed to [`merkleTreePathRoot`](https://docs.midnight.network/compact/compact-std-library/exports#merkletreepathroot) , this variant assumes that the tree leaves have already been hashed externally. circuit merkleTreePathRootNoLeafHash<#n>(path: MerkleTreePath>): MerkleTreeDigest; ### `nativeToken`[​](https://docs.midnight.network/compact/compact-std-library/exports#nativetoken "Direct link to nativetoken") Returns the token type of the native token circuit nativeToken(): Bytes<32>; ### `tokenType`[​](https://docs.midnight.network/compact/compact-std-library/exports#tokentype "Direct link to tokentype") Transforms a domain separator for the given contract into a globally namespaced token type. A contract can issue tokens for its domain separators, which lets it create new tokens, but due to collision resistance, it cannot mint tokens for another contract's token type. This is used as the `color` field in [`CoinInfo`](https://docs.midnight.network/compact/compact-std-library/exports#coininfo) . circuit tokenType(domainSep: Bytes<32>, contract: ContractAddress): Bytes<32>; ### `mintToken`[​](https://docs.midnight.network/compact/compact-std-library/exports#minttoken "Direct link to minttoken") Creates a new shielded coin, minted by this contract, and sends it to the given recipient. Returns the corresponding [`CoinInfo`](https://docs.midnight.network/compact/compact-std-library/exports#coininfo) . This requires inputting a unique nonce to function securely, it is left to the user how to produce this. circuit mintToken( domainSep: Bytes<32>, value: Uint<128>, nonce: Bytes<32>, recipient: Either): CoinInfo; ### `evolveNonce`[​](https://docs.midnight.network/compact/compact-std-library/exports#evolvenonce "Direct link to evolvenonce") Deterministically derives a [`CoinInfo`](https://docs.midnight.network/compact/compact-std-library/exports#coininfo) nonce from a counter index, and a prior nonce. circuit evolveNonce( index: Uint<64>, nonce: Bytes<32>): Bytes<32>; ### `burnAddress`[​](https://docs.midnight.network/compact/compact-std-library/exports#burnaddress "Direct link to burnaddress") Returns a payment address that guarantees any shielded coins sent to it are burned. circuit burnAddress(): Either; ### `receive`[​](https://docs.midnight.network/compact/compact-std-library/exports#receive "Direct link to receive") Receives a shielded coin, adding a validation condition requiring this coin to be present as an output addressed to this contract, and not received by another call circuit receive(coin: CoinInfo): []; ### `send`[​](https://docs.midnight.network/compact/compact-std-library/exports#send "Direct link to send") Sends given value from a shielded coin owned by the contract to a recipient. Any change is returned and should be managed by the contract. Note that this does not currently create coin ciphertexts, so sending to a user public key except for the current user will not lead to this user being informed of the coin they've been sent. circuit send(input: QualifiedCoinInfo, recipient: Either, value: Uint<128>): SendResult; ### `sendImmediate`[​](https://docs.midnight.network/compact/compact-std-library/exports#sendimmediate "Direct link to sendimmediate") Like [`send`](https://docs.midnight.network/compact/compact-std-library/exports#send) , but for coins created within this transaction circuit sendImmediate(input: CoinInfo, target: Either, value: Uint<128>): SendResult; ### `mergeCoin`[​](https://docs.midnight.network/compact/compact-std-library/exports#mergecoin "Direct link to mergecoin") Takes two coins stored on the ledger, and combines them into one circuit mergeCoin(a: QualifiedCoinInfo, b: QualifiedCoinInfo): CoinInfo; ### `mergeCoinImmediate`[​](https://docs.midnight.network/compact/compact-std-library/exports#mergecoinimmediate "Direct link to mergecoinimmediate") Takes one coin stored on the ledger, and one created within this transaction, and combines them into one circuit mergeCoinImmediate(a: QualifiedCoinInfo, b: CoinInfo): CoinInfo; ### `ownPublicKey`[​](https://docs.midnight.network/compact/compact-std-library/exports#ownpublickey "Direct link to ownpublickey") Returns the [`ZswapCoinPublicKey`](https://docs.midnight.network/compact/compact-std-library/exports#zswapcoinpublickey) of the end-user creating this transaction. circuit ownPublicKey(): ZswapCoinPublicKey; ### `createZswapInput`[​](https://docs.midnight.network/compact/compact-std-library/exports#createzswapinput "Direct link to createzswapinput") Notifies the context to create a new Zswap input originating from this call. Should typically not be called manually, prefer [`send`](https://docs.midnight.network/compact/compact-std-library/exports#send) and [`sendImmediate`](https://docs.midnight.network/compact/compact-std-library/exports#sendimmediate) instead. The note about disclosing under `transientHash` also applies to this function. circuit createZswapInput(coin: QualifiedCoinInfo): []; ### `createZswapOutput`[​](https://docs.midnight.network/compact/compact-std-library/exports#createzswapoutput "Direct link to createzswapoutput") Notifies the context to create a new Zswap output originating from this call. Should typically not be called manually, prefer [`send`](https://docs.midnight.network/compact/compact-std-library/exports#send) and [`sendImmediate`](https://docs.midnight.network/compact/compact-std-library/exports#sendimmediate) , and [`receive`](https://docs.midnight.network/compact/compact-std-library/exports#receive) instead. The note about disclosing under `transientHash` also applies to this function. circuit createZswapOutput(coin: CoinInfo, recipient: Either): []; ### `blockTimeLt`[​](https://docs.midnight.network/compact/compact-std-library/exports#blocktimelt "Direct link to blocktimelt") Returns true if the current block time is less than the given value. circuit blockTimeLt(time: Uint<64>): Boolean; ### `blockTimeGte`[​](https://docs.midnight.network/compact/compact-std-library/exports#blocktimegte "Direct link to blocktimegte") Returns true if the current block time is greater than or equal to the given value. circuit blockTimeGte(time: Uint<64>): Boolean; ### `blockTimeGt`[​](https://docs.midnight.network/compact/compact-std-library/exports#blocktimegt "Direct link to blocktimegt") Returns true if the current block time is greater than the given value. circuit blockTimeGt(time: Uint<64>): Boolean; ### `blockTimeLte`[​](https://docs.midnight.network/compact/compact-std-library/exports#blocktimelte "Direct link to blocktimelte") Returns true if the current block time is less than or equal to the given value. circuit blockTimeLte(time: Uint<64>): Boolean; * [Structs](https://docs.midnight.network/compact/compact-std-library/exports#structs) * [`Maybe`](https://docs.midnight.network/compact/compact-std-library/exports#maybe) * [`Either`](https://docs.midnight.network/compact/compact-std-library/exports#either) * [`CurvePoint`](https://docs.midnight.network/compact/compact-std-library/exports#curvepoint) * [`MerkleTreeDigest`](https://docs.midnight.network/compact/compact-std-library/exports#merkletreedigest) * [`MerkleTreePathEntry`](https://docs.midnight.network/compact/compact-std-library/exports#merkletreepathentry) * [`MerkleTreePath`](https://docs.midnight.network/compact/compact-std-library/exports#merkletreepath) * [`ContractAddress`](https://docs.midnight.network/compact/compact-std-library/exports#contractaddress) * [`CoinInfo`](https://docs.midnight.network/compact/compact-std-library/exports#coininfo) * [`QualifiedCoinInfo`](https://docs.midnight.network/compact/compact-std-library/exports#qualifiedcoininfo) * [`ZswapCoinPublicKey`](https://docs.midnight.network/compact/compact-std-library/exports#zswapcoinpublickey) * [`SendResult`](https://docs.midnight.network/compact/compact-std-library/exports#sendresult) * [Circuits](https://docs.midnight.network/compact/compact-std-library/exports#circuits) * [`some`](https://docs.midnight.network/compact/compact-std-library/exports#some) * [`none`](https://docs.midnight.network/compact/compact-std-library/exports#none) * [`left`](https://docs.midnight.network/compact/compact-std-library/exports#left) * [`right`](https://docs.midnight.network/compact/compact-std-library/exports#right) * [`transientHash`](https://docs.midnight.network/compact/compact-std-library/exports#transienthash) * [`transientCommit`](https://docs.midnight.network/compact/compact-std-library/exports#transientcommit) * [`persistentHash`](https://docs.midnight.network/compact/compact-std-library/exports#persistenthash) * [`persistentCommit`](https://docs.midnight.network/compact/compact-std-library/exports#persistentcommit) * [`degradeToTransient`](https://docs.midnight.network/compact/compact-std-library/exports#degradetotransient) * [`upgradeFromTransient`](https://docs.midnight.network/compact/compact-std-library/exports#upgradefromtransient) * [`ecAdd`](https://docs.midnight.network/compact/compact-std-library/exports#ecadd) * [`ecMul`](https://docs.midnight.network/compact/compact-std-library/exports#ecmul) * [`ecMulGenerator`](https://docs.midnight.network/compact/compact-std-library/exports#ecmulgenerator) * [`hashToCurve`](https://docs.midnight.network/compact/compact-std-library/exports#hashtocurve) * [`merkleTreePathRoot`](https://docs.midnight.network/compact/compact-std-library/exports#merkletreepathroot) * [`merkleTreePathRootNoLeafHash`](https://docs.midnight.network/compact/compact-std-library/exports#merkletreepathrootnoleafhash) * [`nativeToken`](https://docs.midnight.network/compact/compact-std-library/exports#nativetoken) * [`tokenType`](https://docs.midnight.network/compact/compact-std-library/exports#tokentype) * [`mintToken`](https://docs.midnight.network/compact/compact-std-library/exports#minttoken) * [`evolveNonce`](https://docs.midnight.network/compact/compact-std-library/exports#evolvenonce) * [`burnAddress`](https://docs.midnight.network/compact/compact-std-library/exports#burnaddress) * [`receive`](https://docs.midnight.network/compact/compact-std-library/exports#receive) * [`send`](https://docs.midnight.network/compact/compact-std-library/exports#send) * [`sendImmediate`](https://docs.midnight.network/compact/compact-std-library/exports#sendimmediate) * [`mergeCoin`](https://docs.midnight.network/compact/compact-std-library/exports#mergecoin) * [`mergeCoinImmediate`](https://docs.midnight.network/compact/compact-std-library/exports#mergecoinimmediate) * [`ownPublicKey`](https://docs.midnight.network/compact/compact-std-library/exports#ownpublickey) * [`createZswapInput`](https://docs.midnight.network/compact/compact-std-library/exports#createzswapinput) * [`createZswapOutput`](https://docs.midnight.network/compact/compact-std-library/exports#createzswapoutput) * [`blockTimeLt`](https://docs.midnight.network/compact/compact-std-library/exports#blocktimelt) * [`blockTimeGte`](https://docs.midnight.network/compact/compact-std-library/exports#blocktimegte) * [`blockTimeGt`](https://docs.midnight.network/compact/compact-std-library/exports#blocktimegt) * [`blockTimeLte`](https://docs.midnight.network/compact/compact-std-library/exports#blocktimelte) --- # EncPublicKeyLegacy | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/type-aliases/EncPublicKeyLegacy#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / EncPublicKeyLegacy Type alias: EncPublicKeyLegacy ============================== type EncPublicKeyLegacy: string; 35 byte hex string --- # CoinPublicKeyLegacy | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/type-aliases/CoinPublicKeyLegacy#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / CoinPublicKeyLegacy Type alias: CoinPublicKeyLegacy =============================== type CoinPublicKeyLegacy: string; Hex-encoded 32-byte byte string Remarks[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/CoinPublicKeyLegacy#remarks "Direct link to Remarks") ------------------------------------------------------------------------------------------------------------------------------------- A coin public key is a public key used to identify the wallet. * [Remarks](https://docs.midnight.network/api-reference/wallet-api/type-aliases/CoinPublicKeyLegacy#remarks) --- # Address | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/type-aliases/Address#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / Address Type alias: Address =================== type Address: string; Bech32m encoded address --- # AddressLegacy | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/type-aliases/AddressLegacy#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / AddressLegacy Type alias: AddressLegacy ========================= type AddressLegacy: string; Concatenated Hex-encoded byte string Remarks[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/AddressLegacy#remarks "Direct link to Remarks") ------------------------------------------------------------------------------------------------------------------------------- CoinPublicKey (32 byte hex string), EncryptionPublicKey (35 byte hex string) concatenated by "|" * [Remarks](https://docs.midnight.network/api-reference/wallet-api/type-aliases/AddressLegacy#remarks) --- # CoinPublicKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/type-aliases/CoinPublicKey#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / CoinPublicKey Type alias: CoinPublicKey ========================= type CoinPublicKey: string; Bech32m encoded CoinPublicKey --- # TransactionHash | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHash#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / TransactionHash Type alias: TransactionHash =========================== type TransactionHash: string; Hex-encoded 32-byte bytes string Remarks[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHash#remarks "Direct link to Remarks") --------------------------------------------------------------------------------------------------------------------------------- A transaction hash is a unique identifier of a transaction, which is used to distinguish it in the network. * [Remarks](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHash#remarks) --- # NothingToProve | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/type-aliases/NothingToProve#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / NothingToProve Type alias: NothingToProve ========================== type NothingToProve: { transaction: Transaction; type: typeof NOTHING_TO_PROVE;}; No-Op transaction data for proving Remarks[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/NothingToProve#remarks "Direct link to Remarks") -------------------------------------------------------------------------------------------------------------------------------- balanceTransaction API allows passing already balanced and proved transaction. NothingToProve is designed to mark this special case and can be passed further to proveTransaction endpoint without a risk of executing unnecessary proving process, and without disturbing transaction flow with supporting special cases Type declaration[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/NothingToProve#type-declaration "Direct link to Type declaration") ----------------------------------------------------------------------------------------------------------------------------------------------------------- ### transaction[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/NothingToProve#transaction "Direct link to transaction") readonly transaction: Transaction; Original transaction ### type[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/NothingToProve#type "Direct link to type") readonly type: typeof NOTHING_TO_PROVE; Used to identify the transaction type * [Remarks](https://docs.midnight.network/api-reference/wallet-api/type-aliases/NothingToProve#remarks) * [Type declaration](https://docs.midnight.network/api-reference/wallet-api/type-aliases/NothingToProve#type-declaration) * [transaction](https://docs.midnight.network/api-reference/wallet-api/type-aliases/NothingToProve#transaction) * [type](https://docs.midnight.network/api-reference/wallet-api/type-aliases/NothingToProve#type) --- # SyncLag | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/type-aliases/SyncLag#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / SyncLag Type alias: SyncLag =================== type SyncLag: { applyGap: bigint; sourceGap: bigint;}; Lag of the wallet syncing process. Type declaration[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/SyncLag#type-declaration "Direct link to Type declaration") ---------------------------------------------------------------------------------------------------------------------------------------------------- ### applyGap[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/SyncLag#applygap "Direct link to applyGap") readonly applyGap: bigint; Blocks your wallet still needs to process, if this is greater than 0, it means that your wallet is not fully synced Formula: backend tip - last transaction index processed by your wallet ### sourceGap[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/SyncLag#sourcegap "Direct link to sourceGap") readonly sourceGap: bigint; Blocks the backend still needs to process, if this is greater than 0, it means that the backend is not fully synced Formula: chain tip - backend tip * [Type declaration](https://docs.midnight.network/api-reference/wallet-api/type-aliases/SyncLag#type-declaration) * [applyGap](https://docs.midnight.network/api-reference/wallet-api/type-aliases/SyncLag#applygap) * [sourceGap](https://docs.midnight.network/api-reference/wallet-api/type-aliases/SyncLag#sourcegap) --- # Ledger data types | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/ledger-adt#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ Compact language version 0.18.0, compiler version 0.26.0. Kernel[​](https://docs.midnight.network/compact/ledger-adt#kernel "Direct link to Kernel") ------------------------------------------------------------------------------------------- This ADT is a special ADT defining various built-in operations and valid only as a top-level ADT type. ### blockTimeGreaterThan[​](https://docs.midnight.network/compact/ledger-adt#blocktimegreaterthan "Direct link to blockTimeGreaterThan") blockTimeGreaterThan(time: Uint<64>): Boolean Checks whether the current block time (measured in seconds since the Unix epoch) is greater than the given amount. ### blockTimeLessThan[​](https://docs.midnight.network/compact/ledger-adt#blocktimelessthan "Direct link to blockTimeLessThan") blockTimeLessThan(time: Uint<64>): Boolean Checks whether the current block time (measured in seconds since the Unix epoch) is less than the given amount. ### checkpoint[​](https://docs.midnight.network/compact/ledger-adt#checkpoint "Direct link to checkpoint") checkpoint(): [] Marks all execution up to this point as being a single atomic unit, allowing partial transaction failures to be split across it. ### claimContractCall[​](https://docs.midnight.network/compact/ledger-adt#claimcontractcall "Direct link to claimContractCall") claimContractCall(addr: Bytes<32>, entry_point: Bytes<32>, comm: Field): [] Require the presence of another contract call in the containing transaction, with a match address, entry point hash, and communication commitment, that is not claimed by any other call. ### claimZswapCoinReceive[​](https://docs.midnight.network/compact/ledger-adt#claimzswapcoinreceive "Direct link to claimZswapCoinReceive") claimZswapCoinReceive(note: Bytes<32>): [] Requires the presence of a commitment in the containing transaction and that no other call claims it as a receive. ### claimZswapCoinSpend[​](https://docs.midnight.network/compact/ledger-adt#claimzswapcoinspend "Direct link to claimZswapCoinSpend") claimZswapCoinSpend(note: Bytes<32>): [] Requires the presence of a commitment in the containing transaction and that no other call claims it as a spend. ### claimZswapNullifier[​](https://docs.midnight.network/compact/ledger-adt#claimzswapnullifier "Direct link to claimZswapNullifier") claimZswapNullifier(nul: Bytes<32>): [] Requires the presence of a nullifier in the containing transaction and that no other call claims it. ### mint[​](https://docs.midnight.network/compact/ledger-adt#mint "Direct link to mint") mint(domain_sep: Bytes<32>, amount: Uint<64>): [] Mints a given amount of shielded coins with a token type derived from the contract's address, and a given domain separator. ### self[​](https://docs.midnight.network/compact/ledger-adt#self "Direct link to self") self(): ContractAddress Returns the current contract's address. ContractAddress is defined in CompactStandardLibrary. Cell[​](https://docs.midnight.network/compact/ledger-adt#cellvalue_type "Direct link to Cell") ------------------------------------------------------------------------------------------------------------------------ This ADT is a single Cell containing a value of type value\_type and is used implicitly when the ledger field type is an ordinary Compact type. Programmers cannot write Cell explicitly when declaring a ledger field.. ### read[​](https://docs.midnight.network/compact/ledger-adt#read "Direct link to read") read(): value_type Returns the current contents of this Cell. _available from Typescript as a getter on the ledger field_ ### resetToDefault[​](https://docs.midnight.network/compact/ledger-adt#resettodefault "Direct link to resetToDefault") resetToDefault(): [] Resets this Cell to the default value of its type. ### write[​](https://docs.midnight.network/compact/ledger-adt#write "Direct link to write") write(value: value_type): [] Overwrites the content of this Cell with the given value. ### writeCoin[​](https://docs.midnight.network/compact/ledger-adt#writecoin "Direct link to writeCoin") writeCoin(coin: CoinInfo, recipient: Either): [] Writes a CoinInfo to this Cell, which is transformed into a QualifiedCoinInfo at runtime by looking up the relevant Merkle tree index. This index must have been allocated within the current transaction or this write fails. CoinInfo, ContractAddress, Either, and ZswapCoinPublicKey are defined in CompactStandardLibrary. **available only for QualifiedCoinInfo value\_type** Counter[​](https://docs.midnight.network/compact/ledger-adt#counter "Direct link to Counter") ---------------------------------------------------------------------------------------------- This ADT is a simple counter. ### decrement[​](https://docs.midnight.network/compact/ledger-adt#decrement "Direct link to decrement") decrement(amount: Uint<16>): [] Decrements the counter by a given amount. Decrementing below zero results in a run-time error. ### increment[​](https://docs.midnight.network/compact/ledger-adt#increment "Direct link to increment") increment(amount: Uint<16>): [] Increments the counter by the given amount. ### lessThan[​](https://docs.midnight.network/compact/ledger-adt#lessthan "Direct link to lessThan") lessThan(threshold: Uint<64>): Boolean Returns if the counter is less than the given threshold value. ### read[​](https://docs.midnight.network/compact/ledger-adt#read-1 "Direct link to read") read(): Uint<64> Retrieves the current value of the counter. _available from Typescript as a getter on the ledger field_ ### resetToDefault[​](https://docs.midnight.network/compact/ledger-adt#resettodefault-1 "Direct link to resetToDefault") resetToDefault(): [] Resets this Counter to its default value of 0. Set[​](https://docs.midnight.network/compact/ledger-adt#setvalue_type "Direct link to Set") --------------------------------------------------------------------------------------------------------------------- This ADT is an unbounded set of values of type value\_type. ### insert[​](https://docs.midnight.network/compact/ledger-adt#insert "Direct link to insert") insert(elem: value_type): [] Updates this Set to include a given element. ### insertCoin[​](https://docs.midnight.network/compact/ledger-adt#insertcoin "Direct link to insertCoin") insertCoin(coin: CoinInfo, recipient: Either): [] Inserts a CoinInfo into this Set, which is transformed into a QualifiedCoinInfo at runtime by looking up the relevant Merkle tree index. This index must have been allocated within the current transaction or this insertion fails. CoinInfo, ContractAddress, Either, and ZswapCoinPublicKey are defined in CompactStandardLibrary. **available only for QualifiedCoinInfo value\_type** ### isEmpty[​](https://docs.midnight.network/compact/ledger-adt#isempty "Direct link to isEmpty") isEmpty(): Boolean Returns whether this Set is the empty set. _available from Typescript as `isEmpty(): boolean`_ ### member[​](https://docs.midnight.network/compact/ledger-adt#member "Direct link to member") member(elem: value_type): Boolean Returns if an element is contained within this Set. _available from Typescript as `member(elem: value_type): boolean`_ ### remove[​](https://docs.midnight.network/compact/ledger-adt#remove "Direct link to remove") remove(elem: value_type): [] Update this Set to not include a given element. ### resetToDefault[​](https://docs.midnight.network/compact/ledger-adt#resettodefault-2 "Direct link to resetToDefault") resetToDefault(): [] Resets this Set to the empty set. ### size[​](https://docs.midnight.network/compact/ledger-adt#size "Direct link to size") size(): Uint<64> Returns the number of unique entries in this Set. _available from Typescript as `size(): bigint`_ ### \[Symbol.iterator\][​](https://docs.midnight.network/compact/ledger-adt#symboliterator "Direct link to [Symbol.iterator]") _callable only from TypeScript_ [Symbol.iterator](): Iterator Iterates over the entries in this Set. Map[​](https://docs.midnight.network/compact/ledger-adt#mapkey_type-value_type "Direct link to Map") --------------------------------------------------------------------------------------------------------------------------------------------------- This ADT is an unbounded set of mappings between values of type key\_type and values of type value\_type. ### insert[​](https://docs.midnight.network/compact/ledger-adt#insert-1 "Direct link to insert") insert(key: key_type, value: value_type): [] Updates this Map to include a new value at a given key. ### insertCoin[​](https://docs.midnight.network/compact/ledger-adt#insertcoin-1 "Direct link to insertCoin") insertCoin(key: key_type, coin: CoinInfo, recipient: Either): [] Inserts a CoinInfo into this Map at a given key, where the CoinInfo is transformed into a QualifiedCoinInfo at runtime by looking up the relevant Merkle tree index. This index must have been allocated within the current transaction or this insertion fails. CoinInfo, ContractAddress, Either, and ZswapCoinPublicKey are defined in CompactStandardLibrary. **available only for QualifiedCoinInfo value\_type** ### insertDefault[​](https://docs.midnight.network/compact/ledger-adt#insertdefault "Direct link to insertDefault") insertDefault(key: key_type): [] Updates this Map to include the value type's default value at a given key. ### isEmpty[​](https://docs.midnight.network/compact/ledger-adt#isempty-1 "Direct link to isEmpty") isEmpty(): Boolean Returns if this Map is the empty map. _available from Typescript as `isEmpty(): boolean`_ ### lookup[​](https://docs.midnight.network/compact/ledger-adt#lookup "Direct link to lookup") lookup(key: key_type): value_type Looks up the value of a key within this Map. The returned value may be another ADT. _available from Typescript as `lookup(key: key_type): value_type`_ ### member[​](https://docs.midnight.network/compact/ledger-adt#member-1 "Direct link to member") member(key: key_type): Boolean Returns if a key is contained within this Map. _available from Typescript as `member(key: key_type): boolean`_ ### remove[​](https://docs.midnight.network/compact/ledger-adt#remove-1 "Direct link to remove") remove(key: key_type): [] Updates this Map to not include a given key. ### resetToDefault[​](https://docs.midnight.network/compact/ledger-adt#resettodefault-3 "Direct link to resetToDefault") resetToDefault(): [] Resets this Map to the empty map. ### size[​](https://docs.midnight.network/compact/ledger-adt#size-1 "Direct link to size") size(): Uint<64> Returns the number of entries in this Map. _available from Typescript as `size(): bigint`_ ### \[Symbol.iterator\][​](https://docs.midnight.network/compact/ledger-adt#symboliterator-1 "Direct link to [Symbol.iterator]") _callable only from TypeScript_ [Symbol.iterator](): Iterator<[key_type, value_type]> Iterates over the key-value pairs contained in this Map. List[​](https://docs.midnight.network/compact/ledger-adt#listvalue_type "Direct link to List") ------------------------------------------------------------------------------------------------------------------------ This ADT is an unbounded list of values of type value\_type. ### head[​](https://docs.midnight.network/compact/ledger-adt#head "Direct link to head") head(): Maybe Retrieves the head of this List, returning a Maybe, ensuring this call succeeds on the empty list. Maybe is defined in CompactStandardLibrary (compact-runtime runtime.ts from Typescript). _available from Typescript as `head(): Maybe`_ ### isEmpty[​](https://docs.midnight.network/compact/ledger-adt#isempty-2 "Direct link to isEmpty") isEmpty(): Boolean Returns if this List is the empty list. _available from Typescript as `isEmpty(): boolean`_ ### length[​](https://docs.midnight.network/compact/ledger-adt#length "Direct link to length") length(): Uint<64> Returns the number of elements contained in this List. _available from Typescript as `length(): bigint`_ ### popFront[​](https://docs.midnight.network/compact/ledger-adt#popfront "Direct link to popFront") popFront(): [] Removes the first element from the front of this list. ### pushFront[​](https://docs.midnight.network/compact/ledger-adt#pushfront "Direct link to pushFront") pushFront(value: value_type): [] Pushes a new element onto the front of this list. ### pushFrontCoin[​](https://docs.midnight.network/compact/ledger-adt#pushfrontcoin "Direct link to pushFrontCoin") pushFrontCoin(coin: CoinInfo, recipient: Either): [] Pushes a CoinInfo onto the front of this List, where the CoinInfo is transformed into a QualifiedCoinInfo at runtime by looking up the relevant Merkle tree index. This index must have been allocated within the current transaction or this push fails. CoinInfo, ContractAddress, Either, and ZswapCoinPublicKey are defined in CompactStandardLibrary. **available only for QualifiedCoinInfo value\_type** ### resetToDefault[​](https://docs.midnight.network/compact/ledger-adt#resettodefault-4 "Direct link to resetToDefault") resetToDefault(): [] Resets this List to the empty list. ### \[Symbol.iterator\][​](https://docs.midnight.network/compact/ledger-adt#symboliterator-2 "Direct link to [Symbol.iterator]") _callable only from TypeScript_ [Symbol.iterator](): Iterator Iterates over the entries in this List. MerkleTree[​](https://docs.midnight.network/compact/ledger-adt#merkletreenat-value_type "Direct link to MerkleTree") -------------------------------------------------------------------------------------------------------------------------------------------------------- This ADT is a bounded Merkle tree of depth nat containing values of type value\_type. ### checkRoot[​](https://docs.midnight.network/compact/ledger-adt#checkroot "Direct link to checkRoot") checkRoot(rt: MerkleTreeDigest): Boolean Tests if the given Merkle tree root is the root for this Merkle tree. MerkleTreeDigest is defined in CompactStandardLibrary (compact-runtime runtime.ts from Typescript). _available from Typescript as `checkRoot(rt: MerkleTreeDigest): boolean`_ ### insert[​](https://docs.midnight.network/compact/ledger-adt#insert-2 "Direct link to insert") insert(item: value_type): [] Inserts a new leaf at the first free index in this Merkle tree. ### insertHash[​](https://docs.midnight.network/compact/ledger-adt#inserthash "Direct link to insertHash") insertHash(hash: Bytes<32>): [] Inserts a new leaf with a given hash at the first free index in this Merkle tree. ### insertHashIndex[​](https://docs.midnight.network/compact/ledger-adt#inserthashindex "Direct link to insertHashIndex") insertHashIndex(hash: Bytes<32>, index: Uint<64>): [] Inserts a new leaf with a given hash at a specific index in this Merkle tree. ### insertIndex[​](https://docs.midnight.network/compact/ledger-adt#insertindex "Direct link to insertIndex") insertIndex(item: value_type, index: Uint<64>): [] Inserts a new leaf at a specific index in this Merkle tree. ### insertIndexDefault[​](https://docs.midnight.network/compact/ledger-adt#insertindexdefault "Direct link to insertIndexDefault") insertIndexDefault(index: Uint<64>): [] Inserts a default value leaf at a specific index in this Merkle tree. This can be used to emulate a removal from the tree. ### isFull[​](https://docs.midnight.network/compact/ledger-adt#isfull "Direct link to isFull") isFull(): Boolean Returns if this Merkle tree is full and further items cannot be directly inserted. _available from Typescript as `isFull(): boolean`_ ### resetToDefault[​](https://docs.midnight.network/compact/ledger-adt#resettodefault-5 "Direct link to resetToDefault") resetToDefault(): [] Resets this Merkle tree to the empty Merkle tree. ### findPathForLeaf[​](https://docs.midnight.network/compact/ledger-adt#findpathforleaf "Direct link to findPathForLeaf") _callable only from TypeScript_ findPathForLeaf(leaf: value_type): MerkleTreePath | undefined Finds the path for a given leaf in a Merkle tree. Be warned that this is O(n) and should be avoided for large trees. Returns undefined if no such leaf exists. MerkleTreePath is defined in compact-runtime runtime.ts. ### firstFree[​](https://docs.midnight.network/compact/ledger-adt#firstfree "Direct link to firstFree") _callable only from TypeScript_ firstFree(): bigint Retrieves the first (guaranteed) free index in the Merkle tree. ### pathForLeaf[​](https://docs.midnight.network/compact/ledger-adt#pathforleaf "Direct link to pathForLeaf") _callable only from TypeScript_ pathForLeaf(index: bigint, leaf: value_type): MerkleTreePath Returns the Merkle path, given the knowledge that a specified leaf is at the given index. It is an error to call this if this leaf is not contained at the given index. MerkleTreePath is defined in compact-runtime runtime.ts. ### root[​](https://docs.midnight.network/compact/ledger-adt#root "Direct link to root") _callable only from TypeScript_ root(): MerkleTreeDigest Retrieves the root of the Merkle tree. MerkleTreeDigest is defined in compact-runtime runtime.ts. HistoricMerkleTree[​](https://docs.midnight.network/compact/ledger-adt#historicmerkletreenat-value_type "Direct link to HistoricMerkleTree") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- This ADT is a bounded Merkle tree of depth nat containing values of type value\_type, with history. ### checkRoot[​](https://docs.midnight.network/compact/ledger-adt#checkroot-1 "Direct link to checkRoot") checkRoot(rt: MerkleTreeDigest): Boolean Tests if the given Merkle tree root is one of the past roots for this Merkle tree. MerkleTreeDigest is defined in CompactStandardLibrary (compact-runtime runtime.ts from Typescript). _available from Typescript as `checkRoot(rt: MerkleTreeDigest): boolean`_ ### insert[​](https://docs.midnight.network/compact/ledger-adt#insert-3 "Direct link to insert") insert(item: value_type): [] Inserts a new leaf at the first free index in this Merkle tree. ### insertHash[​](https://docs.midnight.network/compact/ledger-adt#inserthash-1 "Direct link to insertHash") insertHash(hash: Bytes<32>): [] Inserts a new leaf with a given hash at the first free index in this Merkle tree. ### insertHashIndex[​](https://docs.midnight.network/compact/ledger-adt#inserthashindex-1 "Direct link to insertHashIndex") insertHashIndex(hash: Bytes<32>, index: Uint<64>): [] Inserts a new leaf with a given hash at a specific index in this Merkle tree. ### insertIndex[​](https://docs.midnight.network/compact/ledger-adt#insertindex-1 "Direct link to insertIndex") insertIndex(item: value_type, index: Uint<64>): [] Inserts a new leaf at a specific index in this Merkle tree. ### insertIndexDefault[​](https://docs.midnight.network/compact/ledger-adt#insertindexdefault-1 "Direct link to insertIndexDefault") insertIndexDefault(index: Uint<64>): [] Inserts a default value leaf at a specific index in this Merkle tree. This can be used to emulate a removal from the tree. ### isFull[​](https://docs.midnight.network/compact/ledger-adt#isfull-1 "Direct link to isFull") isFull(): Boolean Returns if this Merkle tree is full and further items cannot be directly inserted. _available from Typescript as `isFull(): boolean`_ ### resetHistory[​](https://docs.midnight.network/compact/ledger-adt#resethistory "Direct link to resetHistory") resetHistory(): [] Resets the history for this Merkle tree, leaving only the current root valid. ### resetToDefault[​](https://docs.midnight.network/compact/ledger-adt#resettodefault-6 "Direct link to resetToDefault") resetToDefault(): [] Resets this Merkle tree to the empty Merkle tree. ### findPathForLeaf[​](https://docs.midnight.network/compact/ledger-adt#findpathforleaf-1 "Direct link to findPathForLeaf") _callable only from TypeScript_ findPathForLeaf(leaf: value_type): MerkleTreePath | undefined Finds the path for a given leaf in a Merkle tree. Be warned that this is O(n) and should be avoided for large trees. Returns undefined if no such leaf exists. MerkleTreePath is defined in compact-runtime runtime.ts. ### firstFree[​](https://docs.midnight.network/compact/ledger-adt#firstfree-1 "Direct link to firstFree") _callable only from TypeScript_ firstFree(): bigint Retrieves the first (guaranteed) free index in the Merkle tree. ### history[​](https://docs.midnight.network/compact/ledger-adt#history "Direct link to history") _callable only from TypeScript_ history(): Iterator An iterator over the roots that are considered valid past roots for this Merkle tree. MerkleTreeDigest is defined in compact-runtime runtime.ts. ### pathForLeaf[​](https://docs.midnight.network/compact/ledger-adt#pathforleaf-1 "Direct link to pathForLeaf") _callable only from TypeScript_ pathForLeaf(index: bigint, leaf: value_type): MerkleTreePath Returns the Merkle path, given the knowledge that a specified leaf is at the given index. It is an error to call this if this leaf is not contained at the given index. MerkleTreePath is defined in compact-runtime runtime.ts. ### root[​](https://docs.midnight.network/compact/ledger-adt#root-1 "Direct link to root") _callable only from TypeScript_ root(): MerkleTreeDigest Retrieves the root of the Merkle tree. MerkleTreeDigest is defined in compact-runtime runtime.ts. * [Kernel](https://docs.midnight.network/compact/ledger-adt#kernel) * [blockTimeGreaterThan](https://docs.midnight.network/compact/ledger-adt#blocktimegreaterthan) * [blockTimeLessThan](https://docs.midnight.network/compact/ledger-adt#blocktimelessthan) * [checkpoint](https://docs.midnight.network/compact/ledger-adt#checkpoint) * [claimContractCall](https://docs.midnight.network/compact/ledger-adt#claimcontractcall) * [claimZswapCoinReceive](https://docs.midnight.network/compact/ledger-adt#claimzswapcoinreceive) * [claimZswapCoinSpend](https://docs.midnight.network/compact/ledger-adt#claimzswapcoinspend) * [claimZswapNullifier](https://docs.midnight.network/compact/ledger-adt#claimzswapnullifier) * [mint](https://docs.midnight.network/compact/ledger-adt#mint) * [self](https://docs.midnight.network/compact/ledger-adt#self) * [Cell](https://docs.midnight.network/compact/ledger-adt#cellvalue_type) * [read](https://docs.midnight.network/compact/ledger-adt#read) * [resetToDefault](https://docs.midnight.network/compact/ledger-adt#resettodefault) * [write](https://docs.midnight.network/compact/ledger-adt#write) * [writeCoin](https://docs.midnight.network/compact/ledger-adt#writecoin) * [Counter](https://docs.midnight.network/compact/ledger-adt#counter) * [decrement](https://docs.midnight.network/compact/ledger-adt#decrement) * [increment](https://docs.midnight.network/compact/ledger-adt#increment) * [lessThan](https://docs.midnight.network/compact/ledger-adt#lessthan) * [read](https://docs.midnight.network/compact/ledger-adt#read-1) * [resetToDefault](https://docs.midnight.network/compact/ledger-adt#resettodefault-1) * [Set](https://docs.midnight.network/compact/ledger-adt#setvalue_type) * [insert](https://docs.midnight.network/compact/ledger-adt#insert) * [insertCoin](https://docs.midnight.network/compact/ledger-adt#insertcoin) * [isEmpty](https://docs.midnight.network/compact/ledger-adt#isempty) * [member](https://docs.midnight.network/compact/ledger-adt#member) * [remove](https://docs.midnight.network/compact/ledger-adt#remove) * [resetToDefault](https://docs.midnight.network/compact/ledger-adt#resettodefault-2) * [size](https://docs.midnight.network/compact/ledger-adt#size) * [\[Symbol.iterator\]](https://docs.midnight.network/compact/ledger-adt#symboliterator) * [Map](https://docs.midnight.network/compact/ledger-adt#mapkey_type-value_type) * [insert](https://docs.midnight.network/compact/ledger-adt#insert-1) * [insertCoin](https://docs.midnight.network/compact/ledger-adt#insertcoin-1) * [insertDefault](https://docs.midnight.network/compact/ledger-adt#insertdefault) * [isEmpty](https://docs.midnight.network/compact/ledger-adt#isempty-1) * [lookup](https://docs.midnight.network/compact/ledger-adt#lookup) * [member](https://docs.midnight.network/compact/ledger-adt#member-1) * [remove](https://docs.midnight.network/compact/ledger-adt#remove-1) * [resetToDefault](https://docs.midnight.network/compact/ledger-adt#resettodefault-3) * [size](https://docs.midnight.network/compact/ledger-adt#size-1) * [\[Symbol.iterator\]](https://docs.midnight.network/compact/ledger-adt#symboliterator-1) * [List](https://docs.midnight.network/compact/ledger-adt#listvalue_type) * [head](https://docs.midnight.network/compact/ledger-adt#head) * [isEmpty](https://docs.midnight.network/compact/ledger-adt#isempty-2) * [length](https://docs.midnight.network/compact/ledger-adt#length) * [popFront](https://docs.midnight.network/compact/ledger-adt#popfront) * [pushFront](https://docs.midnight.network/compact/ledger-adt#pushfront) * [pushFrontCoin](https://docs.midnight.network/compact/ledger-adt#pushfrontcoin) * [resetToDefault](https://docs.midnight.network/compact/ledger-adt#resettodefault-4) * [\[Symbol.iterator\]](https://docs.midnight.network/compact/ledger-adt#symboliterator-2) * [MerkleTree](https://docs.midnight.network/compact/ledger-adt#merkletreenat-value_type) * [checkRoot](https://docs.midnight.network/compact/ledger-adt#checkroot) * [insert](https://docs.midnight.network/compact/ledger-adt#insert-2) * [insertHash](https://docs.midnight.network/compact/ledger-adt#inserthash) * [insertHashIndex](https://docs.midnight.network/compact/ledger-adt#inserthashindex) * [insertIndex](https://docs.midnight.network/compact/ledger-adt#insertindex) * [insertIndexDefault](https://docs.midnight.network/compact/ledger-adt#insertindexdefault) * [isFull](https://docs.midnight.network/compact/ledger-adt#isfull) * [resetToDefault](https://docs.midnight.network/compact/ledger-adt#resettodefault-5) * [findPathForLeaf](https://docs.midnight.network/compact/ledger-adt#findpathforleaf) * [firstFree](https://docs.midnight.network/compact/ledger-adt#firstfree) * [pathForLeaf](https://docs.midnight.network/compact/ledger-adt#pathforleaf) * [root](https://docs.midnight.network/compact/ledger-adt#root) * [HistoricMerkleTree](https://docs.midnight.network/compact/ledger-adt#historicmerkletreenat-value_type) * [checkRoot](https://docs.midnight.network/compact/ledger-adt#checkroot-1) * [insert](https://docs.midnight.network/compact/ledger-adt#insert-3) * [insertHash](https://docs.midnight.network/compact/ledger-adt#inserthash-1) * [insertHashIndex](https://docs.midnight.network/compact/ledger-adt#inserthashindex-1) * [insertIndex](https://docs.midnight.network/compact/ledger-adt#insertindex-1) * [insertIndexDefault](https://docs.midnight.network/compact/ledger-adt#insertindexdefault-1) * [isFull](https://docs.midnight.network/compact/ledger-adt#isfull-1) * [resetHistory](https://docs.midnight.network/compact/ledger-adt#resethistory) * [resetToDefault](https://docs.midnight.network/compact/ledger-adt#resettodefault-6) * [findPathForLeaf](https://docs.midnight.network/compact/ledger-adt#findpathforleaf-1) * [firstFree](https://docs.midnight.network/compact/ledger-adt#firstfree-1) * [history](https://docs.midnight.network/compact/ledger-adt#history) * [pathForLeaf](https://docs.midnight.network/compact/ledger-adt#pathforleaf-1) * [root](https://docs.midnight.network/compact/ledger-adt#root-1) --- # Tools | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/reference/tools#__docusaurus_skipToContent_fallback) Explore with… ▾ --- # Tags | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/tags#__docusaurus_skipToContent_fallback) Tags ==== A[​](https://docs.midnight.network/sdks/tags#A "Direct link to A") ------------------------------------------------------------------- * [authentication1](https://docs.midnight.network/sdks/tags/authentication) * * * D[​](https://docs.midnight.network/sdks/tags#D "Direct link to D") ------------------------------------------------------------------- * [developer guide2](https://docs.midnight.network/sdks/tags/developer-guide) * [developer-tools1](https://docs.midnight.network/sdks/tags/developer-tools) * * * E[​](https://docs.midnight.network/sdks/tags#E "Direct link to E") ------------------------------------------------------------------- * [error codes1](https://docs.midnight.network/sdks/tags/error-codes) * * * I[​](https://docs.midnight.network/sdks/tags#I "Direct link to I") ------------------------------------------------------------------- * [integration1](https://docs.midnight.network/sdks/tags/integration) * [issues1](https://docs.midnight.network/sdks/tags/issues) * * * M[​](https://docs.midnight.network/sdks/tags#M "Direct link to M") ------------------------------------------------------------------- * [midnight.js1](https://docs.midnight.network/sdks/tags/midnight-js) * * * R[​](https://docs.midnight.network/sdks/tags#R "Direct link to R") ------------------------------------------------------------------- * [rate limits1](https://docs.midnight.network/sdks/tags/rate-limits) * * * S[​](https://docs.midnight.network/sdks/tags#S "Direct link to S") ------------------------------------------------------------------- * [sdk4](https://docs.midnight.network/sdks/tags/sdk) * * * T[​](https://docs.midnight.network/sdks/tags#T "Direct link to T") ------------------------------------------------------------------- * [typescript1](https://docs.midnight.network/sdks/tags/typescript) * * * W[​](https://docs.midnight.network/sdks/tags#W "Direct link to W") ------------------------------------------------------------------- * [wallet1](https://docs.midnight.network/sdks/tags/wallet) * * * --- # ApplyStage | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/type-aliases/ApplyStage#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / ApplyStage Type alias: ApplyStage ====================== type ApplyStage: "FailEntirely" | "FailFallible" | "SucceedEntirely"; The status of the transaction Remarks[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/ApplyStage#remarks "Direct link to Remarks") ---------------------------------------------------------------------------------------------------------------------------- * FailEntirely - transaction failed and no part of it was applied * FailFallible - the fallible part of the transaction failed, but the guaranteed part succeeded * SucceedEntirely - transaction succeeded * [Remarks](https://docs.midnight.network/api-reference/wallet-api/type-aliases/ApplyStage#remarks) --- # ProvingRecipe | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/type-aliases/ProvingRecipe#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / ProvingRecipe Type alias: ProvingRecipe ========================= type ProvingRecipe: TransactionToProve | BalanceTransactionToProve | NothingToProve; Transaction data used for proving Remarks[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/ProvingRecipe#remarks "Direct link to Remarks") ------------------------------------------------------------------------------------------------------------------------------- ProvingRecipe is a data structure used for proving the unproven transaction, balancing, and proving a transaction or declaring a recipe that has no transaction to prove * [Remarks](https://docs.midnight.network/api-reference/wallet-api/type-aliases/ProvingRecipe#remarks) --- # BalanceTransactionToProve | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/type-aliases/BalanceTransactionToProve#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / BalanceTransactionToProve Type alias: BalanceTransactionToProve ===================================== type BalanceTransactionToProve: { transactionToBalance: Transaction; transactionToProve: UnprovenTransaction; type: typeof BALANCE_TRANSACTION_TO_PROVE;}; Balance transaction data for proving Remarks[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/BalanceTransactionToProve#remarks "Direct link to Remarks") ------------------------------------------------------------------------------------------------------------------------------------------- BalanceTransactionToProve is a data structure used for proving the unproven transaction (transactionToProve) and merging it with the original transaction (transactionToBalance) Type declaration[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/BalanceTransactionToProve#type-declaration "Direct link to Type declaration") ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### transactionToBalance[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/BalanceTransactionToProve#transactiontobalance "Direct link to transactionToBalance") readonly transactionToBalance: Transaction; Transaction which will be merged with proved `transactionToProve`. It is a original transaction which we want to balance. ### transactionToProve[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/BalanceTransactionToProve#transactiontoprove "Direct link to transactionToProve") readonly transactionToProve: UnprovenTransaction; Unproven transaction which needs to be proven. Transaction which will balance the `transactionToBalance` ### type[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/BalanceTransactionToProve#type "Direct link to type") readonly type: typeof BALANCE_TRANSACTION_TO_PROVE; Used to identify the transaction type * [Remarks](https://docs.midnight.network/api-reference/wallet-api/type-aliases/BalanceTransactionToProve#remarks) * [Type declaration](https://docs.midnight.network/api-reference/wallet-api/type-aliases/BalanceTransactionToProve#type-declaration) * [transactionToBalance](https://docs.midnight.network/api-reference/wallet-api/type-aliases/BalanceTransactionToProve#transactiontobalance) * [transactionToProve](https://docs.midnight.network/api-reference/wallet-api/type-aliases/BalanceTransactionToProve#transactiontoprove) * [type](https://docs.midnight.network/api-reference/wallet-api/type-aliases/BalanceTransactionToProve#type) --- # globals | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/globals#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | API * * * @midnight-ntwrk/wallet-api v5.0.0 ================================= Interfaces[​](https://docs.midnight.network/api-reference/wallet-api/globals#interfaces "Direct link to Interfaces") --------------------------------------------------------------------------------------------------------------------- * [Wallet](https://docs.midnight.network/api-reference/wallet-api/interfaces/Wallet) Type Aliases[​](https://docs.midnight.network/api-reference/wallet-api/globals#type-aliases "Direct link to Type Aliases") --------------------------------------------------------------------------------------------------------------------------- * [Address](https://docs.midnight.network/api-reference/wallet-api/type-aliases/Address) * [AddressLegacy](https://docs.midnight.network/api-reference/wallet-api/type-aliases/AddressLegacy) * [ApplyStage](https://docs.midnight.network/api-reference/wallet-api/type-aliases/ApplyStage) * [BalanceTransactionToProve](https://docs.midnight.network/api-reference/wallet-api/type-aliases/BalanceTransactionToProve) * [CoinPublicKey](https://docs.midnight.network/api-reference/wallet-api/type-aliases/CoinPublicKey) * [CoinPublicKeyLegacy](https://docs.midnight.network/api-reference/wallet-api/type-aliases/CoinPublicKeyLegacy) * [EncPublicKeyLegacy](https://docs.midnight.network/api-reference/wallet-api/type-aliases/EncPublicKeyLegacy) * [NothingToProve](https://docs.midnight.network/api-reference/wallet-api/type-aliases/NothingToProve) * [ProvingRecipe](https://docs.midnight.network/api-reference/wallet-api/type-aliases/ProvingRecipe) * [SyncLag](https://docs.midnight.network/api-reference/wallet-api/type-aliases/SyncLag) * [SyncProgress](https://docs.midnight.network/api-reference/wallet-api/type-aliases/SyncProgress) * [TokenTransfer](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TokenTransfer) * [TokenType](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TokenType) * [TransactionHash](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHash) * [TransactionHistoryEntry](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHistoryEntry) * [TransactionIdentifier](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionIdentifier) * [TransactionToProve](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionToProve) * [WalletState](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState) Variables[​](https://docs.midnight.network/api-reference/wallet-api/globals#variables "Direct link to Variables") ------------------------------------------------------------------------------------------------------------------ * [BALANCE\_TRANSACTION\_TO\_PROVE](https://docs.midnight.network/api-reference/wallet-api/variables/BALANCE_TRANSACTION_TO_PROVE) * [NOTHING\_TO\_PROVE](https://docs.midnight.network/api-reference/wallet-api/variables/NOTHING_TO_PROVE) * [TRANSACTION\_TO\_PROVE](https://docs.midnight.network/api-reference/wallet-api/variables/TRANSACTION_TO_PROVE) * [Interfaces](https://docs.midnight.network/api-reference/wallet-api/globals#interfaces) * [Type Aliases](https://docs.midnight.network/api-reference/wallet-api/globals#type-aliases) * [Variables](https://docs.midnight.network/api-reference/wallet-api/globals#variables) --- # TransactionIdentifier | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionIdentifier#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / TransactionIdentifier Type alias: TransactionIdentifier ================================= type TransactionIdentifier: string; Hex-encoded 32-byte byte string Remarks[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionIdentifier#remarks "Direct link to Remarks") --------------------------------------------------------------------------------------------------------------------------------------- The transaction identifier is used to index merged transactions. * [Remarks](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionIdentifier#remarks) --- # TokenType | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TokenType#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / TokenType Type alias: TokenType ===================== type TokenType: string; Hex-encoded 35-byte byte string Remarks[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TokenType#remarks "Direct link to Remarks") --------------------------------------------------------------------------------------------------------------------------- Token type is a unique identifier of a native token, which is used to distinguish native tokens in the network. "tDUST" is a specific, well-know native token type. * [Remarks](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TokenType#remarks) --- # Compact Compiler Manual Page | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/reference/tools/compiler-usage#__docusaurus_skipToContent_fallback) Explore with… ▾ NAME ==== compactc OVERVIEW ======== The Compact compiler, **compactc**, takes as input a Compact source program in a specified source file and translates it into several target files in a specified directory. SYNOPSYS ======== **compactc** _flag_ **...** _sourcepath_ _targetpath_ DESCRIPTION =========== The flags _flag_ **...** are optional. They are described under FLAGS later in this document. _sourcepath_ should identify a file containing a Compact source program, and _targetpath_ should identify a target directory into which the target files are to be placed. The target directory is created if it does not already exist. **compactc** compiles the source file and produces from it the following target files, where _sourceroot_ is the name of the file identified by _sourcepath_ without any extension. * a Typescript type-definition file _targetdir_**/contract/index.d.cts** * a Javascript source file _targetdir_**/contract/index.cjs** * a Javascript source-map file _targetdir_**/contract/index.cjs.map** * one Zk/ir circuit file for each exported circuit _circuitname_ in _targetdir_**/zkir/**_circuitname_**.zkir**, and * a pair of proving keys for each exported circuit _circuitname_ in _targetdir_**/keys/**_circuitname_**.prover** and _targetdir_**/keys/**_circuitname_**.verifier**. Compact source files can include other Compact source files via an **include** form: **include** '_name_'; They can also import externally defined modules via an **import** form: **import** _name_; **import** '_name_'; By default, the compiler looks for include files and externally defined modules in the current working directory under the full filename _name_**.compact**. When the environment variable **COMPACT\_PATH** is set to a colon-separated (semicolon-separated on Windows) list of directory pathnames _dirpath_**:...:**_dirpath_ (_dirpath_**;...;**_dirpath_ under Windows), the compiler looks instead under the full pathname _dirpath_**/**_name_**.compact** for each _dirpath_ until the file is found or the set of _dirpath_ entries is exhausted. Every Compact source program should import the standard library **CompactStandardLibrary**. This is typically done by placing the following line at the top of the program: **import CompactStandardLibrary;** FLAGS ===== The following flags, if present, affect the compiler's behavior as follows: **\--help** prints help text and exits. **\--version** prints the compiler version and exits. **\--language-version** prints the language version and exits. **\--vscode** causes the compiler to omit newlines from error messages, so that they are rendered properly within the VS Code extension for Compact. **\--skip-zk** causes the compiler to skip the generation of proving keys. Generating proving keys can be time-consuming, so this option is useful when debugging only the Typescript output. The compiler also skips, after printing a warning message, the generation of proving keys when it cannot find zkir. **\--no-communications-commitment** omits the contract communications commitment that enables data integrity for contract-to-contract calls. **\--sourceRoot _sourceRoot-value_** overrides the compiler's setting of the sourceRoot field in the generated source-map (.cjs.map) file. By default, the compiler tries to determine a useful value based on the source and target-directory pathnames, but this value might not be appropriate for the deployed structure of the application. **\--trace-passes** causes the compiler to print tracing information that is generally useful only to compiler developers. EXAMPLES ======== Assuming **src/test.compact** contains a well-formed Compact program exporting circuits _foo_ and _bar_: compactc src/test.compact obj/test produces: obj/test/contract/index.d.ctsobj/test/contract/index.cjsobj/test/contract/index.cjs.mapobj/test/zkir/foo.zkirobj/test/zkir/bar.zkirobj/test/keys/foo.proverobj/test/keys/foo.verifierobj/test/keys/bar.proverobj/test/keys/bar.verifier **compactc --skip-zk src/test.compact obj/test** produces the same, except without the keys. --- # One doc tagged with "advanced" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/advanced#__docusaurus_skipToContent_fallback) [Zero Knowledge loan DApp\ ------------------------](https://docs.midnight.network/next/tutorials/advanced/zk-loan-dapp) Build a zero knowledge loan DApp on Midnight Network. --- # One doc tagged with "best practices" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/best-practices#__docusaurus_skipToContent_fallback) [Security best practices\ -----------------------](https://docs.midnight.network/next/compact/security) Learn about the security best practices for Compact. --- # One doc tagged with "builder" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/builder#__docusaurus_skipToContent_fallback) [Install the toolchain\ ---------------------](https://docs.midnight.network/next/getting-started/installation) Get your Midnight development environment running to set up tools, configure wallets, and deploy your first zero-knowledge application. --- # One doc tagged with "bun" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/bun#__docusaurus_skipToContent_fallback) [Set up Bun for Midnight development\ -----------------------------------](https://docs.midnight.network/next/how-to/bun-runtime-midnight) Set up Bun package manager and the Compact compiler to build smart contracts and applications on the Midnight blockchain. --- # Troubleshoot | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/category/troubleshoot#__docusaurus_skipToContent_fallback) [📄️ Common SDK integration issues\ ---------------------------------\ \ Troubleshoot common issues when building on Midnight Network.](https://docs.midnight.network/sdks/troubleshoot) --- # Community SDKs | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/category/community-sdks#__docusaurus_skipToContent_fallback) [🗃️ Build using MeshSDK\ -----------------------\ \ 4 items](https://docs.midnight.network/sdks/community/build-using-meshsdk) --- # Error codes | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/category/error-codes#__docusaurus_skipToContent_fallback) [📄️ List of error codes\ -----------------------\ \ List of error codes for the Midnight SDKs and client libraries.](https://docs.midnight.network/sdks/error-codes) --- # TokenTransfer | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TokenTransfer#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / TokenTransfer Type alias: TokenTransfer ========================= type TokenTransfer: { amount: bigint; receiverAddress: Address; type: TokenType;}; Data for transferring tokens Type declaration[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TokenTransfer#type-declaration "Direct link to Type declaration") ---------------------------------------------------------------------------------------------------------------------------------------------------------- ### amount[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TokenTransfer#amount "Direct link to amount") readonly amount: bigint; Amount of transferred tokens #### Remarks[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TokenTransfer#remarks "Direct link to Remarks") It is a non-negative integer, which represents the amount of tokens to be transferred. The smallest unit that can be transferred is 1. ### receiverAddress[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TokenTransfer#receiveraddress "Direct link to receiverAddress") readonly receiverAddress: Address; [Address](https://docs.midnight.network/api-reference/wallet-api/type-aliases/Address) of receiver ### type[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TokenTransfer#type "Direct link to type") readonly type: TokenType; [TokenType](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TokenType) of transferred token * [Type declaration](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TokenTransfer#type-declaration) * [amount](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TokenTransfer#amount) * [receiverAddress](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TokenTransfer#receiveraddress) * [type](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TokenTransfer#type) --- # SyncProgress | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/type-aliases/SyncProgress#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / SyncProgress Type alias: SyncProgress ======================== type SyncProgress: { lag: SyncLag; synced: boolean;}; Sync progress of the wallet Type declaration[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/SyncProgress#type-declaration "Direct link to Type declaration") --------------------------------------------------------------------------------------------------------------------------------------------------------- ### lag[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/SyncProgress#lag "Direct link to lag") lag: SyncLag; Lag of the wallet syncing process ### synced[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/SyncProgress#synced "Direct link to synced") synced: boolean; SyncLag.indexer === 0 && SyncLag.wallet === 0 * [Type declaration](https://docs.midnight.network/api-reference/wallet-api/type-aliases/SyncProgress#type-declaration) * [lag](https://docs.midnight.network/api-reference/wallet-api/type-aliases/SyncProgress#lag) * [synced](https://docs.midnight.network/api-reference/wallet-api/type-aliases/SyncProgress#synced) --- # TransactionHistoryEntry | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHistoryEntry#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / TransactionHistoryEntry Type alias: TransactionHistoryEntry =================================== type TransactionHistoryEntry: { applyStage: ApplyStage; deltas: Record; identifiers: TransactionIdentifier[]; transaction: Transaction; transactionHash: TransactionHash;}; Transaction history data Type declaration[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHistoryEntry#type-declaration "Direct link to Type declaration") -------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### applyStage[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHistoryEntry#applystage "Direct link to applyStage") readonly applyStage: ApplyStage; [ApplyStage](https://docs.midnight.network/api-reference/wallet-api/type-aliases/ApplyStage) of the transaction ### deltas[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHistoryEntry#deltas "Direct link to deltas") readonly deltas: Record; The value of this offer for each token type #### Remarks[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHistoryEntry#remarks "Direct link to Remarks") It contains the input coin values - output coin values, for value vectors of the transaction. Note that this will not list any zero value coins; ### identifiers[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHistoryEntry#identifiers "Direct link to identifiers") readonly identifiers: TransactionIdentifier[]; An array of [TransactionIdentifier](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionIdentifier) of the transaction. ### transaction[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHistoryEntry#transaction "Direct link to transaction") readonly transaction: Transaction; Original transaction ### transactionHash[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHistoryEntry#transactionhash "Direct link to transactionHash") readonly transactionHash: TransactionHash; [TransactionHash](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHash) of the transaction * [Type declaration](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHistoryEntry#type-declaration) * [applyStage](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHistoryEntry#applystage) * [deltas](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHistoryEntry#deltas) * [identifiers](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHistoryEntry#identifiers) * [transaction](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHistoryEntry#transaction) * [transactionHash](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHistoryEntry#transactionhash) --- # CoinCommitment | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinCommitment#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / CoinCommitment Type alias: CoinCommitment ========================== type CoinCommitment: string; A Zswap coin commitment, as a hex-encoded 256-bit bitstring --- # ContractAddress | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/type-aliases/ContractAddress#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / ContractAddress Type alias: ContractAddress =========================== type ContractAddress: string; A contract address, as a hex-encoded 35-byte string --- # CoinPublicKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinPublicKey#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / CoinPublicKey Type alias: CoinPublicKey ========================= type CoinPublicKey: string; A user public key capable of receiving Zswap coins, as a hex-encoded 35-byte string --- # One doc tagged with "compatibility" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/compatibility#__docusaurus_skipToContent_fallback) [Fix version mismatch errors\ ---------------------------](https://docs.midnight.network/next/how-to/fix-version-mismatches) Resolve version compatibility issues between Midnight compiler, runtime, and other components using the official compatibility matrix. --- # One doc tagged with "DApps" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/d-apps#__docusaurus_skipToContent_fallback) [Midnight Preview Network onboarding guide\ -----------------------------------------](https://docs.midnight.network/next/how-to/migrate-from-testnet-02-to-preview) Learn how to migrate your existing applications running on testnet-02 to the preview environment. --- # One doc tagged with "deployment" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/deployment#__docusaurus_skipToContent_fallback) [Deploy the hello world contract\ -------------------------------](https://docs.midnight.network/next/guides/deploy-mn-app) Deploy a compiled hello world smart contract to Midnight's Preprod network. --- # One doc tagged with "development" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/development#__docusaurus_skipToContent_fallback) [Install the toolchain\ ---------------------](https://docs.midnight.network/next/getting-started/installation) Get your Midnight development environment running to set up tools, configure wallets, and deploy your first zero-knowledge application. --- # Official SDKs | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/category/official-sdks#__docusaurus_skipToContent_fallback) [📄️ Midnight.js\ ---------------\ \ Comprehensive TypeScript SDK for building DApps on Midnight Network.](https://docs.midnight.network/sdks/official/midnight-js) [📄️ Wallet SDK\ --------------\ \ Developer guide for the Midnight wallet SDK.](https://docs.midnight.network/sdks/official/wallet-developer-guide) --- # Visual Studio Code extension for Compact | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/reference/tools/vsc-plugin#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ The \[Visual Studio Code extension\] for Compact is a plugin that assists with writing and debugging smart contracts written in Midnight's Compact language. DApp developers can create new smart contracts * using a file template * from scratch, optionally using code snippets. Features[​](https://docs.midnight.network/compact/reference/tools/vsc-plugin#features "Direct link to Features") ----------------------------------------------------------------------------------------------------------------- ### Syntax highlighting[​](https://docs.midnight.network/compact/reference/tools/vsc-plugin#syntax-highlighting "Direct link to Syntax highlighting") Smart contracts are written in the Compact language. The following language elements will be recognized and formatted: * Compact keywords, such as `enum`, `struct`, and `circuit` * string, boolean, and numeric literals * comments * parentheses ![Syntax highlighting](https://docs.midnight.network/assets/images/compact-syntax-a76e9fa96b86a7476a71cb0a2eb51e26.png) ### Building Compact source files and error highlighting[​](https://docs.midnight.network/compact/reference/tools/vsc-plugin#building-compact-source-files-and-error-highlighting "Direct link to Building Compact source files and error highlighting") For building smart contracts, you will typically want to add a script definition in `package.json`, like so: "scripts": { "compact": "compact compile --vscode ./src/myContract.compact ./src/managed/myContract"} The preceding assumes that the Compact compiler is on the shell's command search path (if it isn't, follow the instructions provided in [Running Midnight Compact compiler](https://docs.midnight.network/develop/tutorial/building/counter-build#compile-the-code) ). It also uses the Compact compiler's --vscode option to omit newlines in error messages, so that they render properly inside the VS Code environment. This allows you to compile your smart contract using: yarn compact When you edit complex contracts, and you want to have fast interactions, it is more convenient to add a [task file](https://code.visualstudio.com/docs/editor/tasks) `.vscode/tasks.json` configured like this: { "version": "2.0.0", "tasks": [ { "label": "Compile compact file to JS", "type": "shell", "command": "npx compact compile --vscode --skip-zk ${file} ${workspaceFolder}/src/managed", "group": "build", "presentation": { "echo": true, "reveal": "never", "focus": false, "panel": "shared", "showReuseMessage": false, "clear": true, "revealProblems": "onProblem" }, "problemMatcher": [ "$compactException", "$compactInternal", "$compactCommandNotFound" ] } ]} The preceding configuration uses the Compact compiler flag `--skip-zk` to skip the generation of circuits, which can take a long time and may be unnecessary when you only want to the compiler to check your syntax. Moreover, you can configure a `problemMatcher` for VS Code: "problemMatcher": [ "$compactException", "$compactInternal", "$compactCommandNotFound" ] so that all errors reported by the compiler will be shown on the **Problems** tab. ### Code snippets[​](https://docs.midnight.network/compact/reference/tools/vsc-plugin#code-snippets "Direct link to Code snippets") The VS Code extension provides the following [code snippets](https://code.visualstudio.com/docs/editor/userdefinedsnippets) when editing Compact smart contracts: * `ledger` (`state`) * `constructor` in ledger * potentially exported `circuit` (`function` / `transition`) * `witness` (`private` function) * constructor * import Compact `standard library` (`init`, `stdlib`) * `if` statement (`cond`) * `map` (`for`) * `fold` * `enum` * `struct` * `module` * `assert` * `pragma` There is also a `compact` template, which will generate a simple Compact skeleton for a contract. ![Code snippets and errors](https://docs.midnight.network/assets/images/code-snippets-errors-6017f43d451ce0ec358c4a8c1fdfa6ae.gif) ### New Compact smart contract[​](https://docs.midnight.network/compact/reference/tools/vsc-plugin#new-compact-smart-contract "Direct link to New Compact smart contract") If you are creating DApp, you can create a new smart contract with an empty ledger and a single circuit as follows: 1. Bring up the commands pallette (Cmd+Shift+P). 2. Select **Snippets: Fill File with Snippet**. 3. Select **Compact**. Be aware: if you perform these steps in an existing file, the contents of the file are overwritten. Other snippets are available from inside the file. Just start typing the name of the function. ![File template](https://docs.midnight.network/assets/images/file-template-948ccce3632ac1881582a420a797e703.gif) License[​](https://docs.midnight.network/compact/reference/tools/vsc-plugin#license "Direct link to License") -------------------------------------------------------------------------------------------------------------- The Visual Studio Code extension for Compact is distributed under the Apache 2.0 license. * [Features](https://docs.midnight.network/compact/reference/tools/vsc-plugin#features) * [Syntax highlighting](https://docs.midnight.network/compact/reference/tools/vsc-plugin#syntax-highlighting) * [Building Compact source files and error highlighting](https://docs.midnight.network/compact/reference/tools/vsc-plugin#building-compact-source-files-and-error-highlighting) * [Code snippets](https://docs.midnight.network/compact/reference/tools/vsc-plugin#code-snippets) * [New Compact smart contract](https://docs.midnight.network/compact/reference/tools/vsc-plugin#new-compact-smart-contract) * [License](https://docs.midnight.network/compact/reference/tools/vsc-plugin#license) --- # TransactionToProve | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionToProve#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / TransactionToProve Type alias: TransactionToProve ============================== type TransactionToProve: { transaction: UnprovenTransaction; type: typeof TRANSACTION_TO_PROVE;}; Transaction data for proving Remarks[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionToProve#remarks "Direct link to Remarks") ------------------------------------------------------------------------------------------------------------------------------------ TransactionToProve is a data structure used for proving the unproven transaction. Type declaration[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionToProve#type-declaration "Direct link to Type declaration") --------------------------------------------------------------------------------------------------------------------------------------------------------------- ### transaction[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionToProve#transaction "Direct link to transaction") readonly transaction: UnprovenTransaction; Unproven transaction which needs to be proven. ### type[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionToProve#type "Direct link to type") readonly type: typeof TRANSACTION_TO_PROVE; Used to identify the transaction type * [Remarks](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionToProve#remarks) * [Type declaration](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionToProve#type-declaration) * [transaction](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionToProve#transaction) * [type](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionToProve#type) --- # Nonce | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/type-aliases/Nonce#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / Nonce Type alias: Nonce ================= type Nonce: string; A Zswap nonce, as a hex-encoded 256-bit string --- # EncPublicKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/type-aliases/EncPublicKey#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / EncPublicKey Type alias: EncPublicKey ======================== type EncPublicKey: string; An encryption public key, used to inform users of new coins sent to them --- # One doc tagged with "getting-started" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/getting-started#__docusaurus_skipToContent_fallback) [Install the toolchain\ ---------------------](https://docs.midnight.network/next/getting-started/installation) Get your Midnight development environment running to set up tools, configure wallets, and deploy your first zero-knowledge application. --- # One doc tagged with "glossary" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/glossary#__docusaurus_skipToContent_fallback) [Glossary\ --------](https://docs.midnight.network/next/glossary) Coin --- # One doc tagged with "dapp" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/dapp#__docusaurus_skipToContent_fallback) [Zero Knowledge loan DApp\ ------------------------](https://docs.midnight.network/next/tutorials/advanced/zk-loan-dapp) Build a zero knowledge loan DApp on Midnight Network. --- # Midnight SDKs | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks#__docusaurus_skipToContent_fallback) Explore with… ▾ Build privacy-preserving decentralized applications with Midnight's comprehensive SDK ecosystem. Whether you're creating smart contracts, wallets, or full-stack DApps, we have the tools you need. * * * 🚀 Official SDKs[​](https://docs.midnight.network/sdks#-official-sdks "Direct link to 🚀 Official SDKs") --------------------------------------------------------------------------------------------------------- ### Midnight.js Complete TypeScript implementation of the Midnight Network. Includes contract interaction, wallet management, and zero-knowledge proof generation. [Documentation](https://docs.midnight.network/sdks/official/midnight-js) [GitHub](https://github.com/midnightntwrk/midnight-js) ### Wallet SDK SDK for building custom wallets and managing private keys, transactions, and state. Provides fine-grained control over wallet operations. [Documentation](https://docs.midnight.network/sdks/official/wallet-developer-guide) [GitHub](https://github.com/midnightntwrk/midnight-wallet) --- # WalletState | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/wallet-api v5.0.0** • [Readme](https://docs.midnight.network/api-reference/wallet-api) | [API](https://docs.midnight.network/api-reference/wallet-api/globals) * * * [@midnight-ntwrk/wallet-api v5.0.0](https://docs.midnight.network/api-reference/wallet-api) / WalletState Type alias: WalletState ======================= type WalletState: { address: Address; addressLegacy: AddressLegacy; availableCoins: QualifiedCoinInfo[]; balances: Record; coinPublicKey: CoinPublicKey; coinPublicKeyLegacy: CoinPublicKeyLegacy; coins: QualifiedCoinInfo[]; encryptionPublicKey: EncPublicKey; encryptionPublicKeyLegacy: EncPublicKeyLegacy; nullifiers: Nullifier[]; pendingCoins: CoinInfo[]; syncProgress: SyncProgress | undefined; transactionHistory: TransactionHistoryEntry[];}; Wallet state information Remarks[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#remarks "Direct link to Remarks") ----------------------------------------------------------------------------------------------------------------------------- WalletState is a data structure used for storing wallet state information, such as wallet coins, balances, transaction history, etc. Type declaration[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#type-declaration "Direct link to Type declaration") -------------------------------------------------------------------------------------------------------------------------------------------------------- ### address[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#address "Direct link to address") readonly address: Address; Wallet [address](https://docs.midnight.network/api-reference/wallet-api/type-aliases/Address) ### addressLegacy[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#addresslegacy "Direct link to addressLegacy") readonly addressLegacy: AddressLegacy; Wallet [address](https://docs.midnight.network/api-reference/wallet-api/type-aliases/AddressLegacy) ### availableCoins[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#availablecoins "Direct link to availableCoins") readonly availableCoins: QualifiedCoinInfo[]; All available wallet coins that can be spent immediately. ### balances[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#balances "Direct link to balances") readonly balances: Record; A map of balances for all available coins, where the key is a [TokenType](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TokenType) and the value is a balance. Note that this won't list any zero balance coins ### coinPublicKey[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#coinpublickey "Direct link to coinPublicKey") readonly coinPublicKey: CoinPublicKey; Wallet [CoinPublicKey](https://docs.midnight.network/api-reference/wallet-api/type-aliases/CoinPublicKey) ### coinPublicKeyLegacy[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#coinpublickeylegacy "Direct link to coinPublicKeyLegacy") readonly coinPublicKeyLegacy: CoinPublicKeyLegacy; Wallet [CoinPublicKeyLegacy](https://docs.midnight.network/api-reference/wallet-api/type-aliases/CoinPublicKeyLegacy) ### coins[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#coins "Direct link to coins") readonly coins: QualifiedCoinInfo[]; All wallet coins (including those which are pending to spend) ### encryptionPublicKey[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#encryptionpublickey "Direct link to encryptionPublicKey") readonly encryptionPublicKey: EncPublicKey; Wallet EncryptionPublicKey ### encryptionPublicKeyLegacy[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#encryptionpublickeylegacy "Direct link to encryptionPublicKeyLegacy") readonly encryptionPublicKeyLegacy: EncPublicKeyLegacy; Wallet [EncPublicKeyLegacy](https://docs.midnight.network/api-reference/wallet-api/type-aliases/EncPublicKeyLegacy) ### nullifiers[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#nullifiers "Direct link to nullifiers") readonly nullifiers: Nullifier[]; Nullifiers corresponding to the coins. For `0 <= i < coins.length`, nullifiers\[i\] corresponds to coins\[i\] ### pendingCoins[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#pendingcoins "Direct link to pendingCoins") readonly pendingCoins: CoinInfo[]; The coins the wallet is expecting to receive in the future, but which are not yet available for spending ### syncProgress[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#syncprogress "Direct link to syncProgress") readonly syncProgress: SyncProgress | undefined; [SyncProgress](https://docs.midnight.network/api-reference/wallet-api/type-aliases/SyncProgress) of the wallet It can be undefined when wallet is started and if it is not syncing ### transactionHistory[​](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#transactionhistory "Direct link to transactionHistory") readonly transactionHistory: TransactionHistoryEntry[]; Transaction history - an array of [TransactionHistoryEntry](https://docs.midnight.network/api-reference/wallet-api/type-aliases/TransactionHistoryEntry) sorted from the oldest one to the newest one. * [Remarks](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#remarks) * [Type declaration](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#type-declaration) * [address](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#address) * [addressLegacy](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#addresslegacy) * [availableCoins](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#availablecoins) * [balances](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#balances) * [coinPublicKey](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#coinpublickey) * [coinPublicKeyLegacy](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#coinpublickeylegacy) * [coins](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#coins) * [encryptionPublicKey](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#encryptionpublickey) * [encryptionPublicKeyLegacy](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#encryptionpublickeylegacy) * [nullifiers](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#nullifiers) * [pendingCoins](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#pendingcoins) * [syncProgress](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#syncprogress) * [transactionHistory](https://docs.midnight.network/api-reference/wallet-api/type-aliases/WalletState#transactionhistory) --- # CoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / CoinInfo Type alias: CoinInfo ==================== type CoinInfo: { nonce: Nonce; type: TokenType; value: bigint;}; Information required to create a new coin, alongside details about the recipient Type declaration[​](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinInfo#type-declaration "Direct link to Type declaration") ------------------------------------------------------------------------------------------------------------------------------------------------ ### nonce[​](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinInfo#nonce "Direct link to nonce") nonce: Nonce; ### type[​](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinInfo#type "Direct link to type") type: TokenType; ### value[​](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinInfo#value "Direct link to value") value: bigint; * [Type declaration](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinInfo#type-declaration) * [nonce](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinInfo#nonce) * [type](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinInfo#type) * [value](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinInfo#value) --- # TokenType | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/type-aliases/TokenType#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / TokenType Type alias: TokenType ===================== type TokenType: string; A token type (or color), as a hex-encoded 35-byte string --- # Nullifier | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/type-aliases/Nullifier#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / Nullifier Type alias: Nullifier ===================== type Nullifier: string; A Zswap nullifier, as a hex-encoded 256-bit bitstring --- # 2 docs tagged with "errors" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/errors#__docusaurus_skipToContent_fallback) [Fix package repository access failures\ --------------------------------------](https://docs.midnight.network/next/how-to/fix-package-repository-access-failures) Resolve 403 Forbidden errors when installing Midnight npm packages with three proven solutions. [Fix version mismatch errors\ ---------------------------](https://docs.midnight.network/next/how-to/fix-version-mismatches) Resolve version compatibility issues between Midnight compiler, runtime, and other components using the official compatibility matrix. --- # One doc tagged with "loan" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/loan#__docusaurus_skipToContent_fallback) [Zero Knowledge loan DApp\ ------------------------](https://docs.midnight.network/next/tutorials/advanced/zk-loan-dapp) Build a zero knowledge loan DApp on Midnight Network. --- # One doc tagged with "Midnight.js" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/midnight-js#__docusaurus_skipToContent_fallback) [Midnight Preview Network onboarding guide\ -----------------------------------------](https://docs.midnight.network/next/how-to/migrate-from-testnet-02-to-preview) Learn how to migrate your existing applications running on testnet-02 to the preview environment. --- # One doc tagged with "nextjs" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/nextjs#__docusaurus_skipToContent_fallback) [Create a Next.js wallet connector\ ---------------------------------](https://docs.midnight.network/next/guides/nextjs-wallet-connect) Learn how to create a Next.js application that connects to a wallet using the Midnight DApp Connector API. --- # One doc tagged with "nixos" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/nixos#__docusaurus_skipToContent_fallback) [Troubleshoot Compact toolchain installation issue on NixOS\ ----------------------------------------------------------](https://docs.midnight.network/next/troubleshoot/troubleshoot-compact-nixos) Troubleshoot Midnight Compact tools installation issue on NixOS --- # Writing a contract | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/writing#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ Midnight comes with its own programming language, _Compact_, which enables you to write smart contracts as described in the overview. The Compact compiler outputs zero-knowledge circuits that are used to prove the correctness of interactions with the _ledger_. This page walks through the construction of a simple smart contract, which manages a publicly accessible value and supports the operations `get`, `set`, and `clear`. Because the value is public, anyone can call `get`, but if the value is currently set, only the user that last called `set` can `clear` it, and it must be `clear`ed before `set`ting it again. To start, the contract specifies the version of the language it is using, imports Midnight's standard libraries, and declares an `enum` for the state it may currently be in: pragma language_version 0.16;import CompactStandardLibrary;enum State { UNSET, SET} In addition to the `enum` declaration, custom data can also be defined with `struct`s. Details can be found in the language reference. The `ledger` section[​](https://docs.midnight.network/compact/writing#the-ledger-section "Direct link to the-ledger-section") ------------------------------------------------------------------------------------------------------------------------------ A key part of a Compact smart contract is the `ledger` section, which describes the state kept on chain. This example stores a key that can be used to identify the user who is permitted to `clear` the value, the value itself (this example uses a 64-bit unsigned integer), and what state the contract is in. In addition to these, it is necessary to add a `round` counter, which is useful to retain anonymity, as discussed below. Each field in a smart contract's on-chain state is declared with a `ledger` declaration. A constructor can be used to initialize the ledger fields when the contract is deployed. In this case, the ledger declarations are as follows: export ledger authority: Bytes<32>;export ledger value: Uint<64>;export ledger state: State;export ledger round: Counter;constructor(sk: Bytes<32>, v: Uint<64>) { authority = disclose(publicKey(round, sk)); value = disclose(v); state = State.SET;}circuit publicKey(round: Field, sk: Bytes<32>): Bytes<32> { return persistentHash>>( [pad(32, "midnight:examples:lock:pk"), round as Bytes<32>, sk]);} In addition to the `ledger` section, the `constructor` also demonstrates basic interaction with the state contained in it, using the field names to refer to the items in the ledger's state. Many ledger types also support _operations_ as demonstrated in `clear`. The `circuit` definitions[​](https://docs.midnight.network/compact/writing#the-circuit-definitions "Direct link to the-circuit-definitions") --------------------------------------------------------------------------------------------------------------------------------------------- The example above already demonstrates use of a `circuit` to calculate the `publicKey` of a user. A `circuit` in Compact is equivalent to a function in many programming languages, but it is restricted to fixed computational bounds at compile time. A smart contract's `circuit`s can also be its main entry points; they are what users can call directly in transactions. Of the three entry points mentioned above, `get` is _unrestricted_ and is simply implemented as follows: export circuit get(): Uint<64> { assert(state == State.SET, "Attempted to get uninitialized value"); return value;} Here `export` marks this circuit as an entry point to the smart contract, and `assert` ensures that it can only be used when the contract is in the correct state. The [language reference](https://docs.midnight.network/compact/lang-ref#circuits) details permissible contents of `circuit`s. Local state and computations[​](https://docs.midnight.network/compact/writing#local-state-and-computations "Direct link to Local state and computations") ---------------------------------------------------------------------------------------------------------------------------------------------------------- The third context mentioned was the local machine of the user. This is explicitly programmable in the form of the DApp running on the user's machine. Compact can 'call out' to the local context through _witnesses_\[^1\], which are declared in a similar way to circuits. In this case, retrieving a user's _secret key_ requires such a witness, because the secret must be kept local to a user's machine. The code for this follows: witness secretKey(): Bytes<32>;export circuit set(v: Uint<64>): [] { assert(state == State.UNSET, "Attempted to set initialized value"); const sk = secretKey(); const pk = publicKey(round, sk); authority = disclose(pk); value = disclose(v); state = State.SET;}export circuit clear(): [] { assert(state == State.SET, "Attempted to clear uninitialized value"); const sk = secretKey(); const pk = publicKey(round, sk); assert(authority == pk, "Attempted to clear without authorization"); state = State.UNSET; round.increment(1);} Note that the `witness` is not implemented in the Compact source code. Instead, the implementation is the responsibility of the TypeScript code of the DApp. It's important to note that each user could reasonably use a different implementation for the `witness`, so its results cannot be trusted inherently by the contract. The full contract[​](https://docs.midnight.network/compact/writing#the-full-contract "Direct link to The full contract") ------------------------------------------------------------------------------------------------------------------------- All put together, the full example is: pragma language_version 0.16;import CompactStandardLibrary;enum State { UNSET, SET}export ledger authority: Bytes<32>;export ledger value: Uint<64>;export ledger state: State;export ledger round: Counter;constructor(sk: Bytes<32>, v: Uint<64>) { authority = disclose(publicKey(round, sk)); value = disclose(v); state = State.SET;}circuit publicKey(round: Field, sk: Bytes<32>): Bytes<32> { return persistentHash>>( [pad(32, "midnight:examples:lock:pk"), round as Bytes<32>, sk]);}export circuit get(): Uint<64> { assert(state == State.SET, "Attempted to get uninitialized value"); return value;}witness secretKey(): Bytes<32>;export circuit set(v: Uint<64>): [] { assert(state == State.UNSET, "Attempted to set initialized value"); const sk = secretKey(); const pk = publicKey(round, sk); authority = disclose(pk); value = disclose(v); state = State.SET;}export circuit clear(): [] { assert(state == State.SET, "Attempted to clear uninitialized value"); const sk = secretKey(); const pk = publicKey(round, sk); assert(authority == pk, "Attempted to clear without authorization"); state = State.UNSET; round.increment(1);} Basic confidentiality[​](https://docs.midnight.network/compact/writing#basic-confidentiality "Direct link to Basic confidentiality") ------------------------------------------------------------------------------------------------------------------------------------- It may not be immediately apparent what is held confidential in this example and what is enforced in the contract. Thankfully, both are well-defined: * all data that is not a ledger field and is not an argument or return value of a ledger operation is kept confidential * all computation that is not done in a `witness` function is enforced to be correct. In particular, observe that this keeps the `secretKey` output confidential, while enforcing that _its hash_ is the correct value in the case of `clear`. This is also the reason for the `round` parameter: The `pk` "public key" _isn't_ confidential, and would allow linkability between the same user publishing data in multiple rounds. By adding a round parameter into the public key computation, this linkability is broken. Despite the terms "secret key" and "public key", these two keys are _not_ public key cryptography: they are simply a binary string and its hash. This is due to zero-knowledge circuits being able to have similar effects to digital signatures, relying only on the preimage resistance of hashes. This pattern of hashing an arbitrary binary string and using it as a key is quite powerful. A similar concept that can be very useful is the use of _commitment schemes_, where arbitrary data is hashed together with a random _nonce_. The result can be safely placed into the ledger's state, without revealing the original data. (Note that the nonce _must_ not be reused. If it is, you can link the commitments with the same nonces and values.) At a later point, the commitment can be "opened" by revealing the value and nonce, or a contract can simply prove (`assert`) that it _has_ the correct value and nonce, without ever revealing them. The `CompactStandardLibrary` module provides the following circuits for such uses: circuit transientHash(value: T): Field;circuit transientCommit(value: T, rand: Field): Field;circuit persistentHash(value: T): Bytes<32>;circuit persistentCommit(value: T, rand: Bytes<32>): Bytes<32>; The `*Hash` variants are the basic hash function, with `*Commit` being a commitment function to arbitrary data. The `transient*` functions should only be used when the values are _not_ kept in state, while `persistent*` outputs being suitable for storage in a contract's `ledger` state. Next steps[​](https://docs.midnight.network/compact/writing#next-steps "Direct link to Next steps") ---------------------------------------------------------------------------------------------------- This section continues with a more detailed overview of the Compact language. Alternatively, you may wish to jump to a [more detailed example](https://docs.midnight.network/develop/tutorial) that showcases some more interesting things you can do with a DApp on Midnight. While this section has focused on the Compact language, the section about how Midnight works provides more detail about Midnight's ledger and how it functions. \[^1\] The name _witness_ comes from zero-knowledge literature; the etymology is roughly that it's the evidence you need to believe a statement. In this example, it's the evidence you need to believe that a `clear` was permissible. * [The `ledger` section](https://docs.midnight.network/compact/writing#the-ledger-section) * [The `circuit` definitions](https://docs.midnight.network/compact/writing#the-circuit-definitions) * [Local state and computations](https://docs.midnight.network/compact/writing#local-state-and-computations) * [The full contract](https://docs.midnight.network/compact/writing#the-full-contract) * [Basic confidentiality](https://docs.midnight.network/compact/writing#basic-confidentiality) * [Next steps](https://docs.midnight.network/compact/writing#next-steps) --- # Alignment | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/Alignment#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / Alignment Type alias: Alignment ===================== type Alignment: AlignmentSegment[]; The alignment of an onchain field-aligned binary data value. --- # CoinCommitment | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinCommitment#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / CoinCommitment Type alias: CoinCommitment ========================== type CoinCommitment: string; A Zswap coin commitment, as a hex-encoded 256-bit bitstring --- # CoinPublicKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinPublicKey#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / CoinPublicKey Type alias: CoinPublicKey ========================= type CoinPublicKey: string; A user public key capable of receiving Zswap coins, as a hex-encoded 35-byte string --- # DomainSeperator | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/DomainSeperator#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / DomainSeperator Type alias: DomainSeperator =========================== type DomainSeperator: Uint8Array; A token domain seperator, the pre-stage of `TokenType`, as 32-byte bytearray --- # Alignment | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Alignment#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / Alignment Type alias: Alignment ===================== type Alignment: AlignmentSegment[]; The alignment of an onchain field-aligned binary data value. --- # AlignedValue | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / AlignedValue Type alias: AlignedValue ======================== type AlignedValue: { alignment: Alignment; value: Value;}; An onchain data value, in field-aligned binary format, annotated with its alignment. Type declaration[​](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue#type-declaration "Direct link to Type declaration") ----------------------------------------------------------------------------------------------------------------------------------------------------- ### alignment[​](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue#alignment "Direct link to alignment") alignment: Alignment; ### value[​](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue#value "Direct link to value") value: Value; * [Type declaration](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue#type-declaration) * [alignment](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue#alignment) * [value](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue#value) --- # AlignmentAtom | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignmentAtom#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / AlignmentAtom Type alias: AlignmentAtom ========================= type AlignmentAtom: { tag: "compress"; } | { tag: "field"; } | { length: number; tag: "bytes";}; A atom in a larger [Alignment](https://docs.midnight.network/api-reference/ledger/type-aliases/Alignment) . --- # AlignmentSegment | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignmentSegment#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / AlignmentSegment Type alias: AlignmentSegment ============================ type AlignmentSegment: { tag: "option"; value: Alignment[]; } | { tag: "atom"; value: AlignmentAtom;}; A segment in a larger [Alignment](https://docs.midnight.network/api-reference/ledger/type-aliases/Alignment) . --- # CommunicationCommitmentRand | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/CommunicationCommitmentRand#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / CommunicationCommitmentRand Type alias: CommunicationCommitmentRand ======================================= type CommunicationCommitmentRand: string; The hex-encoded randomness to [CommunicationCommitment](https://docs.midnight.network/api-reference/ledger/type-aliases/CommunicationCommitment) --- # EncPublicKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/EncPublicKey#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / EncPublicKey Type alias: EncPublicKey ======================== type EncPublicKey: string; An encryption public key, used to inform users of new coins sent to them --- # ContractAction | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/ContractAction#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ContractAction Type alias: ContractAction ========================== type ContractAction: ContractCall | ContractDeploy | MaintenanceUpdate; An interactions with a contract --- # CommunicationCommitment | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/CommunicationCommitment#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / CommunicationCommitment Type alias: CommunicationCommitment =================================== type CommunicationCommitment: string; A hex-encoded commitment of data shared between two contracts in a call --- # AlignmentSegment | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignmentSegment#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / AlignmentSegment Type alias: AlignmentSegment ============================ type AlignmentSegment: { tag: "option"; value: Alignment[]; } | { tag: "atom"; value: AlignmentAtom;}; A segment in a larger [Alignment](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Alignment) . --- # AlignmentAtom | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignmentAtom#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / AlignmentAtom Type alias: AlignmentAtom ========================= type AlignmentAtom: { tag: "compress"; } | { tag: "field"; } | { length: number; tag: "bytes";}; A atom in a larger [Alignment](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Alignment) . --- # CoinCommitment | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/CoinCommitment#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / CoinCommitment Type alias: CoinCommitment ========================== type CoinCommitment: string; A Zswap coin commitment, as a hex-encoded 256-bit bitstring --- # CoinPublicKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/CoinPublicKey#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / CoinPublicKey Type alias: CoinPublicKey ========================= type CoinPublicKey: string; A user public key capable of receiving Zswap coins, as a hex-encoded 35-byte string --- # DomainSeperator | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/DomainSeperator#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / DomainSeperator Type alias: DomainSeperator =========================== type DomainSeperator: Uint8Array; A token domain seperator, the pre-stage of `TokenType`, as 32-byte bytearray --- # ContractAddress | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/ContractAddress#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / ContractAddress Type alias: ContractAddress =========================== type ContractAddress: string; A contract address, as a hex-encoded 35-byte string --- # TransactionId | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/type-aliases/TransactionId#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / TransactionId Type alias: TransactionId ========================= type TransactionId: string; A transaction identifier, used to index merged transactions --- # TransactionHash | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/type-aliases/TransactionHash#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / TransactionHash Type alias: TransactionHash =========================== type TransactionHash: string; The hash of a transaction, as a hex-encoded 256-bit bytestring --- # 3 docs tagged with "compact" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/compact#__docusaurus_skipToContent_fallback) [Create your first Midnight contract\ -----------------------------------](https://docs.midnight.network/next/getting-started/hello-world) Learn how to create and compile a Hello World smart contract on Midnight's Preprod network. [Set up Bun for Midnight development\ -----------------------------------](https://docs.midnight.network/next/how-to/bun-runtime-midnight) Set up Bun package manager and the Compact compiler to build smart contracts and applications on the Midnight blockchain. [Troubleshoot Compact toolchain installation issue on NixOS\ ----------------------------------------------------------](https://docs.midnight.network/next/troubleshoot/troubleshoot-compact-nixos) Troubleshoot Midnight Compact tools installation issue on NixOS --- # 2 docs tagged with "installation" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/installation#__docusaurus_skipToContent_fallback) [Fix package repository access failures\ --------------------------------------](https://docs.midnight.network/next/how-to/fix-package-repository-access-failures) Resolve 403 Forbidden errors when installing Midnight npm packages with three proven solutions. [Set up Bun for Midnight development\ -----------------------------------](https://docs.midnight.network/next/how-to/bun-runtime-midnight) Set up Bun package manager and the Compact compiler to build smart contracts and applications on the Midnight blockchain. --- # ContractAddress | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/ContractAddress#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ContractAddress Type alias: ContractAddress =========================== type ContractAddress: string; A contract address, as a hex-encoded 35-byte string --- # Fr | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/Fr#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / Fr Type alias: Fr ============== type Fr: Uint8Array; An internal encoding of a value of the proof systems scalar field --- # Effects | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/Effects#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / Effects Type alias: Effects =================== type Effects: { claimedContractCalls: [bigint, ContractAddress, string, Fr][]; claimedNullifiers: Nullifier[]; claimedReceives: CoinCommitment[]; claimedSpends: CoinCommitment[]; mints: Map;}; The contract-external effects of a transcript. Type declaration[​](https://docs.midnight.network/api-reference/ledger/type-aliases/Effects#type-declaration "Direct link to Type declaration") ------------------------------------------------------------------------------------------------------------------------------------------------ ### claimedContractCalls[​](https://docs.midnight.network/api-reference/ledger/type-aliases/Effects#claimedcontractcalls "Direct link to claimedContractCalls") claimedContractCalls: [bigint, ContractAddress, string, Fr][]; The contracts called from this contract. The values are, in order: * The sequence number of this call * The contract being called * The entry point being called * The communications commitment ### claimedNullifiers[​](https://docs.midnight.network/api-reference/ledger/type-aliases/Effects#claimednullifiers "Direct link to claimedNullifiers") claimedNullifiers: Nullifier[]; The nullifiers (spends) this contract call requires ### claimedReceives[​](https://docs.midnight.network/api-reference/ledger/type-aliases/Effects#claimedreceives "Direct link to claimedReceives") claimedReceives: CoinCommitment[]; The coin commitments (outputs) this contract call requires, as coins received ### claimedSpends[​](https://docs.midnight.network/api-reference/ledger/type-aliases/Effects#claimedspends "Direct link to claimedSpends") claimedSpends: CoinCommitment[]; The coin commitments (outputs) this contract call requires, as coins sent ### mints[​](https://docs.midnight.network/api-reference/ledger/type-aliases/Effects#mints "Direct link to mints") mints: Map; The tokens minted in this call, as a map from hex-encoded 256-bit domain separators to non-negative 64-bit integers. * [Type declaration](https://docs.midnight.network/api-reference/ledger/type-aliases/Effects#type-declaration) * [claimedContractCalls](https://docs.midnight.network/api-reference/ledger/type-aliases/Effects#claimedcontractcalls) * [claimedNullifiers](https://docs.midnight.network/api-reference/ledger/type-aliases/Effects#claimednullifiers) * [claimedReceives](https://docs.midnight.network/api-reference/ledger/type-aliases/Effects#claimedreceives) * [claimedSpends](https://docs.midnight.network/api-reference/ledger/type-aliases/Effects#claimedspends) * [mints](https://docs.midnight.network/api-reference/ledger/type-aliases/Effects#mints) --- # BlockContext | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/BlockContext#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / BlockContext Type alias: BlockContext ======================== type BlockContext: { blockHash: string; secondsSinceEpoch: bigint; secondsSinceEpochErr: number;}; The context information about a block available inside the VM Type declaration[​](https://docs.midnight.network/api-reference/ledger/type-aliases/BlockContext#type-declaration "Direct link to Type declaration") ----------------------------------------------------------------------------------------------------------------------------------------------------- ### blockHash[​](https://docs.midnight.network/api-reference/ledger/type-aliases/BlockContext#blockhash "Direct link to blockHash") blockHash: string; The hash of the block prior to this transaction, as a hex-encoded string ### secondsSinceEpoch[​](https://docs.midnight.network/api-reference/ledger/type-aliases/BlockContext#secondssinceepoch "Direct link to secondsSinceEpoch") secondsSinceEpoch: bigint; The seconds since the UNIX epoch that have elapsed ### secondsSinceEpochErr[​](https://docs.midnight.network/api-reference/ledger/type-aliases/BlockContext#secondssinceepocherr "Direct link to secondsSinceEpochErr") secondsSinceEpochErr: number; The maximum error on secondsSinceEpoch that should occur, as a positive seconds value * [Type declaration](https://docs.midnight.network/api-reference/ledger/type-aliases/BlockContext#type-declaration) * [blockHash](https://docs.midnight.network/api-reference/ledger/type-aliases/BlockContext#blockhash) * [secondsSinceEpoch](https://docs.midnight.network/api-reference/ledger/type-aliases/BlockContext#secondssinceepoch) * [secondsSinceEpochErr](https://docs.midnight.network/api-reference/ledger/type-aliases/BlockContext#secondssinceepocherr) --- # CoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / CoinInfo Type alias: CoinInfo ==================== type CoinInfo: { nonce: Nonce; type: TokenType; value: bigint;}; Information required to create a new coin, alongside details about the recipient Type declaration[​](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo#type-declaration "Direct link to Type declaration") ------------------------------------------------------------------------------------------------------------------------------------------------- ### nonce[​](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo#nonce "Direct link to nonce") nonce: Nonce; The coin's randomness, preventing it from colliding with other coins ### type[​](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo#type "Direct link to type") type: TokenType; The coin's type, identifying the currency it represents ### value[​](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo#value "Direct link to value") value: bigint; The coin's value, in atomic units dependent on the currency Bounded to be a non-negative 64-bit integer * [Type declaration](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo#type-declaration) * [nonce](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo#nonce) * [type](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo#type) * [value](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo#value) --- # Nullifier | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/Nullifier#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / Nullifier Type alias: Nullifier ===================== type Nullifier: string; A Zswap nullifier, as a hex-encoded 256-bit bitstring --- # Nonce | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/Nonce#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / Nonce Type alias: Nonce ================= type Nonce: string; A Zswap nonce, as a hex-encoded 256-bit string --- # GatherResult | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/GatherResult#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / GatherResult Type alias: GatherResult ======================== type GatherResult: { content: AlignedValue; tag: "read"; } | { content: EncodedStateValue; tag: "log";}; An individual result of observing the results of a non-verifying VM program execution --- # Signature | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/Signature#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / Signature Type alias: Signature ===================== type Signature: string; A hex-encoded signature BIP-340 signature, with a 3-byte version prefix --- # Key | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/Key#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / Key Type alias: Key =============== type Key: { tag: "value"; value: AlignedValue; } | { tag: "stack";}; A key used to index into an array or map in the onchain VM --- # SigningKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/SigningKey#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / SigningKey Type alias: SigningKey ====================== type SigningKey: string; A hex-encoded signature BIP-340 signing key, with a 3-byte version prefix --- # TransactionHash | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/TransactionHash#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / TransactionHash Type alias: TransactionHash =========================== type TransactionHash: string; The hash of a transaction, as a hex-encoded 256-bit bytestring --- # QualifiedCoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / QualifiedCoinInfo Type alias: QualifiedCoinInfo ============================= type QualifiedCoinInfo: { mt_index: bigint; nonce: Nonce; type: TokenType; value: bigint;}; Information required to spend an existing coin, alongside authorization of the owner Type declaration[​](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo#type-declaration "Direct link to Type declaration") ---------------------------------------------------------------------------------------------------------------------------------------------------------- ### mt\_index[​](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo#mt_index "Direct link to mt_index") mt_index: bigint; The coin's location in the chain's Merkle tree of coin commitments Bounded to be a non-negative 64-bit integer ### nonce[​](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo#nonce "Direct link to nonce") nonce: Nonce; The coin's randomness, preventing it from colliding with other coins ### type[​](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo#type "Direct link to type") type: TokenType; The coin's type, identifying the currency it represents ### value[​](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo#value "Direct link to value") value: bigint; The coin's value, in atomic units dependent on the currency Bounded to be a non-negative 64-bit integer * [Type declaration](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo#type-declaration) * [mt\_index](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo#mt_index) * [nonce](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo#nonce) * [type](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo#type) * [value](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo#value) --- # SignatureVerifyingKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/SignatureVerifyingKey#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / SignatureVerifyingKey Type alias: SignatureVerifyingKey ================================= type SignatureVerifyingKey: string; A hex-encoded signature BIP-340 verifying key, with a 3-byte version prefix --- # TokenType | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/TokenType#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / TokenType Type alias: TokenType ===================== type TokenType: string; A token type (or color), as a hex-encoded 35-byte string --- # TransactionId | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/TransactionId#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / TransactionId Type alias: TransactionId ========================= type TransactionId: string; A transaction identifier, used to index merged transactions --- # Value | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/Value#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / Value Type alias: Value ================= type Value: Uint8Array[]; An onchain data value, in field-aligned binary format. --- # QualifiedCoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/type-aliases/QualifiedCoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / QualifiedCoinInfo Type alias: QualifiedCoinInfo ============================= type QualifiedCoinInfo: { mt_index: bigint; nonce: Nonce; type: TokenType; value: bigint;}; Information required to spend an existing coin, alongside authorization of the owner Type declaration[​](https://docs.midnight.network/api-reference/zswap/type-aliases/QualifiedCoinInfo#type-declaration "Direct link to Type declaration") --------------------------------------------------------------------------------------------------------------------------------------------------------- ### mt\_index[​](https://docs.midnight.network/api-reference/zswap/type-aliases/QualifiedCoinInfo#mt_index "Direct link to mt_index") mt_index: bigint; ### nonce[​](https://docs.midnight.network/api-reference/zswap/type-aliases/QualifiedCoinInfo#nonce "Direct link to nonce") nonce: Nonce; ### type[​](https://docs.midnight.network/api-reference/zswap/type-aliases/QualifiedCoinInfo#type "Direct link to type") type: TokenType; ### value[​](https://docs.midnight.network/api-reference/zswap/type-aliases/QualifiedCoinInfo#value "Direct link to value") value: bigint; * [Type declaration](https://docs.midnight.network/api-reference/zswap/type-aliases/QualifiedCoinInfo#type-declaration) * [mt\_index](https://docs.midnight.network/api-reference/zswap/type-aliases/QualifiedCoinInfo#mt_index) * [nonce](https://docs.midnight.network/api-reference/zswap/type-aliases/QualifiedCoinInfo#nonce) * [type](https://docs.midnight.network/api-reference/zswap/type-aliases/QualifiedCoinInfo#type) * [value](https://docs.midnight.network/api-reference/zswap/type-aliases/QualifiedCoinInfo#value) --- # Build using MeshSDK | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/community/build-using-meshsdk#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ Complete development setup for building Midnight Network DApps using Mesh SDK. Overview[​](https://docs.midnight.network/sdks/community/build-using-meshsdk#overview "Direct link to Overview") ----------------------------------------------------------------------------------------------------------------- **[@meshsdk/midnight-setup](https://www.npmjs.com/package/@meshsdk/midnight-setup) ** provides a comprehensive toolkit for Midnight Network development. This toolkit includes everything you need to build Midnight Network DApps: * **@meshsdk/midnight-setup** - Main npm package with API and types * **packages/ui** - Example React application * **packages/cli** - Command-line tools * **packages/api** - Core API implementation **Example repository** [midnight-setup](https://github.com/MeshJS/midnight-setup) Key features[​](https://docs.midnight.network/sdks/community/build-using-meshsdk#key-features "Direct link to Key features") ----------------------------------------------------------------------------------------------------------------------------- * **Zero-knowledge privacy** - Built for Midnight Network * **TypeScript support** - Full type safety * **React hooks** - Easy integration * **Wallet integration** - Lace Beta Wallet support * **CLI tools** - Development utilities Project structure[​](https://docs.midnight.network/sdks/community/build-using-meshsdk#project-structure "Direct link to Project structure") -------------------------------------------------------------------------------------------------------------------------------------------- ├── packages/│ ├── api/ # Core API implementation│ ├── ui/ # React example app│ └── cli/ # Command-line tools├── compact/ # Smart contract source└── README.md Resources[​](https://docs.midnight.network/sdks/community/build-using-meshsdk#resources "Direct link to Resources") -------------------------------------------------------------------------------------------------------------------- * **NPM Package:** [@meshsdk/midnight-setup](https://www.npmjs.com/package/@meshsdk/midnight-setup) * **Mesh SDK:** [meshjs.dev](https://meshjs.dev/) * **GitHub Repository:** [github.com/MeshJS/midnight-setup](https://github.com/MeshJS/midnight-setup) * [Overview](https://docs.midnight.network/sdks/community/build-using-meshsdk#overview) * [Key features](https://docs.midnight.network/sdks/community/build-using-meshsdk#key-features) * [Project structure](https://docs.midnight.network/sdks/community/build-using-meshsdk#project-structure) * [Resources](https://docs.midnight.network/sdks/community/build-using-meshsdk#resources) --- # Core API methods | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/community/build-using-meshsdk/core-api-methods#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ Midnight setup API[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/core-api-methods#midnight-setup-api "Direct link to Midnight setup API") ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | Method | Description | Usage | | --- | --- | --- | | `deployContract(providers, contractInstance)` | Deploy a new contract | Creates new contract instance | | `joinContract(providers, contractInstance, address)` | Join existing contract | Connect to deployed contract | | `getContractState()` | Read contract state | Get current contract data | | `getLedgerState()` | Read ledger state | Get blockchain data | Provider setup[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/core-api-methods#provider-setup "Direct link to Provider setup") ---------------------------------------------------------------------------------------------------------------------------------------------------- import { setupProviders } from './lib/providers'; const providers = await setupProviders();// Returns: MidnightSetupContractProviders * [Midnight setup API](https://docs.midnight.network/sdks/community/build-using-meshsdk/core-api-methods#midnight-setup-api) * [Provider setup](https://docs.midnight.network/sdks/community/build-using-meshsdk/core-api-methods#provider-setup) --- # List of error codes | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/error-codes#__docusaurus_skipToContent_fallback) Explore with… ▾ List of error codes for the Midnight SDKs and client libraries. --- # One doc tagged with "preview" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/preview#__docusaurus_skipToContent_fallback) [Midnight Preview Network onboarding guide\ -----------------------------------------](https://docs.midnight.network/next/how-to/migrate-from-testnet-02-to-preview) Learn how to migrate your existing applications running on testnet-02 to the preview environment. --- # One doc tagged with "preprod" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/preprod#__docusaurus_skipToContent_fallback) [Interact with hello world contract\ ----------------------------------](https://docs.midnight.network/next/guides/interact-with-mn-app) Build a command-line interface to interact with a deployed hello world contract on the Midnight Network. --- # One doc tagged with "react" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/react#__docusaurus_skipToContent_fallback) [Create a React wallet connector\ -------------------------------](https://docs.midnight.network/next/guides/react-wallet-connect) Learn how to create a React application that connects to a wallet using the Midnight DApp Connector API. --- # One doc tagged with "npm" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/npm#__docusaurus_skipToContent_fallback) [Fix package repository access failures\ --------------------------------------](https://docs.midnight.network/next/how-to/fix-package-repository-access-failures) Resolve 403 Forbidden errors when installing Midnight npm packages with three proven solutions. --- # One doc tagged with "JavaScript" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/java-script#__docusaurus_skipToContent_fallback) [Deploy the hello world contract\ -------------------------------](https://docs.midnight.network/next/guides/deploy-mn-app) Deploy a compiled hello world smart contract to Midnight's Preprod network. --- # AlignedValue | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / AlignedValue Type alias: AlignedValue ======================== type AlignedValue: { alignment: Alignment; value: Value;}; An onchain data value, in field-aligned binary format, annotated with its alignment. Type declaration[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue#type-declaration "Direct link to Type declaration") -------------------------------------------------------------------------------------------------------------------------------------------------------------- ### alignment[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue#alignment "Direct link to alignment") alignment: Alignment; ### value[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue#value "Direct link to value") value: Value; * [Type declaration](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue#type-declaration) * [alignment](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue#alignment) * [value](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue#value) --- # Nonce | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Nonce#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / Nonce Type alias: Nonce ================= type Nonce: string; A Zswap nonce, as a hex-encoded 256-bit string --- # BlockContext | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/BlockContext#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / BlockContext Type alias: BlockContext ======================== type BlockContext: { blockHash: string; secondsSinceEpoch: bigint; secondsSinceEpochErr: number;}; The context information about a block available inside the VM Type declaration[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/BlockContext#type-declaration "Direct link to Type declaration") -------------------------------------------------------------------------------------------------------------------------------------------------------------- ### blockHash[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/BlockContext#blockhash "Direct link to blockHash") blockHash: string; The hash of the block prior to this transaction, as a hex-encoded string ### secondsSinceEpoch[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/BlockContext#secondssinceepoch "Direct link to secondsSinceEpoch") secondsSinceEpoch: bigint; The seconds since the UNIX epoch that have elapsed ### secondsSinceEpochErr[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/BlockContext#secondssinceepocherr "Direct link to secondsSinceEpochErr") secondsSinceEpochErr: number; The maximum error on secondsSinceEpoch that should occur, as a positive seconds value * [Type declaration](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/BlockContext#type-declaration) * [blockHash](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/BlockContext#blockhash) * [secondsSinceEpoch](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/BlockContext#secondssinceepoch) * [secondsSinceEpochErr](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/BlockContext#secondssinceepocherr) --- # CoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/CoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / CoinInfo Type alias: CoinInfo ==================== type CoinInfo: { nonce: Nonce; type: TokenType; value: bigint;}; Information required to create a new coin, alongside details about the recipient Type declaration[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/CoinInfo#type-declaration "Direct link to Type declaration") ---------------------------------------------------------------------------------------------------------------------------------------------------------- ### nonce[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/CoinInfo#nonce "Direct link to nonce") nonce: Nonce; The coin's randomness, preventing it from colliding with other coins ### type[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/CoinInfo#type "Direct link to type") type: TokenType; The coin's type, identifying the currency it represents ### value[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/CoinInfo#value "Direct link to value") value: bigint; The coin's value, in atomic units dependent on the currency Bounded to be a non-negative 64-bit integer * [Type declaration](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/CoinInfo#type-declaration) * [nonce](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/CoinInfo#nonce) * [type](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/CoinInfo#type) * [value](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/CoinInfo#value) --- # Effects | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Effects#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / Effects Type alias: Effects =================== type Effects: { claimedContractCalls: [bigint, ContractAddress, string, Fr][]; claimedNullifiers: Nullifier[]; claimedReceives: CoinCommitment[]; claimedSpends: CoinCommitment[]; mints: Map;}; The contract-external effects of a transcript. Type declaration[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Effects#type-declaration "Direct link to Type declaration") --------------------------------------------------------------------------------------------------------------------------------------------------------- ### claimedContractCalls[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Effects#claimedcontractcalls "Direct link to claimedContractCalls") claimedContractCalls: [bigint, ContractAddress, string, Fr][]; The contracts called from this contract. The values are, in order: * The sequence number of this call * The contract being called * The entry point being called * The communications commitment ### claimedNullifiers[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Effects#claimednullifiers "Direct link to claimedNullifiers") claimedNullifiers: Nullifier[]; The nullifiers (spends) this contract call requires ### claimedReceives[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Effects#claimedreceives "Direct link to claimedReceives") claimedReceives: CoinCommitment[]; The coin commitments (outputs) this contract call requires, as coins received ### claimedSpends[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Effects#claimedspends "Direct link to claimedSpends") claimedSpends: CoinCommitment[]; The coin commitments (outputs) this contract call requires, as coins sent ### mints[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Effects#mints "Direct link to mints") mints: Map; The tokens minted in this call, as a map from hex-encoded 256-bit domain separators to non-negative 64-bit integers. * [Type declaration](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Effects#type-declaration) * [claimedContractCalls](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Effects#claimedcontractcalls) * [claimedNullifiers](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Effects#claimednullifiers) * [claimedReceives](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Effects#claimedreceives) * [claimedSpends](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Effects#claimedspends) * [mints](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Effects#mints) --- # GatherResult | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/GatherResult#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / GatherResult Type alias: GatherResult ======================== type GatherResult: { content: AlignedValue; tag: "read"; } | { content: EncodedStateValue; tag: "log";}; An individual result of observing the results of a non-verifying VM program execution --- # SignatureVerifyingKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/SignatureVerifyingKey#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / SignatureVerifyingKey Type alias: SignatureVerifyingKey ================================= type SignatureVerifyingKey: string; A hex-encoded signature BIP-340 verifying key, with a 3-byte version prefix --- # Key | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Key#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / Key Type alias: Key =============== type Key: { tag: "value"; value: AlignedValue; } | { tag: "stack";}; A key used to index into an array or map in the onchain VM --- # SigningKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/SigningKey#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / SigningKey Type alias: SigningKey ====================== type SigningKey: string; A hex-encoded signature BIP-340 signing key, with a 3-byte version prefix --- # TokenType | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/TokenType#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / TokenType Type alias: TokenType ===================== type TokenType: string; A token type (or color), as a hex-encoded 35-byte string --- # Value | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / Value Type alias: Value ================= type Value: Uint8Array[]; An onchain data value, in field-aligned binary format. --- # Fr | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Fr#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / Fr Type alias: Fr ============== type Fr: Uint8Array; An internal encoding of a value of the proof systems scalar field --- # Nullifier | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Nullifier#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / Nullifier Type alias: Nullifier ===================== type Nullifier: string; A Zswap nullifier, as a hex-encoded 256-bit bitstring --- # QualifiedCoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/QualifiedCoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / QualifiedCoinInfo Type alias: QualifiedCoinInfo ============================= type QualifiedCoinInfo: { mt_index: bigint; nonce: Nonce; type: TokenType; value: bigint;}; Information required to spend an existing coin, alongside authorization of the owner Type declaration[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/QualifiedCoinInfo#type-declaration "Direct link to Type declaration") ------------------------------------------------------------------------------------------------------------------------------------------------------------------- ### mt\_index[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/QualifiedCoinInfo#mt_index "Direct link to mt_index") mt_index: bigint; The coin's location in the chain's Merkle tree of coin commitments Bounded to be a non-negative 64-bit integer ### nonce[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/QualifiedCoinInfo#nonce "Direct link to nonce") nonce: Nonce; The coin's randomness, preventing it from colliding with other coins ### type[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/QualifiedCoinInfo#type "Direct link to type") type: TokenType; The coin's type, identifying the currency it represents ### value[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/QualifiedCoinInfo#value "Direct link to value") value: bigint; The coin's value, in atomic units dependent on the currency Bounded to be a non-negative 64-bit integer * [Type declaration](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/QualifiedCoinInfo#type-declaration) * [mt\_index](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/QualifiedCoinInfo#mt_index) * [nonce](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/QualifiedCoinInfo#nonce) * [type](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/QualifiedCoinInfo#type) * [value](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/QualifiedCoinInfo#value) --- # Op | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/Op#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / Op Type alias: Op ================= type Op: | { noop: { n: number; }; } | "lt" | "eq" | "type" | "size" | "new" | "and" | "or" | "neg" | "log" | "root" | "pop" | { popeq: { cached: boolean; result: R; }; } | { addi: { immediate: number; }; } | { subi: { immediate: number; }; } | { push: { storage: boolean; value: EncodedStateValue; }; } | { branch: { skip: number; }; } | { jmp: { skip: number; }; } | "add" | "sub" | { concat: { cached: boolean; n: number; }; } | "member" | { rem: { cached: boolean; }; } | { dup: { n: number; }; } | { swap: { n: number; }; } | { idx: { cached: boolean; path: Key[]; pushPath: boolean; }; } | { ins: { cached: boolean; n: number; }; } | "ckpt"; An individual operation in the onchain VM Type parameters[​](https://docs.midnight.network/api-reference/ledger/type-aliases/Op#type-parameters "Direct link to Type parameters") ---------------------------------------------------------------------------------------------------------------------------------------- • **R** `null` or [AlignedValue](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) , for gathering and verifying mode respectively * [Type parameters](https://docs.midnight.network/api-reference/ledger/type-aliases/Op#type-parameters) --- # EncodedStateValue | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/EncodedStateValue#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / EncodedStateValue Type alias: EncodedStateValue ============================= type EncodedStateValue: | { tag: "null"; } | { content: EncodedStateValue; tag: "cell"; } | { content: Map; tag: "map"; } | { content: EncodedStateValue[]; tag: "array"; } | { content: [number, Map]; tag: "boundedMerkleTree";}; An alternative encoding of [StateValue](https://docs.midnight.network/api-reference/ledger/classes/StateValue) for use in [Op](https://docs.midnight.network/api-reference/ledger/type-aliases/Op) for technical reasons --- # Transcript | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/Transcript#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / Transcript Type alias: Transcript ========================= type Transcript: { effects: Effects; gas: bigint; program: Op[];}; A transcript of operations, to be recorded in a transaction Type parameters[​](https://docs.midnight.network/api-reference/ledger/type-aliases/Transcript#type-parameters "Direct link to Type parameters") ------------------------------------------------------------------------------------------------------------------------------------------------ • **R** Type declaration[​](https://docs.midnight.network/api-reference/ledger/type-aliases/Transcript#type-declaration "Direct link to Type declaration") --------------------------------------------------------------------------------------------------------------------------------------------------- ### effects[​](https://docs.midnight.network/api-reference/ledger/type-aliases/Transcript#effects "Direct link to effects") effects: Effects; The effects of the transcript, which are checked before execution, and must match those constructed by program ### gas[​](https://docs.midnight.network/api-reference/ledger/type-aliases/Transcript#gas "Direct link to gas") gas: bigint; The execution budget for this transcript, which program must not exceed ### program[​](https://docs.midnight.network/api-reference/ledger/type-aliases/Transcript#program "Direct link to program") program: Op[]; The sequence of operations that this transcript captured * [Type parameters](https://docs.midnight.network/api-reference/ledger/type-aliases/Transcript#type-parameters) * [Type declaration](https://docs.midnight.network/api-reference/ledger/type-aliases/Transcript#type-declaration) * [effects](https://docs.midnight.network/api-reference/ledger/type-aliases/Transcript#effects) * [gas](https://docs.midnight.network/api-reference/ledger/type-aliases/Transcript#gas) * [program](https://docs.midnight.network/api-reference/ledger/type-aliases/Transcript#program) --- # Signature | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Signature#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / Signature Type alias: Signature ===================== type Signature: string; A hex-encoded signature BIP-340 signature, with a 3-byte version prefix --- # Authentication | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/overview/authentication#__docusaurus_skipToContent_fallback) Explore with… ▾ note Coming soon... --- # Rate limits | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/overview/rate-limits#__docusaurus_skipToContent_fallback) Explore with… ▾ note Coming soon... --- # EncodedStateValue | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/EncodedStateValue#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / EncodedStateValue Type alias: EncodedStateValue ============================= type EncodedStateValue: | { tag: "null"; } | { content: EncodedStateValue; tag: "cell"; } | { content: Map; tag: "map"; } | { content: EncodedStateValue[]; tag: "array"; } | { content: [number, Map]; tag: "boundedMerkleTree";}; An alternative encoding of [StateValue](https://docs.midnight.network/api-reference/onchain-runtime/classes/StateValue) for use in [Op](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Op) for technical reasons --- # Transcript | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Transcript#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / Transcript Type alias: Transcript ========================= type Transcript: { effects: Effects; gas: bigint; program: Op[];}; A transcript of operations, to be recorded in a transaction Type parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Transcript#type-parameters "Direct link to Type parameters") --------------------------------------------------------------------------------------------------------------------------------------------------------- • **R** Type declaration[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Transcript#type-declaration "Direct link to Type declaration") ------------------------------------------------------------------------------------------------------------------------------------------------------------ ### effects[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Transcript#effects "Direct link to effects") effects: Effects; The effects of the transcript, which are checked before execution, and must match those constructed by program ### gas[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Transcript#gas "Direct link to gas") gas: bigint; The execution budget for this transcript, which program must not exceed ### program[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Transcript#program "Direct link to program") program: Op[]; The sequence of operations that this transcript captured * [Type parameters](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Transcript#type-parameters) * [Type declaration](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Transcript#type-declaration) * [effects](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Transcript#effects) * [gas](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Transcript#gas) * [program](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Transcript#program) --- # Op | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Op#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / Op Type alias: Op ================= type Op: | { noop: { n: number; }; } | "lt" | "eq" | "type" | "size" | "new" | "and" | "or" | "neg" | "log" | "root" | "pop" | { popeq: { cached: boolean; result: R; }; } | { addi: { immediate: number; }; } | { subi: { immediate: number; }; } | { push: { storage: boolean; value: EncodedStateValue; }; } | { branch: { skip: number; }; } | { jmp: { skip: number; }; } | "add" | "sub" | { concat: { cached: boolean; n: number; }; } | "member" | { rem: { cached: boolean; }; } | { dup: { n: number; }; } | { swap: { n: number; }; } | { idx: { cached: boolean; path: Key[]; pushPath: boolean; }; } | { ins: { cached: boolean; n: number; }; } | "ckpt"; An individual operation in the onchain VM Type parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Op#type-parameters "Direct link to Type parameters") ------------------------------------------------------------------------------------------------------------------------------------------------- • **R** `null` or [AlignedValue](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) , for gathering and verifying mode respectively * [Type parameters](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Op#type-parameters) --- # SingleUpdate | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/type-aliases/SingleUpdate#__docusaurus_skipToContent_fallback) Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / SingleUpdate Type alias: SingleUpdate ======================== type SingleUpdate: ReplaceAuthority | VerifierKeyRemove | VerifierKeyInsert; A single update instruction in a [MaintenanceUpdate](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate) . --- # 3 docs tagged with "security" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/security#__docusaurus_skipToContent_fallback) [Guarantees and limitations\ --------------------------](https://docs.midnight.network/next/concepts/security/guarantees-and-limitations) Coming soon... [Security best practices\ -----------------------](https://docs.midnight.network/next/compact/security) Learn about the security best practices for Compact. [Smart contract security\ -----------------------](https://docs.midnight.network/next/concepts/security/smart-contract-security) Coming soon... --- # Getting started | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/community/build-using-meshsdk/getting-started#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ Get up and running with MeshSDK for Midnight Network development in minutes. Installation[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/getting-started#installation "Direct link to Installation") --------------------------------------------------------------------------------------------------------------------------------------------- yarn add @meshsdk/midnight-setup Basic usage[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/getting-started#basic-usage "Direct link to Basic usage") ------------------------------------------------------------------------------------------------------------------------------------------ import { MidnightSetupAPI } from '@meshsdk/midnight-setup';// Deploy a new contractconst api = await MidnightSetupAPI.deployContract(providers, contractInstance);// Join an existing contractconst api = await MidnightSetupAPI.joinContract(providers, contractInstance, contractAddress);// Get contract stateconst state = await api.getContractState();// Get ledger stateconst ledgerState = await api.getLedgerState(); What's included[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/getting-started#whats-included "Direct link to What's included") ----------------------------------------------------------------------------------------------------------------------------------------------------- This monorepo contains everything you need to build Midnight Network DApps: * **@meshsdk/midnight-setup** - Main npm package with API and types * **packages/ui** - Example React application * **packages/cli** - Command-line tools * **packages/api** - Core API implementation * [Installation](https://docs.midnight.network/sdks/community/build-using-meshsdk/getting-started#installation) * [Basic usage](https://docs.midnight.network/sdks/community/build-using-meshsdk/getting-started#basic-usage) * [What's included](https://docs.midnight.network/sdks/community/build-using-meshsdk/getting-started#whats-included) --- # Common SDK integration issues | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/troubleshoot#__docusaurus_skipToContent_fallback) Explore with… ▾ info Coming soon... --- # 2 docs tagged with "setup" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/setup#__docusaurus_skipToContent_fallback) [Install the toolchain\ ---------------------](https://docs.midnight.network/next/getting-started/installation) Get your Midnight development environment running to set up tools, configure wallets, and deploy your first zero-knowledge application. [Set up Bun for Midnight development\ -----------------------------------](https://docs.midnight.network/next/how-to/bun-runtime-midnight) Set up Bun package manager and the Compact compiler to build smart contracts and applications on the Midnight blockchain. --- # Midnight.js | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/official/midnight-js#__docusaurus_skipToContent_fallback) Explore with… ▾ note Coming soon... --- # Lace wallet integration | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/community/build-using-meshsdk/lace-wallet#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ This project includes a complete Lace Beta Wallet integration for Midnight Network. Wallet features[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/lace-wallet#wallet-features "Direct link to Wallet features") -------------------------------------------------------------------------------------------------------------------------------------------------- | Feature | Description | Implementation | | --- | --- | --- | | Connect Wallet | Connect to Lace Beta Wallet | `wallet.enable()` | | Disconnect Wallet | Disconnect from wallet | `wallet.disconnect()` | | Get Wallet State | Retrieve wallet address and keys | `wallet.state()` | | Deploy Contract | Deploy contracts through wallet | `wallet.submitTransaction()` | | Join Contract | Join existing contracts | `wallet.balanceAndProveTransaction()` | | Balance Transactions | Balance and prove transactions | Wallet API integration | Wallet provider setup[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/lace-wallet#wallet-provider-setup "Direct link to Wallet provider setup") -------------------------------------------------------------------------------------------------------------------------------------------------------------------- // Connect to Lace Walletconst wallet = window.midnight?.mnLace;if (!wallet) { throw new Error('Please install Lace Beta Wallet for Midnight Network');}// Enable wallet and get stateconst walletAPI = await wallet.enable();const walletState = await walletAPI.state();const uris = await wallet.serviceUriConfig(); React wallet hook[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/lace-wallet#react-wallet-hook "Direct link to React wallet hook") -------------------------------------------------------------------------------------------------------------------------------------------------------- import { useMidnightWallet } from './hooks/useMidnightWallet';function App() { const { connectWallet, disconnectWallet, walletState, isConnected } = useMidnightWallet(); return (
{isConnected ? ( ) : ( )}
);} * [Wallet features](https://docs.midnight.network/sdks/community/build-using-meshsdk/lace-wallet#wallet-features) * [Wallet provider setup](https://docs.midnight.network/sdks/community/build-using-meshsdk/lace-wallet#wallet-provider-setup) * [React wallet hook](https://docs.midnight.network/sdks/community/build-using-meshsdk/lace-wallet#react-wallet-hook) --- # 2 docs tagged with "troubleshooting" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/troubleshooting#__docusaurus_skipToContent_fallback) [Fix version mismatch errors\ ---------------------------](https://docs.midnight.network/next/how-to/fix-version-mismatches) Resolve version compatibility issues between Midnight compiler, runtime, and other components using the official compatibility matrix. [Troubleshoot Compact toolchain installation issue on NixOS\ ----------------------------------------------------------](https://docs.midnight.network/next/troubleshoot/troubleshoot-compact-nixos) Troubleshoot Midnight Compact tools installation issue on NixOS --- # 2 docs tagged with "tutorial" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/tutorial#__docusaurus_skipToContent_fallback) [Create a Next.js wallet connector\ ---------------------------------](https://docs.midnight.network/next/guides/nextjs-wallet-connect) Learn how to create a Next.js application that connects to a wallet using the Midnight DApp Connector API. [Create a React wallet connector\ -------------------------------](https://docs.midnight.network/next/guides/react-wallet-connect) Learn how to create a React application that connects to a wallet using the Midnight DApp Connector API. --- # AuthorizedMint | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / AuthorizedMint Class: AuthorizedMint ===================== A request to mint a coin, authorized by the mint's recipient Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------- ### new AuthorizedMint()[​](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#new-authorizedmint "Direct link to new AuthorizedMint()") private new AuthorizedMint(): AuthorizedMint #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#returns "Direct link to Returns") [`AuthorizedMint`](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------- ### coin[​](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#coin "Direct link to coin") readonly coin: CoinInfo; The coin to be minted * * * ### recipient[​](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#recipient "Direct link to recipient") readonly recipient: string; The recipient of this mint Methods[​](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------- ### erase\_proof()[​](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#erase_proof "Direct link to erase_proof()") erase_proof(): ProofErasedAuthorizedMint #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#returns-1 "Direct link to Returns") [`ProofErasedAuthorizedMint`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint) * * * ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#returns-2 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#returns-3 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#deserialize "Direct link to deserialize()") static deserialize(raw, netid): AuthorizedMint #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#returns-4 "Direct link to Returns") [`AuthorizedMint`](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#constructors) * [new AuthorizedMint()](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#new-authorizedmint) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#properties) * [coin](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#coin) * [recipient](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#recipient) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#methods) * [erase\_proof()](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#erase_proof) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/AuthorizedMint#deserialize) --- # One doc tagged with "version" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/version#__docusaurus_skipToContent_fallback) [Fix version mismatch errors\ ---------------------------](https://docs.midnight.network/next/how-to/fix-version-mismatches) Resolve version compatibility issues between Midnight compiler, runtime, and other components using the official compatibility matrix. --- # One doc tagged with "tutorials" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/tutorials#__docusaurus_skipToContent_fallback) [Zero Knowledge loan DApp\ ------------------------](https://docs.midnight.network/next/tutorials/advanced/zk-loan-dapp) Build a zero knowledge loan DApp on Midnight Network. --- # One doc tagged with "zero-knowledge" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/zero-knowledge#__docusaurus_skipToContent_fallback) [Zero Knowledge loan DApp\ ------------------------](https://docs.midnight.network/next/tutorials/advanced/zk-loan-dapp) Build a zero knowledge loan DApp on Midnight Network. --- # One doc tagged with "ZK" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/zk#__docusaurus_skipToContent_fallback) [Install the toolchain\ ---------------------](https://docs.midnight.network/next/getting-started/installation) Get your Midnight development environment running to set up tools, configure wallets, and deploy your first zero-knowledge application. --- # Input | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/Input#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / Input Class: Input ============ A shielded transaction input Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/Input#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------- ### new Input()[​](https://docs.midnight.network/api-reference/zswap/classes/Input#new-input "Direct link to new Input()") private new Input(): Input #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Input#returns "Direct link to Returns") [`Input`](https://docs.midnight.network/api-reference/zswap/classes/Input) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/Input#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------- ### contractAddress[​](https://docs.midnight.network/api-reference/zswap/classes/Input#contractaddress "Direct link to contractAddress") readonly contractAddress: undefined | string; The contract address receiving the input, if the sender is a contract * * * ### nullifier[​](https://docs.midnight.network/api-reference/zswap/classes/Input#nullifier "Direct link to nullifier") readonly nullifier: string; The nullifier of the input Methods[​](https://docs.midnight.network/api-reference/zswap/classes/Input#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/Input#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/Input#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Input#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/Input#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/Input#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Input#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/Input#deserialize "Direct link to deserialize()") static deserialize(raw, netid): Input #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/Input#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Input#returns-3 "Direct link to Returns") [`Input`](https://docs.midnight.network/api-reference/zswap/classes/Input) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/Input#constructors) * [new Input()](https://docs.midnight.network/api-reference/zswap/classes/Input#new-input) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/Input#properties) * [contractAddress](https://docs.midnight.network/api-reference/zswap/classes/Input#contractaddress) * [nullifier](https://docs.midnight.network/api-reference/zswap/classes/Input#nullifier) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/Input#methods) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/Input#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/Input#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/Input#deserialize) --- # 5 docs tagged with "node" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/node#__docusaurus_skipToContent_fallback) [Node endpoints\ --------------](https://docs.midnight.network/next/nodes/node-endpoints) A reference for important Midnight network parameters. [Setting up Boot Nodes\ ---------------------](https://docs.midnight.network/next/nodes/boot-node) A reference on setting up boot nodes for Midnight. [Setting up Cardano-db-sync\ --------------------------](https://docs.midnight.network/next/nodes/cardano-db-sync) A reference on setting up Cardano-db-sync for Midnight. [Setting up Full and Archive Nodes\ ---------------------------------](https://docs.midnight.network/next/nodes/full-node) A reference on setting up full and archive nodes for Midnight. [Setting up RPC Nodes\ --------------------](https://docs.midnight.network/next/nodes/rpc-node) A reference on setting up RPC nodes for Midnight. --- # AlignmentAtom | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignmentAtom#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / AlignmentAtom Type Alias: AlignmentAtom ========================= type AlignmentAtom = | { tag: "compress";} | { tag: "field";} | { length: number; tag: "bytes";}; A atom in a larger [Alignment](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) . --- # Alignment | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / Alignment Type Alias: Alignment ===================== type Alignment = AlignmentSegment[]; The alignment of an onchain field-aligned binary data value. --- # AlignmentSegment | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignmentSegment#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / AlignmentSegment Type Alias: AlignmentSegment ============================ type AlignmentSegment = | { tag: "option"; value: Alignment[];} | { tag: "atom"; value: AlignmentAtom;}; A segment in a larger [Alignment](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Alignment) . --- # CoinCommitment | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CoinCommitment#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CoinCommitment Type Alias: CoinCommitment ========================== type CoinCommitment = string; A Zswap coin commitment, as a hex-encoded 256-bit bitstring --- # CoinPublicKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CoinPublicKey#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CoinPublicKey Type Alias: CoinPublicKey ========================= type CoinPublicKey = string; A user public key capable of receiving Zswap coins, as a hex-encoded 35-byte string --- # CommunicationCommitment | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CommunicationCommitment#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CommunicationCommitment Type Alias: CommunicationCommitment =================================== type CommunicationCommitment = string; A hex-encoded commitment of data shared between two contracts in a call --- # CoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.9.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CoinInfo Type Alias: CoinInfo ==================== type CoinInfo = { nonce: Nonce; type: TokenType; value: bigint;}; Information required to create a new coin, alongside details about the recipient Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CoinInfo#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------------- ### nonce[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CoinInfo#nonce "Direct link to nonce") nonce: Nonce; The coin's randomness, preventing it from colliding with other coins * * * ### type[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CoinInfo#type "Direct link to type") type: TokenType; The coin's type, identifying the currency it represents * * * ### value[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CoinInfo#value "Direct link to value") value: bigint; The coin's value, in atomic units dependent on the currency Bounded to be a non-negative 64-bit integer * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CoinInfo#properties) * [nonce](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CoinInfo#nonce) * [type](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CoinInfo#type) * [value](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CoinInfo#value) --- # CommunicationCommitmentRand | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CommunicationCommitmentRand#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CommunicationCommitmentRand Type Alias: CommunicationCommitmentRand ======================================= type CommunicationCommitmentRand = string; The hex-encoded randomness to [CommunicationCommitment](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CommunicationCommitment) --- # ContractAddress | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ContractAddress#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / ContractAddress Type Alias: ContractAddress =========================== type ContractAddress = string; A contract address, as a hex-encoded 35-byte string --- # BlockContext | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/BlockContext#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / BlockContext Type Alias: BlockContext ======================== type BlockContext = { parentBlockHash: string; secondsSinceEpoch: bigint; secondsSinceEpochErr: number;}; Context information about the block forwarded to [CallContext](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CallContext) . Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/BlockContext#properties "Direct link to Properties") -------------------------------------------------------------------------------------------------------------------------------------------- ### parentBlockHash[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/BlockContext#parentblockhash "Direct link to parentBlockHash") parentBlockHash: string; The hash of the block prior to this transaction, as a hex-encoded string * * * ### secondsSinceEpoch[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/BlockContext#secondssinceepoch "Direct link to secondsSinceEpoch") secondsSinceEpoch: bigint; The seconds since the UNIX epoch that have elapsed * * * ### secondsSinceEpochErr[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/BlockContext#secondssinceepocherr "Direct link to secondsSinceEpochErr") secondsSinceEpochErr: number; The maximum error on [secondsSinceEpoch](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/BlockContext#secondssinceepoch) that should occur, as a positive seconds value * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/BlockContext#properties) * [parentBlockHash](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/BlockContext#parentblockhash) * [secondsSinceEpoch](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/BlockContext#secondssinceepoch) * [secondsSinceEpochErr](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/BlockContext#secondssinceepocherr) --- # MerkleTreeCollapsedUpdate | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / MerkleTreeCollapsedUpdate Class: MerkleTreeCollapsedUpdate ================================ A compact delta on the coin commitments Merkle tree, used to keep local spending trees in sync with the global state without requiring receiving all transactions. Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------------ ### new MerkleTreeCollapsedUpdate(state, start, end)[​](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#new-merkletreecollapsedupdatestate-start-end "Direct link to new MerkleTreeCollapsedUpdate(state, start, end)") new MerkleTreeCollapsedUpdate( state, start, end): MerkleTreeCollapsedUpdate Create a new compact update from a non-compact state, and inclusive `start` and `end` indices #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#parameters "Direct link to Parameters") • **state**: [`ZswapChainState`](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState) • **start**: `bigint` • **end**: `bigint` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#returns "Direct link to Returns") [`MerkleTreeCollapsedUpdate`](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate) #### Throws[​](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#throws "Direct link to Throws") If the indices are out-of-bounds for the state, or `end < start` Methods[​](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#methods "Direct link to Methods") --------------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#parameters-1 "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#parameters-2 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#deserialize "Direct link to deserialize()") static deserialize(raw, netid): MerkleTreeCollapsedUpdate #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#parameters-3 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#returns-3 "Direct link to Returns") [`MerkleTreeCollapsedUpdate`](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#constructors) * [new MerkleTreeCollapsedUpdate(state, start, end)](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#new-merkletreecollapsedupdatestate-start-end) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#methods) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate#deserialize) --- # ProofErasedOffer | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / ProofErasedOffer Class: ProofErasedOffer ======================= An [Offer](https://docs.midnight.network/api-reference/zswap/classes/Offer) , with all proof information erased Primarily for use in testing, or handling data known to be correct from external information Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#constructors "Direct link to Constructors") --------------------------------------------------------------------------------------------------------------------------------------- ### new ProofErasedOffer()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#new-prooferasedoffer "Direct link to new ProofErasedOffer()") private new ProofErasedOffer(): ProofErasedOffer #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#returns "Direct link to Returns") [`ProofErasedOffer`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------- ### deltas[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#deltas "Direct link to deltas") readonly deltas: Map; The value of this offer for each token type; note that this may be negative This is input coin values - output coin values, for value vectors * * * ### inputs[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#inputs "Direct link to inputs") readonly inputs: ProofErasedInput[]; The inputs this offer is composed of * * * ### outputs[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#outputs "Direct link to outputs") readonly outputs: ProofErasedOutput[]; The outputs this offer is composed of * * * ### transient[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#transient "Direct link to transient") readonly transient: ProofErasedTransient[]; The transients this offer is composed of Methods[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------ ### merge()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#merge "Direct link to merge()") merge(other): ProofErasedOffer #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#parameters "Direct link to Parameters") • **other**: [`ProofErasedOffer`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#returns-1 "Direct link to Returns") [`ProofErasedOffer`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer) * * * ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#parameters-1 "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#returns-2 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#parameters-2 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#returns-3 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#deserialize "Direct link to deserialize()") static deserialize(raw, netid): ProofErasedOffer #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#parameters-3 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#returns-4 "Direct link to Returns") [`ProofErasedOffer`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#constructors) * [new ProofErasedOffer()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#new-prooferasedoffer) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#properties) * [deltas](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#deltas) * [inputs](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#inputs) * [outputs](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#outputs) * [transient](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#transient) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#methods) * [merge()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#merge) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer#deserialize) --- # Output | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/Output#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / Output Class: Output ============= A shielded transaction output Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/Output#constructors "Direct link to Constructors") ----------------------------------------------------------------------------------------------------------------------------- ### new Output()[​](https://docs.midnight.network/api-reference/zswap/classes/Output#new-output "Direct link to new Output()") private new Output(): Output #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Output#returns "Direct link to Returns") [`Output`](https://docs.midnight.network/api-reference/zswap/classes/Output) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/Output#properties "Direct link to Properties") ----------------------------------------------------------------------------------------------------------------------- ### commitment[​](https://docs.midnight.network/api-reference/zswap/classes/Output#commitment "Direct link to commitment") readonly commitment: string; The commitment of the output * * * ### contractAddress[​](https://docs.midnight.network/api-reference/zswap/classes/Output#contractaddress "Direct link to contractAddress") readonly contractAddress: undefined | string; The contract address receiving the output, if the recipient is a contract Methods[​](https://docs.midnight.network/api-reference/zswap/classes/Output#methods "Direct link to Methods") -------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/Output#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/Output#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Output#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/Output#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/Output#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Output#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/Output#deserialize "Direct link to deserialize()") static deserialize(raw, netid): Output #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/Output#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Output#returns-3 "Direct link to Returns") [`Output`](https://docs.midnight.network/api-reference/zswap/classes/Output) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/Output#constructors) * [new Output()](https://docs.midnight.network/api-reference/zswap/classes/Output#new-output) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/Output#properties) * [commitment](https://docs.midnight.network/api-reference/zswap/classes/Output#commitment) * [contractAddress](https://docs.midnight.network/api-reference/zswap/classes/Output#contractaddress) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/Output#methods) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/Output#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/Output#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/Output#deserialize) --- # ProofErasedInput | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / ProofErasedInput Class: ProofErasedInput ======================= A [Input](https://docs.midnight.network/api-reference/zswap/classes/Input) , with all proof information erased Primarily for use in testing, or handling data known to be correct from external information Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#constructors "Direct link to Constructors") --------------------------------------------------------------------------------------------------------------------------------------- ### new ProofErasedInput()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#new-prooferasedinput "Direct link to new ProofErasedInput()") private new ProofErasedInput(): ProofErasedInput #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#returns "Direct link to Returns") [`ProofErasedInput`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------- ### contractAddress[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#contractaddress "Direct link to contractAddress") readonly contractAddress: undefined | string; The contract address receiving the input, if the sender is a contract * * * ### nullifier[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#nullifier "Direct link to nullifier") readonly nullifier: string; The nullifier of the input Methods[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------ ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#deserialize "Direct link to deserialize()") static deserialize(raw, netid): ProofErasedInput #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#returns-3 "Direct link to Returns") [`ProofErasedInput`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#constructors) * [new ProofErasedInput()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#new-prooferasedinput) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#properties) * [contractAddress](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#contractaddress) * [nullifier](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#nullifier) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#methods) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedInput#deserialize) --- # LedgerParameters | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / LedgerParameters Class: LedgerParameters ======================= Parameters used by the Midnight ledger, including transaction fees and bounds Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#constructors "Direct link to Constructors") --------------------------------------------------------------------------------------------------------------------------------------- ### new LedgerParameters()[​](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#new-ledgerparameters "Direct link to new LedgerParameters()") private new LedgerParameters(): LedgerParameters #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#returns "Direct link to Returns") [`LedgerParameters`](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------- ### transactionCostModel[​](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#transactioncostmodel "Direct link to transactionCostModel") readonly transactionCostModel: TransactionCostModel; The cost model used for transaction fees contained in these parameters Methods[​](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------ ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#deserialize "Direct link to deserialize()") static deserialize(raw, netid): LedgerParameters #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#returns-3 "Direct link to Returns") [`LedgerParameters`](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters) * * * ### dummyParameters()[​](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#dummyparameters "Direct link to dummyParameters()") static dummyParameters(): LedgerParameters A dummy set of testing parameters #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#returns-4 "Direct link to Returns") [`LedgerParameters`](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#constructors) * [new LedgerParameters()](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#new-ledgerparameters) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#properties) * [transactionCostModel](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#transactioncostmodel) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#methods) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#deserialize) * [dummyParameters()](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters#dummyparameters) --- # EncryptionSecretKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / EncryptionSecretKey Class: EncryptionSecretKey ========================== Holds the encryption secret key of a user, which may be used to determine if a given offer contains outputs addressed to this user Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------ ### new EncryptionSecretKey()[​](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey#new-encryptionsecretkey "Direct link to new EncryptionSecretKey()") private new EncryptionSecretKey(): EncryptionSecretKey #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey#returns "Direct link to Returns") [`EncryptionSecretKey`](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey) Methods[​](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey#methods "Direct link to Methods") --------------------------------------------------------------------------------------------------------------------------- ### test()[​](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey#test "Direct link to test()") test(offer): boolean #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey#parameters "Direct link to Parameters") • **offer**: [`Offer`](https://docs.midnight.network/api-reference/zswap/classes/Offer) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey#returns-1 "Direct link to Returns") `boolean` * * * ### yesIKnowTheSecurityImplicationsOfThis\_serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey#yesiknowthesecurityimplicationsofthis_serialize "Direct link to yesIKnowTheSecurityImplicationsOfThis_serialize()") yesIKnowTheSecurityImplicationsOfThis_serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey#parameters-1 "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey#returns-2 "Direct link to Returns") `Uint8Array` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey#deserialize "Direct link to deserialize()") static deserialize(raw, netid): EncryptionSecretKey #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey#returns-3 "Direct link to Returns") [`EncryptionSecretKey`](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey#constructors) * [new EncryptionSecretKey()](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey#new-encryptionsecretkey) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey#methods) * [test()](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey#test) * [yesIKnowTheSecurityImplicationsOfThis\_serialize()](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey#yesiknowthesecurityimplicationsofthis_serialize) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey#deserialize) --- # 3 docs tagged with "smart contract" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/smart-contract#__docusaurus_skipToContent_fallback) [Create your first Midnight contract\ -----------------------------------](https://docs.midnight.network/next/getting-started/hello-world) Learn how to create and compile a Hello World smart contract on Midnight's Preprod network. [Deploy the hello world contract\ -------------------------------](https://docs.midnight.network/next/guides/deploy-mn-app) Deploy a compiled hello world smart contract to Midnight's Preprod network. [Interact with hello world contract\ ----------------------------------](https://docs.midnight.network/next/guides/interact-with-mn-app) Build a command-line interface to interact with a deployed hello world contract on the Midnight Network. --- # AlignedValue | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / AlignedValue Type Alias: AlignedValue ======================== type AlignedValue = { alignment: Alignment; value: Value;}; An onchain data value, in field-aligned binary format, annotated with its alignment. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue#properties "Direct link to Properties") -------------------------------------------------------------------------------------------------------------------------------------------- ### alignment[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue#alignment "Direct link to alignment") alignment: Alignment; * * * ### value[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue#value "Direct link to value") value: Value; * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue#properties) * [alignment](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue#alignment) * [value](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue#value) --- # DustTokenType | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/DustTokenType#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / DustTokenType Type Alias: DustTokenType ========================= type DustTokenType = { tag: "dust";}; Dust token type Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/DustTokenType#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------------- ### tag[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/DustTokenType#tag "Direct link to tag") tag: "dust"; * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/DustTokenType#properties) * [tag](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/DustTokenType#tag) --- # CallContext | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CallContext#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / CallContext Type Alias: CallContext ======================= type CallContext = { balance: Map; caller?: PublicAddress; comIndices: Map; ownAddress: ContractAddress; parentBlockHash: string; secondsSinceEpoch: bigint; secondsSinceEpochErr: number;}; The context information of a call provided to the VM. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CallContext#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------- ### balance[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CallContext#balance "Direct link to balance") balance: Map; The balances held by the called contract at the time it was called. * * * ### caller?[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CallContext#caller "Direct link to caller?") optional caller: PublicAddress; A public address identifying an entity. * * * ### comIndices[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CallContext#comindices "Direct link to comIndices") comIndices: Map; The commitment indices map accessible to the contract. * * * ### ownAddress[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CallContext#ownaddress "Direct link to ownAddress") ownAddress: ContractAddress; * * * ### parentBlockHash[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CallContext#parentblockhash "Direct link to parentBlockHash") parentBlockHash: string; The hash of the block prior to this transaction, as a hex-encoded string * * * ### secondsSinceEpoch[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CallContext#secondssinceepoch "Direct link to secondsSinceEpoch") secondsSinceEpoch: bigint; The seconds since the UNIX epoch that have elapsed * * * ### secondsSinceEpochErr[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CallContext#secondssinceepocherr "Direct link to secondsSinceEpochErr") secondsSinceEpochErr: number; The maximum error on [secondsSinceEpoch](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CallContext#secondssinceepoch) that should occur, as a positive seconds value * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CallContext#properties) * [balance](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CallContext#balance) * [caller?](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CallContext#caller) * [comIndices](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CallContext#comindices) * [ownAddress](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CallContext#ownaddress) * [parentBlockHash](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CallContext#parentblockhash) * [secondsSinceEpoch](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CallContext#secondssinceepoch) * [secondsSinceEpochErr](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/CallContext#secondssinceepocherr) --- # bigIntModFr | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/bigIntModFr#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / bigIntModFr Function: bigIntModFr() ======================= bigIntModFr(x): bigint Takes a bigint modulus the proof systems scalar field Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/bigIntModFr#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------- • **x**: `bigint` Returns[​](https://docs.midnight.network/api-reference/ledger/functions/bigIntModFr#returns "Direct link to Returns") ---------------------------------------------------------------------------------------------------------------------- `bigint` * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/bigIntModFr#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/bigIntModFr#returns) --- # Nonce | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Nonce#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / Nonce Type Alias: Nonce ================= type Nonce = string; A Zswap nonce, as a hex-encoded 256-bit string --- # DomainSeparator | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/DomainSeparator#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / DomainSeparator Type Alias: DomainSeparator =========================== type DomainSeparator = Uint8Array; A token domain seperator, the pre-stage of `TokenType`, as 32-byte bytearray --- # Key | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Key#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / Key Type Alias: Key =============== type Key = | { tag: "value"; value: AlignedValue;} | { tag: "stack";}; A key used to index into an array or map in the onchain VM --- # DomainSeperator | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/DomainSeperator#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.9.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / DomainSeperator Type Alias: DomainSeperator =========================== type DomainSeperator = Uint8Array; A token domain seperator, the pre-stage of `TokenType`, as 32-byte bytearray --- # dummyContractAddress | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/dummyContractAddress#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / dummyContractAddress Function: dummyContractAddress() ================================ dummyContractAddress(): string A sample contract address, guaranteed to be the same for a given network ID for use in testing Returns[​](https://docs.midnight.network/api-reference/ledger/functions/dummyContractAddress#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------------- `string` * [Returns](https://docs.midnight.network/api-reference/ledger/functions/dummyContractAddress#returns) --- # coinCommitment | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/coinCommitment#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / coinCommitment Function: coinCommitment() ========================== `Internal` coinCommitment(coin, recipient): AlignedValue Internal implementation of the coin commitment primitive. Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/coinCommitment#parameters "Direct link to Parameters") ---------------------------------------------------------------------------------------------------------------------------------- • **coin**: [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) • **recipient**: [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) Returns[​](https://docs.midnight.network/api-reference/ledger/functions/coinCommitment#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------- [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/coinCommitment#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/coinCommitment#returns) --- # PublicAddress | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/PublicAddress#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / PublicAddress Type Alias: PublicAddress ========================= type PublicAddress = | { address: UserAddress; tag: "user";} | { address: ContractAddress; tag: "contract";}; A public address that an entity can be identified by --- # PublicLedgerSegments | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/PublicLedgerSegments#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / PublicLedgerSegments Type Alias: PublicLedgerSegments ================================ type PublicLedgerSegments = { indices: Record; tag: "publicLedgerArray";}; A data structure indicating the locations of all contract references in a given ledger state. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/PublicLedgerSegments#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------------------------- ### indices[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/PublicLedgerSegments#indices "Direct link to indices") indices: Record; For reasonably small ledger states, the keys of the record identify locations of ADTs in the ledger state. For example, if a Compact source file contains contract C {};struct Struct1 { a: Field; b: C;}ledger ls1: List[Field];ledger ls2: List[C];ledger ls3: Set[Struct1]; then the indices record will contain keys `1` and `2`, since ledger declarations `1` and `2` contain contract references while ledger declaration `0` (`List[Field]`) does not. However, the ledger implementation has a fixed maximum length on the state arrays produced by StateValue.toArray. When the number of entries in a given state exceeds the maximum, StateValue.toArray produces nested state arrays, where each inner state array is within the maximum. For each nested state array, there will be a key in the indices record pointing to a PublicLedgerSegments object. * * * ### tag[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/PublicLedgerSegments#tag "Direct link to tag") tag: "publicLedgerArray"; * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/PublicLedgerSegments#properties) * [indices](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/PublicLedgerSegments#indices) * [tag](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/PublicLedgerSegments#tag) --- # Effects | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / Effects Type Alias: Effects =================== type Effects = { claimedContractCalls: [bigint, ContractAddress, string, Fr][]; claimedNullifiers: Nullifier[]; claimedShieldedReceives: CoinCommitment[]; claimedShieldedSpends: CoinCommitment[]; claimedUnshieldedSpends: Map<[TokenType, PublicAddress], bigint>; shieldedMints: Map; unshieldedInputs: Map; unshieldedMints: Map; unshieldedOutputs: Map;}; The contract-external effects of a transcript. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------- ### claimedContractCalls[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#claimedcontractcalls "Direct link to claimedContractCalls") claimedContractCalls: [bigint, ContractAddress, string, Fr][]; The contracts called from this contract. The values are, in order: * The sequence number of this call * The contract being called * The entry point being called * The communications commitment * * * ### claimedNullifiers[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#claimednullifiers "Direct link to claimedNullifiers") claimedNullifiers: Nullifier[]; The nullifiers (spends) this contract call requires * * * ### claimedShieldedReceives[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#claimedshieldedreceives "Direct link to claimedShieldedReceives") claimedShieldedReceives: CoinCommitment[]; The coin commitments (outputs) this contract call requires, as coins received * * * ### claimedShieldedSpends[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#claimedshieldedspends "Direct link to claimedShieldedSpends") claimedShieldedSpends: CoinCommitment[]; The coin commitments (outputs) this contract call requires, as coins sent * * * ### claimedUnshieldedSpends[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#claimedunshieldedspends "Direct link to claimedUnshieldedSpends") claimedUnshieldedSpends: Map<[TokenType, PublicAddress], bigint>; The unshielded UTXO outputs this contract expects to be present. * * * ### shieldedMints[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#shieldedmints "Direct link to shieldedMints") shieldedMints: Map; The shielded tokens minted in this call, as a map from hex-encoded 256-bit domain separators to unsigned 64-bit integers. * * * ### unshieldedInputs[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#unshieldedinputs "Direct link to unshieldedInputs") unshieldedInputs: Map; The unshielded inputs this contract expects. * * * ### unshieldedMints[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#unshieldedmints "Direct link to unshieldedMints") unshieldedMints: Map; The unshielded tokens minted in this call, as a map from hex-encoded 256-bit domain separators to unsigned 64-bit integers. * * * ### unshieldedOutputs[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#unshieldedoutputs "Direct link to unshieldedOutputs") unshieldedOutputs: Map; The unshielded outputs this contract authorizes. * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#properties) * [claimedContractCalls](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#claimedcontractcalls) * [claimedNullifiers](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#claimednullifiers) * [claimedShieldedReceives](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#claimedshieldedreceives) * [claimedShieldedSpends](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#claimedshieldedspends) * [claimedUnshieldedSpends](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#claimedunshieldedspends) * [shieldedMints](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#shieldedmints) * [unshieldedInputs](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#unshieldedinputs) * [unshieldedMints](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#unshieldedmints) * [unshieldedOutputs](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Effects#unshieldedoutputs) --- # EmptyPublicLedger | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/EmptyPublicLedger#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / EmptyPublicLedger Type Alias: EmptyPublicLedger ============================= type EmptyPublicLedger = { indices: undefined; tag: "publicLedgerArray";}; A type indicating that no contract references are present in a contract's ledger state. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/EmptyPublicLedger#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------------- ### indices[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/EmptyPublicLedger#indices "Direct link to indices") indices: undefined; * * * ### tag[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/EmptyPublicLedger#tag "Direct link to tag") tag: "publicLedgerArray"; * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/EmptyPublicLedger#properties) * [indices](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/EmptyPublicLedger#indices) * [tag](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/EmptyPublicLedger#tag) --- # Fr | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Fr#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / Fr Type Alias: Fr ============== type Fr = Uint8Array; An internal encoding of a value of the proof systems scalar field --- # Nullifier | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Nullifier#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / Nullifier Type Alias: Nullifier ===================== type Nullifier = string; A Zswap nullifier, as a hex-encoded 256-bit bitstring --- # GatherResult | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/GatherResult#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / GatherResult Type Alias: GatherResult ======================== type GatherResult = | { content: AlignedValue; tag: "read";} | { content: EncodedStateValue; tag: "log";}; An individual result of observing the results of a non-verifying VM program execution --- # checkProofData | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/checkProofData#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / checkProofData Function: checkProofData() ========================== `Internal` checkProofData( zkir, input, output, public_transcript, private_transcript_outputs): void Internal implementation of proof dry runs. Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/checkProofData#parameters "Direct link to Parameters") ---------------------------------------------------------------------------------------------------------------------------------- • **zkir**: `string` • **input**: [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) • **output**: [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) • **public\_transcript**: [`Op`](https://docs.midnight.network/api-reference/ledger/type-aliases/Op) <[`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) \>\[\] • **private\_transcript\_outputs**: [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) \[\] Returns[​](https://docs.midnight.network/api-reference/ledger/functions/checkProofData#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------- `void` Throws[​](https://docs.midnight.network/api-reference/ledger/functions/checkProofData#throws "Direct link to Throws") ---------------------------------------------------------------------------------------------------------------------- If the proof would not hold * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/checkProofData#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/checkProofData#returns) * [Throws](https://docs.midnight.network/api-reference/ledger/functions/checkProofData#throws) --- # bigIntModFr | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/bigIntModFr#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / bigIntModFr Function: bigIntModFr() ======================= bigIntModFr(x): bigint Takes a bigint modulus the proof systems scalar field Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/bigIntModFr#parameters "Direct link to Parameters") ---------------------------------------------------------------------------------------------------------------------------------------- • **x**: `bigint` Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/bigIntModFr#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------------- `bigint` * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/bigIntModFr#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/bigIntModFr#returns) --- # coinCommitment | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/coinCommitment#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / coinCommitment Function: coinCommitment() ========================== `Internal` coinCommitment(coin, recipient): AlignedValue Internal implementation of the coin commitment primitive. Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/coinCommitment#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------------------- • **coin**: [`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) • **recipient**: [`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/coinCommitment#returns "Direct link to Returns") ---------------------------------------------------------------------------------------------------------------------------------- [`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/coinCommitment#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/coinCommitment#returns) --- # ProofErasedTransaction | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / ProofErasedTransaction Class: ProofErasedTransaction ============================= [Transaction](https://docs.midnight.network/api-reference/zswap/classes/Transaction) , with all proof information erased Primarily for use in testing, or handling data known to be correct from external information Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#constructors "Direct link to Constructors") --------------------------------------------------------------------------------------------------------------------------------------------- ### new ProofErasedTransaction()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#new-prooferasedtransaction "Direct link to new ProofErasedTransaction()") private new ProofErasedTransaction(): ProofErasedTransaction #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#returns "Direct link to Returns") [`ProofErasedTransaction`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------- ### fallibleCoins[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#falliblecoins "Direct link to fallibleCoins") readonly fallibleCoins: undefined | ProofErasedOffer; The fallible Zswap offer * * * ### guaranteedCoins[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#guaranteedcoins "Direct link to guaranteedCoins") readonly guaranteedCoins: undefined | ProofErasedOffer; The guaranteed Zswap offer * * * ### mint[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#mint "Direct link to mint") readonly mint: undefined | ProofErasedAuthorizedMint; The mint this transaction represents, if applicable Methods[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------------ ### fees()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#fees "Direct link to fees()") fees(params): bigint The cost of this transaction, in the atomic unit of the base token #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#parameters "Direct link to Parameters") • **params**: [`LedgerParameters`](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#returns-1 "Direct link to Returns") `bigint` * * * ### identifiers()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#identifiers "Direct link to identifiers()") identifiers(): string[] Returns the set of identifiers contained within this transaction. Any of these _may_ be used to watch for a specific transaction. #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#returns-2 "Direct link to Returns") `string`\[\] * * * ### imbalances()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#imbalances "Direct link to imbalances()") imbalances(guaranteed, fees?): Map For given fees, and a given section (guaranteed/fallible), what the surplus or deficit of this transaction in any token type is. #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#parameters-1 "Direct link to Parameters") • **guaranteed**: `boolean` • **fees?**: `bigint` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#returns-3 "Direct link to Returns") `Map`<`string`, `bigint`\> * * * ### merge()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#merge "Direct link to merge()") merge(other): ProofErasedTransaction Merges this transaction with another #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#parameters-2 "Direct link to Parameters") • **other**: [`ProofErasedTransaction`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#returns-4 "Direct link to Returns") [`ProofErasedTransaction`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction) #### Throws[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#throws "Direct link to Throws") If both transactions have contract interactions, or they spend the same coins * * * ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#parameters-3 "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#returns-5 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#parameters-4 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#returns-6 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#deserialize "Direct link to deserialize()") static deserialize(raw, netid): ProofErasedTransaction #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#parameters-5 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#returns-7 "Direct link to Returns") [`ProofErasedTransaction`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#constructors) * [new ProofErasedTransaction()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#new-prooferasedtransaction) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#properties) * [fallibleCoins](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#falliblecoins) * [guaranteedCoins](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#guaranteedcoins) * [mint](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#mint) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#methods) * [fees()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#fees) * [identifiers()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#identifiers) * [imbalances()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#imbalances) * [merge()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#merge) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction#deserialize) --- # Offer | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/Offer#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / Offer Class: Offer ============ A full Zswap offer; the zswap part of a transaction Consists of sets of [Input](https://docs.midnight.network/api-reference/zswap/classes/Input) s, [Output](https://docs.midnight.network/api-reference/zswap/classes/Output) s, and [Transient](https://docs.midnight.network/api-reference/zswap/classes/Transient) s, as well as a [deltas](https://docs.midnight.network/api-reference/zswap/classes/Offer#deltas) vector of the transaction value Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------- ### new Offer()[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#new-offer "Direct link to new Offer()") private new Offer(): Offer #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#returns "Direct link to Returns") [`Offer`](https://docs.midnight.network/api-reference/zswap/classes/Offer) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------- ### deltas[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#deltas "Direct link to deltas") readonly deltas: Map; The value of this offer for each token type; note that this may be negative This is input coin values - output coin values, for value vectors * * * ### inputs[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#inputs "Direct link to inputs") readonly inputs: Input[]; The inputs this offer is composed of * * * ### outputs[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#outputs "Direct link to outputs") readonly outputs: Output[]; The outputs this offer is composed of * * * ### transient[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#transient "Direct link to transient") readonly transient: Transient[]; The transients this offer is composed of Methods[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------- ### merge()[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#merge "Direct link to merge()") merge(other): Offer Combine this offer with another #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#parameters "Direct link to Parameters") • **other**: [`Offer`](https://docs.midnight.network/api-reference/zswap/classes/Offer) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#returns-1 "Direct link to Returns") [`Offer`](https://docs.midnight.network/api-reference/zswap/classes/Offer) * * * ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#parameters-1 "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#returns-2 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#parameters-2 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#returns-3 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#deserialize "Direct link to deserialize()") static deserialize(raw, netid): Offer #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#parameters-3 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Offer#returns-4 "Direct link to Returns") [`Offer`](https://docs.midnight.network/api-reference/zswap/classes/Offer) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/Offer#constructors) * [new Offer()](https://docs.midnight.network/api-reference/zswap/classes/Offer#new-offer) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/Offer#properties) * [deltas](https://docs.midnight.network/api-reference/zswap/classes/Offer#deltas) * [inputs](https://docs.midnight.network/api-reference/zswap/classes/Offer#inputs) * [outputs](https://docs.midnight.network/api-reference/zswap/classes/Offer#outputs) * [transient](https://docs.midnight.network/api-reference/zswap/classes/Offer#transient) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/Offer#methods) * [merge()](https://docs.midnight.network/api-reference/zswap/classes/Offer#merge) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/Offer#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/Offer#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/Offer#deserialize) --- # ProofErasedTransient | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / ProofErasedTransient Class: ProofErasedTransient =========================== A [Transient](https://docs.midnight.network/api-reference/zswap/classes/Transient) , with all proof information erased Primarily for use in testing, or handling data known to be correct from external information Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------- ### new ProofErasedTransient()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#new-prooferasedtransient "Direct link to new ProofErasedTransient()") private new ProofErasedTransient(): ProofErasedTransient #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#returns "Direct link to Returns") [`ProofErasedTransient`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------- ### commitment[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#commitment "Direct link to commitment") readonly commitment: string; The commitment of the transient * * * ### contractAddress[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#contractaddress "Direct link to contractAddress") readonly contractAddress: undefined | string; The contract address creating the transient, if applicable * * * ### nullifier[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#nullifier "Direct link to nullifier") readonly nullifier: string; The nullifier of the transient Methods[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#deserialize "Direct link to deserialize()") static deserialize(raw, netid): ProofErasedTransient #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#returns-3 "Direct link to Returns") [`ProofErasedTransient`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#constructors) * [new ProofErasedTransient()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#new-prooferasedtransient) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#properties) * [commitment](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#commitment) * [contractAddress](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#contractaddress) * [nullifier](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#nullifier) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#methods) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransient#deserialize) --- # ProofErasedOutput | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / ProofErasedOutput Class: ProofErasedOutput ======================== An [Output](https://docs.midnight.network/api-reference/zswap/classes/Output) with all proof information erased Primarily for use in testing, or handling data known to be correct from external information Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------------- ### new ProofErasedOutput()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#new-prooferasedoutput "Direct link to new ProofErasedOutput()") private new ProofErasedOutput(): ProofErasedOutput #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#returns "Direct link to Returns") [`ProofErasedOutput`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------- ### commitment[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#commitment "Direct link to commitment") readonly commitment: string; The commitment of the output * * * ### contractAddress[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#contractaddress "Direct link to contractAddress") readonly contractAddress: undefined | string; The contract address receiving the output, if the recipient is a contract Methods[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#deserialize "Direct link to deserialize()") static deserialize(raw, netid): ProofErasedOutput #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#returns-3 "Direct link to Returns") [`ProofErasedOutput`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#constructors) * [new ProofErasedOutput()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#new-prooferasedoutput) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#properties) * [commitment](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#commitment) * [contractAddress](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#contractaddress) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#methods) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOutput#deserialize) --- # ProofErasedAuthorizedMint | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / ProofErasedAuthorizedMint Class: ProofErasedAuthorizedMint ================================ A request to mint a coin, authorized by the mint's recipient, with the authorizing proof having been erased Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------------ ### new ProofErasedAuthorizedMint()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#new-prooferasedauthorizedmint "Direct link to new ProofErasedAuthorizedMint()") private new ProofErasedAuthorizedMint(): ProofErasedAuthorizedMint #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#returns "Direct link to Returns") [`ProofErasedAuthorizedMint`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------ ### coin[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#coin "Direct link to coin") readonly coin: CoinInfo; The coin to be minted * * * ### recipient[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#recipient "Direct link to recipient") readonly recipient: string; The recipient of this mint Methods[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#methods "Direct link to Methods") --------------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#deserialize "Direct link to deserialize()") static deserialize(raw, netid): ProofErasedAuthorizedMint #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#returns-3 "Direct link to Returns") [`ProofErasedAuthorizedMint`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#constructors) * [new ProofErasedAuthorizedMint()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#new-prooferasedauthorizedmint) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#properties) * [coin](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#coin) * [recipient](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#recipient) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#methods) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint#deserialize) --- # 3 docs tagged with "wallet" | Midnight Docs [Skip to main content](https://docs.midnight.network/next/tags/wallet#__docusaurus_skipToContent_fallback) [Create a Next.js wallet connector\ ---------------------------------](https://docs.midnight.network/next/guides/nextjs-wallet-connect) Learn how to create a Next.js application that connects to a wallet using the Midnight DApp Connector API. [Create a React wallet connector\ -------------------------------](https://docs.midnight.network/next/guides/react-wallet-connect) Learn how to create a React application that connects to a wallet using the Midnight DApp Connector API. [Interact with hello world contract\ ----------------------------------](https://docs.midnight.network/next/guides/interact-with-mn-app) Build a command-line interface to interact with a deployed hello world contract on the Midnight Network. --- # Compact reference | Midnight Docs [Skip to main content](https://docs.midnight.network/compact/lang-ref#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ Compact is a strongly statically typed, bounded smart contract language, designed to be used in combination with TypeScript for writing smart contracts for the three-part structure of Midnight, where contracts have the following components: * a replicated component on a public ledger * a zero-knowledge circuit component, confidentially proving the correctness of the former * a local, off-chain component that can perform arbitrary code Each contract in Compact can have four kinds of code: * type declarations, to support all of the following * declarations of the data that the contract stores in the public ledger * declarations of `witness` functions, to be supplied in TypeScript * `circuit` definitions, that serve as the operational core of a smart contract A contract can also include code from external files, and it can declare and import modules. Like TypeScript, Compact is an eager call-by-value language. Compact Types[​](https://docs.midnight.network/compact/lang-ref#compact-types "Direct link to Compact Types") -------------------------------------------------------------------------------------------------------------- Compact is **statically typed**: every expression in a Compact program has a static type. Named circuits and witnesses require a type annotation on each of their parameters, and they require a return type annotation. Anonymous circuit expressions can have optional parameter and return type annotations. Constant binding statements can have an optional type annotation. The language is **strongly typed**: the compiler will reject programs that do not type check. It will reject programs where a circuit or witness with a parameter type annotation is called with an incorrectly typed argument for that parameter. It will reject programs where a circuit with a return type annotation returns an incorrectly typed value. If an optional type annotation is omitted, the compiler will infer a type and it will reject programs where no such type can be inferred. Types consist of built-in primitive types, user-defined types defined in the program, and generic type parameters in scope. When the term "type" occurs in this document without any other qualifier, it means either a primitive type, a user-defined type, or a generic type parameter in scope. ### Primitive types[​](https://docs.midnight.network/compact/lang-ref#primitive-types "Direct link to Primitive types") The following are the primitive types of Compact: * `Boolean` is the type of _boolean_ values. There are only two values of `Boolean` type. They are the values of the expressions `true` and `false`. * `Uint`, where `m` is the literal `0` or a generic size parameter in scope and bound to `0`, and where `n` is a natural number literal or a generic size parameter in scope, is the type of _bounded unsigned integer_ values between `0` and `n`, both inclusive. (The lower bound is currently required to be `0`.) `Uint` types with different bounds `0..n` are different types, although [one may be a subtype of the other](https://docs.midnight.network/compact/lang-ref#subtyping-and-least-upper-bounds) . In practice, there is a (large) maximum unsigned integer value determined by the zero-knowledge proving system. The Compact implementation will signal an error if a `Uint` type exceeds this maximum value. * `Uint`, where `n` is a non-zero natural number literal or a generic size parameter in scope and bound to a non-zero natural number, is the type of _sized unsigned integer_ values with binary representations using up to `n` bits. This is the same type as `Uint<0..m>` where `m` is equal to `(2^n)-1`. Sized integer types can be seen as a convenience for programmers. `Uint<32>`, for example, can be more obvious and less error-prone than the equivalent `Uint<0..4294967295>`. Any Compact program that uses sized integer types can be rewritten to one that uses only bounded integer types. * `Field` is the type of elements in the scalar prime field of the zero-knowledge proving system. * `[T, ...]`, where `T, ...` are zero or more comma-separated types is the type of _tuple_ values with element types `T, ...`. Note that tuples are heterogeneous: the element types can all be distinct. The _length_ of a tuple type is the number of element types. Tuple types with different lengths are different types. Tuple types with the same lengths but where at least one element has different types are different types although [one may be a subtype of the other](https://docs.midnight.network/compact/lang-ref#subtyping-and-least-upper-bounds) . * `Vector`, where `n` is a natural number literal or else a generic size parameter in scope and `T` is a type, is a shorthand notation for the tuple type `[T, ...]` with `n` occurrences of the type `T`. Note that a vector type and the corresponding tuple type are two different ways of writing exactly the same type. Unless otherwise specified, type rules for vector types are derived from the rules for the corresponding tuple type. * `Bytes`, where `n` is a natural number literal or else a generic size parameter in scope, is the type of _byte array_ values of length `n`. `Bytes` types with different lengths are different types. `Bytes` types are used in the Compact standard library for hashing. String literals in Compact also have a `Bytes` type, where `n` is the number of bytes in the UTF-8 encoding of the string. * `Opaque`, where `s` is a string literal, is the type of _opaque_ values with tag `s`. The syntax of string literals in Compact is the same as in TypeScript. `Opaque` types with different tags are different types. Opaque values can be manipulated in witnesses but they are opaque to circuits. They are represented in circuits as their hash. The allowed tags are currently only `"string"` and `"Uint8Array"`. ### User-defined types[​](https://docs.midnight.network/compact/lang-ref#user-defined-types "Direct link to User-defined types") Users can define three kinds of types themselves: structures, enumerations, and contracts. #### Structure types[​](https://docs.midnight.network/compact/lang-ref#structure-types "Direct link to Structure types") Structure types are defined by a declaration beginning with the keyword `struct`. Here are some examples: struct Thing { triple: Vector<3, Field>, flag: Boolean,}struct NumberAnd { num: Uint<32>; item: T} A _non-generic structure_ declaration introduces a named structure type, such as `Thing` in the first example above. Each non-generic structure declaration introduces a distinct type, even when the content of the structure is identical to another. Structure declarations can also be _generic structure_ declarations, such as `NumberAnd` in the second example above. They have a non-empty list of comma-separated _generic parameter_ names enclosed in angle brackets. The generic parameters of a generic structure declaration are in scope in its body. Generic structure declarations do not introduce a type. To be used as a type, they must be _specialized_ by providing a comma-separated list of _generic arguments_, e.g., `NumberAnd>`. Generic arguments must be types, natural number literals, or a generic size parameter in scope. Generic structures must be fully specialized: the number of generic arguments must match the number of generic parameters. * Specializations of the same generic structure to the same types are the same type. * Specializations of the same generic structure to different types are different types. * Specializations of different generic structures are always different types, even if the specializations are structurally equivalent. * Specializations of generic structures are always different from non-generic structure types, even if the specialization is structurally equivalent to the non-generic type. A structure declaration has a sequence of named fields which must be separated either by commas or by semicolons. Comma and semicolon separators cannot be mixed within a single structure declaration. A trailing separator is allowed, but not required. Each structure field must have a type annotation. Values of structure types are created with _structure creation_ expressions. These consist of the structure type (so generic structures must be specialized), followed by a sequence of field values enclosed in curly braces (`{ }`). Field values can be given positionally, in the same order as they are declared in the `struct` declaration; or they can be named using the field names from the declaration. Named field values can appear in any order. Positional and named field values can be mixed in the same structure creation expression, but all the positional ones must come before any of the named ones. See [Structure creation](https://docs.midnight.network/compact/lang-ref#structure-creation) for the details. Using the example declarations above, structure values could be created with `Thing {[0, 1, 2], true}` or `NumberAnd> { item: 255, num: 0 }`. Structures may not contain fields containing the same type as the structure, either directly or indirectly. For example, it is an error to use the following pair of declarations: struct Even { predecessor: Odd}struct Odd { predecessor: Even}export circuit doesntWork(s: Even): Odd { return s.predecessor;} #### Enumeration types[​](https://docs.midnight.network/compact/lang-ref#enumeration-types "Direct link to Enumeration types") Enumeration types are defined by a declaration beginning with the keyword `enum`. Here is an example: enum Fruit { apple, pear, plum } An enumeration declaration introduces a named enumeration type, such as `Fruit` in the example above. Each enumeration declaration introduces a distinct type. An enumeration declaration has a sequence of named values separated by commas. A trailing separator is allowed but not required. In the example above, the type `Fruit` has three values: `Fruit.apple`, `Fruit.pear`, and `Fruit.plum`. #### Contract types[​](https://docs.midnight.network/compact/lang-ref#contract-types "Direct link to Contract types") As of this writing, declarations of contracts and the cross-contract calls they support are not yet fully implemented, but the keyword `contract` used to declare contracts is reserved for this use. ### Generic parameter references[​](https://docs.midnight.network/compact/lang-ref#generic-parameter-references "Direct link to Generic parameter references") Generic parameters are declared in generic module declarations, generic structure type declarations, generic circuit definitions, and generic witness declarations. For generic modules, they are in scope within the module. For generic structures, they are in scope for the structure's fields. For generic circuits, they are in scope in the circuit's parameters, its return type annotation, and its body. In these scopes, a reference to a generic parameter (that is not otherwise shadowed by some other identifier binding) is either a type or a natural-number size. ### Subtyping and least upper bounds[​](https://docs.midnight.network/compact/lang-ref#subtyping-and-least-upper-bounds "Direct link to Subtyping and least upper bounds") There is a _subtyping_ relation on Compact types. Informally, if a type `T` is a subtype of a type `S` then every value of type `T` is also a value of type `S` (equivalently, `S` is a supertype of `T`). In that case, Compact allows implicitly using a value of type `T` where a value of type `S` is expected, without any programmer-supplied conversion. Subtyping is defined by the following rules: * Any type `T` is a subtype of itself (subtyping is reflexive) * `Uint<0..n>` is a subtype of `Uint<0..m>` if `n` is less than `m` * `Uint<0..n>` is a subtype of `Field` for all `n` * `[T, ...]` is a subtype of `[S, ...]` if the two tuple types have the length and each type `T` is a subtype of the corresponding type `S` A circuit or witness can be called with argument expressions whose types are subtypes of the corresponding parameter type annotations. A constant binding statement with a type annotation can be initialized with an expression whose type is a subtype of the type annotation. The _least upper bound_ (with respect to subtyping) of a non-empty set of types {`T0`, ..., `Tn`} is a type `S` such that: * **`S` is an upper bound:** `Ti` is a subtype of `S` for all `i` in the range 0..`n`, and * **`S` is the least upper bound:** for all upper bounds `R` of the set of types {`T0`, ..., `Tn`}, `S` is a subtype of `R`. Note that least upper bounds do not necessarily exist for all sets of types. **Tuple and vector types:** We say that a tuple type `[T, ...]` with possibly distinct types `T, ...` "_has a vector type_" if the least upper bound `S` of the set of types {`T`, ...} exists. In that case, the tuple type has the vector type `Vector` where `n` is the length of the tuple. Some operations over tuples (such as mapping and folding) require the tuple type to have a vector type. Note that when a tuple type has a vector type, the tuple type is a subtype of the vector type. Perhaps surprisingly, vector types can be subtypes of tuple types as well. A vector type `Vector` is a subtype of a tuple type `[S, ...]` if the tuple has length `n` and `T` is a subtype of each of the types `S, ...`. The means, for instance, that a vector could be passed to a circuit where a tuple is expected. ### Default values[​](https://docs.midnight.network/compact/lang-ref#default-values "Direct link to Default values") Every type in Compact has a _default value_ of that type. The default values are as follows: * `Boolean`: the value of the literal `false` * `Uint<0..n>` and `Uint`: `0` * `Field`: `0` * `[T, ...]` where `T, ...` is a sequence of zero or more types: the tuple with the corresponding length, each of the default value of the corresponding type * `Bytes`: the byte array of length `n` with all zero bytes * `Opaque<"string">`: an empty string, i.e., `""` * `Opaque<"Uint8Array">`: a zero-length `Uint8Array`, i.e., `new Uint8Array(0)` * structure types: the struct with all fields set to the default value of their type * enumeration types: the first value listed in the declaration ### Representations in TypeScript[​](https://docs.midnight.network/compact/lang-ref#representations-in-typescript "Direct link to Representations in TypeScript") Compact's primitive types are represented in TypeScript as follows: * `Boolean` - `boolean` * `Field` - `bigint` with runtime bounds checks * `Uint` / `Uint<0..n>` - `bigint` with runtime bounds checks * `[T, ...]` - the TypeScript tuple type `[S, ...]` or else the TypeScript array type `S[]` with runtime length checks, where `S` is the TypeScript representation of the corresponding type `T` * `Bytes` - `Uint8Array` with runtime length checks * `Opaque<"string">` - `string` * `Opaque<"Uint8Array">` - `Uint8Array` User-defined types are represented in TypeScript as follows: * `enum` instances - a `number` with runtime membership checks * `struct` instances with fields `a: A, b: B, ...` - an object `{ a: A, b: B, ... }` where `A`, `B`, ... are the TypeScript representations of the Compact types. Note that other `Opaque` types are currently not supported. Include files[​](https://docs.midnight.network/compact/lang-ref#include-files "Direct link to Include files") -------------------------------------------------------------------------------------------------------------- Compact supports code separation and namespaces through separate files and modules. The most basic of these is the statement include "path/to/file"; which may appear at the top level of a source file or module. When encountered, the Compact compiler will search for a Compact source file at `path/to/file.compact` in the current directory and then relative to any of the directories in the `:`\-separated environment variable `COMPACT_PATH`. This file _must_ be found and will be included verbatim in place of the `include` statement. Modules, exports, and imports[​](https://docs.midnight.network/compact/lang-ref#modules-exports-and-imports "Direct link to Modules, exports, and imports") ------------------------------------------------------------------------------------------------------------------------------------------------------------ A module is a collection of definitions whose namespace is hidden from surrounding code. A module is defined with module Mod1 { ...}module Mod2 { ...} By default, identifiers defined within the body of a module are visible only within the module, i.e., they are not exported from the module. Any identifier defined at or imported into the top level of a module can be exported from the module in one of two ways: (1) by prefixing the definition with the `export` keyword, or by listing the identifier in a separate `export` declaration. For example, the following module exports `G` and `S` but not `F`. module M { export { G }; export struct S { x: Uint<16>, y: Boolean } circuit F(s: S): Boolean { return s.y; } circuit G(s: S): Uint<16> { return F(s) ? s.x : 0; }} A module can be imported into another definition scope, bringing all its exported entries into that scope, potentially with a prefix. For instance: module Runner { export circuit run(): [] {}}import Runner;// run is now in scopeimport Runner prefix SomePrefix_;// SomePrefix_run is now in scopemodule Identity { export { id } circuit id(x: T): T { return x; }}import Identity;// id is now in scope, with Field as type T Compact's standard library can be imported by `import CompactStandardLibrary`. The standard library defines a number of useful types and circuits along with ledger ADTs such as `Counter`, `Map`, and `MerkleTree`. When importing module `M`, if the program does not contain a visible module definition the compiler looks in the file system in the relative path of the current directory for `M.compact`. In the case where a module is defined in a different program (file), the program must only contain a top-level module definition. Otherwise, the compiler throws a static error stating that the program does not contain a single module definition. For example, the program `M.compact` below defines a module: module M { export { F }; export struct S { x: Uint<16>, y: Boolean } circuit F(x: S): Boolean { return S.y; }}// circuit cant_exists() : [] {}// If cant_exists is uncommented, the compiler will throw an error when compiling// test.compact Then, `test.compact` imports `M`: //module M {// export { G };// export struct S { x: Uint<16>, y: Boolean }// circuit G(x: S): Boolean {// return S.y;// }//}// If M is uncommented, the compiler will import this module and not the one// defined in M.compact. In this case, the compiler will throw an error for// exporting F.import M;export { F }; The import syntax allows the module to be identified by a string pathname. In this case, the compiler first looks for the imported module relative to the current directory (the path of the importing program) and then in the directories identified by `COMPACT_PATH`. Importing by a pathname allows importing multiple modules with the same name. For example, consider the program `M.compact`: module M { export { F }; export struct S { x: Uint<16>, y: Boolean } circuit F(x: S): Boolean { return S.y; }} And the program `A/M.compact`: module M { export { F }; export struct S { x: Uint<16>, y: Boolean } circuit F(x: S): Boolean { return S.y; }} And finally the program `test.compact` can export both `$F` and `A_F` but not `$G`: module M { export { G }; export struct S { x: Uint<16>, y: Boolean } circuit G(x: S): Boolean { return S.y; }}import "M" prefix $;// this imports M.compact and not the module M defined aboveimport "A/M" prefix A_;export { $F ,A_F// ,$G// uncommenting this will result in an error }; Top-level exports[​](https://docs.midnight.network/compact/lang-ref#top-level-exports "Direct link to Top-level exports") -------------------------------------------------------------------------------------------------------------------------- The circuits exported at the top level of a contract (i.e., not merely exported from a module) are the entry points of the contract and may not take generic arguments. Although multiple circuits with the same name are allowed generally to support [function overloading](https://docs.midnight.network/compact/lang-ref#circuit-and-witness-calls) , it is a static error if more than one circuit with the same name is exported from the top level. User-defined types exported from the top level of the main file can be used to describe the argument and return types of witnesses and exported circuits; these may accept generic arguments, but generic arguments not actually used as types are dropped in the exported type. For example: export struct S<#n, T> { v: Vector; curidx: Uint<0..n> } is exported for use as a TypeScript type with the `T` parameter but not the `n` parameter, i.e.,: export type S = { v: T[]; curidx: bigint } Ledger field names exported from the top level are visible for direct inspection by code outside of the contract via the generated TypeScript `ledger()` function. Circuits[​](https://docs.midnight.network/compact/lang-ref#circuits "Direct link to Circuits") ----------------------------------------------------------------------------------------------- The basic operational element in Compact is the `circuit`. This corresponds closely to a function in most languages but is compiled directly into a zero-knowledge circuit. Circuits are declared as: circuit c(a: A, b: B, ...): R { ...}circuit id(value: T): T { return value;} where `A`, `B`, ..., and `R` are types, and `a`, `b` are parameters. The circuit body itself is a sequence of statements, and each path through the body must end with a `return` statement, unless the return type is `[]`. ### Pure and impure circuits[​](https://docs.midnight.network/compact/lang-ref#pure-and-impure-circuits "Direct link to Pure and impure circuits") A Compact circuit is considered _pure_ if it computes its outputs from its inputs without reference to or modification of public state (via the ledger) or private state (via witnesses). In practice, the compiler considers a circuit to be impure if the body of the circuit contains a ledger operation, a call to any impure circuit, or a call to a witness. Some external circuits defined in `CompactStandardLibrary` are witnesses; calls to these make the caller impure. The remainder are considered pure, so calls to those do not make the caller impure. A Compact program can declare a circuit to be pure by prefixing the circuit definition with the `pure` modifier, which must follow the `export` modifier, if present, e.g.: pure circuit c(a: Field): Field { ...}export pure circuit c(a: Field): Field { ...} The only effect of the `pure` modifier is that the compiler will flag the declaration as an error if its own analysis determines that the circuit is actually impure. The pure modifier allows an application to ensure that the circuit will be present in the `PureCircuits` type declaration and via the `pureCircuits` constant in the TypeScript module produced for a (correct) Compact program by the Compact compiler. ### Statements[​](https://docs.midnight.network/compact/lang-ref#statements "Direct link to Statements") A statement may be * a `for` loop * an `if` statement * a `return` statement * an `assert` * a block - a sequence of statements in a nested scope, enclosed by curly braces * a `const` binding statement * an expression #### `for` loop[​](https://docs.midnight.network/compact/lang-ref#for-loop "Direct link to for-loop") A `for` loop repeats for a fixed number of iterations, using one of the two syntaxes below: for (const i of ) for (const i of ..) #### `if` statement[​](https://docs.midnight.network/compact/lang-ref#if-statement "Direct link to if-statement") An `if` statement is of one of the following forms: if (testexpr) if (testexpr) else #### `return` statement[​](https://docs.midnight.network/compact/lang-ref#return-statement "Direct link to return-statement") If a circuit's return type is `[]`, return; is a valid statement. Otherwise, return ; for an expression `` of the declared return type is a valid return statement. #### `assert` statement[​](https://docs.midnight.network/compact/lang-ref#assert-statement "Direct link to assert-statement") An assertion can be made with assert(, "what constraint was violated"); where `` should evaluate to a `Boolean`. If `` evaluates to true, the assertion succeeds; if `` evaluates to false, it fails with the given message. Each assertion is checked at runtime and constrained in-circuit. #### `const` binding statement[​](https://docs.midnight.network/compact/lang-ref#const-binding-statement "Direct link to const-binding-statement") A new constant can be brought into scope with const x = ; A `const` binding statement can bind multiple constants. The constant bindings are performed from left-to-right. const x = , y = ; A variable bound by a constant binding cannot be referenced before it is initialized. circuit c(): Field { // const y = x; // rejected by Compactc const x = 1, y = x; // const y = x, x = 1; // rejected by Compactc return y;} Each of the constant bindings may optionally be annotated with a type, in which case the type is checked with the expression. const x: T = ; const x: T = , y = ; The name of a constant may not be reused within a block, and constants cannot be reassigned, although they can be shadowed in a nested block: circuit c(): Field { const answer = 42; // const answer = 12, answer = 1; // rejected by Compactc { const answer = 12; assert answer != 42 "shadowing didn't work!"; } return answer; // returns 42} Constant initializer expressions are evaluated when the binding statement is executed. ### Expressions[​](https://docs.midnight.network/compact/lang-ref#expressions "Direct link to Expressions") This section describes the syntax of Compact expressions and provides their static typing rules and their evaluation rules. The syntax of expressions is given by an EBNF grammar. We use the following notational conventions in the grammar: * Terminals are in **bold monospaced** font * Non-terminals are in _emphasized_ font * Alternation is indicated by a vertical bar (`|`) * Repetition of zero or more items is indicated by enclosing them in curly braces (`{` and `}`) * Optional items are indicated by enclosing them in square brackets (`[` and `]`) A Compact expression either has a static type, or else it contains a type error. The static type of an expression, if it has one, is either a Compact type or else a ledger state type. If an expression in a program contains a type error, it means that the Compact compiler will not compile that program. Subexpressions of Compact expressions are always required to be well-typed (free from type errors). Every Compact expression either evaluates to a value, or else it raises an exception. The evaluation of an expression is defined in terms of the evaluation of its subexpressions. If the evaluation of a subexpression raises an exception, then the evaluation of the containing expression will stop and raise the same exception. #### Literals[​](https://docs.midnight.network/compact/lang-ref#literals "Direct link to Literals") Compact has syntax for boolean, numeric, and string literal expressions. | | | | | --- | --- | --- | | _expr_ | → | **true** | | | \| | **false** | | | \| | _nat_ | | | \| | _str_ | | | \| | **pad**  **(**  _nat_  **,**  _str_  **)** | **Boolean literals** are the reserved words `true` and `false`. The static type of a boolean literal is `Boolean`. It evaluates to one of the two boolean values. **Numeric literals** are non-negative decimal integers. They are either the number `0` or a sequence of digits starting with a non-zero digit. The static type of a natural number literal `n` is `Uint<0..n>`. There is an implementation-defined maximum unsigned integer value. A numeric literal larger than this value will have an invalid static type `Uint<0..n>` for some `n` larger than the maximum unsigned integer. This expression will be a static type error unless the literal is smaller than the maximum `Field` value and is used in a type cast expression of the form `e as Field`. A natural number literal evaluates to the unsigned integer value that it denotes. **String literals** use TypeScript string literal syntax. Note that they can therefore be enclosed in either single (`'`) or double (`"`) quotes, and they can contain escaped characters. Strings are represented by their UTF-8 encoding. The **length** of a string is the length of its UTF-8 encoding. The static type of a string literal is `Bytes` where `n` is the length of the string. It evaluates to a byte array containing its UTF-8 encoding. In addition, the expression `pad(n, s)` is a string literal, where `pad` is a reserved word, `n` is a natural number literal and `s` is a string literal whose length must be less than or equal to `n`. The static type of a padded string literal `pad(n, s)` is `Bytes`. It evaluates to a byte array containing the UTF-8 encoding of `s`, followed by `0` bytes up to the padded length `n`. #### Variable references[​](https://docs.midnight.network/compact/lang-ref#variable-references "Direct link to Variable references") The syntax of Compact identifiers is the same as the syntax of TypeScript identifiers. A variable is an identifier that is bound as a parameter in a circuit declaration or else as a constant in a `const` binding statement. | | | | | --- | --- | --- | | _expr_ | → | _id_ | **Circuit parameters** are bound by circuit declarations. The static type of a circuit parameter reference is the declared static type given by the parameter declaration's type annotation. It evaluates to the value of the corresponding argument expression that was passed to the circuit call. **Constants** are bound by `const` binding statements. If the binding statement has a type annotation, then the constant reference's static type is the declared static type given by the type annotation, and the type of the right-hand side initializer expression must be a subtype of the declared type. If the binding statement does not have a type annotation, then the constant reference's static type is the inferred static type (that is, the type of the binding statement's initializer expression). A constant reference evaluates to the value of the binding statement's initializer expression. Note that constant references can have ledger state types because they can be initialized with a ledger state type's default value. #### Default values of a type[​](https://docs.midnight.network/compact/lang-ref#default-values-of-a-type "Direct link to Default values of a type") Every Compact type and ledger state type has a default value. | | | | | --- | --- | --- | | _expr_ | → | **default**  **<**  _type_  **\>** | | | \| | **default**  **<**  _ledger-adt_  **\>** | The expression `default`, where `T` is a Compact type or a ledger state type, has static type `T`. It evaluates to the default value of that type. Note that default value expressions can have ledger state types. #### Circuit and witness calls[​](https://docs.midnight.network/compact/lang-ref#circuit-and-witness-calls "Direct link to Circuit and witness calls") Circuits and witnesses, collectively referred to as functions, are called via an expression of the form `f(e, ...)`, where `f` is a function and `e, ...` is a sequence of zero or more comma-separated argument expressions. | | | | | --- | --- | --- | | _expr_ | → | _fun_  **(**  \[_expr_  {**,**  _expr_}\]  **)** | | _fun_ | → | _id_  \[_targs_\] | | | \| | **(**  \[_var-or-arg_  {**,**  _var-or-arg_}\]  **)**  **:**  \[_type_\]  **\=>**  _body_ | | | \| | **(**  _fun_  **)** | | _targs_ | → | **<**  \[_targ_  {**,**  _targ_}\]  **\>** | | _targ_ | → | _nat_ | | | \| | _type_ | | _var-or-arg_ | → | _id_ | | | \| | _arg_ | | _arg_ | → | _id_  **:**  _type_ | | _body_ | → | _block_ | | | \| | _expr_ | The function expression can take several different forms: A **function name** is the name of a circuit or witness from a circuit or witness declaration in scope. An **anonymous circuit** is an inline circuit definition having the form `(P, ...) => body` or `(P, ...): R => body`, where `P, ...` are zero or more comma-separated parameter declarations, `R` is an optional return type annotation, and `body` is the circuit's body. Each parameter consists of an identifier `x` (the parameter's name) and an optional type annotation `: T` where `T` is a Compact type. The optional return type `R` is a Compact type. The body is either a block (a sequence of zero or more semicolon-delimited statements enclosed in curly braces (`{ }`)), or an expression. There is no syntax for generic anonymous circuits. This is because circuits are not first-class values: they cannot be passed around or stored in data structures, they _must_ be called. And generic circuits must be specialized to call them, so anonymous generic circuits would have to be immediately specialized. In that case, the programmer can just write the non-generic version themselves. A **parenthesized function** has the form `(f)` where `f` is a function expression, that is either a function name, an anonymous circuit, or a parenthesized function. Because functions are not first class, parameter names and constant names are not allowed as the function part of a call. Nor are arbitrary expressions allowed, for the same reason. Because circuits and witnesses are not first class, parameter names and constant names are not allowed as the circuit or witness part of a call. Nor are arbitrary expressions allowed, for the same reason. Generic functions cannot be called without explicitly specializing them with generic arguments enclosed in angle brackets. Calls to generic functions must be fully specialized: the number of generic arguments must match the number of generic parameters. The _underlying function_ of a function expression is a non-parenthesized function expression. For a function name it is the function name, for an anonymous circuit it is the anonymous circuit, and for a parenthesized function it is the underlying function of the parenthesized function expression. Type checking a function call depends on the form of the underlying function. * **For a named function:** Function names may be _overloaded_: more than one function of the same name may be present in the scope of a call to that function. A call whose underlying function is a name can thus have zero or more candidate functions, i.e., all of those that have the given name and are present in the scope of the call. A candidate function is not necessarily compatible with the number and kinds of the generic parameter values, nor with the number and types of the argument expressions provided at the call site. It is compatible if and only if the number of generic parameters is the same as the number of generic arguments, each generic argument is of the required kind (a size or a type), the number of declared parameters is the same as the number of argument expressions, and if the declared type of each parameter is a supertype of the corresponding argument expression. If exactly one candidate is compatible, the call is made to that candidate. It is a static type error otherwise (if there is not exactly one compatible candidate). The static type of a call to a named function is the return type of the called function. * **For an anonymous circuit:** Parameters that have type annotations will be type checked, and parameters that do not have type annotations will have types inferred. The argument subexpressions are type checked and then: * If there is a type annotation for a parameter, it is a static type error if the type of the corresponding argument expression is not a subtype of the type annotation. * If there is no type annotation for a parameter, the parameter's type is inferred as the type of the corresponding argument expression. If there is a return type annotation, then the circuit's body is type checked under the assumption that the parameters have their declared or inferred types. It is a static type error if there is a returned subexpression whose static type is not a subtype of the return type annotation. A return statement of the form `return;` is type checked as if it returned a value of type `[]`. Every control flow path through a body that does not explicitly end with a return statement implicitly ends with one of the form `return;`. If there is no return type annotation, then a return type is inferred from the body. The body is type checked under the assumption that the parameters have their declared or inferred types. The inferred return type is the least upper bound of the types of all the returned subexpressions, with the same treatment of `return;` and control-flow paths that do not end in an explicit return as described above. The static type of a call to an anonymous circuit is the declared or inferred return type. Calls are evaluated by evaluating the argument expressions in order from left to right. Then, if a circuit is being called, the statements in the body of the circuit are executed with the parameter names bound to the corresponding argument values. The value of a circuit call is the value returned from the execution of the body. If a witness is being called, the contract will invoke the TypeScript or JavaScript witness function with the argument values. The value of a witness call is the value returned by the witness function. #### Structure creation[​](https://docs.midnight.network/compact/lang-ref#structure-creation "Direct link to Structure creation") Structure values are created with structure creation expressions. The expression `S {f, ...}` is a structure creation expression, where `S` is a structure type and `f` is a sequence of zero or more comma-separated field value specifiers. A field value specifier can be one of three things: * A **positional** field value is an expression. Evaluating the expression gives the value for the field. Positional field values must be given in the order that fields are declared in the corresponding structure declaration. * A **named** field value is of the form `id: e` where `id` is a field name and `e` is an expression. Evaluating the expression gives the value for the corresponding named field. Named fields can appear in any order. If named and positional fields are mixed, all the named fields must appear after all the positional fields. * A **spread** expression is of the form `...e` where `...` is the literal three dots (ellipsis) token and `e` is an expression. Evaluating the expression must give a value of the same structure type as the one being created. The fields of the created structure are given values from the spread structure as described below. If there is a spread expression, it must occur as the first field value specifier and all other specifiers must be named field values. | | | | | --- | --- | --- | | _expr_ | → | _tref_  **{**  \[_new-field_  {**,**  _new-field_}\]  **}** | | _new-field_ | → | _expr_ | | | \| | _id_  **:**  _expr_ | | | \| | **...**  _expr_ | | _tref_ | → | _id_  \[_targs_\] | The examples below demonstrate the use of positional and spread field values: struct S { a: Uint<32>, b: Boolean, c: Bytes<8> }circuit f(x: Uint<32>, y: Boolean, z: Bytes<8>): S { const s1 = S { c: z, a: x, b: y }; // Alternatively, s1 can be created with the positional syntax S { x, y, z } // or a mix of positional and named field values S { x, c: z, b: y }. const s2 = S { ...s1, b: true }; // s2 is created using the spread syntax. So, s2 has the same field values // as s1 except that b is true. const s3 = S { ...s2, c: 'abcdefgh' }; // s3 is also created using the spread syntax. s3 has the same field values // as s2 except that c is 'abcdefgh'. return s3;} The structure type must come from a structure declaration in scope. If the structure is generic, then it must be explicitly specialized with generic arguments enclosed in angle brackets. Generic structures must be fully specialized: the number of generic arguments must match the number of generic parameters. The static type of a non-generic structure creation expression is the named structure type. The generic arguments to a generic structure can be types, natural number literals, or the names of generic parameters in scope. A generic structure creation expression is type checked by substituting the generic arguments for the generic parameters in the structure's definition. The static type of a generic structure creation expression is a structure with the same name as the generic type and field types obtained by substituting the generic arguments for the generic parameters in the structure's declaration. **If there is no spread field specifier:** It is a static error if the number of field specifiers does not match the number of fields in the corresponding structure declaration (a value must be given for every field). It is a static error if a named field specifier occurs before a positional field specifier. It is a static error if a field name occurs more than once, and it is a static error if a field name occurs that is not the name of a field in the corresponding structure declaration. It is a static type error if the type of a positional field subexpression is not a subtype of the declared type of the (positionally) corresponding field in the structure declaration. It is a static type error if the type of a named field subexpression is not a subtype of the declared type of the corresponding (named) field in the structure declaration. **If there is a spread field specifier:** It is a static error if the spread field specifier does not come first in the sequence. It is a static type error if the type of the spread subexpression is not the same type as structure to be created. It is a static error if there are any positional field specifiers. It is a static error if a field name occurs that is not the name of a field in the corresponding structure declaration. It is a static type error if the type of a named field subexpression is not a subtype of the declared type of the corresponding (named) field in the structure declaration. A structure creation expression is evaluated by evaluating the field specifier subexpressions in order from left to right. The result is a structure value whose fields have values based on the corresponding field specifier: if there is a positional or named field specifier for the field, the field value is the value of the subexpression, otherwise there must be a spread expression and the field value is the value of the corresponding field in the (structure) value of the spread subexpression. #### Tuple creation[​](https://docs.midnight.network/compact/lang-ref#tuple-creation "Direct link to Tuple creation") Tuple values are created with expressions of the form `[e, ...]` where `e, ...` is a sequence of zero or more comma-separated argument expressions. A non-empty sequence can have an optional trailing comma. The _length_ of a tuple is the number of subexpressions in the tuple creation expression. | | | | | --- | --- | --- | | _expr_ | → | **\[**  \[_expr_  {**,**  _expr_}\]  \[**,**\]  **\]** | The static type of a tuple creation expression is `[T, ...]` with the number of types matches length of the tuple and each type `T` is the type of the corresponding expression. It is evaluated by evaluating the subexpressions from left to right. Its value is a tuple whose length is the number of subexpressions and whose elements are the subexpression values. #### Parenthesized expressions[​](https://docs.midnight.network/compact/lang-ref#parenthesized-expressions "Direct link to Parenthesized expressions") Compact allows parenthesized expressions of the form `(e)`, where `e` is an expression. They can be used to control the order of evaluation. | | | | | --- | --- | --- | | _expr_ | → | **(**  _expr_  **)** | The type of the parenthesized expression is the type of the subexpression. Its value is the value of the subexpression. #### Sequence expressions[​](https://docs.midnight.network/compact/lang-ref#sequence-expressions "Direct link to Sequence expressions") Expressions can be sequenced for their side effects. An expression of the form `(e0, e1, e2, ...)` or `e0, e1, e2, ...` where `e0, e1, e2, ...` is a sequence of two or more comma-separated expressions is a sequence expression. The latter form where parentheses can be omitted is only allowed in some context which can be viewed in [the formal grammar of Compact](https://docs.midnight.network/compact/compact-grammar) . | | | | | --- | --- | --- | | _expr_ | → | **(**  _expr_  {**,**  _expr_}  **,**  _expr_  **)** | | | \| | _expr_  {**,**  _expr_}  **,**  _expr_ | The static type of a sequence expression is the static type of the last subexpression. It is evaluated by evaluating the subexpressions from left to right. Its value is the value of the last subexpression. #### Ledger expressions[​](https://docs.midnight.network/compact/lang-ref#ledger-expressions "Direct link to Ledger expressions") A Compact program interacts with its public state by invoking operations upon the ledger or ledger state types. There are two different forms of ledger calls. **Kernel operations** are operations that do not depend on specific ledger state. They can be invoked by expressions of the form `k.op(e, ...)`, where `k` is the name of a ledger field declared to have the special ADT type `Kernel`, `op` is the name of a builtin kernel operation and `e, ...` is a comma separated sequence of zero or more argument expressions. The `CompactStandardLibrary` predefines the ledger field name `kernel` to have ledger type `Kernel`, so for example, the built-in `self` operation can be called from a circuit as follows: import CompactStandardLibrary;circuit f(): ContractAddress { return kernel.self();} **Ledger ADT operations** are operations on the program's public ledger state. They are invoked by expressions of the form `member.op(e, ...)....`, where `member` is a ledger field name ([declared via a `ledger` field declaration](https://docs.midnight.network/compact/lang-ref#declaring-and-maintaining-public-state) ) and `.op(e, ...)....` are a sequence of zero or more ledger ADT operation invocations, where each `op` is the name of a ledger ADT operation and each `e, ...` is a sequence of zero or more comma-separated argument expressions. | | | | | --- | --- | --- | | _expr_ | → | **ledger**  _ledger-accessor_ | | | \| | **ledger**  **.**  _id_  {_ledger-accessor_} | | _ledger-accessor_ | → | **.**  _id_  **(**  \[_expr_  {**,**  _expr_}\]  **)** | Note that ledger ADT operations can be chained, because the result of a ledger ADT operation might itself have a ledger state type. Kernel operations cannot be chained, because the kernel is not a ledger state type and is not returned by any operation. The static type of a kernel operation expression is the return type of the corresponding kernel operation according to the ledger data types reference. The static type of a ledger ADT operation expression is the return type of the corresponding ADT operation according to the ledger data types reference. Note that this might be a Compact type or it might be a ledger ADT type. Values of ledger ADT types can have ADT operations invoked (immediately) on them, but any other use would be a static type error. Kernel operations are evaluated by evaluating the argument subexpressions in order from left to right and then invoking the corresponding kernel operation with the argument values. A ledger ADT operation `member` (that is not followed by a ledger accessor) is implicitly an invocation of the `read` operation. It is evaluated as if it were `member.read()`. A ledger ADT operation `member.op(e, ...)` is evaluated by evaluating the argument subexpressions from left to right, and then invoking the operation `op` on the public ledger member `member` with the argument values. A ledger ADT operation `adt.op(e, ...)` where `adt` is itself a ledger ADT operation is evaluated by first evaluating `adt`, then evaluating the argument subexpressions from left to right, and then invoking the operation `op` on the ledger ADT value of `adt` with the argument values. #### Element and member access expressions[​](https://docs.midnight.network/compact/lang-ref#element-and-member-access-expressions "Direct link to Element and member access expressions") Compact has expressions for accessing the elements of tuple values and the members of structure values. An expression of the form `e[n]` where `e` is an expression and `n` is a numeric literal is a tuple element access. An expression of the form `e.id` where `e` is an expression and `id` is the name of a structure member is a structure member access. | | | | | --- | --- | --- | | _expr_ | → | _expr_  **\[**  _nat_  **\]** | | | \| | _expr_  **.**  _id_ | Tuple element accesses are type checked by checking the type of the subexpression. It is a type error if this type is not a tuple type `[T, ...]`. It is a type error if the length of the tuple is less than or equal to the numeric literal in the expression. The type of the expression is the corresponding element type `T` at position `n` in the tuple type. Tuple element accesses are evaluated by evaluating the subexpression. The value of the expression will be the element value at the given zero-based index. The subexpression will have a tuple value and the element access will not be out of bounds, because the expression is well-typed. Member access expressions are type checked by checking the type of the subexpression. It is a type error if this type is not a structure type. It is a type error if the structure type does not contain a member with the same name as the name in the expression. The type of the expression is the type of the corresponding named member of the subexpression's structure type. Member access expressions are evaluated by evaluating the subexpression. The value of the expression will be the member value with the given name. The subexpression will have a structure value and the name will exist, because the expression is well-typed. #### Boolean negation expressions[​](https://docs.midnight.network/compact/lang-ref#boolean-negation-expressions "Direct link to Boolean negation expressions") Compact has unary boolean negation expressions of the form `!e` where `e` is an expression. | | | | | --- | --- | --- | | _expr_ | → | **!**  _expr_ | A boolean negation expression is type checked by checking the type of the subexpression. It is a type error if this type is not `Boolean`. The type of the expression will be `Boolean`. Negation expressions are evaluated by evaluating the subexpression. The value of the expression will be `true` if the value of the subexpression is `false` and vice versa. The subexpression will have a boolean value because the expression is well-typed. #### Binary arithmetic expressions[​](https://docs.midnight.network/compact/lang-ref#binary-arithmetic-expressions "Direct link to Binary arithmetic expressions") Binary arithmetic expressions are of the form `e0 op e1` where `e0` and `e1` are expressions and `op` is one of Compact's binary arithmetic operators. The binary arithmetic operators are **add** (`+`), **subtract** (`-`) and **multiply** (`*`). | | | | | --- | --- | --- | | _expr_ | → | _expr_  **+**  _expr_ | | | \| | _expr_  **\-**  _expr_ | | | \| | _expr_  **\***  _expr_ | Arithmetic expressions require the type of both subexpressions to be numeric types, that is, either a `Field` or a `Uint`. The type of the result will depend on the types of the subexpressions as follows: * If either subexpression has type `Field`, the result will have type `Field` * Otherwise the left subexpression will have type `Uint<0..m>` and the right subexpression will have type `Uint<0..n>` for some bounds `m` and `n`. The type of the result depends on the operation as follows: * For add, the result will have type `Uint<0..m+n>` * For subtract, the result will have type `Uint<0..m>` * For multiply, the result will have type `Uint<0..m*n>` For arithmetic operations with `Uint` result types, it is a static type error if the result's bound would be greater than the maximum unsigned integer. Arithmetic expressions are evaluated by first evaluating the subexpressions in order from left to right. Integer addition, subtraction, or multiplication is then used on the subexpression values. The overflow and underflow behavior differs for `Field` and `Uint` operations: * `Field` arithmetic overflow and underflow wraps around 0; that is, the result of an arithmetic operation whose result is a `Field` is the actual arithmetic value modulo `k`, where `k` is one more than the maximum field value. * `Uint` addition and multiplication cannot overflow: the static type of the result will always be large enough to hold the result value * `Uint` subtraction checks if the value of the right subexpression is greater than the value of the left subexpression. If so, it is a runtime error (the result would be negative). Otherwise the unsigned subtraction is performed. The static typing rules imply that if `Field` arithmetic semantics is desired, then at least one of the operands must have static type `Field`. #### Type cast expressions[​](https://docs.midnight.network/compact/lang-ref#type-cast-expressions "Direct link to Type cast expressions") Type cast expressions in Compact are of the form `e as T` where `e` is an expression, `as` is a reserved words, and `T` is a Compact type. TypeScript-style casts of the form `e` are not supported in Compact. | | | | | --- | --- | --- | | _expr_ | → | _expr_  **as**  _type_ | Type cast expressions are type checked by checking the type of the subexpression. If the cast from the subexpression's type to the type `T` named in the type cast is allowed, then the static type of the expression will be `T`. Otherwise, it is a static type error. Upcasts, i.e., casts from a type to a supertype, are allowed but never required and never result in a static or run-time error. The table below describes the allowed type casts. Casting between types not shown in the table is not allowed. The entries in the table can be one of: * **static:** the type cast only changes the static type and does not have any effect at runtime * **conversion:** the type cast always succeeds but has the runtime effect of converting between different source and target representations, which normally has a low cost * **checked:** the type cast is checked at runtime and can fail * **no:** the type cast is not allowed * a number: see the corresponding note below the table | | | TO | | | | | --- | --- | --- | --- | --- | --- | | | | Field | Uint<0..n> | Boolean | Bytes | | --- | --- | --- | --- | --- | --- | | FROM | Field | static | checked | 1 | 2 | | Uint<0..m> | static | 3 | conversion | no | | enum type | conversion | no | no | no | | Boolean | conversion | 4 | no | no | | Bytes | 5 | no | no | 6 | 1. `Field` to `Boolean`: the value `0` is converted to `false` and all other values are converted to `true`. 2. `Field` to `Bytes`: the value of the field is converted into `Bytes` of the given length, with the least-significant byte of the field occurring first in the `Bytes`. The `Bytes` will be padded to the length with trailing zeros. It is a runtime error if the field value does not fit in the length. 3. `Uint<0..m>` to `Uint<0..n>`: if `m` is less than or equal to `n` this is a static cast. Otherwise it is checked and will fail at runtime if the value is greater than `n`. 4. `Boolean` to `Uint<0..n>`: If `n` is not 0 then this is a conversion of `false` to 0 and `true` to 1. Otherwise, it is checked and will fail at runtime if the value is `true` (and convert `false` to 0). 5. `Bytes` to `Field`: the bytes are converted into a field with the least-significant byte of the field occurring first in the `Bytes`. It is a runtime error if the result would exceed the maximum `Field` value. 6. `Bytes` to `Bytes`: the cast is a static cast if `m` equals `n`, and is not allowed otherwise. Allowed type casts are evaluated by first evaluating the subexpression. Then, if the cast is static, the result is the subexpression's value interpreted as the type `T` mentioned in the cast expression. If the cast is a conversion, the JavaScript representation of the subexpression's value is converted into the representation of a value of type `T`. If the cast is checked, the check is performed before conversion and the cast fails (at runtime) if the check fails. The exceptions noted in the table are evaluated as described above after evaluating the subexpression. #### Relational comparison expressions[​](https://docs.midnight.network/compact/lang-ref#relational-comparison-expressions "Direct link to Relational comparison expressions") Relational comparison expressions are of the form `e0 op e1` where `e0` and `e1` are expressions and `op` is one of Compact's relational operators. The relational operators are **equals** (`==`), **not equals** (`!=`), **less than** (`<`), **greater than** (`>`), **less than or equals** (`<=`), and **greater than or equals** (`>=`). | | | | | --- | --- | --- | | _expr_ | → | _expr_  **\==**  _expr_ | | | \| | _expr_  **!=**  _expr_ | | | \| | _expr_  **<**  _expr_ | | | \| | _expr_  **\>**  _expr_ | | | \| | _expr_  **<=**  _expr_ | | | \| | _expr_  **\>=**  _expr_ | Equals and not equals require the types of the subexpressions to be in the subtype relation. That is, the type of the first subexpression must be a subtype of the type of the second subexpression, or else the type of the second subexpression must be a subtype of the type of the first subexpression. Less than, greater than, less than or equals, and greater than or equals require the type of both subexpressions to be unsigned integer types (note that `Field` cannot be compared with these operators). The type of the result is `Boolean`. Relational comparison expressions are evaluated by evaluating the subexpressions in order from left to right. Then the comparison is performed as described below. **Equals** The comparison that is performed depends on the type of the operands: * **`Boolean`:** if the operands have type `Boolean`, then the values must be the same boolean value. Both operands will have type `Boolean` due to the static typing rules. * **`Uint`:** if the operands have unsigned integer types, then the integer values must be equal. Both operands will have unsigned integer types due to the static typing rules. * **`Field`:** if either operand has type `Field`, then the integer values of the operands must be equal. Both operands will have numeric (`Field` or unsigned integer) types due to the static typing rules. * **`Bytes:`** if the operands have bytes types, then the corresponding bytes at each index must be equal. Both operands will have bytes types and their lengths will be equal due to the static typing rules. * **`Tuple:`** if the operands have tuple types, then the corresponding element values at each index must be equal according to these rules, based on the static element types. Both operands will have tuple types, they will have the the same length, and their element types will be in the subtype relation due to the static typing rules. * **`Opaque:`** if the operands have opaque types, then the runtime values must be equal according to JavaScript's strict equality (`===`) operator. Both operands will have the same opaque type due to the static typing rules. * **structure type:** if the operands have structure types, then the corresponding values of each field must be equal according to these rules, based on the field types. Both operands will have the same structure type due to the static typing rules. * **enum type:** if the operands have enum types, then they must be the same enum value. Both operands will have the same enum type due to the static typing rules. **Not equals** The operands are compared according to the rules for equals above, and then the boolean result is negated. **Less than, greater than, less than or equals, and greater than or equals** The integer values of the operands are compared according to the relational operation. Both operands will have unsigned integer types due to the static typing rules. #### Short-circuit logical expressions[​](https://docs.midnight.network/compact/lang-ref#short-circuit-logical-expressions "Direct link to Short-circuit logical expressions") Compact supports short-circuit logical expressions of the form `e0 op e1` where `e0` and `e1` are expressions and `op` is one of the logical operators **or** (`||`) or **and** (`&&`). | | | | | --- | --- | --- | | _expr_ | → | _expr_  **\|**  _expr_ | | | \| | _expr_  **&&**  _expr_ | Logical expressions require the type of the left subexpression to be `Boolean`. The type of the right subexpression must be a supertype of `Boolean`. The only supertype of `Boolean` is `Boolean` itself. The entire expression will have the same type as the type of the right subexpression. Logical expressions are evaluated by first evaluating the left subexpression. Then, the value of that expression determines the value of the entire expression as follows: * For or, if the value of the left subexpression is `false` then the right subexpression is evaluated and its value is the value of the entire expression. Otherwise, the right subexpression is **not** evaluated and the value of the left subexpression, implicitly cast to the type of the entire expression, is the value of the entire expression. * For and, if the left subexpression is `true` then the right subexpression is evaluated and its value is the value of the entire expression. Otherwise, the right subexpression is **not** evaluated and the value of the left subexpression, implicitly cast to the type of the entire expression, is the value of the entire expression. #### Conditional expressions[​](https://docs.midnight.network/compact/lang-ref#conditional-expressions "Direct link to Conditional expressions") Compact supports conditional expressions of the form `e0 ? e1 : e2` where `e0`, `e1`, and `e2` are expressions. | | | | | --- | --- | --- | | _expr_ | → | _expr_  **?**  _expr_  **:**  _expr_ | Conditional expressions require the type of `e0` to be `Boolean`. The types of `e1` and `e2` must be in the subtype relation. That is, either the type of `e1` is a subtype of the type of `e2` or else the type of `e2` is a subtype of the type of `e1`. The type of the entire expression is the type of `e2` if `e1` is a subtype of `e2` and the type of `e1` if `e2` is a subtype of `e1`. Conditional expressions are evaluated by first evaluating `e0`. Then, the value of that expression determines which of the other subexpressions is evaluated: * if the value of `e0` is `true`, then `e1` is evaluated and its value is the value of the entire expression * if the value of `e0` is `false`, then `e2` is evaluated and its value is the value of the entire expression The evaluation rules ensure that only one of `e1` and `e2` is evaluated. #### Map and fold expressions[​](https://docs.midnight.network/compact/lang-ref#map-and-fold-expressions "Direct link to Map and fold expressions") Compact supports expressions that perform the higher-order operations _map_ and (left) _fold_ over tuples that have a vector type (not arbitrary tuples). Map expressions have the form `map(f, e, e, ...)` where `map` is a keyword, `f` is a circuit or witness taking at least one argument, and the `e`s are expressions. A circuit or witness taking _n_ arguments can be mapped over _n_ argument vectors by providing _n_ vector subexpressions to the `map`. Fold expressions have the form `fold(f, init, e, e, ...)` where `fold` is a keyword, `f` is a circuit or witness, and `init` and the `e`s are expressions. A circuit or witness taking _n_+1 arguments can be folded over an initial value `init` and _n_ vectors by providing _n_ vector subexpressions to the `fold`. | | | | | --- | --- | --- | | _expr_ | → | **map**  **(**  _fun_  **,**  _expr_  {**,**  _expr_}  **)** | | | \| | **fold**  **(**  _fun_  **,**  _expr_  **,**  _expr_  {**,**  _expr_}  **)** | The syntax of the circuit or witness is given by the grammar production for _fun_ in the section **Circuit and witness calls** above. A map expression is type checked by checking the type of the witness or circuit `f` to find its parameter types and its return type `R`. `f` must have at least one parameter. The map expression must have the same number of vector subexpressions as the number of parameters of `f`. Each of the vector subexpressions must have a vector type and all these vector types must have the same length `n`. If the type of the _i_th parameter to `f` is `T`, then the type of the _i_th vector subexpression must be `Vector` where `S` is a subtype of `T`. The type of entire expression is `Vector`. A fold expression is type checked by checking the type of the witness or circuit `f` to find its parameter types and its return type `R`. `f` must have at least two parameters, and the type of the first parameter must be the same type as the return type `R`. The fold expression must have one fewer vector subexpression than the number of parameters of `f`. The subexpression `e` gives the initial value for the fold. It must have a type which is a subtype `R`. Each of the vector subexpressions must have a vector type and all these vector types must have the same length `n`. If the type of the _i_+1th parameter of `f` is `T` then the type of the _i_th vector subexpression must be `Vector` where `S` is a subtype of `T`. The type of the entire expression is `R`. Map expressions are evaluated by evaluating the vector subexpressions from left to right. These values are the input vector values. The witness or circuit `f` is then applied in turn, from index 0 up to index `n`\-1, to arguments taken from the input vector values. The result is a vector of length `n` where each _i_th element is the result of applying `f` to the _i_th element of the corresponding input vector values. Fold expressions are evaluated by evaluating the initial value expression `e` and then evaluating the vector subexpressions from left to right. The values of the vector expressions are the input vector values. The witness or circuit `f` is then applied in turn, from index 0 up to index `n`\-1, to an accumulator value argument and arguments taken from the input vector values. The 0th (initial) accumulator value is the value of the expression `e`, and each subsequent _i_+1th accumulator value is the result of applying `f` to the _i_th accumulator value and to the _i_th element of the corresponding input vector values. The result is the `n`th (final) accumulator value where `n` is the length of the input vectors. #### Ledger assignment expressions[​](https://docs.midnight.network/compact/lang-ref#ledger-assignment-expressions "Direct link to Ledger assignment expressions") Compact has ledger assignment statements. They have the form `lhs op e` where `lhs` is a ledger expression as defined in the section **Ledger expressions** above, `op` is one of the assignment operators `=` (assignment), `+=` (addition assignment), or `-=` (subtraction assignment), and `e` is an expression. | | | | | --- | --- | --- | | _expr_ | → | **ledger**  **.**  _id_  _ledger-accessor_  **\=**  _expr_ | | | → | **ledger**  **.**  _id_  _ledger-accessor_  **+=**  _expr_ | | | → | **ledger**  **.**  _id_  _ledger-accessor_  **\-=**  _expr_ | `lhs = e` is shorthand for `lhs.write(e)`. `lhs += e` is shorthand for `lhs.increment(e)`. `lhs -= e` is shorthand for `lhs.decrement(e)`. Ledger assignment statements are type checked exactly as if they were their longer equivalent invoking a ledger ADT operation. They are evaluated exactly as if their longer equivalent were evaluated as a ledger expression. Declaring witnesses for private state[​](https://docs.midnight.network/compact/lang-ref#declaring-witnesses-for-private-state "Direct link to Declaring witnesses for private state") -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Compact code can call code external to the zero-knowledge circuits to read and update private state via `witness` functions. A `witness` function declaration can appear anywhere a `circuit` definition can appear, including within modules. A witness function does not have a body, and its implementation is instead an input to the contract in the TypeScript target. For instance: witness something(x: Boolean): Field; A `witness` function can be called in the same way as a `circuit`. danger Do not assume in your contract that the code of any `witness` function is the code that you wrote in your own implementation. Any DApp may provide any implementation that it wants for your `witness` functions. Results from them should be treated as untrusted input. Declaring and maintaining public state[​](https://docs.midnight.network/compact/lang-ref#declaring-and-maintaining-public-state "Direct link to Declaring and maintaining public state") ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Compact code can declare public state through `ledger` declarations. A ledger declaration defines one piece of information the contract stores in Midnight's public ledger. Multiple ledger declarations can appear in a program, or none. They can appear anywhere circuit definitions can appear, including within modules. A ledger declaration associates a ledger field name with one of a set of predefined [ledger ADT types](https://docs.midnight.network/compact/lang-ref#ledger-state-types) For instance: ledger val: Field;export ledger cnt: Counter;sealed ledger u8list: List>;export sealed ledger mapping: Map; ### Ledger state types[​](https://docs.midnight.network/compact/lang-ref#ledger-state-types "Direct link to Ledger state types") In a `ledger` declaration, the following types are valid: * `T`, for any Compact type `T` * `Counter` * `Set`, for any Compact type `T` * `Map`, for any Compact types `K` and `T` * `Map`, for any Compact type `K` and ledger state type `V` (see the following section) * `List`, for any Compact type `T` * `MerkleTree`, for a compile time integer `1 < n <= 32`, and any Compact type `T` * `HistoricMerkleTree`, for a compile time integer `1 < n <= 32`, and any Compact type `T` Each ledger type supports a set of operations, which can be invoked with .() A ledger field that is declared with a Compact type `T` implicitly has the type `Cell`. `Cell` has operations such as `read`, `write`, and `reset_to_default`. The `read` and `write` operations for the `Cell` type of any Compact type `T` have syntactic sugar. If `x` is a field in the ledger of any Compact type, then you may write x // expression equivalent to x.read()x = val // statement equivalent to x.write(val) The `read`, `increment`, and `decrement` operations of type `Counter` type also have syntactic sugar. If `c` is a `Counter` field in the ledger, then you may write c // expression equivalent to c.read()c += val // statement equivalent to c.increment(val)c -= val // statement equivalent to c.decrement(val) A comprehensive list of operations can be found in the Compact [ledger data type documentation](https://docs.midnight.network/compact/ledger-adt) . ### Nested state types in the `Map` type[​](https://docs.midnight.network/compact/lang-ref#nested-state-types-in-the-map-type "Direct link to nested-state-types-in-the-map-type") The only ledger state type in which values of other state types may be held is `Map`. The key values in a `Map` must be non-state types (simple Compact types), but the mapped values may be counters, sets, lists, other maps, and so on. Here is a small example: import CompactStandardLibrary;ledger fld: Map>;export circuit initNestedMap(b: Boolean): [] { fld.insert(b, default>);}export circuit initNestedCounter(b: Boolean, n: Field): [] { fld.lookup(b).insert(n, default);}export circuit incrementNestedCounter(b: Boolean, n: Field, k: Uint<16>): [] { fld.lookup(b).lookup(n).increment(k);}export circuit readNestedCounter1(b: Boolean, n: Field): Uint<64> { return fld.lookup(b).lookup(n).read();}export circuit readNestedCounter2(b: Boolean, n: Field): Uint<64> { return fld.lookup(b).lookup(n);} In this example, * `fld` is bound to a `Map` from `Boolean` values to `Map`s from `Field` values to `Counter`s * `initNestedMap` can be used to create the inner `Map` for a particular outer-`Map` key * `initNestedCounter` can be used to create a `Counter` for a given outer-`Map` key and a given inner-`Map` key * `incrementNestedCounter` can be used to increment an existing `Counter` for a given outer-`Map` key and a given inner-`Map` key * either `readNestedCounter1` or `readNestedCounter2` can be used to read the value of an existing `Counter` for a given outer-`Map` key and a given inner-`Map` key. Notes: 1. Nesting is permitted only within `Map` values. That is, nesting is not permitted in `Map` keys or within any ledger state type other than `Map`. 2. Nested values must be initialized before first use. The syntax `default` is used to create default ledger state type values, just as it can be used to create default Compact type values. 3. Ledger state type values are not first-class objects, so when accessing a nested value, the entire indirection chain must be used. For example, the following will result in a compiler error: export circuit incrementNestedCounter(b: Boolean, n: Field, k: Uint<16>): [] { fld.lookup(b); // ERROR: incomplete chain of indirects } 4. When the last lookup is a read of a base type one can omit the explicit `read()` indirect, as illustrated by the definitions of `readNestedCounter1` and `readNestedCounter2` above, which have the same behavior. 5. For convenience, local variables can hold default ledger state type values, so the following definition of `initNestedMap` is equivalent to the one above. export circuit initNestedMap(b: Boolean): [] { const t = default>; fld.insert(b, t); } ### Sealed and unsealed ledger fields[​](https://docs.midnight.network/compact/lang-ref#sealed-and-unsealed-ledger-fields "Direct link to Sealed and unsealed ledger fields") Any ledger field can be optionally marked _sealed_ by prefixing the ledger field declaration with the keyword `sealed`. A sealed field cannot be set except during contract initialization. That is, its value can be modified only by the contract constructor (if any), either directly within the body of the constructor or via helper circuits called by the constructor. The `sealed` keyword must come after the `export` keyword (if present) and before the `ledger` keyword, as in the following example: sealed ledger field1: Uint<32>;export sealed ledger field2: Uint<32>;circuit init(x: Uint<32>): [] { field2 = x;}constructor(x: Uint<16>) { field1 = 2 * x; init(x);} It is a static error if a sealed ledger field can be set by any code that is reachable from an exported circuit. Contract constructor[​](https://docs.midnight.network/compact/lang-ref#contract-constructor "Direct link to Contract constructor") ----------------------------------------------------------------------------------------------------------------------------------- A contract can be initialized via a contract constructor defined at the program's top level. The constructor, if any, is typically used to initialize public state and can also be used to initialize private state through witness calls. A constructor can take zero or more arguments. For example: enum STATE { unset, set }ledger state: STATE;ledger value: Field;constructor(v: Field) { value = v; state = STATE.set;} At most one contract constructor can be defined for a contract, and it must appear only at the program top level, i.e., it cannot be defined in a module. To initialize ledger fields that are visible only within a module, the constructor can call a circuit that is exported from the module. For example: module PublicState { enum STATE { unset, set } ledger state: STATE; ledger value: Field; export circuit init(v: Field): [] { value = v; state = STATE.set; }}import PublicState;constructor(v: Field) { init(v);} ### Runtime representations and type/bounds checks[​](https://docs.midnight.network/compact/lang-ref#runtime-representations-and-typebounds-checks "Direct link to Runtime representations and type/bounds checks") The TypeScript type representing a Compact type is defined in [Representations in TypeScript](https://docs.midnight.network/compact/lang-ref#representations-in-typescript) . Compact represents values exactly as TypeScript represents values, i.e., as ordinary JavaScript values. So a Compact boolean is represented at run time as a JavaScript boolean, a Compact tuple is represented as a JavaScript array, and enum values are represented by numbers. To maintain type safety, Compact verifies at run time that values passed by an outside caller to an exported circuit or returned from an outside witness have the expected types. This is necessary even when the caller or witness is written in properly typed TypeScript because some Compact types have size and range limits that are not expressible via the TypeScript type system: * `Field` values are limited by a maximum field value * `Uint` values are limited by the declared bounds * `Bytes` and tuple values are limited by their lengths * enum values are limited by the maximum index for the enum elements It is also necessary because compile-time type checks are easily defeated in TypeScript and are nonexistent when a caller or witness is coded in JavaScript. Certain values to be stored in public state require size, length, and other properties to be maintained explicitly, because these properties cannot be determined solely from the JavaScript representation of the value. For this purpose, the `@midnight/compact-runtime` package provides explicit runtime types satisfying the `CompactType` interface, where `T` is the corresponding TypeScript type. This representation is _not_ user-facing most of the time, except when replicating the behavior of the operations implemented in `@midnight/compact-runtime`. The following constructors can be used to create a `CompactType` instance for a primitive type: * `Boolean` - `new CompactTypeBoolean()` * `Field` - `new CompactTypeField()` * `Uint<0..n>` - `new CompactTypeUnsignedInteger(n, length)`, where `length` is the number of bytes required to store `n` * `Uint` - as `Uint<0..(2 ** n) - 1>` * `Bytes` - `new CompactTypeBytes(n)` * `Vector` - `new CompactTypeVector(n, rt_T)`, where `rt_T` is the runtime type of `T` * `Opaque<"String">` - `new CompactTypeString()` * `Opaque<"Uint8Array">` - `new CompactTypeUint8Array()`. For user-defined types, structures are not currently easily constructed at runtime and require implementing `CompactType` manually or using compiler internals. Enumerations are exposed through `new CompactTypeEnum(maxValue, length)`, where `maxValue` is the maximum permissible integer assignable, and `length` its representation length in bytes (almost always 1). TypeScript target[​](https://docs.midnight.network/compact/lang-ref#typescript-target "Direct link to TypeScript target") -------------------------------------------------------------------------------------------------------------------------- When compiled, a contract generates several artifacts. Key to these are the exported circuits from the contract's top level. These are divided into two categories: [pure circuits and impure circuits](https://docs.midnight.network/compact/lang-ref#pure-and-impure-circuits) . In the `contract` directory, the semantics of the contract is encoded in TypeScript, in the form of a `index.cjs` JavaScript implementation file and a `index.d.cts` type declaration file. For most uses, it is recommended to rely on the information and interface provided in `index.d.cts`. For each of the impure circuits, a zero-knowledge prover/verifier key pair is also generated, as well as instructions for proof generation. These can be found in the output directory's `keys` and `zkir` subdirectories respectively. ### Structure of the exported TypeScript[​](https://docs.midnight.network/compact/lang-ref#structure-of-the-exported-typescript "Direct link to Structure of the exported TypeScript") The exported TypeScript exposes a number of declarations that can be used to interact with the contract from any TypeScript application. Some of these also require use of the `@midnight/compact-runtime` library, which all contracts depend upon and which implements key built-in behaviors. A contract exports the following in the TypeScript module: * The TypeScript type corresponding to each user-defined type exported from the contract's top level * A `Witnesses` type, which describes the format external witnesses must satisfy to instantiate the contract * A `ImpureCircuits` type, which describes the set of impure circuits exported from the contract's top level * A `PureCircuits` type, which describes the set of pure circuits exported from the contract's top level * A `Circuits` type, which describes the set of all exported circuits * A `Contract = Witnesses>` class, which: * can be constructed by passing in an instance of `W` * exposes members `circuits: Circuits` and `impureCircuits: ImpureCircuits` * provides initial contract states via `initialState(privateState: T): [T, runtime.ContractState]` * A constant `pureCircuits: PureCircuits` object, providing all pure circuits as pure functions * A `Ledger` type, providing views into a current ledger state, by permitting direct calls of all read functions of `ledger` objects, as well of some TypeScript specific ones that cannot be called from Compact, such as iterators * A `ledger(state: runtime.StateValue): Ledger` constructor of the `Ledger` type, giving access to the values of exported ledger fields. The argument `T` for a number of these should be interpreted as the type of the local/private state. For the most part, `circuit` and `witness` functions are translated simply by translating their Compact types into corresponding TypeScript types for parameters and return values. For `PureCircuits`, this is all that happens, for the other `_Circuits` instances, they receive an additional first parameter of type `runtime.CircuitContext`, and their result type `R` is wrapped in `runtime.CircuitResults`. For `Witnesses`, they receive an additional first parameter of type `runtime.WitnessContext`, and their result type `R` is wrapped in `[T, R]`. See the [runtime API docs](https://docs.midnight.network/develop/reference/midnight-api/compact-runtime) for the details of these types. This wrapping makes the entirety of the contract code _functional_, ensuring calls have no hidden side effects. * [Compact Types](https://docs.midnight.network/compact/lang-ref#compact-types) * [Primitive types](https://docs.midnight.network/compact/lang-ref#primitive-types) * [User-defined types](https://docs.midnight.network/compact/lang-ref#user-defined-types) * [Generic parameter references](https://docs.midnight.network/compact/lang-ref#generic-parameter-references) * [Subtyping and least upper bounds](https://docs.midnight.network/compact/lang-ref#subtyping-and-least-upper-bounds) * [Default values](https://docs.midnight.network/compact/lang-ref#default-values) * [Representations in TypeScript](https://docs.midnight.network/compact/lang-ref#representations-in-typescript) * [Include files](https://docs.midnight.network/compact/lang-ref#include-files) * [Modules, exports, and imports](https://docs.midnight.network/compact/lang-ref#modules-exports-and-imports) * [Top-level exports](https://docs.midnight.network/compact/lang-ref#top-level-exports) * [Circuits](https://docs.midnight.network/compact/lang-ref#circuits) * [Pure and impure circuits](https://docs.midnight.network/compact/lang-ref#pure-and-impure-circuits) * [Statements](https://docs.midnight.network/compact/lang-ref#statements) * [Expressions](https://docs.midnight.network/compact/lang-ref#expressions) * [Declaring witnesses for private state](https://docs.midnight.network/compact/lang-ref#declaring-witnesses-for-private-state) * [Declaring and maintaining public state](https://docs.midnight.network/compact/lang-ref#declaring-and-maintaining-public-state) * [Ledger state types](https://docs.midnight.network/compact/lang-ref#ledger-state-types) * [Nested state types in the `Map` type](https://docs.midnight.network/compact/lang-ref#nested-state-types-in-the-map-type) * [Sealed and unsealed ledger fields](https://docs.midnight.network/compact/lang-ref#sealed-and-unsealed-ledger-fields) * [Contract constructor](https://docs.midnight.network/compact/lang-ref#contract-constructor) * [Runtime representations and type/bounds checks](https://docs.midnight.network/compact/lang-ref#runtime-representations-and-typebounds-checks) * [TypeScript target](https://docs.midnight.network/compact/lang-ref#typescript-target) * [Structure of the exported TypeScript](https://docs.midnight.network/compact/lang-ref#structure-of-the-exported-typescript) --- # RawTokenType | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/RawTokenType#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / RawTokenType Type Alias: RawTokenType ======================== type RawTokenType = string; The internal identifier attached to a [TokenType](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/TokenType) , as a hex-encoded string. --- # QualifiedShieldedCoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedShieldedCoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / QualifiedShieldedCoinInfo Type Alias: QualifiedShieldedCoinInfo ===================================== type QualifiedShieldedCoinInfo = { mt_index: bigint; nonce: Nonce; type: RawTokenType; value: bigint;}; Information required to spend an existing coin, alongside authorization of the owner Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedShieldedCoinInfo#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------------------------- ### mt\_index[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedShieldedCoinInfo#mt_index "Direct link to mt_index") mt_index: bigint; The coin's location in the chain's Merkle tree of coin commitments Bounded to be a non-negative 64-bit integer * * * ### nonce[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedShieldedCoinInfo#nonce "Direct link to nonce") nonce: Nonce; The coin's randomness, preventing it from colliding with other coins * * * ### type[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedShieldedCoinInfo#type "Direct link to type") type: RawTokenType; The coin's type, identifying the currency it represents * * * ### value[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedShieldedCoinInfo#value "Direct link to value") value: bigint; The coin's value, in atomic units dependent on the currency Bounded to be a non-negative 64-bit integer * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedShieldedCoinInfo#properties) * [mt\_index](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedShieldedCoinInfo#mt_index) * [nonce](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedShieldedCoinInfo#nonce) * [type](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedShieldedCoinInfo#type) * [value](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedShieldedCoinInfo#value) --- # RunningCost | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/RunningCost#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / RunningCost Type Alias: RunningCost ======================= type RunningCost = { bytesDeleted: bigint; bytesWritten: bigint; computeTime: bigint; readTime: bigint;}; A running tally of synthetic resource costs. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/RunningCost#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------- ### bytesDeleted[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/RunningCost#bytesdeleted "Direct link to bytesDeleted") bytesDeleted: bigint; The number of (modelled) bytes deleted. * * * ### bytesWritten[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/RunningCost#byteswritten "Direct link to bytesWritten") bytesWritten: bigint; The number of (modelled) bytes written. * * * ### computeTime[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/RunningCost#computetime "Direct link to computeTime") computeTime: bigint; The amount of (modelled) time spent in single-threaded compute, measured in picoseconds. * * * ### readTime[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/RunningCost#readtime "Direct link to readTime") readTime: bigint; The amount of (modelled) time spent reading from disk, measured in picoseconds. * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/RunningCost#properties) * [bytesDeleted](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/RunningCost#bytesdeleted) * [bytesWritten](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/RunningCost#byteswritten) * [computeTime](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/RunningCost#computetime) * [readTime](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/RunningCost#readtime) --- # communicationCommitment | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/communicationCommitment#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / communicationCommitment Function: communicationCommitment() =================================== communicationCommitment( input, output, rand): CommunicationCommitment Computes the communication commitment corresponding to an input/output pair and randomness. Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/communicationCommitment#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------------------- • **input**: [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) • **output**: [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) • **rand**: `string` Returns[​](https://docs.midnight.network/api-reference/ledger/functions/communicationCommitment#returns "Direct link to Returns") ---------------------------------------------------------------------------------------------------------------------------------- [`CommunicationCommitment`](https://docs.midnight.network/api-reference/ledger/type-aliases/CommunicationCommitment) * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/communicationCommitment#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/communicationCommitment#returns) --- # bigIntToValue | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/bigIntToValue#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / bigIntToValue Function: bigIntToValue() ========================= `Internal` bigIntToValue(x): Value Internal conversion between bigints and their field-aligned binary representation Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/bigIntToValue#parameters "Direct link to Parameters") --------------------------------------------------------------------------------------------------------------------------------- • **x**: `bigint` Returns[​](https://docs.midnight.network/api-reference/ledger/functions/bigIntToValue#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------ [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/bigIntToValue#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/bigIntToValue#returns) --- # dummyContractAddress | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/dummyContractAddress#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / dummyContractAddress Function: dummyContractAddress() ================================ dummyContractAddress(): string A sample contract address, guaranteed to be the same for a given network ID for use in testing Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/dummyContractAddress#returns "Direct link to Returns") ---------------------------------------------------------------------------------------------------------------------------------------- `string` * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/dummyContractAddress#returns) --- # ContractReferenceLocations | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ContractReferenceLocations#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / ContractReferenceLocations Type Alias: ContractReferenceLocations ====================================== type ContractReferenceLocations = | EmptyPublicLedger | PublicLedgerSegments; A data structure indicating the locations of all contract references in a given ledger state. If it is a [EmptyPublicLedger](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/EmptyPublicLedger) , then no contract references are present in the ledger state. If it is a [PublicLedgerSegments](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/PublicLedgerSegments) , then contract references are present and can be extracted using [contractDependencies](https://docs.midnight.network/api-reference/compact-runtime/functions/contractDependencies) . --- # SigningKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SigningKey#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / SigningKey Type Alias: SigningKey ====================== type SigningKey = string; A hex-encoded signature BIP-340 signing key, with a 3-byte version prefix --- # Signature | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Signature#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / Signature Type Alias: Signature ===================== type Signature = string; A hex-encoded signature BIP-340 signature, with a 3-byte version prefix --- # ShieldedTokenType | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ShieldedTokenType#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / ShieldedTokenType Type Alias: ShieldedTokenType ============================= type ShieldedTokenType = { raw: RawTokenType; tag: "shielded";}; Shielded token type (or color), as a hex-encoded 35-byte string Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ShieldedTokenType#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------------- ### raw[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ShieldedTokenType#raw "Direct link to raw") raw: RawTokenType; * * * ### tag[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ShieldedTokenType#tag "Direct link to tag") tag: "shielded"; * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ShieldedTokenType#properties) * [raw](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ShieldedTokenType#raw) * [tag](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ShieldedTokenType#tag) --- # ShieldedCoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ShieldedCoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / ShieldedCoinInfo Type Alias: ShieldedCoinInfo ============================ type ShieldedCoinInfo = { nonce: Nonce; type: RawTokenType; value: bigint;}; Information required to create a new coin, alongside details about the recipient Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ShieldedCoinInfo#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------------ ### nonce[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ShieldedCoinInfo#nonce "Direct link to nonce") nonce: Nonce; The coin's randomness, preventing it from colliding with other coins * * * ### type[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ShieldedCoinInfo#type "Direct link to type") type: RawTokenType; The coin's type, identifying the currency it represents * * * ### value[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ShieldedCoinInfo#value "Direct link to value") value: bigint; The coin's value, in atomic units dependent on the currency Bounded to be a non-negative 64-bit integer * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ShieldedCoinInfo#properties) * [nonce](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ShieldedCoinInfo#nonce) * [type](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ShieldedCoinInfo#type) * [value](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ShieldedCoinInfo#value) --- # SignatureVerifyingKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SignatureVerifyingKey#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / SignatureVerifyingKey Type Alias: SignatureVerifyingKey ================================= type SignatureVerifyingKey = string; A hex-encoded signature BIP-340 verifying key, with a 3-byte version prefix --- # QualifiedCoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedCoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.9.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / QualifiedCoinInfo Type Alias: QualifiedCoinInfo ============================= type QualifiedCoinInfo = { mt_index: bigint; nonce: Nonce; type: TokenType; value: bigint;}; Information required to spend an existing coin, alongside authorization of the owner Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedCoinInfo#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------------- ### mt\_index[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedCoinInfo#mt_index "Direct link to mt_index") mt_index: bigint; The coin's location in the chain's Merkle tree of coin commitments Bounded to be a non-negative 64-bit integer * * * ### nonce[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedCoinInfo#nonce "Direct link to nonce") nonce: Nonce; The coin's randomness, preventing it from colliding with other coins * * * ### type[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedCoinInfo#type "Direct link to type") type: TokenType; The coin's type, identifying the currency it represents * * * ### value[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedCoinInfo#value "Direct link to value") value: bigint; The coin's value, in atomic units dependent on the currency Bounded to be a non-negative 64-bit integer * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedCoinInfo#properties) * [mt\_index](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedCoinInfo#mt_index) * [nonce](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedCoinInfo#nonce) * [type](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedCoinInfo#type) * [value](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/QualifiedCoinInfo#value) --- # decodeCoinPublicKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/decodeCoinPublicKey#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / decodeCoinPublicKey Function: decodeCoinPublicKey() =============================== decodeCoinPublicKey(pk): CoinPublicKey Decode a [CoinPublicKey](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinPublicKey) from a `Uint8Array` originating from Compact's `CoinPublicKey` type Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/decodeCoinPublicKey#parameters "Direct link to Parameters") --------------------------------------------------------------------------------------------------------------------------------------- • **pk**: `Uint8Array` Returns[​](https://docs.midnight.network/api-reference/ledger/functions/decodeCoinPublicKey#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------------ [`CoinPublicKey`](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinPublicKey) * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/decodeCoinPublicKey#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/decodeCoinPublicKey#returns) --- # decodeContractAddress | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/decodeContractAddress#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / decodeContractAddress Function: decodeContractAddress() ================================= decodeContractAddress(addr): ContractAddress Decode a [ContractAddress](https://docs.midnight.network/api-reference/ledger/type-aliases/ContractAddress) from a `Uint8Array` originating from Compact's `ContractAddress` type Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/decodeContractAddress#parameters "Direct link to Parameters") ----------------------------------------------------------------------------------------------------------------------------------------- • **addr**: `Uint8Array` Returns[​](https://docs.midnight.network/api-reference/ledger/functions/decodeContractAddress#returns "Direct link to Returns") -------------------------------------------------------------------------------------------------------------------------------- [`ContractAddress`](https://docs.midnight.network/api-reference/ledger/type-aliases/ContractAddress) * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/decodeContractAddress#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/decodeContractAddress#returns) --- # decodeTokenType | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/decodeTokenType#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / decodeTokenType Function: decodeTokenType() =========================== decodeTokenType(tt): TokenType Decode a [TokenType](https://docs.midnight.network/api-reference/ledger/type-aliases/TokenType) from a `Uint8Array` originating from Compact's `TokenType` type Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/decodeTokenType#parameters "Direct link to Parameters") ----------------------------------------------------------------------------------------------------------------------------------- • **tt**: `Uint8Array` Returns[​](https://docs.midnight.network/api-reference/ledger/functions/decodeTokenType#returns "Direct link to Returns") -------------------------------------------------------------------------------------------------------------------------- [`TokenType`](https://docs.midnight.network/api-reference/ledger/type-aliases/TokenType) * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/decodeTokenType#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/decodeTokenType#returns) --- # ecMul | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/ecMul#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ecMul Function: ecMul() ================= `Internal` ecMul(a, b): Value Internal implementation of the elliptic curve multiplication primitive Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/ecMul#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------- • **a**: [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) • **b**: [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/ledger/functions/ecMul#returns "Direct link to Returns") ---------------------------------------------------------------------------------------------------------------- [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Throws[​](https://docs.midnight.network/api-reference/ledger/functions/ecMul#throws "Direct link to Throws") ------------------------------------------------------------------------------------------------------------- If a does not encode an elliptic curve point or b does not encode a field element * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/ecMul#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/ecMul#returns) * [Throws](https://docs.midnight.network/api-reference/ledger/functions/ecMul#throws) --- # communicationCommitmentRandomness | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/communicationCommitmentRandomness#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / communicationCommitmentRandomness Function: communicationCommitmentRandomness() ============================================= communicationCommitmentRandomness(): CommunicationCommitmentRand Samples a new [CommunicationCommitmentRand](https://docs.midnight.network/api-reference/ledger/type-aliases/CommunicationCommitmentRand) uniformly Returns[​](https://docs.midnight.network/api-reference/ledger/functions/communicationCommitmentRandomness#returns "Direct link to Returns") -------------------------------------------------------------------------------------------------------------------------------------------- [`CommunicationCommitmentRand`](https://docs.midnight.network/api-reference/ledger/type-aliases/CommunicationCommitmentRand) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/communicationCommitmentRandomness#returns) --- # ecAdd | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/ecAdd#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ecAdd Function: ecAdd() ================= `Internal` ecAdd(a, b): Value Internal implementation of the elliptic curve addition primitive Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/ecAdd#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------- • **a**: [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) • **b**: [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/ledger/functions/ecAdd#returns "Direct link to Returns") ---------------------------------------------------------------------------------------------------------------- [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Throws[​](https://docs.midnight.network/api-reference/ledger/functions/ecAdd#throws "Direct link to Throws") ------------------------------------------------------------------------------------------------------------- If either input does not encode an elliptic curve point * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/ecAdd#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/ecAdd#returns) * [Throws](https://docs.midnight.network/api-reference/ledger/functions/ecAdd#throws) --- # SparseCompactADT | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactADT#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / SparseCompactADT Type Alias: SparseCompactADT ============================ type SparseCompactADT = | SparseCompactCellADT | SparseCompactArrayLikeADT | SparseCompactMapADT; A discriminated union describing the locations of contract references in either a Compact `Cell`, `List`, `Set`, or `Map` ADT. --- # Op | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Op#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / Op Type Alias: Op ================= type Op = | { noop: { n: number; };} | "lt" | "eq" | "type" | "size" | "new" | "and" | "or" | "neg" | "log" | "root" | "pop" | { popeq: { cached: boolean; result: R; };} | { addi: { immediate: number; };} | { subi: { immediate: number; };} | { push: { storage: boolean; value: EncodedStateValue; };} | { branch: { skip: number; };} | { jmp: { skip: number; };} | "add" | "sub" | { concat: { cached: boolean; n: number; };} | "member" | { rem: { cached: boolean; };} | { dup: { n: number; };} | { swap: { n: number; };} | { idx: { cached: boolean; path: Key[]; pushPath: boolean; };} | { ins: { cached: boolean; n: number; };} | "ckpt"; An individual operation in the onchain VM Type Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Op#type-parameters "Direct link to Type Parameters") ------------------------------------------------------------------------------------------------------------------------------------------------- ### R[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Op#r "Direct link to R") `R` `null` or [AlignedValue](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue) , for gathering and verifying mode respectively * [Type Parameters](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Op#type-parameters) * [R](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Op#r) --- # ecMulGenerator | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/ecMulGenerator#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ecMulGenerator Function: ecMulGenerator() ========================== `Internal` ecMulGenerator(val): Value Internal implementation of the elliptic curve generator multiplication primitive Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/ecMulGenerator#parameters "Direct link to Parameters") ---------------------------------------------------------------------------------------------------------------------------------- • **val**: [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/ledger/functions/ecMulGenerator#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------- [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Throws[​](https://docs.midnight.network/api-reference/ledger/functions/ecMulGenerator#throws "Direct link to Throws") ---------------------------------------------------------------------------------------------------------------------- if val does not encode a field element * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/ecMulGenerator#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/ecMulGenerator#returns) * [Throws](https://docs.midnight.network/api-reference/ledger/functions/ecMulGenerator#throws) --- # degradeToTransient | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/degradeToTransient#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / degradeToTransient Function: degradeToTransient() ============================== `Internal` degradeToTransient(persistent): Value Internal implementation of the degrade to transient primitive Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/degradeToTransient#parameters "Direct link to Parameters") -------------------------------------------------------------------------------------------------------------------------------------- • **persistent**: [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/ledger/functions/degradeToTransient#returns "Direct link to Returns") ----------------------------------------------------------------------------------------------------------------------------- [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Throws[​](https://docs.midnight.network/api-reference/ledger/functions/degradeToTransient#throws "Direct link to Throws") -------------------------------------------------------------------------------------------------------------------------- If persistent does not encode a 32-byte bytestring * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/degradeToTransient#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/degradeToTransient#returns) * [Throws](https://docs.midnight.network/api-reference/ledger/functions/degradeToTransient#throws) --- # encodeCoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/encodeCoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / encodeCoinInfo Function: encodeCoinInfo() ========================== encodeCoinInfo(coin): { color: Uint8Array; nonce: Uint8Array; value: bigint;} Encode a [CoinInfo](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo) into a Compact's `CoinInfo` TypeScript representation Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/encodeCoinInfo#parameters "Direct link to Parameters") ---------------------------------------------------------------------------------------------------------------------------------- • **coin**: [`CoinInfo`](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo) Returns[​](https://docs.midnight.network/api-reference/ledger/functions/encodeCoinInfo#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------- { color: Uint8Array; nonce: Uint8Array; value: bigint;} ### color[​](https://docs.midnight.network/api-reference/ledger/functions/encodeCoinInfo#color "Direct link to color") color: Uint8Array; ### nonce[​](https://docs.midnight.network/api-reference/ledger/functions/encodeCoinInfo#nonce "Direct link to nonce") nonce: Uint8Array; ### value[​](https://docs.midnight.network/api-reference/ledger/functions/encodeCoinInfo#value "Direct link to value") value: bigint; * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/encodeCoinInfo#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/encodeCoinInfo#returns) * [color](https://docs.midnight.network/api-reference/ledger/functions/encodeCoinInfo#color) * [nonce](https://docs.midnight.network/api-reference/ledger/functions/encodeCoinInfo#nonce) * [value](https://docs.midnight.network/api-reference/ledger/functions/encodeCoinInfo#value) --- # decodeCoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/decodeCoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / decodeCoinInfo Function: decodeCoinInfo() ========================== decodeCoinInfo(coin): CoinInfo Decode a [CoinInfo](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo) from Compact's `CoinInfo` TypeScript representation Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/decodeCoinInfo#parameters "Direct link to Parameters") ---------------------------------------------------------------------------------------------------------------------------------- • **coin** • **coin.color**: `Uint8Array` • **coin.nonce**: `Uint8Array` • **coin.value**: `bigint` Returns[​](https://docs.midnight.network/api-reference/ledger/functions/decodeCoinInfo#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------- [`CoinInfo`](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo) * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/decodeCoinInfo#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/decodeCoinInfo#returns) --- # createCoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/createCoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / createCoinInfo Function: createCoinInfo() ========================== createCoinInfo(type_, value): CoinInfo Creates a new [CoinInfo](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo) , sampling a uniform nonce Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/createCoinInfo#parameters "Direct link to Parameters") ---------------------------------------------------------------------------------------------------------------------------------- • **type\_**: `string` • **value**: `bigint` Returns[​](https://docs.midnight.network/api-reference/ledger/functions/createCoinInfo#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------- [`CoinInfo`](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo) * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/createCoinInfo#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/createCoinInfo#returns) --- # decodeQualifiedCoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/decodeQualifiedCoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / decodeQualifiedCoinInfo Function: decodeQualifiedCoinInfo() =================================== decodeQualifiedCoinInfo(coin): QualifiedCoinInfo Decode a [QualifiedCoinInfo](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo) from Compact's `QualifiedCoinInfo` TypeScript representation Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/decodeQualifiedCoinInfo#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------------------- • **coin** • **coin.color**: `Uint8Array` • **coin.mt\_index**: `bigint` • **coin.nonce**: `Uint8Array` • **coin.value**: `bigint` Returns[​](https://docs.midnight.network/api-reference/ledger/functions/decodeQualifiedCoinInfo#returns "Direct link to Returns") ---------------------------------------------------------------------------------------------------------------------------------- [`QualifiedCoinInfo`](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo) * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/decodeQualifiedCoinInfo#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/decodeQualifiedCoinInfo#returns) --- # maxField | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/maxField#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / maxField Function: maxField() ==================== maxField(): bigint Returns the maximum representable value in the proof systems scalar field (that is, 1 less than the prime modulus) Returns[​](https://docs.midnight.network/api-reference/ledger/functions/maxField#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------- `bigint` * [Returns](https://docs.midnight.network/api-reference/ledger/functions/maxField#returns) --- # leafHash | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/leafHash#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / leafHash Function: leafHash() ==================== `Internal` leafHash(value): AlignedValue Internal implementation of the Merkle tree leaf hash primitive. Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/leafHash#parameters "Direct link to Parameters") ---------------------------------------------------------------------------------------------------------------------------- • **value**: [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) Returns[​](https://docs.midnight.network/api-reference/ledger/functions/leafHash#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------- [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/leafHash#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/leafHash#returns) --- # checkProofData | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/checkProofData#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / checkProofData Function: checkProofData() ========================== `Internal` checkProofData( zkir, input, output, public_transcript, private_transcript_outputs): void Internal implementation of proof dry runs. Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/checkProofData#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------------------- • **zkir**: `string` • **input**: [`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) • **output**: [`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) • **public\_transcript**: [`Op`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Op) <[`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) \>\[\] • **private\_transcript\_outputs**: [`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) \[\] Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/checkProofData#returns "Direct link to Returns") ---------------------------------------------------------------------------------------------------------------------------------- `void` Throws[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/checkProofData#throws "Direct link to Throws") ------------------------------------------------------------------------------------------------------------------------------- If the proof would not hold * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/checkProofData#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/checkProofData#returns) * [Throws](https://docs.midnight.network/api-reference/onchain-runtime/functions/checkProofData#throws) --- # SystemTransaction | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / SystemTransaction Class: SystemTransaction ======================== A priviledged transaction issued by the system. Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------------- ### new SystemTransaction()[​](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction#new-systemtransaction "Direct link to new SystemTransaction()") private new SystemTransaction(): SystemTransaction #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction#returns "Direct link to Returns") [`SystemTransaction`](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction) Methods[​](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction#deserialize "Direct link to deserialize()") static deserialize(raw, netid): Transaction #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction#returns-3 "Direct link to Returns") [`Transaction`](https://docs.midnight.network/api-reference/zswap/classes/Transaction) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction#constructors) * [new SystemTransaction()](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction#new-systemtransaction) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction#methods) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction#deserialize) --- # TransactionCostModel | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / TransactionCostModel Class: TransactionCostModel =========================== Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------- ### new TransactionCostModel()[​](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#new-transactioncostmodel "Direct link to new TransactionCostModel()") private new TransactionCostModel(): TransactionCostModel #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#returns "Direct link to Returns") [`TransactionCostModel`](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------- ### inputFeeOverhead[​](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#inputfeeoverhead "Direct link to inputFeeOverhead") readonly inputFeeOverhead: bigint; The increase in fees to expect from adding a new input to a transaction * * * ### outputFeeOverhead[​](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#outputfeeoverhead "Direct link to outputFeeOverhead") readonly outputFeeOverhead: bigint; The increase in fees to expect from adding a new output to a transaction Methods[​](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#deserialize "Direct link to deserialize()") static deserialize(raw, netid): TransactionCostModel #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#returns-3 "Direct link to Returns") [`TransactionCostModel`](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel) * * * ### dummyTransactionCostModel()[​](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#dummytransactioncostmodel "Direct link to dummyTransactionCostModel()") static dummyTransactionCostModel(): TransactionCostModel A dummy cost model, for use in testing #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#returns-4 "Direct link to Returns") [`TransactionCostModel`](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#constructors) * [new TransactionCostModel()](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#new-transactioncostmodel) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#properties) * [inputFeeOverhead](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#inputfeeoverhead) * [outputFeeOverhead](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#outputfeeoverhead) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#methods) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#deserialize) * [dummyTransactionCostModel()](https://docs.midnight.network/api-reference/zswap/classes/TransactionCostModel#dummytransactioncostmodel) --- # Transient | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/Transient#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / Transient Class: Transient ================ A shielded "transient"; an output that is immediately spent within the same transaction Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/Transient#constructors "Direct link to Constructors") -------------------------------------------------------------------------------------------------------------------------------- ### new Transient()[​](https://docs.midnight.network/api-reference/zswap/classes/Transient#new-transient "Direct link to new Transient()") private new Transient(): Transient #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Transient#returns "Direct link to Returns") [`Transient`](https://docs.midnight.network/api-reference/zswap/classes/Transient) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/Transient#properties "Direct link to Properties") -------------------------------------------------------------------------------------------------------------------------- ### commitment[​](https://docs.midnight.network/api-reference/zswap/classes/Transient#commitment "Direct link to commitment") readonly commitment: string; The commitment of the transient * * * ### contractAddress[​](https://docs.midnight.network/api-reference/zswap/classes/Transient#contractaddress "Direct link to contractAddress") readonly contractAddress: undefined | string; The contract address creating the transient, if applicable * * * ### nullifier[​](https://docs.midnight.network/api-reference/zswap/classes/Transient#nullifier "Direct link to nullifier") readonly nullifier: string; The nullifier of the transient Methods[​](https://docs.midnight.network/api-reference/zswap/classes/Transient#methods "Direct link to Methods") ----------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/Transient#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/Transient#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Transient#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/Transient#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/Transient#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Transient#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/Transient#deserialize "Direct link to deserialize()") static deserialize(raw, netid): Transient #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/Transient#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Transient#returns-3 "Direct link to Returns") [`Transient`](https://docs.midnight.network/api-reference/zswap/classes/Transient) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/Transient#constructors) * [new Transient()](https://docs.midnight.network/api-reference/zswap/classes/Transient#new-transient) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/Transient#properties) * [commitment](https://docs.midnight.network/api-reference/zswap/classes/Transient#commitment) * [contractAddress](https://docs.midnight.network/api-reference/zswap/classes/Transient#contractaddress) * [nullifier](https://docs.midnight.network/api-reference/zswap/classes/Transient#nullifier) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/Transient#methods) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/Transient#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/Transient#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/Transient#deserialize) --- # UnprovenAuthorizedMint | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / UnprovenAuthorizedMint Class: UnprovenAuthorizedMint ============================= A request to mint a coin, authorized by the mint's recipient, without the proof for the authorization being generated Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#constructors "Direct link to Constructors") --------------------------------------------------------------------------------------------------------------------------------------------- ### new UnprovenAuthorizedMint()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#new-unprovenauthorizedmint "Direct link to new UnprovenAuthorizedMint()") private new UnprovenAuthorizedMint(): UnprovenAuthorizedMint #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#returns "Direct link to Returns") [`UnprovenAuthorizedMint`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------- ### coin[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#coin "Direct link to coin") readonly coin: CoinInfo; The coin to be minted * * * ### recipient[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#recipient "Direct link to recipient") readonly recipient: string; The recipient of this mint Methods[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------------ ### erase\_proof()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#erase_proof "Direct link to erase_proof()") erase_proof(): ProofErasedAuthorizedMint #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#returns-1 "Direct link to Returns") [`ProofErasedAuthorizedMint`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedAuthorizedMint) * * * ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#returns-2 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#returns-3 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#deserialize "Direct link to deserialize()") static deserialize(raw, netid): UnprovenAuthorizedMint #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#returns-4 "Direct link to Returns") [`UnprovenAuthorizedMint`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#constructors) * [new UnprovenAuthorizedMint()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#new-unprovenauthorizedmint) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#properties) * [coin](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#coin) * [recipient](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#recipient) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#methods) * [erase\_proof()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#erase_proof) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint#deserialize) --- # EncodedStateValue | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/EncodedStateValue#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / EncodedStateValue Type Alias: EncodedStateValue ============================= type EncodedStateValue = | { tag: "null";} | { content: AlignedValue; tag: "cell";} | { content: Map; tag: "map";} | { content: EncodedStateValue[]; tag: "array";} | { content: [number, Map]; tag: "boundedMerkleTree";}; An alternative encoding of [StateValue](https://docs.midnight.network/api-reference/compact-runtime/classes/StateValue) for use in [Op](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Op) for technical reasons --- # SparseCompactArrayLikeADT | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactArrayLikeADT#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / SparseCompactArrayLikeADT Type Alias: SparseCompactArrayLikeADT ===================================== type SparseCompactArrayLikeADT = | SparseCompactSetADT | SparseCompactListADT; A data structure indicating the locations of all contract references in a Compact `Set` or `List` ADT. --- # encodeCoinPublicKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/encodeCoinPublicKey#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / encodeCoinPublicKey Function: encodeCoinPublicKey() =============================== encodeCoinPublicKey(pk): Uint8Array Encode a [CoinPublicKey](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinPublicKey) into a `Uint8Array` for use in Compact's `CoinPublicKey` type Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/encodeCoinPublicKey#parameters "Direct link to Parameters") --------------------------------------------------------------------------------------------------------------------------------------- • **pk**: `string` Returns[​](https://docs.midnight.network/api-reference/ledger/functions/encodeCoinPublicKey#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------------ `Uint8Array` * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/encodeCoinPublicKey#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/encodeCoinPublicKey#returns) --- # encodeTokenType | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/encodeTokenType#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / encodeTokenType Function: encodeTokenType() =========================== encodeTokenType(tt): Uint8Array Encode a [TokenType](https://docs.midnight.network/api-reference/ledger/type-aliases/TokenType) into a `Uint8Array` for use in Compact's `TokenType` type Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/encodeTokenType#parameters "Direct link to Parameters") ----------------------------------------------------------------------------------------------------------------------------------- • **tt**: `string` Returns[​](https://docs.midnight.network/api-reference/ledger/functions/encodeTokenType#returns "Direct link to Returns") -------------------------------------------------------------------------------------------------------------------------- `Uint8Array` * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/encodeTokenType#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/encodeTokenType#returns) --- # degradeToTransient | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/degradeToTransient#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / degradeToTransient Function: degradeToTransient() ============================== `Internal` degradeToTransient(persistent): Value Internal implementation of the degrade to transient primitive Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/degradeToTransient#parameters "Direct link to Parameters") ----------------------------------------------------------------------------------------------------------------------------------------------- • **persistent**: [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/degradeToTransient#returns "Direct link to Returns") -------------------------------------------------------------------------------------------------------------------------------------- [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Throws[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/degradeToTransient#throws "Direct link to Throws") ----------------------------------------------------------------------------------------------------------------------------------- If persistent does not encode a 32-byte bytestring * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/degradeToTransient#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/degradeToTransient#returns) * [Throws](https://docs.midnight.network/api-reference/onchain-runtime/functions/degradeToTransient#throws) --- # decodeTokenType | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeTokenType#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / decodeTokenType Function: decodeTokenType() =========================== decodeTokenType(tt): TokenType Decode a [TokenType](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/TokenType) from a `Uint8Array` originating from Compact's `TokenType` type Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeTokenType#parameters "Direct link to Parameters") -------------------------------------------------------------------------------------------------------------------------------------------- • **tt**: `Uint8Array` Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeTokenType#returns "Direct link to Returns") ----------------------------------------------------------------------------------------------------------------------------------- [`TokenType`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/TokenType) * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeTokenType#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeTokenType#returns) --- # decodeContractAddress | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeContractAddress#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / decodeContractAddress Function: decodeContractAddress() ================================= decodeContractAddress(addr): ContractAddress Decode a [ContractAddress](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/ContractAddress) from a `Uint8Array` originating from Compact's `ContractAddress` type Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeContractAddress#parameters "Direct link to Parameters") -------------------------------------------------------------------------------------------------------------------------------------------------- • **addr**: `Uint8Array` Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeContractAddress#returns "Direct link to Returns") ----------------------------------------------------------------------------------------------------------------------------------------- [`ContractAddress`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/ContractAddress) * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeContractAddress#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeContractAddress#returns) --- # decodeQualifiedCoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeQualifiedCoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / decodeQualifiedCoinInfo Function: decodeQualifiedCoinInfo() =================================== decodeQualifiedCoinInfo(coin): QualifiedCoinInfo Decode a [QualifiedCoinInfo](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/QualifiedCoinInfo) from Compact's `QualifiedCoinInfo` TypeScript representation Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeQualifiedCoinInfo#parameters "Direct link to Parameters") ---------------------------------------------------------------------------------------------------------------------------------------------------- • **coin** • **coin.color**: `Uint8Array` • **coin.mt\_index**: `bigint` • **coin.nonce**: `Uint8Array` • **coin.value**: `bigint` Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeQualifiedCoinInfo#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------------------------- [`QualifiedCoinInfo`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/QualifiedCoinInfo) * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeQualifiedCoinInfo#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeQualifiedCoinInfo#returns) --- # decodeCoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeCoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / decodeCoinInfo Function: decodeCoinInfo() ========================== decodeCoinInfo(coin): CoinInfo Decode a [CoinInfo](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/CoinInfo) from Compact's `CoinInfo` TypeScript representation Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeCoinInfo#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------------------- • **coin** • **coin.color**: `Uint8Array` • **coin.nonce**: `Uint8Array` • **coin.value**: `bigint` Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeCoinInfo#returns "Direct link to Returns") ---------------------------------------------------------------------------------------------------------------------------------- [`CoinInfo`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/CoinInfo) * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeCoinInfo#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeCoinInfo#returns) --- # decodeCoinPublicKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeCoinPublicKey#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / decodeCoinPublicKey Function: decodeCoinPublicKey() =============================== decodeCoinPublicKey(pk): CoinPublicKey Decode a [CoinPublicKey](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/CoinPublicKey) from a `Uint8Array` originating from Compact's `CoinPublicKey` type Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeCoinPublicKey#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------------------------ • **pk**: `Uint8Array` Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeCoinPublicKey#returns "Direct link to Returns") --------------------------------------------------------------------------------------------------------------------------------------- [`CoinPublicKey`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/CoinPublicKey) * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeCoinPublicKey#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/decodeCoinPublicKey#returns) --- # bigIntToValue | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/bigIntToValue#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / bigIntToValue Function: bigIntToValue() ========================= `Internal` bigIntToValue(x): Value Internal conversion between bigints and their field-aligned binary representation Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/bigIntToValue#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------------------ • **x**: `bigint` Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/bigIntToValue#returns "Direct link to Returns") --------------------------------------------------------------------------------------------------------------------------------- [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/bigIntToValue#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/bigIntToValue#returns) --- # SparseCompactCellADT | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactCellADT#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / SparseCompactCellADT Type Alias: SparseCompactCellADT ================================ type SparseCompactCellADT = { tag: "cell"; valueType: SparseCompactValue;}; A data structure indicating the locations of all contract references in a Compact `Cell` ADT. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactCellADT#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------------------------- ### tag[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactCellADT#tag "Direct link to tag") tag: "cell"; * * * ### valueType[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactCellADT#valuetype "Direct link to valueType") valueType: SparseCompactValue; A data structure indicating the locations of all contract references in the Compact value contained in the outer `Cell` ADT. * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactCellADT#properties) * [tag](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactCellADT#tag) * [valueType](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactCellADT#valuetype) --- # SparseCompactListADT | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactListADT#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / SparseCompactListADT Type Alias: SparseCompactListADT ================================ type SparseCompactListADT = { tag: "list"; valueType: SparseCompactValue;}; A data structure indicating the locations of all contract references in a Compact `List` ADT. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactListADT#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------------------------- ### tag[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactListADT#tag "Direct link to tag") tag: "list"; * * * ### valueType[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactListADT#valuetype "Direct link to valueType") valueType: SparseCompactValue; A data structure indicating the locations of all contract references in a Compact value in the outer `List` ADT. * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactListADT#properties) * [tag](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactListADT#tag) * [valueType](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactListADT#valuetype) --- # SparseCompactSetADT | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactSetADT#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / SparseCompactSetADT Type Alias: SparseCompactSetADT =============================== type SparseCompactSetADT = { tag: "set"; valueType: SparseCompactValue;}; A data structure indicating the locations of all contract references in a Compact `Set` ADT. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactSetADT#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------------------- ### tag[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactSetADT#tag "Direct link to tag") tag: "set"; * * * ### valueType[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactSetADT#valuetype "Direct link to valueType") valueType: SparseCompactValue; A data structure indicating the locations of all contract references in a Compact value in the outer `Set` ADT. * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactSetADT#properties) * [tag](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactSetADT#tag) * [valueType](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactSetADT#valuetype) --- # SparseCompactContractAddress | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactContractAddress#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / SparseCompactContractAddress Type Alias: SparseCompactContractAddress ======================================== type SparseCompactContractAddress = { tag: "contractAddress";}; A data structure indicating that the current CompactValue being explored is a contract reference. When this type is recognized, the current CompactValue should be a [ContractAddress](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/ContractAddress) , and the address is added to the dependency set. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactContractAddress#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------------------------ ### tag[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactContractAddress#tag "Direct link to tag") tag: "contractAddress"; * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactContractAddress#properties) * [tag](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactContractAddress#tag) --- # maxAlignedSize | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/maxAlignedSize#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / maxAlignedSize Function: maxAlignedSize() ========================== `Internal` maxAlignedSize(alignment): bigint Internal implementation of the max aligned size primitive. Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/maxAlignedSize#parameters "Direct link to Parameters") ---------------------------------------------------------------------------------------------------------------------------------- • **alignment**: [`Alignment`](https://docs.midnight.network/api-reference/ledger/type-aliases/Alignment) Returns[​](https://docs.midnight.network/api-reference/ledger/functions/maxAlignedSize#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------- `bigint` * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/maxAlignedSize#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/maxAlignedSize#returns) --- # encodeQualifiedCoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/encodeQualifiedCoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / encodeQualifiedCoinInfo Function: encodeQualifiedCoinInfo() =================================== encodeQualifiedCoinInfo(coin): { color: Uint8Array; mt_index: bigint; nonce: Uint8Array; value: bigint;} Encode a [QualifiedCoinInfo](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo) into a Compact's `QualifiedCoinInfo` TypeScript representation Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/encodeQualifiedCoinInfo#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------------------- • **coin**: [`QualifiedCoinInfo`](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo) Returns[​](https://docs.midnight.network/api-reference/ledger/functions/encodeQualifiedCoinInfo#returns "Direct link to Returns") ---------------------------------------------------------------------------------------------------------------------------------- { color: Uint8Array; mt_index: bigint; nonce: Uint8Array; value: bigint;} ### color[​](https://docs.midnight.network/api-reference/ledger/functions/encodeQualifiedCoinInfo#color "Direct link to color") color: Uint8Array; ### mt\_index[​](https://docs.midnight.network/api-reference/ledger/functions/encodeQualifiedCoinInfo#mt_index "Direct link to mt_index") mt_index: bigint; ### nonce[​](https://docs.midnight.network/api-reference/ledger/functions/encodeQualifiedCoinInfo#nonce "Direct link to nonce") nonce: Uint8Array; ### value[​](https://docs.midnight.network/api-reference/ledger/functions/encodeQualifiedCoinInfo#value "Direct link to value") value: bigint; * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/encodeQualifiedCoinInfo#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/encodeQualifiedCoinInfo#returns) * [color](https://docs.midnight.network/api-reference/ledger/functions/encodeQualifiedCoinInfo#color) * [mt\_index](https://docs.midnight.network/api-reference/ledger/functions/encodeQualifiedCoinInfo#mt_index) * [nonce](https://docs.midnight.network/api-reference/ledger/functions/encodeQualifiedCoinInfo#nonce) * [value](https://docs.midnight.network/api-reference/ledger/functions/encodeQualifiedCoinInfo#value) --- # encodeContractAddress | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/encodeContractAddress#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / encodeContractAddress Function: encodeContractAddress() ================================= encodeContractAddress(addr): Uint8Array Encode a [ContractAddress](https://docs.midnight.network/api-reference/ledger/type-aliases/ContractAddress) into a `Uint8Array` for use in Compact's `ContractAddress` type Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/encodeContractAddress#parameters "Direct link to Parameters") ----------------------------------------------------------------------------------------------------------------------------------------- • **addr**: `string` Returns[​](https://docs.midnight.network/api-reference/ledger/functions/encodeContractAddress#returns "Direct link to Returns") -------------------------------------------------------------------------------------------------------------------------------- `Uint8Array` * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/encodeContractAddress#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/encodeContractAddress#returns) --- # leafHash | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/leafHash#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / leafHash Function: leafHash() ==================== `Internal` leafHash(value): AlignedValue Internal implementation of the Merkle tree leaf hash primitive. Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/leafHash#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------------- • **value**: [`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/leafHash#returns "Direct link to Returns") ---------------------------------------------------------------------------------------------------------------------------- [`AlignedValue`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/AlignedValue) * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/leafHash#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/leafHash#returns) --- # maxField | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/maxField#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / maxField Function: maxField() ==================== maxField(): bigint Returns the maximum representable value in the proof systems scalar field (that is, 1 less than the prime modulus) Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/maxField#returns "Direct link to Returns") ---------------------------------------------------------------------------------------------------------------------------- `bigint` * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/maxField#returns) --- # SparseCompactMapADT | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactMapADT#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / SparseCompactMapADT Type Alias: SparseCompactMapADT =============================== type SparseCompactMapADT = { keyType?: SparseCompactValue; tag: "map"; valueType?: | SparseCompactADT | SparseCompactValue;}; A data structure indicating the locations of all contract references in a Compact `Map` ADT. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactMapADT#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------------------- ### keyType?[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactMapADT#keytype "Direct link to keyType?") optional keyType: SparseCompactValue; A data structure indicating the locations of all contract references in the Compact values that are the keys of the outer `Map` ADT. * * * ### tag[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactMapADT#tag "Direct link to tag") tag: "map"; * * * ### valueType?[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactMapADT#valuetype "Direct link to valueType?") optional valueType: | SparseCompactADT | SparseCompactValue; A data structure indicating the locations of all contract references in the Compact entities that are the values of the outer `Map` ADT. Since the values of a `Map` ADT may be either Compact values or other `Map` ADTs, we take the union of the corresponding data structures. * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactMapADT#properties) * [keyType?](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactMapADT#keytype) * [tag](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactMapADT#tag) * [valueType?](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactMapADT#valuetype) --- # SparseCompactType | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactType#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / SparseCompactType Type Alias: SparseCompactType ============================= type SparseCompactType = | SparseCompactVector | SparseCompactStruct | SparseCompactContractAddress; A data structure indicating the locations of contract references in a Compact struct, vector, or (the terminating case) a contract address. --- # SparseCompactValue | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactValue#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / SparseCompactValue Type Alias: SparseCompactValue ============================== type SparseCompactValue = { descriptor: CompactType; sparseType: SparseCompactType; tag: "compactValue";}; A data structure indicating the locations of all contract references in a Compact value. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactValue#properties "Direct link to Properties") -------------------------------------------------------------------------------------------------------------------------------------------------- ### descriptor[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactValue#descriptor "Direct link to descriptor") descriptor: CompactType; A descriptor that can be used to convert an [AlignedValue](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/AlignedValue) into a TypeScript representation of the same value. This descriptor will only ever decode `struct`s or `Vector`s that contain contract addresses. * * * ### sparseType[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactValue#sparsetype "Direct link to sparseType") sparseType: SparseCompactType; A data structure indicating how to navigate to the contract addresses present in the output of the above `descriptor`. * * * ### tag[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactValue#tag "Direct link to tag") tag: "compactValue"; * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactValue#properties) * [descriptor](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactValue#descriptor) * [sparseType](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactValue#sparsetype) * [tag](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactValue#tag) --- # SparseCompactVector | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactVector#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / SparseCompactVector Type Alias: SparseCompactVector =============================== type SparseCompactVector = { sparseType: SparseCompactType; tag: "vector";}; A data structure indicating the locations of contract references in a Compact vector. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactVector#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------------------- ### sparseType[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactVector#sparsetype "Direct link to sparseType") sparseType: SparseCompactType; A data structure indicating the locations of contract references in the elements of a Compact vector. * * * ### tag[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactVector#tag "Direct link to tag") tag: "vector"; * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactVector#properties) * [sparseType](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactVector#sparsetype) * [tag](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactVector#tag) --- # nativeToken | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/nativeToken#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / nativeToken Function: nativeToken() ======================= nativeToken(): TokenType The base/system token type Returns[​](https://docs.midnight.network/api-reference/ledger/functions/nativeToken#returns "Direct link to Returns") ---------------------------------------------------------------------------------------------------------------------- [`TokenType`](https://docs.midnight.network/api-reference/ledger/type-aliases/TokenType) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/nativeToken#returns) --- # verifySignature | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/verifySignature#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / verifySignature Function: verifySignature() =========================== verifySignature( vk, data, signature): boolean Verifies if a signature is correct Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/verifySignature#parameters "Direct link to Parameters") ----------------------------------------------------------------------------------------------------------------------------------- • **vk**: `string` • **data**: `Uint8Array` • **signature**: `string` Returns[​](https://docs.midnight.network/api-reference/ledger/functions/verifySignature#returns "Direct link to Returns") -------------------------------------------------------------------------------------------------------------------------- `boolean` * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/verifySignature#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/verifySignature#returns) --- # UnprovenInput | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / UnprovenInput Class: UnprovenInput ==================== A [Input](https://docs.midnight.network/api-reference/zswap/classes/Input) , before being proven All "shielded" information in the input can still be extracted at this stage! Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------ ### new UnprovenInput()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#new-unproveninput "Direct link to new UnprovenInput()") private new UnprovenInput(): UnprovenInput #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#returns "Direct link to Returns") [`UnprovenInput`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------ ### contractAddress[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#contractaddress "Direct link to contractAddress") readonly contractAddress: undefined | string; The contract address receiving the input, if the sender is a contract * * * ### nullifier[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#nullifier "Direct link to nullifier") readonly nullifier: string; The nullifier of the input Methods[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#methods "Direct link to Methods") --------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#deserialize "Direct link to deserialize()") static deserialize(raw, netid): UnprovenInput #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#returns-3 "Direct link to Returns") [`UnprovenInput`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput) * * * ### newContractOwned()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#newcontractowned "Direct link to newContractOwned()") static newContractOwned( coin, contract, state): UnprovenInput Creates a new input, spending a specific coin from a smart contract, against a state which contains this coin. Note that inputs created in this way _also_ need to be authorized by the contract #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#parameters-3 "Direct link to Parameters") • **coin**: [`QualifiedCoinInfo`](https://docs.midnight.network/api-reference/zswap/type-aliases/QualifiedCoinInfo) • **contract**: `string` • **state**: [`ZswapChainState`](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#returns-4 "Direct link to Returns") [`UnprovenInput`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#constructors) * [new UnprovenInput()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#new-unproveninput) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#properties) * [contractAddress](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#contractaddress) * [nullifier](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#nullifier) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#methods) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#deserialize) * [newContractOwned()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput#newcontractowned) --- # UnprovenOutput | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / UnprovenOutput Class: UnprovenOutput ===================== An [Output](https://docs.midnight.network/api-reference/zswap/classes/Output) before being proven All "shielded" information in the output can still be extracted at this stage! Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------- ### new UnprovenOutput()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#new-unprovenoutput "Direct link to new UnprovenOutput()") private new UnprovenOutput(): UnprovenOutput #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#returns "Direct link to Returns") [`UnprovenOutput`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------- ### commitment[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#commitment "Direct link to commitment") readonly commitment: string; The commitment of the output * * * ### contractAddress[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#contractaddress "Direct link to contractAddress") readonly contractAddress: undefined | string; The contract address receiving the output, if the recipient is a contract Methods[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#deserialize "Direct link to deserialize()") static deserialize(raw, netid): UnprovenOutput #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#returns-3 "Direct link to Returns") [`UnprovenOutput`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput) * * * ### new()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#new "Direct link to new()") static new( coin, target_cpk, target_epk?): UnprovenOutput Creates a new output, targeted to a user's coin public key. Optionally the output contains a ciphertext encrypted to the user's encryption public key, which may be omitted _only_ if the [CoinInfo](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinInfo) is transferred to the recipient another way #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#parameters-3 "Direct link to Parameters") • **coin**: [`CoinInfo`](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinInfo) • **target\_cpk**: `string` • **target\_epk?**: `string` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#returns-4 "Direct link to Returns") [`UnprovenOutput`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput) * * * ### newContractOwned()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#newcontractowned "Direct link to newContractOwned()") static newContractOwned(coin, contract): UnprovenOutput Creates a new output, targeted to a smart contract A contract must _also_ explicitly receive a coin created in this way for the output to be valid #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#parameters-4 "Direct link to Parameters") • **coin**: [`CoinInfo`](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinInfo) • **contract**: `string` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#returns-5 "Direct link to Returns") [`UnprovenOutput`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#constructors) * [new UnprovenOutput()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#new-unprovenoutput) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#properties) * [commitment](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#commitment) * [contractAddress](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#contractaddress) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#methods) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#deserialize) * [new()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#new) * [newContractOwned()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput#newcontractowned) --- # UnprovenOffer | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / UnprovenOffer Class: UnprovenOffer ==================== A [Offer](https://docs.midnight.network/api-reference/zswap/classes/Offer) , prior to being proven All "shielded" information in the offer can still be extracted at this stage! Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------ ### new UnprovenOffer()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#new-unprovenoffer "Direct link to new UnprovenOffer()") new UnprovenOffer(): UnprovenOffer #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#returns "Direct link to Returns") [`UnprovenOffer`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------ ### deltas[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#deltas "Direct link to deltas") readonly deltas: Map; The value of this offer for each token type; note that this may be negative This is input coin values - output coin values, for value vectors * * * ### inputs[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#inputs "Direct link to inputs") readonly inputs: UnprovenInput[]; The inputs this offer is composed of * * * ### outputs[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#outputs "Direct link to outputs") readonly outputs: UnprovenOutput[]; The outputs this offer is composed of * * * ### transient[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#transient "Direct link to transient") readonly transient: UnprovenTransient[]; The transients this offer is composed of Methods[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#methods "Direct link to Methods") --------------------------------------------------------------------------------------------------------------------- ### merge()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#merge "Direct link to merge()") merge(other): UnprovenOffer Combine this offer with another #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#parameters "Direct link to Parameters") • **other**: [`UnprovenOffer`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#returns-1 "Direct link to Returns") [`UnprovenOffer`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer) * * * ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#parameters-1 "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#returns-2 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#parameters-2 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#returns-3 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#deserialize "Direct link to deserialize()") static deserialize(raw, netid): UnprovenOffer #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#parameters-3 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#returns-4 "Direct link to Returns") [`UnprovenOffer`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer) * * * ### fromInput()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#frominput "Direct link to fromInput()") static fromInput( input, type_, value): UnprovenOffer Creates a singleton offer, from an [UnprovenInput](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput) and its value vector #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#parameters-4 "Direct link to Parameters") • **input**: [`UnprovenInput`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput) • **type\_**: `string` • **value**: `bigint` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#returns-5 "Direct link to Returns") [`UnprovenOffer`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer) * * * ### fromOutput()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#fromoutput "Direct link to fromOutput()") static fromOutput( output, type_, value): UnprovenOffer Creates a singleton offer, from an [UnprovenOutput](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput) and its value vector #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#parameters-5 "Direct link to Parameters") • **output**: [`UnprovenOutput`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput) • **type\_**: `string` • **value**: `bigint` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#returns-6 "Direct link to Returns") [`UnprovenOffer`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer) * * * ### fromTransient()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#fromtransient "Direct link to fromTransient()") static fromTransient(transient): UnprovenOffer Creates a singleton offer, from an [UnprovenTransient](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient) #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#parameters-6 "Direct link to Parameters") • **transient**: [`UnprovenTransient`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#returns-7 "Direct link to Returns") [`UnprovenOffer`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#constructors) * [new UnprovenOffer()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#new-unprovenoffer) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#properties) * [deltas](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#deltas) * [inputs](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#inputs) * [outputs](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#outputs) * [transient](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#transient) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#methods) * [merge()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#merge) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#deserialize) * [fromInput()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#frominput) * [fromOutput()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#fromoutput) * [fromTransient()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer#fromtransient) --- # Transaction | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/Transaction#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / Transaction Class: Transaction ================== A Midnight transaction, consisting a guaranteed and fallible [Offer](https://docs.midnight.network/api-reference/zswap/classes/Offer) , and contract call information hidden from this API. The guaranteed section are run first, and fee payment is taken during this part. If it succeeds, the fallible section is also run, and atomically rolled back if it fails. Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------- ### new Transaction()[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#new-transaction "Direct link to new Transaction()") private new Transaction(): Transaction #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#returns "Direct link to Returns") [`Transaction`](https://docs.midnight.network/api-reference/zswap/classes/Transaction) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------- ### fallibleCoins[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#falliblecoins "Direct link to fallibleCoins") readonly fallibleCoins: undefined | Offer; The fallible Zswap offer * * * ### guaranteedCoins[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#guaranteedcoins "Direct link to guaranteedCoins") readonly guaranteedCoins: undefined | Offer; The guaranteed Zswap offer * * * ### mint[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#mint "Direct link to mint") readonly mint: undefined | AuthorizedMint; The mint this transaction represents, if applicable Methods[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------- ### eraseProofs()[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#eraseproofs "Direct link to eraseProofs()") eraseProofs(): ProofErasedTransaction Erases the proofs contained in this transaction #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#returns-1 "Direct link to Returns") [`ProofErasedTransaction`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction) * * * ### fees()[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#fees "Direct link to fees()") fees(params): bigint The cost of this transaction, in the atomic unit of the base token #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#parameters "Direct link to Parameters") • **params**: [`LedgerParameters`](https://docs.midnight.network/api-reference/zswap/classes/LedgerParameters) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#returns-2 "Direct link to Returns") `bigint` * * * ### identifiers()[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#identifiers "Direct link to identifiers()") identifiers(): string[] Returns the set of identifiers contained within this transaction. Any of these _may_ be used to watch for a specific transaction. #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#returns-3 "Direct link to Returns") `string`\[\] * * * ### imbalances()[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#imbalances "Direct link to imbalances()") imbalances(guaranteed, fees?): Map For given fees, and a given section (guaranteed/fallible), what the surplus or deficit of this transaction in any token type is. #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#parameters-1 "Direct link to Parameters") • **guaranteed**: `boolean` • **fees?**: `bigint` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#returns-4 "Direct link to Returns") `Map`<`string`, `bigint`\> * * * ### merge()[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#merge "Direct link to merge()") merge(other): Transaction Merges this transaction with another #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#parameters-2 "Direct link to Parameters") • **other**: [`Transaction`](https://docs.midnight.network/api-reference/zswap/classes/Transaction) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#returns-5 "Direct link to Returns") [`Transaction`](https://docs.midnight.network/api-reference/zswap/classes/Transaction) #### Throws[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#throws "Direct link to Throws") If both transactions have contract interactions, or they spend the same coins * * * ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#parameters-3 "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#returns-6 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#parameters-4 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#returns-7 "Direct link to Returns") `string` * * * ### transactionHash()[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#transactionhash "Direct link to transactionHash()") transactionHash(): string Returns the hash associated with this transaction. Due to the ability to merge transactions, this should not be used to watch for a specific transaction. #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#returns-8 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#deserialize "Direct link to deserialize()") static deserialize(raw, netid): Transaction #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#parameters-5 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#returns-9 "Direct link to Returns") [`Transaction`](https://docs.midnight.network/api-reference/zswap/classes/Transaction) * * * ### fromUnproven()[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#fromunproven "Direct link to fromUnproven()") static fromUnproven(prove, unproven): Promise Type hint that you should use an external proving function, for instance via the proof server. #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#parameters-6 "Direct link to Parameters") • **prove** • **unproven**: [`UnprovenTransaction`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/Transaction#returns-10 "Direct link to Returns") `Promise`<[`Transaction`](https://docs.midnight.network/api-reference/zswap/classes/Transaction) \> * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/Transaction#constructors) * [new Transaction()](https://docs.midnight.network/api-reference/zswap/classes/Transaction#new-transaction) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/Transaction#properties) * [fallibleCoins](https://docs.midnight.network/api-reference/zswap/classes/Transaction#falliblecoins) * [guaranteedCoins](https://docs.midnight.network/api-reference/zswap/classes/Transaction#guaranteedcoins) * [mint](https://docs.midnight.network/api-reference/zswap/classes/Transaction#mint) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/Transaction#methods) * [eraseProofs()](https://docs.midnight.network/api-reference/zswap/classes/Transaction#eraseproofs) * [fees()](https://docs.midnight.network/api-reference/zswap/classes/Transaction#fees) * [identifiers()](https://docs.midnight.network/api-reference/zswap/classes/Transaction#identifiers) * [imbalances()](https://docs.midnight.network/api-reference/zswap/classes/Transaction#imbalances) * [merge()](https://docs.midnight.network/api-reference/zswap/classes/Transaction#merge) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/Transaction#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/Transaction#tostring) * [transactionHash()](https://docs.midnight.network/api-reference/zswap/classes/Transaction#transactionhash) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/Transaction#deserialize) * [fromUnproven()](https://docs.midnight.network/api-reference/zswap/classes/Transaction#fromunproven) --- # ZswapChainState | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / ZswapChainState Class: ZswapChainState ====================== The on-chain state of Zswap, consisting of a Merkle tree of coin commitments, a set of nullifiers, an index into the Merkle tree, and a set of valid past Merkle tree roots Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#constructors "Direct link to Constructors") -------------------------------------------------------------------------------------------------------------------------------------- ### new ZswapChainState()[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#new-zswapchainstate "Direct link to new ZswapChainState()") new ZswapChainState(): ZswapChainState #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#returns "Direct link to Returns") [`ZswapChainState`](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#properties "Direct link to Properties") -------------------------------------------------------------------------------------------------------------------------------- ### firstFree[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#firstfree "Direct link to firstFree") readonly firstFree: bigint; The first free index in the coin commitment tree Methods[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#methods "Direct link to Methods") ----------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#returns-2 "Direct link to Returns") `string` * * * ### tryApply()[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#tryapply "Direct link to tryApply()") tryApply(offer, whitelist?): [ZswapChainState, Map] Try to apply an [Offer](https://docs.midnight.network/api-reference/zswap/classes/Offer) to the state, returning the updated state and a map on newly inserted coin commitments to their inserted indices. #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#parameters-2 "Direct link to Parameters") • **offer**: [`Offer`](https://docs.midnight.network/api-reference/zswap/classes/Offer) • **whitelist?**: `Set`<`string`\> A set of contract addresses that are of interest. If set, _only_ these addresses are tracked, and all other information is discarded. #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#returns-3 "Direct link to Returns") \[[`ZswapChainState`](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState)\ , `Map`<`string`, `bigint`\>\] * * * ### tryApplyProofErased()[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#tryapplyprooferased "Direct link to tryApplyProofErased()") tryApplyProofErased(offer, whitelist?): [ZswapChainState, Map] [tryApply](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#tryapply) for [ProofErasedOffer](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer) s #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#parameters-3 "Direct link to Parameters") • **offer**: [`ProofErasedOffer`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer) • **whitelist?**: `Set`<`string`\> #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#returns-4 "Direct link to Returns") \[[`ZswapChainState`](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState)\ , `Map`<`string`, `bigint`\>\] * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#deserialize "Direct link to deserialize()") static deserialize(raw, netid): ZswapChainState #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#parameters-4 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#returns-5 "Direct link to Returns") [`ZswapChainState`](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState) * * * ### deserializeFromLedgerState()[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#deserializefromledgerstate "Direct link to deserializeFromLedgerState()") static deserializeFromLedgerState(raw, netid): ZswapChainState Given a whole ledger serialized state, deserialize only the Zswap portion #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#parameters-5 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#returns-6 "Direct link to Returns") [`ZswapChainState`](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#constructors) * [new ZswapChainState()](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#new-zswapchainstate) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#properties) * [firstFree](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#firstfree) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#methods) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#tostring) * [tryApply()](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#tryapply) * [tryApplyProofErased()](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#tryapplyprooferased) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#deserialize) * [deserializeFromLedgerState()](https://docs.midnight.network/api-reference/zswap/classes/ZswapChainState#deserializefromledgerstate) --- # ecMulGenerator | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecMulGenerator#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / ecMulGenerator Function: ecMulGenerator() ========================== `Internal` ecMulGenerator(val): Value Internal implementation of the elliptic curve generator multiplication primitive Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecMulGenerator#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------------------- • **val**: [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecMulGenerator#returns "Direct link to Returns") ---------------------------------------------------------------------------------------------------------------------------------- [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Throws[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecMulGenerator#throws "Direct link to Throws") ------------------------------------------------------------------------------------------------------------------------------- if val does not encode a field element * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecMulGenerator#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecMulGenerator#returns) * [Throws](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecMulGenerator#throws) --- # encodeCoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeCoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / encodeCoinInfo Function: encodeCoinInfo() ========================== encodeCoinInfo(coin): { color: Uint8Array; nonce: Uint8Array; value: bigint;} Encode a [CoinInfo](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/CoinInfo) into a Compact's `CoinInfo` TypeScript representation Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeCoinInfo#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------------------- • **coin**: [`CoinInfo`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/CoinInfo) Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeCoinInfo#returns "Direct link to Returns") ---------------------------------------------------------------------------------------------------------------------------------- { color: Uint8Array; nonce: Uint8Array; value: bigint;} ### color[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeCoinInfo#color "Direct link to color") color: Uint8Array; ### nonce[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeCoinInfo#nonce "Direct link to nonce") nonce: Uint8Array; ### value[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeCoinInfo#value "Direct link to value") value: bigint; * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeCoinInfo#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeCoinInfo#returns) * [color](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeCoinInfo#color) * [nonce](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeCoinInfo#nonce) * [value](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeCoinInfo#value) --- # sampleCoinPublicKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/sampleCoinPublicKey#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / sampleCoinPublicKey Function: sampleCoinPublicKey() =============================== sampleCoinPublicKey(): CoinPublicKey Samples a dummy user coin public key, for use in testing Returns[​](https://docs.midnight.network/api-reference/ledger/functions/sampleCoinPublicKey#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------------ [`CoinPublicKey`](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinPublicKey) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/sampleCoinPublicKey#returns) --- # ecAdd | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecAdd#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / ecAdd Function: ecAdd() ================= `Internal` ecAdd(a, b): Value Internal implementation of the elliptic curve addition primitive Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecAdd#parameters "Direct link to Parameters") ---------------------------------------------------------------------------------------------------------------------------------- • **a**: [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) • **b**: [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecAdd#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------- [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Throws[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecAdd#throws "Direct link to Throws") ---------------------------------------------------------------------------------------------------------------------- If either input does not encode an elliptic curve point * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecAdd#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecAdd#returns) * [Throws](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecAdd#throws) --- # UnshieldedTokenType | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/UnshieldedTokenType#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / UnshieldedTokenType Type Alias: UnshieldedTokenType =============================== type UnshieldedTokenType = { raw: RawTokenType; tag: "unshielded";}; Unshielded token type (or color), as a hex-encoded 35-byte string Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/UnshieldedTokenType#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------------------- ### raw[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/UnshieldedTokenType#raw "Direct link to raw") raw: RawTokenType; * * * ### tag[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/UnshieldedTokenType#tag "Direct link to tag") tag: "unshielded"; * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/UnshieldedTokenType#properties) * [raw](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/UnshieldedTokenType#raw) * [tag](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/UnshieldedTokenType#tag) --- # UserAddress | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/UserAddress#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / UserAddress Type Alias: UserAddress ======================= type UserAddress = string; A user public key address, as a hex-encoded 35-byte string --- # TokenType | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/TokenType#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / TokenType Type Alias: TokenType ===================== type TokenType = | UnshieldedTokenType | ShieldedTokenType | DustTokenType; A token type (or color), as a hex-encoded 35-byte string, shielded, unshielded, or Dust --- # Transcript | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Transcript#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / Transcript Type Alias: Transcript ========================= type Transcript = { effects: Effects; gas: RunningCost; program: Op[];}; A transcript of operations, to be recorded in a transaction Type Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Transcript#type-parameters "Direct link to Type Parameters") --------------------------------------------------------------------------------------------------------------------------------------------------------- ### R[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Transcript#r "Direct link to R") `R` Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Transcript#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------ ### effects[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Transcript#effects "Direct link to effects") effects: Effects; The effects of the transcript, which are checked before execution, and must match those constructed by [program](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Transcript#program) * * * ### gas[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Transcript#gas "Direct link to gas") gas: RunningCost; The execution budget for this transcript, which [program](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Transcript#program) must not exceed * * * ### program[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Transcript#program "Direct link to program") program: Op[]; The sequence of operations that this transcript captured * [Type Parameters](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Transcript#type-parameters) * [R](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Transcript#r) * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Transcript#properties) * [effects](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Transcript#effects) * [gas](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Transcript#gas) * [program](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Transcript#program) --- # SparseCompactStruct | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactStruct#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / SparseCompactStruct Type Alias: SparseCompactStruct =============================== type SparseCompactStruct = { elements: Record; tag: "struct";}; A data structure indicating the locations of contract references in a Compact struct. Properties[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactStruct#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------------------------- ### elements[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactStruct#elements "Direct link to elements") elements: Record; A data structure indicating the locations of contract references in the elements of a Compact struct. The keys of the record correspond to fields of the Compact struct that contain contract references. We use the keys of the record to explore the elements of the corresponding CompactStruct. * * * ### tag[​](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactStruct#tag "Direct link to tag") tag: "struct"; * [Properties](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactStruct#properties) * [elements](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactStruct#elements) * [tag](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/SparseCompactStruct#tag) --- # ContractDeploy | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ContractDeploy Class: ContractDeploy ===================== A contract deployment segment, instructing the creation of a new contract address, if not already present Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy#constructors "Direct link to Constructors") -------------------------------------------------------------------------------------------------------------------------------------- ### new ContractDeploy(initial\_state)[​](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy#new-contractdeployinitial_state "Direct link to new ContractDeploy(initial_state)") new ContractDeploy(initial_state): ContractDeploy Creates a deployment for an arbitrary contract state The deployment and its address are randomised. #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy#parameters "Direct link to Parameters") • **initial\_state**: [`ContractState`](https://docs.midnight.network/api-reference/ledger/classes/ContractState) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy#returns "Direct link to Returns") [`ContractDeploy`](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy#properties "Direct link to Properties") -------------------------------------------------------------------------------------------------------------------------------- ### address[​](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy#address "Direct link to address") readonly address: string; The address this deployment will attempt to create * * * ### initialState[​](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy#initialstate "Direct link to initialState") readonly initialState: ContractState; Methods[​](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy#methods "Direct link to Methods") ----------------------------------------------------------------------------------------------------------------------- ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy#returns-1 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy#constructors) * [new ContractDeploy(initial\_state)](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy#new-contractdeployinitial_state) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy#properties) * [address](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy#address) * [initialState](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy#initialstate) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy#methods) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy#tostring) --- # ContractMaintenanceAuthority | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ContractMaintenanceAuthority Class: ContractMaintenanceAuthority =================================== A committee permitted to make changes to this contract. If a threshold of the public keys in this committee sign off, they can change the rules of this contract, or recompile it for a new version. If the threshold is greater than the number of committee members, it is impossible for them to sign anything. Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------------------------- ### new ContractMaintenanceAuthority(committee, threshold, counter)[​](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#new-contractmaintenanceauthoritycommittee-threshold-counter "Direct link to new ContractMaintenanceAuthority(committee, threshold, counter)") new ContractMaintenanceAuthority( committee, threshold, counter?): ContractMaintenanceAuthority Constructs a new authority from its components #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#parameters "Direct link to Parameters") • **committee**: `string`\[\] • **threshold**: `number` • **counter?**: `bigint` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#returns "Direct link to Returns") [`ContractMaintenanceAuthority`](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------------------- ### committee[​](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#committee "Direct link to committee") readonly committee: string[]; The committee public keys * * * ### counter[​](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#counter "Direct link to counter") readonly counter: bigint; The replay protection counter * * * ### threshold[​](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#threshold "Direct link to threshold") readonly threshold: number; How many keys must sign rule changes Methods[​](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#serialize "Direct link to serialize()") serialize(networkid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#parameters-1 "Direct link to Parameters") • **networkid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#parameters-2 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#deserialize "Direct link to deserialize()") static deserialize(raw, networkid): ContractState #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#parameters-3 "Direct link to Parameters") • **raw**: `Uint8Array` • **networkid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#returns-3 "Direct link to Returns") [`ContractState`](https://docs.midnight.network/api-reference/ledger/classes/ContractState) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#constructors) * [new ContractMaintenanceAuthority(committee, threshold, counter)](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#new-contractmaintenanceauthoritycommittee-threshold-counter) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#properties) * [committee](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#committee) * [counter](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#counter) * [threshold](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#threshold) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#methods) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority#deserialize) --- # hashToCurve | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/hashToCurve#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / hashToCurve Function: hashToCurve() ======================= `Internal` hashToCurve(align, val): Value Internal implementation of the hash to curve primitive Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/hashToCurve#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------- • **align**: [`Alignment`](https://docs.midnight.network/api-reference/ledger/type-aliases/Alignment) • **val**: [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/ledger/functions/hashToCurve#returns "Direct link to Returns") ---------------------------------------------------------------------------------------------------------------------- [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Throws[​](https://docs.midnight.network/api-reference/ledger/functions/hashToCurve#throws "Direct link to Throws") ------------------------------------------------------------------------------------------------------------------- If val does not have alignment align * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/hashToCurve#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/hashToCurve#returns) * [Throws](https://docs.midnight.network/api-reference/ledger/functions/hashToCurve#throws) --- # sampleTokenType | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/sampleTokenType#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / sampleTokenType Function: sampleTokenType() =========================== sampleTokenType(): TokenType Samples a uniform token type, for use in testing Returns[​](https://docs.midnight.network/api-reference/ledger/functions/sampleTokenType#returns "Direct link to Returns") -------------------------------------------------------------------------------------------------------------------------- [`TokenType`](https://docs.midnight.network/api-reference/ledger/type-aliases/TokenType) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/sampleTokenType#returns) --- # signatureVerifyingKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/signatureVerifyingKey#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / signatureVerifyingKey Function: signatureVerifyingKey() ================================= signatureVerifyingKey(sk): SignatureVerifyingKey Returns the verifying key for a given signing key Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/signatureVerifyingKey#parameters "Direct link to Parameters") ----------------------------------------------------------------------------------------------------------------------------------------- • **sk**: `string` Returns[​](https://docs.midnight.network/api-reference/ledger/functions/signatureVerifyingKey#returns "Direct link to Returns") -------------------------------------------------------------------------------------------------------------------------------- [`SignatureVerifyingKey`](https://docs.midnight.network/api-reference/ledger/type-aliases/SignatureVerifyingKey) * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/signatureVerifyingKey#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/signatureVerifyingKey#returns) --- # signData | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/signData#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / signData Function: signData() ==================== signData(key, data): Signature Signs arbitrary data with the given signing key. WARNING: Do not expose access to this function for valuable keys for data that is not strictly controlled! Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/signData#parameters "Direct link to Parameters") ---------------------------------------------------------------------------------------------------------------------------- • **key**: `string` • **data**: `Uint8Array` Returns[​](https://docs.midnight.network/api-reference/ledger/functions/signData#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------- [`Signature`](https://docs.midnight.network/api-reference/ledger/type-aliases/Signature) * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/signData#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/signData#returns) --- # sampleSigningKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/sampleSigningKey#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / sampleSigningKey Function: sampleSigningKey() ============================ sampleSigningKey(): SigningKey Randomly samples a [SigningKey](https://docs.midnight.network/api-reference/ledger/type-aliases/SigningKey) . Returns[​](https://docs.midnight.network/api-reference/ledger/functions/sampleSigningKey#returns "Direct link to Returns") --------------------------------------------------------------------------------------------------------------------------- [`SigningKey`](https://docs.midnight.network/api-reference/ledger/type-aliases/SigningKey) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/sampleSigningKey#returns) --- # sampleContractAddress | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/sampleContractAddress#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / sampleContractAddress Function: sampleContractAddress() ================================= sampleContractAddress(): ContractAddress Samples a uniform contract address, for use in testing Returns[​](https://docs.midnight.network/api-reference/ledger/functions/sampleContractAddress#returns "Direct link to Returns") -------------------------------------------------------------------------------------------------------------------------------- [`ContractAddress`](https://docs.midnight.network/api-reference/ledger/type-aliases/ContractAddress) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/sampleContractAddress#returns) --- # encodeTokenType | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeTokenType#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / encodeTokenType Function: encodeTokenType() =========================== encodeTokenType(tt): Uint8Array Encode a [TokenType](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/TokenType) into a `Uint8Array` for use in Compact's `TokenType` type Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeTokenType#parameters "Direct link to Parameters") -------------------------------------------------------------------------------------------------------------------------------------------- • **tt**: `string` Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeTokenType#returns "Direct link to Returns") ----------------------------------------------------------------------------------------------------------------------------------- `Uint8Array` * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeTokenType#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeTokenType#returns) --- # maxAlignedSize | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/maxAlignedSize#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / maxAlignedSize Function: maxAlignedSize() ========================== `Internal` maxAlignedSize(alignment): bigint Internal implementation of the max aligned size primitive. Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/maxAlignedSize#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------------------- • **alignment**: [`Alignment`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Alignment) Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/maxAlignedSize#returns "Direct link to Returns") ---------------------------------------------------------------------------------------------------------------------------------- `bigint` * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/maxAlignedSize#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/maxAlignedSize#returns) --- # encodeCoinPublicKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeCoinPublicKey#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / encodeCoinPublicKey Function: encodeCoinPublicKey() =============================== encodeCoinPublicKey(pk): Uint8Array Encode a [CoinPublicKey](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/CoinPublicKey) into a `Uint8Array` for use in Compact's `CoinPublicKey` type Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeCoinPublicKey#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------------------------ • **pk**: `string` Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeCoinPublicKey#returns "Direct link to Returns") --------------------------------------------------------------------------------------------------------------------------------------- `Uint8Array` * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeCoinPublicKey#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeCoinPublicKey#returns) --- # Value | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/type-aliases/Value#__docusaurus_skipToContent_fallback) Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / Value Type Alias: Value ================= type Value = Uint8Array[]; An onchain data value, in field-aligned binary format. --- # CostModel | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/CostModel#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / CostModel Class: CostModel ================ A cost model for calculating transaction fees Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/CostModel#constructors "Direct link to Constructors") --------------------------------------------------------------------------------------------------------------------------------- ### new CostModel()[​](https://docs.midnight.network/api-reference/ledger/classes/CostModel#new-costmodel "Direct link to new CostModel()") private new CostModel(): CostModel #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/CostModel#returns "Direct link to Returns") [`CostModel`](https://docs.midnight.network/api-reference/ledger/classes/CostModel) Methods[​](https://docs.midnight.network/api-reference/ledger/classes/CostModel#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------ ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/CostModel#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/CostModel#parameters "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/CostModel#returns-1 "Direct link to Returns") `string` * * * ### dummyCostModel()[​](https://docs.midnight.network/api-reference/ledger/classes/CostModel#dummycostmodel "Direct link to dummyCostModel()") static dummyCostModel(): CostModel A cost model for use in non-critical contexts #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/CostModel#returns-2 "Direct link to Returns") [`CostModel`](https://docs.midnight.network/api-reference/ledger/classes/CostModel) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/CostModel#constructors) * [new CostModel()](https://docs.midnight.network/api-reference/ledger/classes/CostModel#new-costmodel) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/CostModel#methods) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/CostModel#tostring) * [dummyCostModel()](https://docs.midnight.network/api-reference/ledger/classes/CostModel#dummycostmodel) --- # ContractOperationVersion | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersion#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ContractOperationVersion Class: ContractOperationVersion =============================== The version associated with a [ContractOperation](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation) Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersion#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------------ ### new ContractOperationVersion(version)[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersion#new-contractoperationversionversion "Direct link to new ContractOperationVersion(version)") new ContractOperationVersion(version): ContractOperationVersion #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersion#parameters "Direct link to Parameters") • **version**: `"v1"` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersion#returns "Direct link to Returns") [`ContractOperationVersion`](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersion) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersion#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------ ### version[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersion#version "Direct link to version") readonly version: "v1"; Methods[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersion#methods "Direct link to Methods") --------------------------------------------------------------------------------------------------------------------------------- ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersion#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersion#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersion#returns-1 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersion#constructors) * [new ContractOperationVersion(version)](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersion#new-contractoperationversionversion) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersion#properties) * [version](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersion#version) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersion#methods) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersion#tostring) --- # ContractOperationVersionedVerifierKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ContractOperationVersionedVerifierKey Class: ContractOperationVersionedVerifierKey ============================================ A versioned verifier key to be associated with a [ContractOperation](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation) . Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------------------------- ### new ContractOperationVersionedVerifierKey(version, rawVk)[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey#new-contractoperationversionedverifierkeyversion-rawvk "Direct link to new ContractOperationVersionedVerifierKey(version, rawVk)") new ContractOperationVersionedVerifierKey(version, rawVk): ContractOperationVersionedVerifierKey #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey#parameters "Direct link to Parameters") • **version**: `"v1"` • **rawVk**: `Uint8Array` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey#returns "Direct link to Returns") [`ContractOperationVersionedVerifierKey`](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------------------- ### rawVk[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey#rawvk "Direct link to rawVk") readonly rawVk: Uint8Array; * * * ### version[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey#version "Direct link to version") readonly version: "v1"; Methods[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------------------------------- ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey#returns-1 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey#constructors) * [new ContractOperationVersionedVerifierKey(version, rawVk)](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey#new-contractoperationversionedverifierkeyversion-rawvk) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey#properties) * [rawVk](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey#rawvk) * [version](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey#version) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey#methods) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey#tostring) --- # Input | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/Input#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / Input Class: Input ============ A shielded transaction input Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/Input#constructors "Direct link to Constructors") ----------------------------------------------------------------------------------------------------------------------------- ### new Input()[​](https://docs.midnight.network/api-reference/ledger/classes/Input#new-input "Direct link to new Input()") private new Input(): Input #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Input#returns "Direct link to Returns") [`Input`](https://docs.midnight.network/api-reference/ledger/classes/Input) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/Input#properties "Direct link to Properties") ----------------------------------------------------------------------------------------------------------------------- ### contractAddress[​](https://docs.midnight.network/api-reference/ledger/classes/Input#contractaddress "Direct link to contractAddress") readonly contractAddress: undefined | string; The contract address receiving the input, if the sender is a contract * * * ### nullifier[​](https://docs.midnight.network/api-reference/ledger/classes/Input#nullifier "Direct link to nullifier") readonly nullifier: string; The nullifier of the input Methods[​](https://docs.midnight.network/api-reference/ledger/classes/Input#methods "Direct link to Methods") -------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/Input#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Input#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Input#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/Input#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Input#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Input#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/Input#deserialize "Direct link to deserialize()") static deserialize(raw, netid): Input #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Input#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Input#returns-3 "Direct link to Returns") [`Input`](https://docs.midnight.network/api-reference/ledger/classes/Input) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/Input#constructors) * [new Input()](https://docs.midnight.network/api-reference/ledger/classes/Input#new-input) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/Input#properties) * [contractAddress](https://docs.midnight.network/api-reference/ledger/classes/Input#contractaddress) * [nullifier](https://docs.midnight.network/api-reference/ledger/classes/Input#nullifier) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/Input#methods) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/Input#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/Input#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/Input#deserialize) --- # AuthorizedMint | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / AuthorizedMint Class: AuthorizedMint ===================== A request to mint a coin, authorized by the mint's recipient Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#constructors "Direct link to Constructors") -------------------------------------------------------------------------------------------------------------------------------------- ### new AuthorizedMint()[​](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#new-authorizedmint "Direct link to new AuthorizedMint()") private new AuthorizedMint(): AuthorizedMint #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#returns "Direct link to Returns") [`AuthorizedMint`](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#properties "Direct link to Properties") -------------------------------------------------------------------------------------------------------------------------------- ### coin[​](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#coin "Direct link to coin") readonly coin: CoinInfo; The coin to be minted * * * ### recipient[​](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#recipient "Direct link to recipient") readonly recipient: string; The recipient of this mint Methods[​](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#methods "Direct link to Methods") ----------------------------------------------------------------------------------------------------------------------- ### erase\_proof()[​](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#erase_proof "Direct link to erase_proof()") erase_proof(): ProofErasedAuthorizedMint #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#returns-1 "Direct link to Returns") [`ProofErasedAuthorizedMint`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint) * * * ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#returns-2 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#returns-3 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#deserialize "Direct link to deserialize()") static deserialize(raw, netid): AuthorizedMint #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#returns-4 "Direct link to Returns") [`AuthorizedMint`](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#constructors) * [new AuthorizedMint()](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#new-authorizedmint) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#properties) * [coin](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#coin) * [recipient](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#recipient) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#methods) * [erase\_proof()](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#erase_proof) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/AuthorizedMint#deserialize) --- # ContractOperation | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ContractOperation Class: ContractOperation ======================== An individual operation, or entry point of a contract, consisting primarily of a ZK verifier keys, potentially for different versions of the proving system. Only the latest available version is exposed to this API. Note that the serialized form of the key is checked on initialization Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#constructors "Direct link to Constructors") ----------------------------------------------------------------------------------------------------------------------------------------- ### new ContractOperation()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#new-contractoperation "Direct link to new ContractOperation()") new ContractOperation(): ContractOperation #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#returns "Direct link to Returns") [`ContractOperation`](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#properties "Direct link to Properties") ----------------------------------------------------------------------------------------------------------------------------------- ### verifierKey[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#verifierkey "Direct link to verifierKey") verifierKey: Uint8Array; Methods[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#methods "Direct link to Methods") -------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#serialize "Direct link to serialize()") serialize(networkid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#parameters "Direct link to Parameters") • **networkid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#deserialize "Direct link to deserialize()") static deserialize(raw, networkid): ContractOperation #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **networkid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#returns-3 "Direct link to Returns") [`ContractOperation`](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#constructors) * [new ContractOperation()](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#new-contractoperation) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#properties) * [verifierKey](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#verifierkey) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#methods) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation#deserialize) --- # persistentCommit | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/persistentCommit#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / persistentCommit Function: persistentCommit() ============================ `Internal` persistentCommit( align, val, opening): Value Internal implementation of the persistent commitment primitive Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/persistentCommit#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------------ • **align**: [`Alignment`](https://docs.midnight.network/api-reference/ledger/type-aliases/Alignment) • **val**: [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) • **opening**: [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/ledger/functions/persistentCommit#returns "Direct link to Returns") --------------------------------------------------------------------------------------------------------------------------- [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Throws[​](https://docs.midnight.network/api-reference/ledger/functions/persistentCommit#throws "Direct link to Throws") ------------------------------------------------------------------------------------------------------------------------ If val does not have alignment align, opening does not encode a 32-byte bytestring, or any component has a compress alignment * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/persistentCommit#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/persistentCommit#returns) * [Throws](https://docs.midnight.network/api-reference/ledger/functions/persistentCommit#throws) --- # persistentHash | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/persistentHash#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / persistentHash Function: persistentHash() ========================== `Internal` persistentHash(align, val): Value Internal implementation of the persistent hash primitive Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/persistentHash#parameters "Direct link to Parameters") ---------------------------------------------------------------------------------------------------------------------------------- • **align**: [`Alignment`](https://docs.midnight.network/api-reference/ledger/type-aliases/Alignment) • **val**: [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/ledger/functions/persistentHash#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------- [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Throws[​](https://docs.midnight.network/api-reference/ledger/functions/persistentHash#throws "Direct link to Throws") ---------------------------------------------------------------------------------------------------------------------- If val does not have alignment align, or any component has a compress alignment * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/persistentHash#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/persistentHash#returns) * [Throws](https://docs.midnight.network/api-reference/ledger/functions/persistentHash#throws) --- # upgradeFromTransient | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/upgradeFromTransient#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / upgradeFromTransient Function: upgradeFromTransient() ================================ `Internal` upgradeFromTransient(transient): Value Internal implementation of the upgrade from transient primitive Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/upgradeFromTransient#parameters "Direct link to Parameters") ---------------------------------------------------------------------------------------------------------------------------------------- • **transient**: [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/ledger/functions/upgradeFromTransient#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------------- [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Throws[​](https://docs.midnight.network/api-reference/ledger/functions/upgradeFromTransient#throws "Direct link to Throws") ---------------------------------------------------------------------------------------------------------------------------- If transient does not encode a field element * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/upgradeFromTransient#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/upgradeFromTransient#returns) * [Throws](https://docs.midnight.network/api-reference/ledger/functions/upgradeFromTransient#throws) --- # valueToBigInt | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/valueToBigInt#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / valueToBigInt Function: valueToBigInt() ========================= `Internal` valueToBigInt(x): bigint Internal conversion between field-aligned binary values and bigints within the scalar field Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/valueToBigInt#parameters "Direct link to Parameters") --------------------------------------------------------------------------------------------------------------------------------- • **x**: [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/ledger/functions/valueToBigInt#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------ `bigint` Throws[​](https://docs.midnight.network/api-reference/ledger/functions/valueToBigInt#throws "Direct link to Throws") --------------------------------------------------------------------------------------------------------------------- If the value does not encode a field element * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/valueToBigInt#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/valueToBigInt#returns) * [Throws](https://docs.midnight.network/api-reference/ledger/functions/valueToBigInt#throws) --- # encodeContractAddress | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeContractAddress#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / encodeContractAddress Function: encodeContractAddress() ================================= encodeContractAddress(addr): Uint8Array Encode a [ContractAddress](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/ContractAddress) into a `Uint8Array` for use in Compact's `ContractAddress` type Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeContractAddress#parameters "Direct link to Parameters") -------------------------------------------------------------------------------------------------------------------------------------------------- • **addr**: `string` Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeContractAddress#returns "Direct link to Returns") ----------------------------------------------------------------------------------------------------------------------------------------- `Uint8Array` * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeContractAddress#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeContractAddress#returns) --- # ecMul | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecMul#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / ecMul Function: ecMul() ================= `Internal` ecMul(a, b): Value Internal implementation of the elliptic curve multiplication primitive Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecMul#parameters "Direct link to Parameters") ---------------------------------------------------------------------------------------------------------------------------------- • **a**: [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) • **b**: [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecMul#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------- [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Throws[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecMul#throws "Direct link to Throws") ---------------------------------------------------------------------------------------------------------------------- If a does not encode an elliptic curve point or b does not encode a field element * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecMul#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecMul#returns) * [Throws](https://docs.midnight.network/api-reference/onchain-runtime/functions/ecMul#throws) --- # encodeQualifiedCoinInfo | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeQualifiedCoinInfo#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / encodeQualifiedCoinInfo Function: encodeQualifiedCoinInfo() =================================== encodeQualifiedCoinInfo(coin): { color: Uint8Array; mt_index: bigint; nonce: Uint8Array; value: bigint;} Encode a [QualifiedCoinInfo](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/QualifiedCoinInfo) into a Compact's `QualifiedCoinInfo` TypeScript representation Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeQualifiedCoinInfo#parameters "Direct link to Parameters") ---------------------------------------------------------------------------------------------------------------------------------------------------- • **coin**: [`QualifiedCoinInfo`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/QualifiedCoinInfo) Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeQualifiedCoinInfo#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------------------------- { color: Uint8Array; mt_index: bigint; nonce: Uint8Array; value: bigint;} ### color[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeQualifiedCoinInfo#color "Direct link to color") color: Uint8Array; ### mt\_index[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeQualifiedCoinInfo#mt_index "Direct link to mt_index") mt_index: bigint; ### nonce[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeQualifiedCoinInfo#nonce "Direct link to nonce") nonce: Uint8Array; ### value[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeQualifiedCoinInfo#value "Direct link to value") value: bigint; * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeQualifiedCoinInfo#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeQualifiedCoinInfo#returns) * [color](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeQualifiedCoinInfo#color) * [mt\_index](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeQualifiedCoinInfo#mt_index) * [nonce](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeQualifiedCoinInfo#nonce) * [value](https://docs.midnight.network/api-reference/onchain-runtime/functions/encodeQualifiedCoinInfo#value) --- # verifySignature | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/verifySignature#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / verifySignature Function: verifySignature() =========================== verifySignature( vk, data, signature): boolean Verifies if a signature is correct Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/verifySignature#parameters "Direct link to Parameters") -------------------------------------------------------------------------------------------------------------------------------------------- • **vk**: `string` • **data**: `Uint8Array` • **signature**: `string` Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/verifySignature#returns "Direct link to Returns") ----------------------------------------------------------------------------------------------------------------------------------- `boolean` * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/verifySignature#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/verifySignature#returns) --- # LocalState | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/LocalState#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / LocalState Class: LocalState ================= The local state of a user/wallet, consisting of their secret key, and a set of unspent coins. It also keeps track of coins that are in-flight, either expecting to spend or expecting to receive, and a local copy of the global coin commitment Merkle tree to generate proofs against. Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#constructors "Direct link to Constructors") --------------------------------------------------------------------------------------------------------------------------------- ### new LocalState()[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#new-localstate "Direct link to new LocalState()") new LocalState(): LocalState Creates a new state with a randomly sampled secret key #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#returns "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/zswap/classes/LocalState) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------- ### coinPublicKey[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#coinpublickey "Direct link to coinPublicKey") readonly coinPublicKey: string; The coin public key of this wallet * * * ### coins[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#coins "Direct link to coins") readonly coins: Set; The set of _spendable_ coins of this wallet * * * ### encryptionPublicKey[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#encryptionpublickey "Direct link to encryptionPublicKey") readonly encryptionPublicKey: string; The encryption public key of this wallet * * * ### firstFree[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#firstfree "Direct link to firstFree") readonly firstFree: bigint; The first free index in the internal coin commitments Merkle tree. This may be used to identify which merkle tree updates are necessary. * * * ### pendingOutputs[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#pendingoutputs "Direct link to pendingOutputs") readonly pendingOutputs: Map; The outputs that this wallet is expecting to receive in the future * * * ### pendingSpends[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#pendingspends "Direct link to pendingSpends") readonly pendingSpends: Map; The spends that this wallet is expecting to be finalized on-chain in the future Methods[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------ ### apply()[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#apply "Direct link to apply()") apply(offer): LocalState Locally applies an offer to the current state, returning the updated state #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#parameters "Direct link to Parameters") • **offer**: [`Offer`](https://docs.midnight.network/api-reference/zswap/classes/Offer) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#returns-1 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/zswap/classes/LocalState) * * * ### applyCollapsedUpdate()[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#applycollapsedupdate "Direct link to applyCollapsedUpdate()") applyCollapsedUpdate(update): LocalState Applies a collapsed Merkle tree update to the current local state, fast forwarding through the indices included in it, if it is a correct update. The general flow for usage if Alice is in state A, and wants to ask Bob how to reach the new state B, is: * Find where she left off – what's her firstFree? * Find out where she's going – ask for Bob's firstFree. * Find what contents she does care about – ask Bob for the filtered entries she want to include proper in her tree. * In order, of Merkle tree indicies: * Insert (with `apply` offers Alice cares about). * Skip (with this method) sections Alice does not care about, obtaining the collapsed update covering the gap from Bob. Note that `firstFree` is not included in the tree itself, and both ends of updates _are_ included. #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#parameters-1 "Direct link to Parameters") • **update**: [`MerkleTreeCollapsedUpdate`](https://docs.midnight.network/api-reference/zswap/classes/MerkleTreeCollapsedUpdate) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#returns-2 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/zswap/classes/LocalState) * * * ### applyFailed()[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#applyfailed "Direct link to applyFailed()") applyFailed(offer): LocalState Locally marks an offer as failed, allowing inputs used in it to be spendable once more. #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#parameters-2 "Direct link to Parameters") • **offer**: [`Offer`](https://docs.midnight.network/api-reference/zswap/classes/Offer) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#returns-3 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/zswap/classes/LocalState) * * * ### applyFailedProofErased()[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#applyfailedprooferased "Direct link to applyFailedProofErased()") applyFailedProofErased(offer): LocalState Locally marks an proof-erased offer as failed, allowing inputs used in it to be spendable once more. #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#parameters-3 "Direct link to Parameters") • **offer**: [`ProofErasedOffer`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#returns-4 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/zswap/classes/LocalState) * * * ### applyProofErased()[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#applyprooferased "Direct link to applyProofErased()") applyProofErased(offer): LocalState Locally applies a proof-erased offer to the current state, returning the updated state #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#parameters-4 "Direct link to Parameters") • **offer**: [`ProofErasedOffer`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedOffer) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#returns-5 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/zswap/classes/LocalState) * * * ### applyProofErasedTx()[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#applyprooferasedtx "Direct link to applyProofErasedTx()") applyProofErasedTx(tx, res): LocalState Locally applies a proof-erased transaction to the current state, returning the updated state #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#parameters-5 "Direct link to Parameters") • **tx**: [`ProofErasedTransaction`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction) • **res**: `"success"` | `"partialSuccess"` | `"failure"` The result type of applying this transaction against the ledger state #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#returns-6 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/zswap/classes/LocalState) * * * ### applySystemTx()[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#applysystemtx "Direct link to applySystemTx()") applySystemTx(tx): LocalState Locally applies a system transaction to the current state, returning the updated state #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#parameters-6 "Direct link to Parameters") • **tx**: [`SystemTransaction`](https://docs.midnight.network/api-reference/zswap/classes/SystemTransaction) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#returns-7 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/zswap/classes/LocalState) * * * ### applyTx()[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#applytx "Direct link to applyTx()") applyTx(tx, res): LocalState Locally applies a transaction to the current state, returning the updated state #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#parameters-7 "Direct link to Parameters") • **tx**: [`Transaction`](https://docs.midnight.network/api-reference/zswap/classes/Transaction) • **res**: `"success"` | `"partialSuccess"` | `"failure"` The result type of applying this transaction against the ledger state #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#returns-8 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/zswap/classes/LocalState) * * * ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#parameters-8 "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#returns-9 "Direct link to Returns") `Uint8Array` * * * ### spend()[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#spend "Direct link to spend()") spend(coin): [LocalState, UnprovenInput] Initiates a new spend of a specific coin, outputting the corresponding [UnprovenInput](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput) , and the updated state marking this coin as in-flight. #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#parameters-9 "Direct link to Parameters") • **coin**: [`QualifiedCoinInfo`](https://docs.midnight.network/api-reference/zswap/type-aliases/QualifiedCoinInfo) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#returns-10 "Direct link to Returns") \[[`LocalState`](https://docs.midnight.network/api-reference/zswap/classes/LocalState)\ , [`UnprovenInput`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenInput)\ \] * * * ### spendFromOutput()[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#spendfromoutput "Direct link to spendFromOutput()") spendFromOutput(coin, output): [LocalState, UnprovenTransient] Initiates a new spend of a new-yet-received output, outputting the corresponding [UnprovenTransient](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient) , and the updated state marking this coin as in-flight. #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#parameters-10 "Direct link to Parameters") • **coin**: [`QualifiedCoinInfo`](https://docs.midnight.network/api-reference/zswap/type-aliases/QualifiedCoinInfo) • **output**: [`UnprovenOutput`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#returns-11 "Direct link to Returns") \[[`LocalState`](https://docs.midnight.network/api-reference/zswap/classes/LocalState)\ , [`UnprovenTransient`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient)\ \] * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#parameters-11 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#returns-12 "Direct link to Returns") `string` * * * ### watchFor()[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#watchfor "Direct link to watchFor()") watchFor(coin): LocalState Adds a coin to the list of coins that are expected to be received This should be used if an output is creating a coin for this wallet, which does not contain a ciphertext to detect it. In this case, the wallet must know the commitment ahead of time to notice the receipt. #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#parameters-12 "Direct link to Parameters") • **coin**: [`CoinInfo`](https://docs.midnight.network/api-reference/zswap/type-aliases/CoinInfo) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#returns-13 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/zswap/classes/LocalState) * * * ### yesIKnowTheSecurityImplicationsOfThis\_encryptionSecretKey()[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#yesiknowthesecurityimplicationsofthis_encryptionsecretkey "Direct link to yesIKnowTheSecurityImplicationsOfThis_encryptionSecretKey()") yesIKnowTheSecurityImplicationsOfThis_encryptionSecretKey(): EncryptionSecretKey #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#returns-14 "Direct link to Returns") [`EncryptionSecretKey`](https://docs.midnight.network/api-reference/zswap/classes/EncryptionSecretKey) * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#deserialize "Direct link to deserialize()") static deserialize(raw, netid): LocalState #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#parameters-13 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#returns-15 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/zswap/classes/LocalState) * * * ### fromSeed()[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#fromseed "Direct link to fromSeed()") static fromSeed(seed): LocalState Creates a new state from a predefined random seed (which can act as a recovery phrase) #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#parameters-14 "Direct link to Parameters") • **seed**: `Uint8Array` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/LocalState#returns-16 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/zswap/classes/LocalState) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/LocalState#constructors) * [new LocalState()](https://docs.midnight.network/api-reference/zswap/classes/LocalState#new-localstate) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/LocalState#properties) * [coinPublicKey](https://docs.midnight.network/api-reference/zswap/classes/LocalState#coinpublickey) * [coins](https://docs.midnight.network/api-reference/zswap/classes/LocalState#coins) * [encryptionPublicKey](https://docs.midnight.network/api-reference/zswap/classes/LocalState#encryptionpublickey) * [firstFree](https://docs.midnight.network/api-reference/zswap/classes/LocalState#firstfree) * [pendingOutputs](https://docs.midnight.network/api-reference/zswap/classes/LocalState#pendingoutputs) * [pendingSpends](https://docs.midnight.network/api-reference/zswap/classes/LocalState#pendingspends) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/LocalState#methods) * [apply()](https://docs.midnight.network/api-reference/zswap/classes/LocalState#apply) * [applyCollapsedUpdate()](https://docs.midnight.network/api-reference/zswap/classes/LocalState#applycollapsedupdate) * [applyFailed()](https://docs.midnight.network/api-reference/zswap/classes/LocalState#applyfailed) * [applyFailedProofErased()](https://docs.midnight.network/api-reference/zswap/classes/LocalState#applyfailedprooferased) * [applyProofErased()](https://docs.midnight.network/api-reference/zswap/classes/LocalState#applyprooferased) * [applyProofErasedTx()](https://docs.midnight.network/api-reference/zswap/classes/LocalState#applyprooferasedtx) * [applySystemTx()](https://docs.midnight.network/api-reference/zswap/classes/LocalState#applysystemtx) * [applyTx()](https://docs.midnight.network/api-reference/zswap/classes/LocalState#applytx) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/LocalState#serialize) * [spend()](https://docs.midnight.network/api-reference/zswap/classes/LocalState#spend) * [spendFromOutput()](https://docs.midnight.network/api-reference/zswap/classes/LocalState#spendfromoutput) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/LocalState#tostring) * [watchFor()](https://docs.midnight.network/api-reference/zswap/classes/LocalState#watchfor) * [yesIKnowTheSecurityImplicationsOfThis\_encryptionSecretKey()](https://docs.midnight.network/api-reference/zswap/classes/LocalState#yesiknowthesecurityimplicationsofthis_encryptionsecretkey) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/LocalState#deserialize) * [fromSeed()](https://docs.midnight.network/api-reference/zswap/classes/LocalState#fromseed) --- # UnprovenTransient | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / UnprovenTransient Class: UnprovenTransient ======================== A [Transient](https://docs.midnight.network/api-reference/zswap/classes/Transient) , before being proven All "shielded" information in the transient can still be extracted at this stage! Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------------- ### new UnprovenTransient()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#new-unproventransient "Direct link to new UnprovenTransient()") private new UnprovenTransient(): UnprovenTransient #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#returns "Direct link to Returns") [`UnprovenTransient`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------- ### commitment[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#commitment "Direct link to commitment") readonly commitment: string; The commitment of the transient * * * ### contractAddress[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#contractaddress "Direct link to contractAddress") readonly contractAddress: undefined | string; The contract address creating the transient, if applicable * * * ### nullifier[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#nullifier "Direct link to nullifier") readonly nullifier: string; The nullifier of the transient Methods[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#deserialize "Direct link to deserialize()") static deserialize(raw, netid): UnprovenTransient #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#returns-3 "Direct link to Returns") [`UnprovenTransient`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient) * * * ### newFromContractOwnedOutput()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#newfromcontractownedoutput "Direct link to newFromContractOwnedOutput()") static newFromContractOwnedOutput(coin, output): UnprovenTransient Creates a new contract-owned transient, from a given output and its coin. The [QualifiedCoinInfo](https://docs.midnight.network/api-reference/zswap/type-aliases/QualifiedCoinInfo) should have an `mt_index` of `0` #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#parameters-3 "Direct link to Parameters") • **coin**: [`QualifiedCoinInfo`](https://docs.midnight.network/api-reference/zswap/type-aliases/QualifiedCoinInfo) • **output**: [`UnprovenOutput`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOutput) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#returns-4 "Direct link to Returns") [`UnprovenTransient`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#constructors) * [new UnprovenTransient()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#new-unproventransient) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#properties) * [commitment](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#commitment) * [contractAddress](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#contractaddress) * [nullifier](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#nullifier) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#methods) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#deserialize) * [newFromContractOwnedOutput()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransient#newfromcontractownedoutput) --- # UnprovenTransaction | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight/zswap v3.0.2** • [Readme](https://docs.midnight.network/api-reference/zswap) | [API](https://docs.midnight.network/api-reference/zswap/globals) * * * [@midnight/zswap v3.0.2](https://docs.midnight.network/api-reference/zswap) / UnprovenTransaction Class: UnprovenTransaction ========================== [Transaction](https://docs.midnight.network/api-reference/zswap/classes/Transaction) , prior to being proven All "shielded" information in the transaction can still be extracted at this stage! Constructors[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------ ### new UnprovenTransaction(guaranteed, fallible)[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#new-unproventransactionguaranteed-fallible "Direct link to new UnprovenTransaction(guaranteed, fallible)") new UnprovenTransaction(guaranteed, fallible?): UnprovenTransaction Creates the transaction from guaranteed/fallible [UnprovenOffer](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer) s #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#parameters "Direct link to Parameters") • **guaranteed**: [`UnprovenOffer`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer) • **fallible?**: [`UnprovenOffer`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenOffer) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#returns "Direct link to Returns") [`UnprovenTransaction`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction) Properties[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------ ### fallibleCoins[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#falliblecoins "Direct link to fallibleCoins") readonly fallibleCoins: undefined | UnprovenOffer; The fallible Zswap offer * * * ### guaranteedCoins[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#guaranteedcoins "Direct link to guaranteedCoins") readonly guaranteedCoins: undefined | UnprovenOffer; The guaranteed Zswap offer * * * ### mint[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#mint "Direct link to mint") readonly mint: undefined | UnprovenAuthorizedMint; The mint this transaction represents, if applicable Methods[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#methods "Direct link to Methods") --------------------------------------------------------------------------------------------------------------------------- ### eraseProofs()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#eraseproofs "Direct link to eraseProofs()") eraseProofs(): ProofErasedTransaction Erases the proofs contained in this transaction #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#returns-1 "Direct link to Returns") [`ProofErasedTransaction`](https://docs.midnight.network/api-reference/zswap/classes/ProofErasedTransaction) * * * ### identifiers()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#identifiers "Direct link to identifiers()") identifiers(): string[] Returns the set of identifiers contained within this transaction. Any of these _may_ be used to watch for a specific transaction. #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#returns-2 "Direct link to Returns") `string`\[\] * * * ### merge()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#merge "Direct link to merge()") merge(other): UnprovenTransaction Merges this transaction with another #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#parameters-1 "Direct link to Parameters") • **other**: [`UnprovenTransaction`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#returns-3 "Direct link to Returns") [`UnprovenTransaction`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction) #### Throws[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#throws "Direct link to Throws") If both transactions have contract interactions, or they spend the same coins * * * ### serialize()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#parameters-2 "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#returns-4 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#parameters-3 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#returns-5 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#deserialize "Direct link to deserialize()") static deserialize(raw, netid): UnprovenTransaction #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#parameters-4 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/zswap/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#returns-6 "Direct link to Returns") [`UnprovenTransaction`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction) * * * ### fromMint()[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#frommint "Direct link to fromMint()") static fromMint(mint): UnprovenTransaction Creates a minting claim transaction, the funds claimed must have been legitimately minted previously. #### Parameters[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#parameters-5 "Direct link to Parameters") • **mint**: [`UnprovenAuthorizedMint`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenAuthorizedMint) #### Returns[​](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#returns-7 "Direct link to Returns") [`UnprovenTransaction`](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction) * [Constructors](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#constructors) * [new UnprovenTransaction(guaranteed, fallible)](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#new-unproventransactionguaranteed-fallible) * [Properties](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#properties) * [fallibleCoins](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#falliblecoins) * [guaranteedCoins](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#guaranteedcoins) * [mint](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#mint) * [Methods](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#methods) * [eraseProofs()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#eraseproofs) * [identifiers()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#identifiers) * [merge()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#merge) * [serialize()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#serialize) * [toString()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#tostring) * [deserialize()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#deserialize) * [fromMint()](https://docs.midnight.network/api-reference/zswap/classes/UnprovenTransaction#frommint) --- # ContractCallPrototype | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/ContractCallPrototype#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ContractCallPrototype Class: ContractCallPrototype ============================ A [ContractCall](https://docs.midnight.network/api-reference/ledger/classes/ContractCall) still being assembled Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallPrototype#constructors "Direct link to Constructors") --------------------------------------------------------------------------------------------------------------------------------------------- ### new ContractCallPrototype(address, entry\_point, op, guaranteed\_public\_transcript, fallible\_public\_transcript, private\_transcript\_outputs, input, output, communication\_commitment\_rand, key\_location)[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallPrototype#new-contractcallprototypeaddress-entry_point-op-guaranteed_public_transcript-fallible_public_transcript-private_transcript_outputs-input-output-communication_commitment_rand-key_location "Direct link to new ContractCallPrototype(address, entry_point, op, guaranteed_public_transcript, fallible_public_transcript, private_transcript_outputs, input, output, communication_commitment_rand, key_location)") new ContractCallPrototype( address, entry_point, op, guaranteed_public_transcript, fallible_public_transcript, private_transcript_outputs, input, output, communication_commitment_rand, key_location): ContractCallPrototype #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallPrototype#parameters "Direct link to Parameters") • **address**: `string` The address being called • **entry\_point**: `string` | `Uint8Array` The entry point being called • **op**: [`ContractOperation`](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation) The operation expected at this entry point • **guaranteed\_public\_transcript**: `undefined` | [`Transcript`](https://docs.midnight.network/api-reference/ledger/type-aliases/Transcript) <[`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) \> The guaranteed transcript computed for this call • **fallible\_public\_transcript**: `undefined` | [`Transcript`](https://docs.midnight.network/api-reference/ledger/type-aliases/Transcript) <[`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) \> The fallible transcript computed for this call • **private\_transcript\_outputs**: [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) \[\] The private transcript recorded for this call • **input**: [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) The input(s) provided to this call • **output**: [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) The output(s) computed from this call • **communication\_commitment\_rand**: `string` The communication randomness used for this call • **key\_location**: `string` An identifier for how the key for this call may be looked up #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallPrototype#returns "Direct link to Returns") [`ContractCallPrototype`](https://docs.midnight.network/api-reference/ledger/classes/ContractCallPrototype) Methods[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallPrototype#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------------ ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallPrototype#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallPrototype#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallPrototype#returns-1 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/ContractCallPrototype#constructors) * [new ContractCallPrototype(address, entry\_point, op, guaranteed\_public\_transcript, fallible\_public\_transcript, private\_transcript\_outputs, input, output, communication\_commitment\_rand, key\_location)](https://docs.midnight.network/api-reference/ledger/classes/ContractCallPrototype#new-contractcallprototypeaddress-entry_point-op-guaranteed_public_transcript-fallible_public_transcript-private_transcript_outputs-input-output-communication_commitment_rand-key_location) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/ContractCallPrototype#methods) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/ContractCallPrototype#tostring) --- # ContractCall | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ContractCall Class: ContractCall =================== A single contract call segment Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------ ### new ContractCall()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#new-contractcall "Direct link to new ContractCall()") private new ContractCall(): ContractCall #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#returns "Direct link to Returns") [`ContractCall`](https://docs.midnight.network/api-reference/ledger/classes/ContractCall) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------ ### address[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#address "Direct link to address") readonly address: string; The address being called * * * ### communicationCommitment[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#communicationcommitment "Direct link to communicationCommitment") readonly communicationCommitment: string; The communication commitment of this call * * * ### entryPoint[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#entrypoint "Direct link to entryPoint") readonly entryPoint: string | Uint8Array; The entry point being called * * * ### fallibleTranscript[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#fallibletranscript "Direct link to fallibleTranscript") readonly fallibleTranscript: undefined | Transcript; The fallible execution stage transcript * * * ### guaranteedTranscript[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#guaranteedtranscript "Direct link to guaranteedTranscript") readonly guaranteedTranscript: undefined | Transcript; The guaranteed execution stage transcript Methods[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#methods "Direct link to Methods") --------------------------------------------------------------------------------------------------------------------- ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#parameters "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#returns-1 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#constructors) * [new ContractCall()](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#new-contractcall) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#properties) * [address](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#address) * [communicationCommitment](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#communicationcommitment) * [entryPoint](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#entrypoint) * [fallibleTranscript](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#fallibletranscript) * [guaranteedTranscript](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#guaranteedtranscript) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#methods) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/ContractCall#tostring) --- # LocalState | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/LocalState#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / LocalState Class: LocalState ================= The local state of a user/wallet, consisting of their secret key, and a set of unspent coins. It also keeps track of coins that are in-flight, either expecting to spend or expecting to receive, and a local copy of the global coin commitment Merkle tree to generate proofs against. Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------- ### new LocalState()[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#new-localstate "Direct link to new LocalState()") new LocalState(): LocalState Creates a new state with a randomly sampled secret key #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#returns "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/ledger/classes/LocalState) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------- ### coinPublicKey[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#coinpublickey "Direct link to coinPublicKey") readonly coinPublicKey: string; The coin public key of this wallet * * * ### coins[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#coins "Direct link to coins") readonly coins: Set; The set of _spendable_ coins of this wallet * * * ### encryptionPublicKey[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#encryptionpublickey "Direct link to encryptionPublicKey") readonly encryptionPublicKey: string; The encryption public key of this wallet * * * ### firstFree[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#firstfree "Direct link to firstFree") readonly firstFree: bigint; The first free index in the internal coin commitments Merkle tree. This may be used to identify which merkle tree updates are necessary. * * * ### pendingOutputs[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#pendingoutputs "Direct link to pendingOutputs") readonly pendingOutputs: Map; The outputs that this wallet is expecting to receive in the future * * * ### pendingSpends[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#pendingspends "Direct link to pendingSpends") readonly pendingSpends: Map; The spends that this wallet is expecting to be finalized on-chain in the future Methods[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------- ### apply()[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#apply "Direct link to apply()") apply(offer): LocalState Locally applies an offer to the current state, returning the updated state #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#parameters "Direct link to Parameters") • **offer**: [`Offer`](https://docs.midnight.network/api-reference/ledger/classes/Offer) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#returns-1 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/ledger/classes/LocalState) * * * ### applyCollapsedUpdate()[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#applycollapsedupdate "Direct link to applyCollapsedUpdate()") applyCollapsedUpdate(update): LocalState Applies a collapsed Merkle tree update to the current local state, fast forwarding through the indices included in it, if it is a correct update. The general flow for usage if Alice is in state A, and wants to ask Bob how to reach the new state B, is: * Find where she left off – what's her firstFree? * Find out where she's going – ask for Bob's firstFree. * Find what contents she does care about – ask Bob for the filtered entries she want to include proper in her tree. * In order, of Merkle tree indicies: * Insert (with `apply` offers Alice cares about). * Skip (with this method) sections Alice does not care about, obtaining the collapsed update covering the gap from Bob. Note that `firstFree` is not included in the tree itself, and both ends of updates _are_ included. #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#parameters-1 "Direct link to Parameters") • **update**: [`MerkleTreeCollapsedUpdate`](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#returns-2 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/ledger/classes/LocalState) * * * ### applyFailed()[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#applyfailed "Direct link to applyFailed()") applyFailed(offer): LocalState Locally marks an offer as failed, allowing inputs used in it to be spendable once more. #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#parameters-2 "Direct link to Parameters") • **offer**: [`Offer`](https://docs.midnight.network/api-reference/ledger/classes/Offer) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#returns-3 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/ledger/classes/LocalState) * * * ### applyFailedProofErased()[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#applyfailedprooferased "Direct link to applyFailedProofErased()") applyFailedProofErased(offer): LocalState Locally marks an proof-erased offer as failed, allowing inputs used in it to be spendable once more. #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#parameters-3 "Direct link to Parameters") • **offer**: [`ProofErasedOffer`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#returns-4 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/ledger/classes/LocalState) * * * ### applyProofErased()[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#applyprooferased "Direct link to applyProofErased()") applyProofErased(offer): LocalState Locally applies a proof-erased offer to the current state, returning the updated state #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#parameters-4 "Direct link to Parameters") • **offer**: [`ProofErasedOffer`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#returns-5 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/ledger/classes/LocalState) * * * ### applyProofErasedTx()[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#applyprooferasedtx "Direct link to applyProofErasedTx()") applyProofErasedTx(tx, res): LocalState Locally applies a proof-erased transaction to the current state, returning the updated state #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#parameters-5 "Direct link to Parameters") • **tx**: [`ProofErasedTransaction`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction) • **res**: `"success"` | `"partialSuccess"` | `"failure"` The result type of applying this transaction against the ledger state #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#returns-6 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/ledger/classes/LocalState) * * * ### applySystemTx()[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#applysystemtx "Direct link to applySystemTx()") applySystemTx(tx): LocalState Locally applies a system transaction to the current state, returning the updated state #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#parameters-6 "Direct link to Parameters") • **tx**: [`SystemTransaction`](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#returns-7 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/ledger/classes/LocalState) * * * ### applyTx()[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#applytx "Direct link to applyTx()") applyTx(tx, res): LocalState Locally applies a transaction to the current state, returning the updated state #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#parameters-7 "Direct link to Parameters") • **tx**: [`Transaction`](https://docs.midnight.network/api-reference/ledger/classes/Transaction) • **res**: `"success"` | `"partialSuccess"` | `"failure"` The result type of applying this transaction against the ledger state #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#returns-8 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/ledger/classes/LocalState) * * * ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#parameters-8 "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#returns-9 "Direct link to Returns") `Uint8Array` * * * ### spend()[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#spend "Direct link to spend()") spend(coin): [LocalState, UnprovenInput] Initiates a new spend of a specific coin, outputting the corresponding [UnprovenInput](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput) , and the updated state marking this coin as in-flight. #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#parameters-9 "Direct link to Parameters") • **coin**: [`QualifiedCoinInfo`](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#returns-10 "Direct link to Returns") \[[`LocalState`](https://docs.midnight.network/api-reference/ledger/classes/LocalState)\ , [`UnprovenInput`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput)\ \] * * * ### spendFromOutput()[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#spendfromoutput "Direct link to spendFromOutput()") spendFromOutput(coin, output): [LocalState, UnprovenTransient] Initiates a new spend of a new-yet-received output, outputting the corresponding [UnprovenTransient](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient) , and the updated state marking this coin as in-flight. #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#parameters-10 "Direct link to Parameters") • **coin**: [`QualifiedCoinInfo`](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo) • **output**: [`UnprovenOutput`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#returns-11 "Direct link to Returns") \[[`LocalState`](https://docs.midnight.network/api-reference/ledger/classes/LocalState)\ , [`UnprovenTransient`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient)\ \] * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#parameters-11 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#returns-12 "Direct link to Returns") `string` * * * ### watchFor()[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#watchfor "Direct link to watchFor()") watchFor(coin): LocalState Adds a coin to the list of coins that are expected to be received This should be used if an output is creating a coin for this wallet, which does not contain a ciphertext to detect it. In this case, the wallet must know the commitment ahead of time to notice the receipt. #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#parameters-12 "Direct link to Parameters") • **coin**: [`CoinInfo`](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#returns-13 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/ledger/classes/LocalState) * * * ### yesIKnowTheSecurityImplicationsOfThis\_encryptionSecretKey()[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#yesiknowthesecurityimplicationsofthis_encryptionsecretkey "Direct link to yesIKnowTheSecurityImplicationsOfThis_encryptionSecretKey()") yesIKnowTheSecurityImplicationsOfThis_encryptionSecretKey(): EncryptionSecretKey #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#returns-14 "Direct link to Returns") [`EncryptionSecretKey`](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey) * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#deserialize "Direct link to deserialize()") static deserialize(raw, netid): LocalState #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#parameters-13 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#returns-15 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/ledger/classes/LocalState) * * * ### fromSeed()[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#fromseed "Direct link to fromSeed()") static fromSeed(seed): LocalState Creates a new state from a predefined random seed (which can act as a recovery phrase) #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#parameters-14 "Direct link to Parameters") • **seed**: `Uint8Array` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LocalState#returns-16 "Direct link to Returns") [`LocalState`](https://docs.midnight.network/api-reference/ledger/classes/LocalState) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/LocalState#constructors) * [new LocalState()](https://docs.midnight.network/api-reference/ledger/classes/LocalState#new-localstate) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/LocalState#properties) * [coinPublicKey](https://docs.midnight.network/api-reference/ledger/classes/LocalState#coinpublickey) * [coins](https://docs.midnight.network/api-reference/ledger/classes/LocalState#coins) * [encryptionPublicKey](https://docs.midnight.network/api-reference/ledger/classes/LocalState#encryptionpublickey) * [firstFree](https://docs.midnight.network/api-reference/ledger/classes/LocalState#firstfree) * [pendingOutputs](https://docs.midnight.network/api-reference/ledger/classes/LocalState#pendingoutputs) * [pendingSpends](https://docs.midnight.network/api-reference/ledger/classes/LocalState#pendingspends) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/LocalState#methods) * [apply()](https://docs.midnight.network/api-reference/ledger/classes/LocalState#apply) * [applyCollapsedUpdate()](https://docs.midnight.network/api-reference/ledger/classes/LocalState#applycollapsedupdate) * [applyFailed()](https://docs.midnight.network/api-reference/ledger/classes/LocalState#applyfailed) * [applyFailedProofErased()](https://docs.midnight.network/api-reference/ledger/classes/LocalState#applyfailedprooferased) * [applyProofErased()](https://docs.midnight.network/api-reference/ledger/classes/LocalState#applyprooferased) * [applyProofErasedTx()](https://docs.midnight.network/api-reference/ledger/classes/LocalState#applyprooferasedtx) * [applySystemTx()](https://docs.midnight.network/api-reference/ledger/classes/LocalState#applysystemtx) * [applyTx()](https://docs.midnight.network/api-reference/ledger/classes/LocalState#applytx) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/LocalState#serialize) * [spend()](https://docs.midnight.network/api-reference/ledger/classes/LocalState#spend) * [spendFromOutput()](https://docs.midnight.network/api-reference/ledger/classes/LocalState#spendfromoutput) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/LocalState#tostring) * [watchFor()](https://docs.midnight.network/api-reference/ledger/classes/LocalState#watchfor) * [yesIKnowTheSecurityImplicationsOfThis\_encryptionSecretKey()](https://docs.midnight.network/api-reference/ledger/classes/LocalState#yesiknowthesecurityimplicationsofthis_encryptionsecretkey) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/LocalState#deserialize) * [fromSeed()](https://docs.midnight.network/api-reference/ledger/classes/LocalState#fromseed) --- # signatureVerifyingKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/signatureVerifyingKey#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / signatureVerifyingKey Function: signatureVerifyingKey() ================================= signatureVerifyingKey(sk): SignatureVerifyingKey Returns the verifying key for a given signing key Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/signatureVerifyingKey#parameters "Direct link to Parameters") -------------------------------------------------------------------------------------------------------------------------------------------------- • **sk**: `string` Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/signatureVerifyingKey#returns "Direct link to Returns") ----------------------------------------------------------------------------------------------------------------------------------------- [`SignatureVerifyingKey`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/SignatureVerifyingKey) * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/signatureVerifyingKey#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/signatureVerifyingKey#returns) --- # sampleContractAddress | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/sampleContractAddress#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / sampleContractAddress Function: sampleContractAddress() ================================= sampleContractAddress(): ContractAddress Samples a uniform contract address, for use in testing Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/sampleContractAddress#returns "Direct link to Returns") ----------------------------------------------------------------------------------------------------------------------------------------- [`ContractAddress`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/ContractAddress) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/sampleContractAddress#returns) --- # sampleSigningKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/sampleSigningKey#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / sampleSigningKey Function: sampleSigningKey() ============================ sampleSigningKey(): SigningKey Randomly samples a [SigningKey](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/SigningKey) . Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/sampleSigningKey#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------------------ [`SigningKey`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/SigningKey) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/sampleSigningKey#returns) --- # LedgerParameters | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / LedgerParameters Class: LedgerParameters ======================= Parameters used by the Midnight ledger, including transaction fees and bounds Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------------- ### new LedgerParameters()[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#new-ledgerparameters "Direct link to new LedgerParameters()") private new LedgerParameters(): LedgerParameters #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#returns "Direct link to Returns") [`LedgerParameters`](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------- ### transactionCostModel[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#transactioncostmodel "Direct link to transactionCostModel") readonly transactionCostModel: TransactionCostModel; The cost model used for transaction fees contained in these parameters Methods[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#deserialize "Direct link to deserialize()") static deserialize(raw, netid): LedgerParameters #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#returns-3 "Direct link to Returns") [`LedgerParameters`](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters) * * * ### dummyParameters()[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#dummyparameters "Direct link to dummyParameters()") static dummyParameters(): LedgerParameters A dummy set of testing parameters #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#returns-4 "Direct link to Returns") [`LedgerParameters`](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#constructors) * [new LedgerParameters()](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#new-ledgerparameters) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#properties) * [transactionCostModel](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#transactioncostmodel) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#methods) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#deserialize) * [dummyParameters()](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters#dummyparameters) --- # tokenType | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/tokenType#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / tokenType Function: tokenType() ===================== tokenType(domain_sep, contract): TokenType Derives the [TokenType](https://docs.midnight.network/api-reference/ledger/type-aliases/TokenType) associated with a particular [DomainSeperator](https://docs.midnight.network/api-reference/ledger/type-aliases/DomainSeperator) and contract. Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/tokenType#parameters "Direct link to Parameters") ----------------------------------------------------------------------------------------------------------------------------- • **domain\_sep**: `Uint8Array` • **contract**: `string` Returns[​](https://docs.midnight.network/api-reference/ledger/functions/tokenType#returns "Direct link to Returns") -------------------------------------------------------------------------------------------------------------------- [`TokenType`](https://docs.midnight.network/api-reference/ledger/type-aliases/TokenType) * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/tokenType#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/tokenType#returns) --- # hashToCurve | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/hashToCurve#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / hashToCurve Function: hashToCurve() ======================= `Internal` hashToCurve(align, val): Value Internal implementation of the hash to curve primitive Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/hashToCurve#parameters "Direct link to Parameters") ---------------------------------------------------------------------------------------------------------------------------------------- • **align**: [`Alignment`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Alignment) • **val**: [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/hashToCurve#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------------- [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Throws[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/hashToCurve#throws "Direct link to Throws") ---------------------------------------------------------------------------------------------------------------------------- If val does not have alignment align * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/hashToCurve#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/hashToCurve#returns) * [Throws](https://docs.midnight.network/api-reference/onchain-runtime/functions/hashToCurve#throws) --- # persistentCommit | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/persistentCommit#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / persistentCommit Function: persistentCommit() ============================ `Internal` persistentCommit( align, val, opening): Value Internal implementation of the persistent commitment primitive Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/persistentCommit#parameters "Direct link to Parameters") --------------------------------------------------------------------------------------------------------------------------------------------- • **align**: [`Alignment`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Alignment) • **val**: [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) • **opening**: [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/persistentCommit#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------------------ [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Throws[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/persistentCommit#throws "Direct link to Throws") --------------------------------------------------------------------------------------------------------------------------------- If val does not have alignment align, opening does not encode a 32-byte bytestring, or any component has a compress alignment * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/persistentCommit#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/persistentCommit#returns) * [Throws](https://docs.midnight.network/api-reference/onchain-runtime/functions/persistentCommit#throws) --- # persistentHash | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/persistentHash#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / persistentHash Function: persistentHash() ========================== `Internal` persistentHash(align, val): Value Internal implementation of the persistent hash primitive Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/persistentHash#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------------------- • **align**: [`Alignment`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Alignment) • **val**: [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/persistentHash#returns "Direct link to Returns") ---------------------------------------------------------------------------------------------------------------------------------- [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Throws[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/persistentHash#throws "Direct link to Throws") ------------------------------------------------------------------------------------------------------------------------------- If val does not have alignment align, or any component has a compress alignment * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/persistentHash#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/persistentHash#returns) * [Throws](https://docs.midnight.network/api-reference/onchain-runtime/functions/persistentHash#throws) --- # sampleTokenType | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/sampleTokenType#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / sampleTokenType Function: sampleTokenType() =========================== sampleTokenType(): TokenType Samples a uniform token type, for use in testing Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/sampleTokenType#returns "Direct link to Returns") ----------------------------------------------------------------------------------------------------------------------------------- [`TokenType`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/TokenType) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/sampleTokenType#returns) --- # signData | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/signData#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / signData Function: signData() ==================== signData(key, data): Signature Signs arbitrary data with the given signing key. WARNING: Do not expose access to this function for valuable keys for data that is not strictly controlled! Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/signData#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------------- • **key**: `string` • **data**: `Uint8Array` Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/signData#returns "Direct link to Returns") ---------------------------------------------------------------------------------------------------------------------------- [`Signature`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Signature) * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/signData#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/signData#returns) --- # ContractCallsPrototype | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ContractCallsPrototype Class: ContractCallsPrototype ============================= An atomic collection of [ContractAction](https://docs.midnight.network/api-reference/ledger/type-aliases/ContractAction) s, which may interact with each other Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------------------- ### new ContractCallsPrototype()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#new-contractcallsprototype "Direct link to new ContractCallsPrototype()") new ContractCallsPrototype(): ContractCallsPrototype #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#returns "Direct link to Returns") [`ContractCallsPrototype`](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype) Methods[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------------- ### addCall()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#addcall "Direct link to addCall()") addCall(call): ContractCallsPrototype #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#parameters "Direct link to Parameters") • **call**: [`ContractCallPrototype`](https://docs.midnight.network/api-reference/ledger/classes/ContractCallPrototype) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#returns-1 "Direct link to Returns") [`ContractCallsPrototype`](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype) * * * ### addDeploy()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#adddeploy "Direct link to addDeploy()") addDeploy(deploy): ContractCallsPrototype #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#parameters-1 "Direct link to Parameters") • **deploy**: [`ContractDeploy`](https://docs.midnight.network/api-reference/ledger/classes/ContractDeploy) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#returns-2 "Direct link to Returns") [`ContractCallsPrototype`](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype) * * * ### addMaintenanceUpdate()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#addmaintenanceupdate "Direct link to addMaintenanceUpdate()") addMaintenanceUpdate(upd): ContractCallsPrototype #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#parameters-2 "Direct link to Parameters") • **upd**: [`MaintenanceUpdate`](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#returns-3 "Direct link to Returns") [`ContractCallsPrototype`](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype) * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#parameters-3 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#returns-4 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#constructors) * [new ContractCallsPrototype()](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#new-contractcallsprototype) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#methods) * [addCall()](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#addcall) * [addDeploy()](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#adddeploy) * [addMaintenanceUpdate()](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#addmaintenanceupdate) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype#tostring) --- # LedgerState | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / LedgerState Class: LedgerState ================== The state of the Midnight ledger Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#constructors "Direct link to Constructors") ----------------------------------------------------------------------------------------------------------------------------------- ### new LedgerState(zswap)[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#new-ledgerstatezswap "Direct link to new LedgerState(zswap)") new LedgerState(zswap): LedgerState Initializes from a Zswap state, with an empty contract set #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#parameters "Direct link to Parameters") • **zswap**: [`ZswapChainState`](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#returns "Direct link to Returns") [`LedgerState`](https://docs.midnight.network/api-reference/ledger/classes/LedgerState) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#properties "Direct link to Properties") ----------------------------------------------------------------------------------------------------------------------------- ### unmintedNativeTokenSupply[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#unmintednativetokensupply "Direct link to unmintedNativeTokenSupply") readonly unmintedNativeTokenSupply: bigint; The remaining unminted supply of native tokens. * * * ### zswap[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#zswap "Direct link to zswap") readonly zswap: ZswapChainState; The Zswap part of the ledger state Methods[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#methods "Direct link to Methods") -------------------------------------------------------------------------------------------------------------------- ### apply()[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#apply "Direct link to apply()") apply(transaction, context): [LedgerState, TransactionResult] Applies a [ProofErasedTransaction](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction) #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#parameters-1 "Direct link to Parameters") • **transaction**: [`ProofErasedTransaction`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction) • **context**: [`TransactionContext`](https://docs.midnight.network/api-reference/ledger/classes/TransactionContext) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#returns-1 "Direct link to Returns") \[[`LedgerState`](https://docs.midnight.network/api-reference/ledger/classes/LedgerState)\ , [`TransactionResult`](https://docs.midnight.network/api-reference/ledger/classes/TransactionResult)\ \] * * * ### applySystemTx()[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#applysystemtx "Direct link to applySystemTx()") applySystemTx(transaction): LedgerState Applies a system transaction to this ledger state. #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#parameters-2 "Direct link to Parameters") • **transaction**: [`SystemTransaction`](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#returns-2 "Direct link to Returns") [`LedgerState`](https://docs.midnight.network/api-reference/ledger/classes/LedgerState) * * * ### index()[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#index "Direct link to index()") index(address): undefined | ContractState Indexes into the contract state map with a given contract address #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#parameters-3 "Direct link to Parameters") • **address**: `string` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#returns-3 "Direct link to Returns") `undefined` | [`ContractState`](https://docs.midnight.network/api-reference/ledger/classes/ContractState) * * * ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#parameters-4 "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#returns-4 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#parameters-5 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#returns-5 "Direct link to Returns") `string` * * * ### treasuryBalance()[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#treasurybalance "Direct link to treasuryBalance()") treasuryBalance(token_type): bigint Retrieves the balance of the treasury for a specific token type. #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#parameters-6 "Direct link to Parameters") • **token\_type**: `string` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#returns-6 "Direct link to Returns") `bigint` * * * ### unclaimedMints()[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#unclaimedmints "Direct link to unclaimedMints()") unclaimedMints(recipient, token_type): bigint How much in minting rewards a recipient, for a specific token type, is owed and can claim. #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#parameters-7 "Direct link to Parameters") • **recipient**: `string` • **token\_type**: `string` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#returns-7 "Direct link to Returns") `bigint` * * * ### updateIndex()[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#updateindex "Direct link to updateIndex()") updateIndex(address, context): LedgerState Sets the state of a given contract address from a [QueryContext](https://docs.midnight.network/api-reference/ledger/classes/QueryContext) #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#parameters-8 "Direct link to Parameters") • **address**: `string` • **context**: [`QueryContext`](https://docs.midnight.network/api-reference/ledger/classes/QueryContext) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#returns-8 "Direct link to Returns") [`LedgerState`](https://docs.midnight.network/api-reference/ledger/classes/LedgerState) * * * ### blank()[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#blank "Direct link to blank()") static blank(): LedgerState A fully blank state #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#returns-9 "Direct link to Returns") [`LedgerState`](https://docs.midnight.network/api-reference/ledger/classes/LedgerState) * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#deserialize "Direct link to deserialize()") static deserialize(raw, netid): LedgerState #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#parameters-9 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#returns-10 "Direct link to Returns") [`LedgerState`](https://docs.midnight.network/api-reference/ledger/classes/LedgerState) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#constructors) * [new LedgerState(zswap)](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#new-ledgerstatezswap) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#properties) * [unmintedNativeTokenSupply](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#unmintednativetokensupply) * [zswap](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#zswap) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#methods) * [apply()](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#apply) * [applySystemTx()](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#applysystemtx) * [index()](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#index) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#tostring) * [treasuryBalance()](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#treasurybalance) * [unclaimedMints()](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#unclaimedmints) * [updateIndex()](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#updateindex) * [blank()](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#blank) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/LedgerState#deserialize) --- # partitionTranscripts | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/partitionTranscripts#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / partitionTranscripts Function: partitionTranscripts() ================================ partitionTranscripts(calls, params): [Transcript | undefined, Transcript | undefined][] Finalizes a set of programs against their initial contexts, resulting in guaranteed and fallible [Transcript](https://docs.midnight.network/api-reference/ledger/type-aliases/Transcript) s, optimally allocated, and heuristically covered for gas fees. Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/partitionTranscripts#parameters "Direct link to Parameters") ---------------------------------------------------------------------------------------------------------------------------------------- • **calls**: [`PreTranscript`](https://docs.midnight.network/api-reference/ledger/classes/PreTranscript) \[\] • **params**: [`LedgerParameters`](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters) Returns[​](https://docs.midnight.network/api-reference/ledger/functions/partitionTranscripts#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------------- \[[`Transcript`](https://docs.midnight.network/api-reference/ledger/type-aliases/Transcript)\ <[`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue)\ \> | `undefined`, [`Transcript`](https://docs.midnight.network/api-reference/ledger/type-aliases/Transcript)\ <[`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue)\ \> | `undefined`\]\[\] * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/partitionTranscripts#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/partitionTranscripts#returns) --- # transientHash | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/transientHash#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / transientHash Function: transientHash() ========================= `Internal` transientHash(align, val): Value Internal implementation of the transient hash primitive Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/transientHash#parameters "Direct link to Parameters") --------------------------------------------------------------------------------------------------------------------------------- • **align**: [`Alignment`](https://docs.midnight.network/api-reference/ledger/type-aliases/Alignment) • **val**: [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/ledger/functions/transientHash#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------ [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Throws[​](https://docs.midnight.network/api-reference/ledger/functions/transientHash#throws "Direct link to Throws") --------------------------------------------------------------------------------------------------------------------- If val does not have alignment align * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/transientHash#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/transientHash#returns) * [Throws](https://docs.midnight.network/api-reference/ledger/functions/transientHash#throws) --- # transientCommit | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/transientCommit#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / transientCommit Function: transientCommit() =========================== `Internal` transientCommit( align, val, opening): Value Internal implementation of the transient commitment primitive Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/transientCommit#parameters "Direct link to Parameters") ----------------------------------------------------------------------------------------------------------------------------------- • **align**: [`Alignment`](https://docs.midnight.network/api-reference/ledger/type-aliases/Alignment) • **val**: [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) • **opening**: [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/ledger/functions/transientCommit#returns "Direct link to Returns") -------------------------------------------------------------------------------------------------------------------------- [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) Throws[​](https://docs.midnight.network/api-reference/ledger/functions/transientCommit#throws "Direct link to Throws") ----------------------------------------------------------------------------------------------------------------------- If val does not have alignment align, or opening does not encode a field element * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/transientCommit#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/transientCommit#returns) * [Throws](https://docs.midnight.network/api-reference/ledger/functions/transientCommit#throws) --- # valueToBigInt | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/valueToBigInt#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / valueToBigInt Function: valueToBigInt() ========================= `Internal` valueToBigInt(x): bigint Internal conversion between field-aligned binary values and bigints within the scalar field Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/valueToBigInt#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------------------ • **x**: [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/valueToBigInt#returns "Direct link to Returns") --------------------------------------------------------------------------------------------------------------------------------- `bigint` Throws[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/valueToBigInt#throws "Direct link to Throws") ------------------------------------------------------------------------------------------------------------------------------ If the value does not encode a field element * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/valueToBigInt#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/valueToBigInt#returns) * [Throws](https://docs.midnight.network/api-reference/onchain-runtime/functions/valueToBigInt#throws) --- # EncryptionSecretKey | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / EncryptionSecretKey Class: EncryptionSecretKey ========================== Holds the encryption secret key of a user, which may be used to determine if a given offer contains outputs addressed to this user Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------- ### new EncryptionSecretKey()[​](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey#new-encryptionsecretkey "Direct link to new EncryptionSecretKey()") private new EncryptionSecretKey(): EncryptionSecretKey #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey#returns "Direct link to Returns") [`EncryptionSecretKey`](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey) Methods[​](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------------- ### test()[​](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey#test "Direct link to test()") test(offer): boolean #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey#parameters "Direct link to Parameters") • **offer**: [`Offer`](https://docs.midnight.network/api-reference/ledger/classes/Offer) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey#returns-1 "Direct link to Returns") `boolean` * * * ### yesIKnowTheSecurityImplicationsOfThis\_serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey#yesiknowthesecurityimplicationsofthis_serialize "Direct link to yesIKnowTheSecurityImplicationsOfThis_serialize()") yesIKnowTheSecurityImplicationsOfThis_serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey#parameters-1 "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey#returns-2 "Direct link to Returns") `Uint8Array` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey#deserialize "Direct link to deserialize()") static deserialize(raw, netid): EncryptionSecretKey #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey#returns-3 "Direct link to Returns") [`EncryptionSecretKey`](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey#constructors) * [new EncryptionSecretKey()](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey#new-encryptionsecretkey) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey#methods) * [test()](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey#test) * [yesIKnowTheSecurityImplicationsOfThis\_serialize()](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey#yesiknowthesecurityimplicationsofthis_serialize) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/EncryptionSecretKey#deserialize) --- # ProofErasedInput | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ProofErasedInput Class: ProofErasedInput ======================= A [Input](https://docs.midnight.network/api-reference/ledger/classes/Input) , with all proof information erased Primarily for use in testing, or handling data known to be correct from external information Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------------- ### new ProofErasedInput()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#new-prooferasedinput "Direct link to new ProofErasedInput()") private new ProofErasedInput(): ProofErasedInput #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#returns "Direct link to Returns") [`ProofErasedInput`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------- ### contractAddress[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#contractaddress "Direct link to contractAddress") readonly contractAddress: undefined | string; The contract address receiving the input, if the sender is a contract * * * ### nullifier[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#nullifier "Direct link to nullifier") readonly nullifier: string; The nullifier of the input Methods[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#deserialize "Direct link to deserialize()") static deserialize(raw, netid): ProofErasedInput #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#returns-3 "Direct link to Returns") [`ProofErasedInput`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#constructors) * [new ProofErasedInput()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#new-prooferasedinput) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#properties) * [contractAddress](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#contractaddress) * [nullifier](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#nullifier) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#methods) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedInput#deserialize) --- # ProofErasedOffer | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ProofErasedOffer Class: ProofErasedOffer ======================= An [Offer](https://docs.midnight.network/api-reference/ledger/classes/Offer) , with all proof information erased Primarily for use in testing, or handling data known to be correct from external information Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------------- ### new ProofErasedOffer()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#new-prooferasedoffer "Direct link to new ProofErasedOffer()") private new ProofErasedOffer(): ProofErasedOffer #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#returns "Direct link to Returns") [`ProofErasedOffer`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------- ### deltas[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#deltas "Direct link to deltas") readonly deltas: Map; The value of this offer for each token type; note that this may be negative This is input coin values - output coin values, for value vectors * * * ### inputs[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#inputs "Direct link to inputs") readonly inputs: ProofErasedInput[]; The inputs this offer is composed of * * * ### outputs[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#outputs "Direct link to outputs") readonly outputs: ProofErasedOutput[]; The outputs this offer is composed of * * * ### transient[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#transient "Direct link to transient") readonly transient: ProofErasedTransient[]; The transients this offer is composed of Methods[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------- ### merge()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#merge "Direct link to merge()") merge(other): ProofErasedOffer #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#parameters "Direct link to Parameters") • **other**: [`ProofErasedOffer`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#returns-1 "Direct link to Returns") [`ProofErasedOffer`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer) * * * ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#parameters-1 "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#returns-2 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#parameters-2 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#returns-3 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#deserialize "Direct link to deserialize()") static deserialize(raw, netid): ProofErasedOffer #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#parameters-3 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#returns-4 "Direct link to Returns") [`ProofErasedOffer`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#constructors) * [new ProofErasedOffer()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#new-prooferasedoffer) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#properties) * [deltas](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#deltas) * [inputs](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#inputs) * [outputs](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#outputs) * [transient](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#transient) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#methods) * [merge()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#merge) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer#deserialize) --- # Output | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/Output#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / Output Class: Output ============= A shielded transaction output Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/Output#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------ ### new Output()[​](https://docs.midnight.network/api-reference/ledger/classes/Output#new-output "Direct link to new Output()") private new Output(): Output #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Output#returns "Direct link to Returns") [`Output`](https://docs.midnight.network/api-reference/ledger/classes/Output) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/Output#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------ ### commitment[​](https://docs.midnight.network/api-reference/ledger/classes/Output#commitment "Direct link to commitment") readonly commitment: string; The commitment of the output * * * ### contractAddress[​](https://docs.midnight.network/api-reference/ledger/classes/Output#contractaddress "Direct link to contractAddress") readonly contractAddress: undefined | string; The contract address receiving the output, if the recipient is a contract Methods[​](https://docs.midnight.network/api-reference/ledger/classes/Output#methods "Direct link to Methods") --------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/Output#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Output#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Output#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/Output#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Output#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Output#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/Output#deserialize "Direct link to deserialize()") static deserialize(raw, netid): Output #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Output#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Output#returns-3 "Direct link to Returns") [`Output`](https://docs.midnight.network/api-reference/ledger/classes/Output) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/Output#constructors) * [new Output()](https://docs.midnight.network/api-reference/ledger/classes/Output#new-output) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/Output#properties) * [commitment](https://docs.midnight.network/api-reference/ledger/classes/Output#commitment) * [contractAddress](https://docs.midnight.network/api-reference/ledger/classes/Output#contractaddress) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/Output#methods) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/Output#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/Output#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/Output#deserialize) --- # MerkleTreeCollapsedUpdate | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / MerkleTreeCollapsedUpdate Class: MerkleTreeCollapsedUpdate ================================ A compact delta on the coin commitments Merkle tree, used to keep local spending trees in sync with the global state without requiring receiving all transactions. Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------------- ### new MerkleTreeCollapsedUpdate(state, start, end)[​](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#new-merkletreecollapsedupdatestate-start-end "Direct link to new MerkleTreeCollapsedUpdate(state, start, end)") new MerkleTreeCollapsedUpdate( state, start, end): MerkleTreeCollapsedUpdate Create a new compact update from a non-compact state, and inclusive `start` and `end` indices #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#parameters "Direct link to Parameters") • **state**: [`ZswapChainState`](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState) • **start**: `bigint` • **end**: `bigint` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#returns "Direct link to Returns") [`MerkleTreeCollapsedUpdate`](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate) #### Throws[​](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#throws "Direct link to Throws") If the indices are out-of-bounds for the state, or `end < start` Methods[​](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#parameters-1 "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#parameters-2 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#deserialize "Direct link to deserialize()") static deserialize(raw, netid): MerkleTreeCollapsedUpdate #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#parameters-3 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#returns-3 "Direct link to Returns") [`MerkleTreeCollapsedUpdate`](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#constructors) * [new MerkleTreeCollapsedUpdate(state, start, end)](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#new-merkletreecollapsedupdatestate-start-end) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#methods) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/MerkleTreeCollapsedUpdate#deserialize) --- # Offer | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/Offer#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / Offer Class: Offer ============ A full Zswap offer; the zswap part of a transaction Consists of sets of [Input](https://docs.midnight.network/api-reference/ledger/classes/Input) s, [Output](https://docs.midnight.network/api-reference/ledger/classes/Output) s, and [Transient](https://docs.midnight.network/api-reference/ledger/classes/Transient) s, as well as a [deltas](https://docs.midnight.network/api-reference/ledger/classes/Offer#deltas) vector of the transaction value Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#constructors "Direct link to Constructors") ----------------------------------------------------------------------------------------------------------------------------- ### new Offer()[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#new-offer "Direct link to new Offer()") private new Offer(): Offer #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#returns "Direct link to Returns") [`Offer`](https://docs.midnight.network/api-reference/ledger/classes/Offer) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#properties "Direct link to Properties") ----------------------------------------------------------------------------------------------------------------------- ### deltas[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#deltas "Direct link to deltas") readonly deltas: Map; The value of this offer for each token type; note that this may be negative This is input coin values - output coin values, for value vectors * * * ### inputs[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#inputs "Direct link to inputs") readonly inputs: Input[]; The inputs this offer is composed of * * * ### outputs[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#outputs "Direct link to outputs") readonly outputs: Output[]; The outputs this offer is composed of * * * ### transient[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#transient "Direct link to transient") readonly transient: Transient[]; The transients this offer is composed of Methods[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#methods "Direct link to Methods") -------------------------------------------------------------------------------------------------------------- ### merge()[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#merge "Direct link to merge()") merge(other): Offer Combine this offer with another #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#parameters "Direct link to Parameters") • **other**: [`Offer`](https://docs.midnight.network/api-reference/ledger/classes/Offer) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#returns-1 "Direct link to Returns") [`Offer`](https://docs.midnight.network/api-reference/ledger/classes/Offer) * * * ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#parameters-1 "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#returns-2 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#parameters-2 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#returns-3 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#deserialize "Direct link to deserialize()") static deserialize(raw, netid): Offer #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#parameters-3 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Offer#returns-4 "Direct link to Returns") [`Offer`](https://docs.midnight.network/api-reference/ledger/classes/Offer) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/Offer#constructors) * [new Offer()](https://docs.midnight.network/api-reference/ledger/classes/Offer#new-offer) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/Offer#properties) * [deltas](https://docs.midnight.network/api-reference/ledger/classes/Offer#deltas) * [inputs](https://docs.midnight.network/api-reference/ledger/classes/Offer#inputs) * [outputs](https://docs.midnight.network/api-reference/ledger/classes/Offer#outputs) * [transient](https://docs.midnight.network/api-reference/ledger/classes/Offer#transient) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/Offer#methods) * [merge()](https://docs.midnight.network/api-reference/ledger/classes/Offer#merge) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/Offer#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/Offer#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/Offer#deserialize) --- # StateMap | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/StateMap#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / StateMap Class: StateMap =============== Represents a key-value map, where keys are [AlignedValue](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) s, and values are [StateValue](https://docs.midnight.network/api-reference/ledger/classes/StateValue) s. Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/StateMap#constructors "Direct link to Constructors") -------------------------------------------------------------------------------------------------------------------------------- ### new StateMap()[​](https://docs.midnight.network/api-reference/ledger/classes/StateMap#new-statemap "Direct link to new StateMap()") new StateMap(): StateMap #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateMap#returns "Direct link to Returns") [`StateMap`](https://docs.midnight.network/api-reference/ledger/classes/StateMap) Methods[​](https://docs.midnight.network/api-reference/ledger/classes/StateMap#methods "Direct link to Methods") ----------------------------------------------------------------------------------------------------------------- ### get()[​](https://docs.midnight.network/api-reference/ledger/classes/StateMap#get "Direct link to get()") get(key): undefined | StateValue #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/StateMap#parameters "Direct link to Parameters") • **key**: [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateMap#returns-1 "Direct link to Returns") `undefined` | [`StateValue`](https://docs.midnight.network/api-reference/ledger/classes/StateValue) * * * ### insert()[​](https://docs.midnight.network/api-reference/ledger/classes/StateMap#insert "Direct link to insert()") insert(key, value): StateMap #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/StateMap#parameters-1 "Direct link to Parameters") • **key**: [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) • **value**: [`StateValue`](https://docs.midnight.network/api-reference/ledger/classes/StateValue) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateMap#returns-2 "Direct link to Returns") [`StateMap`](https://docs.midnight.network/api-reference/ledger/classes/StateMap) * * * ### keys()[​](https://docs.midnight.network/api-reference/ledger/classes/StateMap#keys "Direct link to keys()") keys(): AlignedValue[] #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateMap#returns-3 "Direct link to Returns") [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) \[\] * * * ### remove()[​](https://docs.midnight.network/api-reference/ledger/classes/StateMap#remove "Direct link to remove()") remove(key): StateMap #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/StateMap#parameters-2 "Direct link to Parameters") • **key**: [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateMap#returns-4 "Direct link to Returns") [`StateMap`](https://docs.midnight.network/api-reference/ledger/classes/StateMap) * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/StateMap#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/StateMap#parameters-3 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateMap#returns-5 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/StateMap#constructors) * [new StateMap()](https://docs.midnight.network/api-reference/ledger/classes/StateMap#new-statemap) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/StateMap#methods) * [get()](https://docs.midnight.network/api-reference/ledger/classes/StateMap#get) * [insert()](https://docs.midnight.network/api-reference/ledger/classes/StateMap#insert) * [keys()](https://docs.midnight.network/api-reference/ledger/classes/StateMap#keys) * [remove()](https://docs.midnight.network/api-reference/ledger/classes/StateMap#remove) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/StateMap#tostring) --- # tokenType | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/tokenType#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / tokenType Function: tokenType() ===================== tokenType(domain_sep, contract): TokenType Derives the [TokenType](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/TokenType) associated with a particular [DomainSeperator](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/DomainSeperator) and contract. Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/tokenType#parameters "Direct link to Parameters") -------------------------------------------------------------------------------------------------------------------------------------- • **domain\_sep**: `Uint8Array` • **contract**: `string` Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/tokenType#returns "Direct link to Returns") ----------------------------------------------------------------------------------------------------------------------------- [`TokenType`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/TokenType) * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/tokenType#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/tokenType#returns) --- # transientCommit | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/transientCommit#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / transientCommit Function: transientCommit() =========================== `Internal` transientCommit( align, val, opening): Value Internal implementation of the transient commitment primitive Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/transientCommit#parameters "Direct link to Parameters") -------------------------------------------------------------------------------------------------------------------------------------------- • **align**: [`Alignment`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Alignment) • **val**: [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) • **opening**: [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/transientCommit#returns "Direct link to Returns") ----------------------------------------------------------------------------------------------------------------------------------- [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Throws[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/transientCommit#throws "Direct link to Throws") -------------------------------------------------------------------------------------------------------------------------------- If val does not have alignment align, or opening does not encode a field element * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/transientCommit#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/transientCommit#returns) * [Throws](https://docs.midnight.network/api-reference/onchain-runtime/functions/transientCommit#throws) --- # PreTranscript | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/PreTranscript#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / PreTranscript Class: PreTranscript ==================== A transcript prior to partitioning, consisting of the context to run it in, the program that will make up the transcript, and optionally a communication commitment to bind calls together. Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/PreTranscript#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------- ### new PreTranscript(context, program, comm\_comm)[​](https://docs.midnight.network/api-reference/ledger/classes/PreTranscript#new-pretranscriptcontext-program-comm_comm "Direct link to new PreTranscript(context, program, comm_comm)") new PreTranscript( context, program, comm_comm?): PreTranscript #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/PreTranscript#parameters "Direct link to Parameters") • **context**: [`QueryContext`](https://docs.midnight.network/api-reference/ledger/classes/QueryContext) • **program**: [`Op`](https://docs.midnight.network/api-reference/ledger/type-aliases/Op) <[`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) \>\[\] • **comm\_comm?**: `string` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/PreTranscript#returns "Direct link to Returns") [`PreTranscript`](https://docs.midnight.network/api-reference/ledger/classes/PreTranscript) Methods[​](https://docs.midnight.network/api-reference/ledger/classes/PreTranscript#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------- ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/PreTranscript#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/PreTranscript#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/PreTranscript#returns-1 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/PreTranscript#constructors) * [new PreTranscript(context, program, comm\_comm)](https://docs.midnight.network/api-reference/ledger/classes/PreTranscript#new-pretranscriptcontext-program-comm_comm) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/PreTranscript#methods) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/PreTranscript#tostring) --- # MaintenanceUpdate | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / MaintenanceUpdate Class: MaintenanceUpdate ======================== A contract maintenance update, updating associated operations, or changing the maintenance authority. Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#constructors "Direct link to Constructors") ----------------------------------------------------------------------------------------------------------------------------------------- ### new MaintenanceUpdate(address, updates, counter)[​](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#new-maintenanceupdateaddress-updates-counter "Direct link to new MaintenanceUpdate(address, updates, counter)") new MaintenanceUpdate( address, updates, counter): MaintenanceUpdate #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#parameters "Direct link to Parameters") • **address**: `string` • **updates**: [`SingleUpdate`](https://docs.midnight.network/api-reference/ledger/type-aliases/SingleUpdate) \[\] • **counter**: `bigint` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#returns "Direct link to Returns") [`MaintenanceUpdate`](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#properties "Direct link to Properties") ----------------------------------------------------------------------------------------------------------------------------------- ### address[​](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#address "Direct link to address") readonly address: string; The address this deployment will attempt to create * * * ### counter[​](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#counter "Direct link to counter") readonly counter: bigint; The counter this update is valid against * * * ### dataToSign[​](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#datatosign "Direct link to dataToSign") readonly dataToSign: Uint8Array; The raw data any valid signature must be over to approve this update. * * * ### signatures[​](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#signatures "Direct link to signatures") readonly signatures: [bigint, string][]; The signatures on this update * * * ### updates[​](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#updates "Direct link to updates") readonly updates: SingleUpdate[]; The updates to carry out Methods[​](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#methods "Direct link to Methods") -------------------------------------------------------------------------------------------------------------------------- ### addSignature()[​](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#addsignature "Direct link to addSignature()") addSignature(idx, signature): MaintenanceUpdate Adds a new signature to this update #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#parameters-1 "Direct link to Parameters") • **idx**: `bigint` • **signature**: `string` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#returns-1 "Direct link to Returns") [`MaintenanceUpdate`](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate) * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#parameters-2 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#returns-2 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#constructors) * [new MaintenanceUpdate(address, updates, counter)](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#new-maintenanceupdateaddress-updates-counter) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#properties) * [address](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#address) * [counter](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#counter) * [dataToSign](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#datatosign) * [signatures](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#signatures) * [updates](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#updates) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#methods) * [addSignature()](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#addsignature) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/MaintenanceUpdate#tostring) --- # ReplaceAuthority | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/ReplaceAuthority#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ReplaceAuthority Class: ReplaceAuthority ======================= An update instruction to replace the current contract maintenance authority with a new one. Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/ReplaceAuthority#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------------- ### new ReplaceAuthority(authority)[​](https://docs.midnight.network/api-reference/ledger/classes/ReplaceAuthority#new-replaceauthorityauthority "Direct link to new ReplaceAuthority(authority)") new ReplaceAuthority(authority): ReplaceAuthority #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ReplaceAuthority#parameters "Direct link to Parameters") • **authority**: [`ContractMaintenanceAuthority`](https://docs.midnight.network/api-reference/ledger/classes/ContractMaintenanceAuthority) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ReplaceAuthority#returns "Direct link to Returns") [`ReplaceAuthority`](https://docs.midnight.network/api-reference/ledger/classes/ReplaceAuthority) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/ReplaceAuthority#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------- ### authority[​](https://docs.midnight.network/api-reference/ledger/classes/ReplaceAuthority#authority "Direct link to authority") readonly authority: ContractMaintenanceAuthority; Methods[​](https://docs.midnight.network/api-reference/ledger/classes/ReplaceAuthority#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------- ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/ReplaceAuthority#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ReplaceAuthority#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ReplaceAuthority#returns-1 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/ReplaceAuthority#constructors) * [new ReplaceAuthority(authority)](https://docs.midnight.network/api-reference/ledger/classes/ReplaceAuthority#new-replaceauthorityauthority) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/ReplaceAuthority#properties) * [authority](https://docs.midnight.network/api-reference/ledger/classes/ReplaceAuthority#authority) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/ReplaceAuthority#methods) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/ReplaceAuthority#tostring) --- # ProofErasedOutput | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ProofErasedOutput Class: ProofErasedOutput ======================== An [Output](https://docs.midnight.network/api-reference/ledger/classes/Output) with all proof information erased Primarily for use in testing, or handling data known to be correct from external information Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#constructors "Direct link to Constructors") ----------------------------------------------------------------------------------------------------------------------------------------- ### new ProofErasedOutput()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#new-prooferasedoutput "Direct link to new ProofErasedOutput()") private new ProofErasedOutput(): ProofErasedOutput #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#returns "Direct link to Returns") [`ProofErasedOutput`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#properties "Direct link to Properties") ----------------------------------------------------------------------------------------------------------------------------------- ### commitment[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#commitment "Direct link to commitment") readonly commitment: string; The commitment of the output * * * ### contractAddress[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#contractaddress "Direct link to contractAddress") readonly contractAddress: undefined | string; The contract address receiving the output, if the recipient is a contract Methods[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#methods "Direct link to Methods") -------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#deserialize "Direct link to deserialize()") static deserialize(raw, netid): ProofErasedOutput #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#returns-3 "Direct link to Returns") [`ProofErasedOutput`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#constructors) * [new ProofErasedOutput()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#new-prooferasedoutput) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#properties) * [commitment](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#commitment) * [contractAddress](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#contractaddress) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#methods) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOutput#deserialize) --- # ProofErasedTransient | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ProofErasedTransient Class: ProofErasedTransient =========================== A [Transient](https://docs.midnight.network/api-reference/ledger/classes/Transient) , with all proof information erased Primarily for use in testing, or handling data known to be correct from external information Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#constructors "Direct link to Constructors") -------------------------------------------------------------------------------------------------------------------------------------------- ### new ProofErasedTransient()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#new-prooferasedtransient "Direct link to new ProofErasedTransient()") private new ProofErasedTransient(): ProofErasedTransient #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#returns "Direct link to Returns") [`ProofErasedTransient`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#properties "Direct link to Properties") -------------------------------------------------------------------------------------------------------------------------------------- ### commitment[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#commitment "Direct link to commitment") readonly commitment: string; The commitment of the transient * * * ### contractAddress[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#contractaddress "Direct link to contractAddress") readonly contractAddress: undefined | string; The contract address creating the transient, if applicable * * * ### nullifier[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#nullifier "Direct link to nullifier") readonly nullifier: string; The nullifier of the transient Methods[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#methods "Direct link to Methods") ----------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#deserialize "Direct link to deserialize()") static deserialize(raw, netid): ProofErasedTransient #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#returns-3 "Direct link to Returns") [`ProofErasedTransient`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#constructors) * [new ProofErasedTransient()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#new-prooferasedtransient) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#properties) * [commitment](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#commitment) * [contractAddress](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#contractaddress) * [nullifier](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#nullifier) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#methods) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransient#deserialize) --- # ProofErasedAuthorizedMint | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ProofErasedAuthorizedMint Class: ProofErasedAuthorizedMint ================================ A request to mint a coin, authorized by the mint's recipient, with the authorizing proof having been erased Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------------- ### new ProofErasedAuthorizedMint()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#new-prooferasedauthorizedmint "Direct link to new ProofErasedAuthorizedMint()") private new ProofErasedAuthorizedMint(): ProofErasedAuthorizedMint #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#returns "Direct link to Returns") [`ProofErasedAuthorizedMint`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------------- ### coin[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#coin "Direct link to coin") readonly coin: CoinInfo; The coin to be minted * * * ### recipient[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#recipient "Direct link to recipient") readonly recipient: string; The recipient of this mint Methods[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#deserialize "Direct link to deserialize()") static deserialize(raw, netid): ProofErasedAuthorizedMint #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#returns-3 "Direct link to Returns") [`ProofErasedAuthorizedMint`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#constructors) * [new ProofErasedAuthorizedMint()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#new-prooferasedauthorizedmint) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#properties) * [coin](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#coin) * [recipient](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#recipient) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#methods) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint#deserialize) --- # Example integration | Midnight Docs [Skip to main content](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ The fastest way to build on Midnight Network with pre-built smart contracts, complete API, and ready-to-use code snippets. Try the project[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#try-the-project "Direct link to Try the project") ---------------------------------------------------------------------------------------------------------------------------------------------------------- To test the complete setup locally, follow these steps strictly: **Repository:** [https://github.com/MeshJS/midnight-setup](https://github.com/MeshJS/midnight-setup) ### Clone the repository[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#clone-the-repository "Direct link to Clone the repository") Clone the repo locally using HTTPS or SSH. * using https: git clone https://github.com/MeshJS/midnight-setup.git * using ssh: git clone git@github.com:MeshJS/midnight-setup.git ### Navigate to the folder[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#navigate-to-the-folder "Direct link to Navigate to the folder") Change into the cloned repo directory. cd midnight-setup ### Install dependencies[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#install-dependencies "Direct link to Install dependencies") Install all workspace dependencies. yarn install ### Set environment variable[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#set-environment-variable "Direct link to Set environment variable") Set the network ID for the UI app. cd packages/ui && echo 'VITE_NETWORK_ID="TestNet"' > .env ### Build all packages[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#build-all-packages "Direct link to Build all packages") Build all packages in the monorepo. cd ../../ && yarn build:all ### Download fetch parameters[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#download-fetch-parameters "Direct link to Download fetch parameters") Download the required zk parameters for local runs. cd packages/cli && ./fetch-zk-params.sh ### Start testnet with Docker[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#start-testnet-with-docker "Direct link to Start testnet with Docker") Start the local testnet services with Docker Compose. docker-compose -f testnet.yml up -d ### Run the frontend[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#run-the-frontend "Direct link to Run the frontend") Start the UI app dev server. cd ../ui && yarn start Your application will be available at `http://localhost:8080`. Provider setup[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#provider-setup "Direct link to Provider setup") ------------------------------------------------------------------------------------------------------------------------------------------------------- Set up the required providers before interacting with the contract APIs. import { FetchZkConfigProvider } from "@midnight-ntwrk/midnight-js-fetch-zk-config-provider";import { httpClientProofProvider } from "@midnight-ntwrk/midnight-js-http-client-proof-provider";import { indexerPublicDataProvider } from "@midnight-ntwrk/midnight-js-indexer-public-data-provider";import { levelPrivateStateProvider } from "@midnight-ntwrk/midnight-js-level-private-state-provider";import type { MidnightSetupContractProviders } from "@meshsdk/midnight-setup";export async function setupProviders(): Promise { const wallet = window.midnight?.mnLace; if (!wallet) { throw new Error("Please install Lace Beta Wallet for Midnight Network"); } const walletAPI = await wallet.enable(); const walletState = await walletAPI.state(); const uris = await wallet.serviceUriConfig(); return { privateStateProvider: levelPrivateStateProvider({ privateStateStoreName: "my-dapp-state", }), zkConfigProvider: new FetchZkConfigProvider( window.location.origin, fetch.bind(window), ), proofProvider: httpClientProofProvider(uris.proverServerUri), publicDataProvider: indexerPublicDataProvider( uris.indexerUri, uris.indexerWsUri, ), walletProvider: { coinPublicKey: walletState.coinPublicKey, encryptionPublicKey: walletState.encryptionPublicKey, balanceTx: (tx, newCoins) => { return walletAPI.balanceAndProveTransaction(tx, newCoins); }, }, midnightProvider: { submitTx: (tx) => { return walletAPI.submitTransaction(tx); }, }, };} Core operations[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#core-operations "Direct link to Core operations") ---------------------------------------------------------------------------------------------------------------------------------------------------------- These examples show the core contract workflows available in the SDK. ### Deploy a contract[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#deploy-a-contract "Direct link to Deploy a contract") Deploy a new contract instance and capture its address. import { MidnightSetupAPI } from "@meshsdk/midnight-setup";import { setupProviders } from "./providers";async function deployContract() { const providers = await setupProviders(); const contractInstance = new MyContract({}); const api = await MidnightSetupAPI.deployContract(providers, contractInstance); console.log("Contract deployed at:", api.deployedContractAddress); return api;} ### Join existing contract[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#join-existing-contract "Direct link to Join existing contract") Connect to an already deployed contract by address. async function joinContract(contractAddress: string) { const providers = await setupProviders(); const contractInstance = new MyContract({}); const api = await MidnightSetupAPI.joinContract(providers, contractInstance, contractAddress); return api;} ### Read contract state[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#read-contract-state "Direct link to Read contract state") Query the contract and ledger state from the API. // Get contract stateconst contractState = await api.getContractState();console.log("Contract data:", contractState.data);// Get ledger stateconst ledgerState = await api.getLedgerState();console.log("Message:", ledgerState.ledgerState?.message); React integration[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#react-integration "Direct link to React integration") ---------------------------------------------------------------------------------------------------------------------------------------------------------------- Use the hook and component patterns below to wire the SDK into a React app. ### Custom hook[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#custom-hook "Direct link to Custom hook") Wrap the deploy and join flows in a reusable React hook. import { useState, useCallback } from 'react';import { MidnightSetupAPI } from '@meshsdk/midnight-setup';import { setupProviders } from './providers';export const useMidnightContract = () => { const [api, setApi] = useState(null); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); const deployContract = useCallback(async (contractInstance) => { setIsLoading(true); setError(null); try { const providers = await setupProviders(); const newApi = await MidnightSetupAPI.deployContract(providers, contractInstance); setApi(newApi); return newApi; } catch (err) { setError(err.message); throw err; } finally { setIsLoading(false); } }, []); const joinContract = useCallback(async (contractInstance, address) => { setIsLoading(true); setError(null); try { const providers = await setupProviders(); const newApi = await MidnightSetupAPI.joinContract(providers, contractInstance, address); setApi(newApi); return newApi; } catch (err) { setError(err.message); throw err; } finally { setIsLoading(false); } }, []); return { api, deployContract, joinContract, isLoading, error };}; ### React component[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#react-component "Direct link to React component") Use the hook in a simple contract manager UI. import React, { useState } from 'react';import { useMidnightContract } from './hooks/useMidnightContract';function ContractManager() { const { api, deployContract, joinContract, isLoading, error } = useMidnightContract(); const [contractAddress, setContractAddress] = useState(''); const handleDeploy = async () => { try { const contractInstance = new MyContract({}); const newApi = await deployContract(contractInstance); console.log('Deployed:', newApi.deployedContractAddress); } catch (err) { console.error('Deploy failed:', err); } }; const handleJoin = async () => { try { const contractInstance = new MyContract({}); await joinContract(contractInstance, contractAddress); console.log('Joined contract:', contractAddress); } catch (err) { console.error('Join failed:', err); } }; return (

Contract Manager

{error && (
Error: {error}
)}
setContractAddress(e.target.value)} />
);} Error handling[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#error-handling "Direct link to Error handling") ------------------------------------------------------------------------------------------------------------------------------------------------------- Use these patterns to surface common SDK errors and protect the UI. ### Common error patterns[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#common-error-patterns "Direct link to Common error patterns") Map known SDK errors to friendly messages. const handleMidnightError = (error: Error) => { if (error.message.includes('Please install Lace Beta Wallet')) { return 'Please install Lace Beta Wallet for Midnight Network'; } if (error.message.includes('Insufficient funds')) { return 'Insufficient funds for transaction'; } if (error.message.includes('Contract not found')) { return 'Contract address not found or invalid'; } return 'An unexpected error occurred';}; ### Error boundary[​](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#error-boundary "Direct link to Error boundary") Catch rendering errors and show a fallback UI. import React from 'react';export class MidnightErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(error) { return { hasError: true }; } componentDidCatch(error, errorInfo) { console.error('Midnight Error:', error, errorInfo); } render() { if (this.state.hasError) { return (

Something went wrong with Midnight Network

); } return this.props.children; }} * [Try the project](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#try-the-project) * [Clone the repository](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#clone-the-repository) * [Navigate to the folder](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#navigate-to-the-folder) * [Install dependencies](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#install-dependencies) * [Set environment variable](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#set-environment-variable) * [Build all packages](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#build-all-packages) * [Download fetch parameters](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#download-fetch-parameters) * [Start testnet with Docker](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#start-testnet-with-docker) * [Run the frontend](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#run-the-frontend) * [Provider setup](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#provider-setup) * [Core operations](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#core-operations) * [Deploy a contract](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#deploy-a-contract) * [Join existing contract](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#join-existing-contract) * [Read contract state](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#read-contract-state) * [React integration](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#react-integration) * [Custom hook](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#custom-hook) * [React component](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#react-component) * [Error handling](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#error-handling) * [Common error patterns](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#common-error-patterns) * [Error boundary](https://docs.midnight.network/sdks/community/build-using-meshsdk/example-integration#error-boundary) --- # upgradeFromTransient | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/upgradeFromTransient#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / upgradeFromTransient Function: upgradeFromTransient() ================================ `Internal` upgradeFromTransient(transient): Value Internal implementation of the upgrade from transient primitive Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/upgradeFromTransient#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------------------------- • **transient**: [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/upgradeFromTransient#returns "Direct link to Returns") ---------------------------------------------------------------------------------------------------------------------------------------- [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Throws[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/upgradeFromTransient#throws "Direct link to Throws") ------------------------------------------------------------------------------------------------------------------------------------- If transient does not encode a field element * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/upgradeFromTransient#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/upgradeFromTransient#returns) * [Throws](https://docs.midnight.network/api-reference/onchain-runtime/functions/upgradeFromTransient#throws) --- # ProofErasedTransaction | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ProofErasedTransaction Class: ProofErasedTransaction ============================= [Transaction](https://docs.midnight.network/api-reference/ledger/classes/Transaction) , with all proof information erased Primarily for use in testing, or handling data known to be correct from external information Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------------------- ### new ProofErasedTransaction()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#new-prooferasedtransaction "Direct link to new ProofErasedTransaction()") private new ProofErasedTransaction(): ProofErasedTransaction #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#returns "Direct link to Returns") [`ProofErasedTransaction`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------------- ### contractCalls[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#contractcalls "Direct link to contractCalls") readonly contractCalls: ContractAction[]; The contract interactions contained in this transaction * * * ### fallibleCoins[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#falliblecoins "Direct link to fallibleCoins") readonly fallibleCoins: undefined | ProofErasedOffer; The fallible Zswap offer * * * ### guaranteedCoins[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#guaranteedcoins "Direct link to guaranteedCoins") readonly guaranteedCoins: undefined | ProofErasedOffer; The guaranteed Zswap offer * * * ### mint[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#mint "Direct link to mint") readonly mint: undefined | ProofErasedAuthorizedMint; The mint this transaction represents, if applicable Methods[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------------- ### fees()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#fees "Direct link to fees()") fees(params): bigint The cost of this transaction, in the atomic unit of the base token #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#parameters "Direct link to Parameters") • **params**: [`LedgerParameters`](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#returns-1 "Direct link to Returns") `bigint` * * * ### identifiers()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#identifiers "Direct link to identifiers()") identifiers(): string[] Returns the set of identifiers contained within this transaction. Any of these _may_ be used to watch for a specific transaction. #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#returns-2 "Direct link to Returns") `string`\[\] * * * ### imbalances()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#imbalances "Direct link to imbalances()") imbalances(guaranteed, fees?): Map For given fees, and a given section (guaranteed/fallible), what the surplus or deficit of this transaction in any token type is. #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#parameters-1 "Direct link to Parameters") • **guaranteed**: `boolean` • **fees?**: `bigint` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#returns-3 "Direct link to Returns") `Map`<`string`, `bigint`\> * * * ### merge()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#merge "Direct link to merge()") merge(other): ProofErasedTransaction Merges this transaction with another #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#parameters-2 "Direct link to Parameters") • **other**: [`ProofErasedTransaction`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#returns-4 "Direct link to Returns") [`ProofErasedTransaction`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction) #### Throws[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#throws "Direct link to Throws") If both transactions have contract interactions, or they spend the same coins * * * ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#parameters-3 "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#returns-5 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#parameters-4 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#returns-6 "Direct link to Returns") `string` * * * ### wellFormed()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#wellformed "Direct link to wellFormed()") wellFormed(ref_state, strictness): void Tests well-formedness criteria, optionally including transaction balancing For obvious reasons, doesn't check proofs #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#parameters-5 "Direct link to Parameters") • **ref\_state**: [`LedgerState`](https://docs.midnight.network/api-reference/ledger/classes/LedgerState) • **strictness**: [`WellFormedStrictness`](https://docs.midnight.network/api-reference/ledger/classes/WellFormedStrictness) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#returns-7 "Direct link to Returns") `void` #### Throws[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#throws-1 "Direct link to Throws") If the transaction is not well-formed for any reason * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#deserialize "Direct link to deserialize()") static deserialize(raw, netid): ProofErasedTransaction #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#parameters-6 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#returns-8 "Direct link to Returns") [`ProofErasedTransaction`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#constructors) * [new ProofErasedTransaction()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#new-prooferasedtransaction) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#properties) * [contractCalls](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#contractcalls) * [fallibleCoins](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#falliblecoins) * [guaranteedCoins](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#guaranteedcoins) * [mint](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#mint) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#methods) * [fees()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#fees) * [identifiers()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#identifiers) * [imbalances()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#imbalances) * [merge()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#merge) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#tostring) * [wellFormed()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#wellformed) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction#deserialize) --- # QueryResults | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/QueryResults#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / QueryResults Class: QueryResults =================== The results of making a query against a specific state or context Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/QueryResults#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------ ### new QueryResults()[​](https://docs.midnight.network/api-reference/ledger/classes/QueryResults#new-queryresults "Direct link to new QueryResults()") private new QueryResults(): QueryResults #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/QueryResults#returns "Direct link to Returns") [`QueryResults`](https://docs.midnight.network/api-reference/ledger/classes/QueryResults) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/QueryResults#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------ ### context[​](https://docs.midnight.network/api-reference/ledger/classes/QueryResults#context "Direct link to context") readonly context: QueryContext; The context state after executing the query. This can be used to execute further queries * * * ### events[​](https://docs.midnight.network/api-reference/ledger/classes/QueryResults#events "Direct link to events") readonly events: GatherResult[]; Any events/results that occurred during or from the query * * * ### gasCost[​](https://docs.midnight.network/api-reference/ledger/classes/QueryResults#gascost "Direct link to gasCost") readonly gasCost: bigint; The measured cost of executing the query Methods[​](https://docs.midnight.network/api-reference/ledger/classes/QueryResults#methods "Direct link to Methods") --------------------------------------------------------------------------------------------------------------------- ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/QueryResults#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/QueryResults#parameters "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/QueryResults#returns-1 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/QueryResults#constructors) * [new QueryResults()](https://docs.midnight.network/api-reference/ledger/classes/QueryResults#new-queryresults) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/QueryResults#properties) * [context](https://docs.midnight.network/api-reference/ledger/classes/QueryResults#context) * [events](https://docs.midnight.network/api-reference/ledger/classes/QueryResults#events) * [gasCost](https://docs.midnight.network/api-reference/ledger/classes/QueryResults#gascost) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/QueryResults#methods) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/QueryResults#tostring) --- # runProgram | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/functions/runProgram#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / runProgram Function: runProgram() ====================== runProgram( initial, ops, cost_model, gas_limit?): VmResults Runs a VM program against an initial stack, with an optional gas limit Parameters[​](https://docs.midnight.network/api-reference/ledger/functions/runProgram#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------ • **initial**: [`VmStack`](https://docs.midnight.network/api-reference/ledger/classes/VmStack) • **ops**: [`Op`](https://docs.midnight.network/api-reference/ledger/type-aliases/Op) <`null`\>\[\] • **cost\_model**: [`CostModel`](https://docs.midnight.network/api-reference/ledger/classes/CostModel) • **gas\_limit?**: `bigint` Returns[​](https://docs.midnight.network/api-reference/ledger/functions/runProgram#returns "Direct link to Returns") --------------------------------------------------------------------------------------------------------------------- [`VmResults`](https://docs.midnight.network/api-reference/ledger/classes/VmResults) * [Parameters](https://docs.midnight.network/api-reference/ledger/functions/runProgram#parameters) * [Returns](https://docs.midnight.network/api-reference/ledger/functions/runProgram#returns) --- # TransactionCostModel | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / TransactionCostModel Class: TransactionCostModel =========================== Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#constructors "Direct link to Constructors") -------------------------------------------------------------------------------------------------------------------------------------------- ### new TransactionCostModel()[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#new-transactioncostmodel "Direct link to new TransactionCostModel()") private new TransactionCostModel(): TransactionCostModel #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#returns "Direct link to Returns") [`TransactionCostModel`](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#properties "Direct link to Properties") -------------------------------------------------------------------------------------------------------------------------------------- ### inputFeeOverhead[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#inputfeeoverhead "Direct link to inputFeeOverhead") readonly inputFeeOverhead: bigint; The increase in fees to expect from adding a new input to a transaction * * * ### outputFeeOverhead[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#outputfeeoverhead "Direct link to outputFeeOverhead") readonly outputFeeOverhead: bigint; The increase in fees to expect from adding a new output to a transaction Methods[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#methods "Direct link to Methods") ----------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#deserialize "Direct link to deserialize()") static deserialize(raw, netid): TransactionCostModel #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#returns-3 "Direct link to Returns") [`TransactionCostModel`](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel) * * * ### dummyTransactionCostModel()[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#dummytransactioncostmodel "Direct link to dummyTransactionCostModel()") static dummyTransactionCostModel(): TransactionCostModel A dummy cost model, for use in testing #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#returns-4 "Direct link to Returns") [`TransactionCostModel`](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#constructors) * [new TransactionCostModel()](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#new-transactioncostmodel) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#properties) * [inputFeeOverhead](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#inputfeeoverhead) * [outputFeeOverhead](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#outputfeeoverhead) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#methods) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#deserialize) * [dummyTransactionCostModel()](https://docs.midnight.network/api-reference/ledger/classes/TransactionCostModel#dummytransactioncostmodel) --- # ContractState | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/ContractState#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ContractState Class: ContractState ==================== The state of a contract, consisting primarily of the [data](https://docs.midnight.network/api-reference/ledger/classes/ContractState#data) accessible directly to the contract, and the map of [ContractOperation](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation) s that can be called on it, the keys of which can be accessed with [operations](https://docs.midnight.network/api-reference/ledger/classes/ContractState#operations) , and the individual operations can be read with [operation](https://docs.midnight.network/api-reference/ledger/classes/ContractState#operation) and written to with [setOperation](https://docs.midnight.network/api-reference/ledger/classes/ContractState#setoperation) . Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------- ### new ContractState()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#new-contractstate "Direct link to new ContractState()") new ContractState(): ContractState Creates a blank contract state #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#returns "Direct link to Returns") [`ContractState`](https://docs.midnight.network/api-reference/ledger/classes/ContractState) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------- ### data[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#data "Direct link to data") data: StateValue; The current value of the primary state of the contract * * * ### maintenanceAuthority[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#maintenanceauthority "Direct link to maintenanceAuthority") maintenanceAuthority: ContractMaintenanceAuthority; The maintenance authority associated with this contract Methods[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------- ### operation()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#operation "Direct link to operation()") operation(operation): undefined | ContractOperation Get the operation at a specific entry point name #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#parameters "Direct link to Parameters") • **operation**: `string` | `Uint8Array` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#returns-1 "Direct link to Returns") `undefined` | [`ContractOperation`](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation) * * * ### operations()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#operations "Direct link to operations()") operations(): (string | Uint8Array)[] Return a list of the entry points currently registered on this contract #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#returns-2 "Direct link to Returns") (`string` | `Uint8Array`)\[\] * * * ### query()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#query "Direct link to query()") query(query, cost_model): GatherResult[] Runs a series of operations against the current state, and returns the results #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#parameters-1 "Direct link to Parameters") • **query**: [`Op`](https://docs.midnight.network/api-reference/ledger/type-aliases/Op) <`null`\>\[\] • **cost\_model**: [`CostModel`](https://docs.midnight.network/api-reference/ledger/classes/CostModel) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#returns-3 "Direct link to Returns") [`GatherResult`](https://docs.midnight.network/api-reference/ledger/type-aliases/GatherResult) \[\] * * * ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#serialize "Direct link to serialize()") serialize(networkid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#parameters-2 "Direct link to Parameters") • **networkid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#returns-4 "Direct link to Returns") `Uint8Array` * * * ### setOperation()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#setoperation "Direct link to setOperation()") setOperation(operation, value): void Set a specific entry point name to contain a given operation #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#parameters-3 "Direct link to Parameters") • **operation**: `string` | `Uint8Array` • **value**: [`ContractOperation`](https://docs.midnight.network/api-reference/ledger/classes/ContractOperation) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#returns-5 "Direct link to Returns") `void` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#parameters-4 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#returns-6 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#deserialize "Direct link to deserialize()") static deserialize(raw, networkid): ContractState #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#parameters-5 "Direct link to Parameters") • **raw**: `Uint8Array` • **networkid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ContractState#returns-7 "Direct link to Returns") [`ContractState`](https://docs.midnight.network/api-reference/ledger/classes/ContractState) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/ContractState#constructors) * [new ContractState()](https://docs.midnight.network/api-reference/ledger/classes/ContractState#new-contractstate) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/ContractState#properties) * [data](https://docs.midnight.network/api-reference/ledger/classes/ContractState#data) * [maintenanceAuthority](https://docs.midnight.network/api-reference/ledger/classes/ContractState#maintenanceauthority) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/ContractState#methods) * [operation()](https://docs.midnight.network/api-reference/ledger/classes/ContractState#operation) * [operations()](https://docs.midnight.network/api-reference/ledger/classes/ContractState#operations) * [query()](https://docs.midnight.network/api-reference/ledger/classes/ContractState#query) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/ContractState#serialize) * [setOperation()](https://docs.midnight.network/api-reference/ledger/classes/ContractState#setoperation) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/ContractState#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/ContractState#deserialize) --- # SystemTransaction | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / SystemTransaction Class: SystemTransaction ======================== A priviledged transaction issued by the system. Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction#constructors "Direct link to Constructors") ----------------------------------------------------------------------------------------------------------------------------------------- ### new SystemTransaction()[​](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction#new-systemtransaction "Direct link to new SystemTransaction()") private new SystemTransaction(): SystemTransaction #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction#returns "Direct link to Returns") [`SystemTransaction`](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction) Methods[​](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction#methods "Direct link to Methods") -------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction#deserialize "Direct link to deserialize()") static deserialize(raw, netid): Transaction #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction#returns-3 "Direct link to Returns") [`Transaction`](https://docs.midnight.network/api-reference/ledger/classes/Transaction) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction#constructors) * [new SystemTransaction()](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction#new-systemtransaction) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction#methods) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/SystemTransaction#deserialize) --- # runProgram | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/runProgram#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / runProgram Function: runProgram() ====================== runProgram( initial, ops, cost_model, gas_limit?): VmResults Runs a VM program against an initial stack, with an optional gas limit Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/runProgram#parameters "Direct link to Parameters") --------------------------------------------------------------------------------------------------------------------------------------- • **initial**: [`VmStack`](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmStack) • **ops**: [`Op`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Op) <`null`\>\[\] • **cost\_model**: [`CostModel`](https://docs.midnight.network/api-reference/onchain-runtime/classes/CostModel) • **gas\_limit?**: `bigint` Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/runProgram#returns "Direct link to Returns") ------------------------------------------------------------------------------------------------------------------------------ [`VmResults`](https://docs.midnight.network/api-reference/onchain-runtime/classes/VmResults) * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/runProgram#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/runProgram#returns) --- # transientHash | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/onchain-runtime/functions/transientHash#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/onchain-runtime v0.2.2** • [Readme](https://docs.midnight.network/api-reference/onchain-runtime) | [API](https://docs.midnight.network/api-reference/onchain-runtime/globals) * * * [@midnight-ntwrk/onchain-runtime v0.2.2](https://docs.midnight.network/api-reference/onchain-runtime) / transientHash Function: transientHash() ========================= `Internal` transientHash(align, val): Value Internal implementation of the transient hash primitive Parameters[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/transientHash#parameters "Direct link to Parameters") ------------------------------------------------------------------------------------------------------------------------------------------ • **align**: [`Alignment`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Alignment) • **val**: [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Returns[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/transientHash#returns "Direct link to Returns") --------------------------------------------------------------------------------------------------------------------------------- [`Value`](https://docs.midnight.network/api-reference/onchain-runtime/type-aliases/Value) Throws[​](https://docs.midnight.network/api-reference/onchain-runtime/functions/transientHash#throws "Direct link to Throws") ------------------------------------------------------------------------------------------------------------------------------ If val does not have alignment align * [Parameters](https://docs.midnight.network/api-reference/onchain-runtime/functions/transientHash#parameters) * [Returns](https://docs.midnight.network/api-reference/onchain-runtime/functions/transientHash#returns) * [Throws](https://docs.midnight.network/api-reference/onchain-runtime/functions/transientHash#throws) --- # TransactionResult | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/TransactionResult#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / TransactionResult Class: TransactionResult ======================== The result status of applying a transaction. Includes an error message if the transaction failed, or partially failed. Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionResult#constructors "Direct link to Constructors") ----------------------------------------------------------------------------------------------------------------------------------------- ### new TransactionResult()[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionResult#new-transactionresult "Direct link to new TransactionResult()") private new TransactionResult(): TransactionResult #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionResult#returns "Direct link to Returns") [`TransactionResult`](https://docs.midnight.network/api-reference/ledger/classes/TransactionResult) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionResult#properties "Direct link to Properties") ----------------------------------------------------------------------------------------------------------------------------------- ### error?[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionResult#error "Direct link to error?") optional readonly error: string; * * * ### type[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionResult#type "Direct link to type") readonly type: "success" | "partialSuccess" | "failure"; Methods[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionResult#methods "Direct link to Methods") -------------------------------------------------------------------------------------------------------------------------- ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionResult#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionResult#parameters "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionResult#returns-1 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/TransactionResult#constructors) * [new TransactionResult()](https://docs.midnight.network/api-reference/ledger/classes/TransactionResult#new-transactionresult) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/TransactionResult#properties) * [error?](https://docs.midnight.network/api-reference/ledger/classes/TransactionResult#error) * [type](https://docs.midnight.network/api-reference/ledger/classes/TransactionResult#type) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/TransactionResult#methods) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/TransactionResult#tostring) --- # VerifierKeyRemove | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyRemove#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / VerifierKeyRemove Class: VerifierKeyRemove ======================== An update instruction to remove a verifier key of a specific operation and version. Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyRemove#constructors "Direct link to Constructors") ----------------------------------------------------------------------------------------------------------------------------------------- ### new VerifierKeyRemove(operation, version)[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyRemove#new-verifierkeyremoveoperation-version "Direct link to new VerifierKeyRemove(operation, version)") new VerifierKeyRemove(operation, version): VerifierKeyRemove #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyRemove#parameters "Direct link to Parameters") • **operation**: `string` | `Uint8Array` • **version**: [`ContractOperationVersion`](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersion) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyRemove#returns "Direct link to Returns") [`VerifierKeyRemove`](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyRemove) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyRemove#properties "Direct link to Properties") ----------------------------------------------------------------------------------------------------------------------------------- ### operation[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyRemove#operation "Direct link to operation") readonly operation: string | Uint8Array; * * * ### version[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyRemove#version "Direct link to version") readonly version: ContractOperationVersion; Methods[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyRemove#methods "Direct link to Methods") -------------------------------------------------------------------------------------------------------------------------- ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyRemove#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyRemove#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyRemove#returns-1 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyRemove#constructors) * [new VerifierKeyRemove(operation, version)](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyRemove#new-verifierkeyremoveoperation-version) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyRemove#properties) * [operation](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyRemove#operation) * [version](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyRemove#version) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyRemove#methods) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyRemove#tostring) --- # VmResults | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/VmResults#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / VmResults Class: VmResults ================ Represents the results of a VM call Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/VmResults#constructors "Direct link to Constructors") --------------------------------------------------------------------------------------------------------------------------------- ### new VmResults()[​](https://docs.midnight.network/api-reference/ledger/classes/VmResults#new-vmresults "Direct link to new VmResults()") private new VmResults(): VmResults #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/VmResults#returns "Direct link to Returns") [`VmResults`](https://docs.midnight.network/api-reference/ledger/classes/VmResults) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/VmResults#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------- ### events[​](https://docs.midnight.network/api-reference/ledger/classes/VmResults#events "Direct link to events") readonly events: GatherResult[]; The events that got emitted by this VM invocation * * * ### gasCost[​](https://docs.midnight.network/api-reference/ledger/classes/VmResults#gascost "Direct link to gasCost") readonly gasCost: bigint; The computed gas cost of running this VM invocation * * * ### stack[​](https://docs.midnight.network/api-reference/ledger/classes/VmResults#stack "Direct link to stack") readonly stack: VmStack; The VM stack at the end of the VM invocation Methods[​](https://docs.midnight.network/api-reference/ledger/classes/VmResults#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------ ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/VmResults#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/VmResults#parameters "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/VmResults#returns-1 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/VmResults#constructors) * [new VmResults()](https://docs.midnight.network/api-reference/ledger/classes/VmResults#new-vmresults) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/VmResults#properties) * [events](https://docs.midnight.network/api-reference/ledger/classes/VmResults#events) * [gasCost](https://docs.midnight.network/api-reference/ledger/classes/VmResults#gascost) * [stack](https://docs.midnight.network/api-reference/ledger/classes/VmResults#stack) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/VmResults#methods) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/VmResults#tostring) --- # VmStack | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/VmStack#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / VmStack Class: VmStack ============== Represents the state of the VM's stack at a specific point. The stack is an array of [StateValue](https://docs.midnight.network/api-reference/ledger/classes/StateValue) s, each of which is also annotated with whether it is "strong" or "weak"; that is, whether it is permitted to be stored on-chain or not. Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/VmStack#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------- ### new VmStack()[​](https://docs.midnight.network/api-reference/ledger/classes/VmStack#new-vmstack "Direct link to new VmStack()") new VmStack(): VmStack #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/VmStack#returns "Direct link to Returns") [`VmStack`](https://docs.midnight.network/api-reference/ledger/classes/VmStack) Methods[​](https://docs.midnight.network/api-reference/ledger/classes/VmStack#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------- ### get()[​](https://docs.midnight.network/api-reference/ledger/classes/VmStack#get "Direct link to get()") get(idx): undefined | StateValue #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/VmStack#parameters "Direct link to Parameters") • **idx**: `number` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/VmStack#returns-1 "Direct link to Returns") `undefined` | [`StateValue`](https://docs.midnight.network/api-reference/ledger/classes/StateValue) * * * ### isStrong()[​](https://docs.midnight.network/api-reference/ledger/classes/VmStack#isstrong "Direct link to isStrong()") isStrong(idx): undefined | boolean #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/VmStack#parameters-1 "Direct link to Parameters") • **idx**: `number` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/VmStack#returns-2 "Direct link to Returns") `undefined` | `boolean` * * * ### length()[​](https://docs.midnight.network/api-reference/ledger/classes/VmStack#length "Direct link to length()") length(): number #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/VmStack#returns-3 "Direct link to Returns") `number` * * * ### push()[​](https://docs.midnight.network/api-reference/ledger/classes/VmStack#push "Direct link to push()") push(value, is_strong): void #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/VmStack#parameters-2 "Direct link to Parameters") • **value**: [`StateValue`](https://docs.midnight.network/api-reference/ledger/classes/StateValue) • **is\_strong**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/VmStack#returns-4 "Direct link to Returns") `void` * * * ### removeLast()[​](https://docs.midnight.network/api-reference/ledger/classes/VmStack#removelast "Direct link to removeLast()") removeLast(): void #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/VmStack#returns-5 "Direct link to Returns") `void` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/VmStack#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/VmStack#parameters-3 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/VmStack#returns-6 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/VmStack#constructors) * [new VmStack()](https://docs.midnight.network/api-reference/ledger/classes/VmStack#new-vmstack) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/VmStack#methods) * [get()](https://docs.midnight.network/api-reference/ledger/classes/VmStack#get) * [isStrong()](https://docs.midnight.network/api-reference/ledger/classes/VmStack#isstrong) * [length()](https://docs.midnight.network/api-reference/ledger/classes/VmStack#length) * [push()](https://docs.midnight.network/api-reference/ledger/classes/VmStack#push) * [removeLast()](https://docs.midnight.network/api-reference/ledger/classes/VmStack#removelast) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/VmStack#tostring) --- # Transient | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/Transient#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / Transient Class: Transient ================ A shielded "transient"; an output that is immediately spent within the same transaction Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/Transient#constructors "Direct link to Constructors") --------------------------------------------------------------------------------------------------------------------------------- ### new Transient()[​](https://docs.midnight.network/api-reference/ledger/classes/Transient#new-transient "Direct link to new Transient()") private new Transient(): Transient #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Transient#returns "Direct link to Returns") [`Transient`](https://docs.midnight.network/api-reference/ledger/classes/Transient) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/Transient#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------- ### commitment[​](https://docs.midnight.network/api-reference/ledger/classes/Transient#commitment "Direct link to commitment") readonly commitment: string; The commitment of the transient * * * ### contractAddress[​](https://docs.midnight.network/api-reference/ledger/classes/Transient#contractaddress "Direct link to contractAddress") readonly contractAddress: undefined | string; The contract address creating the transient, if applicable * * * ### nullifier[​](https://docs.midnight.network/api-reference/ledger/classes/Transient#nullifier "Direct link to nullifier") readonly nullifier: string; The nullifier of the transient Methods[​](https://docs.midnight.network/api-reference/ledger/classes/Transient#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------ ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/Transient#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Transient#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Transient#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/Transient#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Transient#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Transient#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/Transient#deserialize "Direct link to deserialize()") static deserialize(raw, netid): Transient #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Transient#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Transient#returns-3 "Direct link to Returns") [`Transient`](https://docs.midnight.network/api-reference/ledger/classes/Transient) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/Transient#constructors) * [new Transient()](https://docs.midnight.network/api-reference/ledger/classes/Transient#new-transient) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/Transient#properties) * [commitment](https://docs.midnight.network/api-reference/ledger/classes/Transient#commitment) * [contractAddress](https://docs.midnight.network/api-reference/ledger/classes/Transient#contractaddress) * [nullifier](https://docs.midnight.network/api-reference/ledger/classes/Transient#nullifier) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/Transient#methods) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/Transient#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/Transient#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/Transient#deserialize) --- # VerifierKeyInsert | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyInsert#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / VerifierKeyInsert Class: VerifierKeyInsert ======================== An update instruction to insert a verifier key at a specific operation and version. Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyInsert#constructors "Direct link to Constructors") ----------------------------------------------------------------------------------------------------------------------------------------- ### new VerifierKeyInsert(operation, vk)[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyInsert#new-verifierkeyinsertoperation-vk "Direct link to new VerifierKeyInsert(operation, vk)") new VerifierKeyInsert(operation, vk): VerifierKeyInsert #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyInsert#parameters "Direct link to Parameters") • **operation**: `string` | `Uint8Array` • **vk**: [`ContractOperationVersionedVerifierKey`](https://docs.midnight.network/api-reference/ledger/classes/ContractOperationVersionedVerifierKey) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyInsert#returns "Direct link to Returns") [`VerifierKeyInsert`](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyInsert) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyInsert#properties "Direct link to Properties") ----------------------------------------------------------------------------------------------------------------------------------- ### operation[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyInsert#operation "Direct link to operation") readonly operation: string | Uint8Array; * * * ### vk[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyInsert#vk "Direct link to vk") readonly vk: ContractOperationVersionedVerifierKey; Methods[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyInsert#methods "Direct link to Methods") -------------------------------------------------------------------------------------------------------------------------- ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyInsert#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyInsert#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyInsert#returns-1 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyInsert#constructors) * [new VerifierKeyInsert(operation, vk)](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyInsert#new-verifierkeyinsertoperation-vk) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyInsert#properties) * [operation](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyInsert#operation) * [vk](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyInsert#vk) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyInsert#methods) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/VerifierKeyInsert#tostring) --- # UnprovenAuthorizedMint | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / UnprovenAuthorizedMint Class: UnprovenAuthorizedMint ============================= A request to mint a coin, authorized by the mint's recipient, without the proof for the authorization being generated Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------------------- ### new UnprovenAuthorizedMint()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#new-unprovenauthorizedmint "Direct link to new UnprovenAuthorizedMint()") private new UnprovenAuthorizedMint(): UnprovenAuthorizedMint #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#returns "Direct link to Returns") [`UnprovenAuthorizedMint`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------------- ### coin[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#coin "Direct link to coin") readonly coin: CoinInfo; The coin to be minted * * * ### recipient[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#recipient "Direct link to recipient") readonly recipient: string; The recipient of this mint Methods[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------------- ### erase\_proof()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#erase_proof "Direct link to erase_proof()") erase_proof(): ProofErasedAuthorizedMint #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#returns-1 "Direct link to Returns") [`ProofErasedAuthorizedMint`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedAuthorizedMint) * * * ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#returns-2 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#returns-3 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#deserialize "Direct link to deserialize()") static deserialize(raw, netid): UnprovenAuthorizedMint #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#returns-4 "Direct link to Returns") [`UnprovenAuthorizedMint`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#constructors) * [new UnprovenAuthorizedMint()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#new-unprovenauthorizedmint) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#properties) * [coin](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#coin) * [recipient](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#recipient) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#methods) * [erase\_proof()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#erase_proof) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint#deserialize) --- # StateBoundedMerkleTree | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / StateBoundedMerkleTree Class: StateBoundedMerkleTree ============================= Represents a fixed-depth Merkle tree storing hashed data, whose preimages are unknown Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------------------- ### new StateBoundedMerkleTree(height)[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#new-stateboundedmerkletreeheight "Direct link to new StateBoundedMerkleTree(height)") new StateBoundedMerkleTree(height): StateBoundedMerkleTree Create a blank tree with the given height #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#parameters "Direct link to Parameters") • **height**: `number` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#returns "Direct link to Returns") [`StateBoundedMerkleTree`](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#properties "Direct link to Properties") ---------------------------------------------------------------------------------------------------------------------------------------- ### height[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#height "Direct link to height") readonly height: number; Methods[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------------- ### collapse()[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#collapse "Direct link to collapse()") `Internal` collapse(start, end): StateBoundedMerkleTree Erases all but necessary hashes between, and inclusive of, `start` and `end` inidices #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#parameters-1 "Direct link to Parameters") • **start**: `bigint` • **end**: `bigint` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#returns-1 "Direct link to Returns") [`StateBoundedMerkleTree`](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree) #### Throws[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#throws "Direct link to Throws") If the indices are out-of-bounds for the tree, or `end < start` * * * ### findPathForLeaf()[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#findpathforleaf "Direct link to findPathForLeaf()") `Internal` findPathForLeaf(leaf): AlignedValue Internal implementation of the finding path primitive #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#parameters-2 "Direct link to Parameters") • **leaf**: [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#returns-2 "Direct link to Returns") [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) #### Throws[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#throws-1 "Direct link to Throws") If the leaf is not in the tree * * * ### pathForLeaf()[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#pathforleaf "Direct link to pathForLeaf()") `Internal` pathForLeaf(index, leaf): AlignedValue Internal implementation of the path construction primitive #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#parameters-3 "Direct link to Parameters") • **index**: `bigint` • **leaf**: [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#returns-3 "Direct link to Returns") [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) #### Throws[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#throws-2 "Direct link to Throws") If the index is out-of-bounds for the tree * * * ### root()[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#root "Direct link to root()") `Internal` root(): Value Internal implementation of the merkle tree root primitive #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#returns-4 "Direct link to Returns") [`Value`](https://docs.midnight.network/api-reference/ledger/type-aliases/Value) * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#parameters-4 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#returns-5 "Direct link to Returns") `string` * * * ### update()[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#update "Direct link to update()") update(index, leaf): StateBoundedMerkleTree Inserts a value into the Merkle tree, returning the updated tree #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#parameters-5 "Direct link to Parameters") • **index**: `bigint` • **leaf**: [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#returns-6 "Direct link to Returns") [`StateBoundedMerkleTree`](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree) #### Throws[​](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#throws-3 "Direct link to Throws") If the index is out-of-bounds for the tree * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#constructors) * [new StateBoundedMerkleTree(height)](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#new-stateboundedmerkletreeheight) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#properties) * [height](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#height) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#methods) * [collapse()](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#collapse) * [findPathForLeaf()](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#findpathforleaf) * [pathForLeaf()](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#pathforleaf) * [root()](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#root) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#tostring) * [update()](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree#update) --- # TransactionContext | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/TransactionContext#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / TransactionContext Class: TransactionContext ========================= The context against which a transaction is run. Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionContext#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------ ### new TransactionContext(ref\_state, block\_context, whitelist)[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionContext#new-transactioncontextref_state-block_context-whitelist "Direct link to new TransactionContext(ref_state, block_context, whitelist)") new TransactionContext( ref_state, block_context, whitelist?): TransactionContext #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionContext#parameters "Direct link to Parameters") • **ref\_state**: [`LedgerState`](https://docs.midnight.network/api-reference/ledger/classes/LedgerState) A past ledger state that is used as a reference point for 'static' data. • **block\_context**: [`BlockContext`](https://docs.midnight.network/api-reference/ledger/type-aliases/BlockContext) Information about the block this transaction is, or will be, contained in. • **whitelist?**: `Set`<`string`\> A list of contracts that are being tracked, or `undefined` to track all contracts. #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionContext#returns "Direct link to Returns") [`TransactionContext`](https://docs.midnight.network/api-reference/ledger/classes/TransactionContext) Methods[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionContext#methods "Direct link to Methods") --------------------------------------------------------------------------------------------------------------------------- ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionContext#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionContext#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/TransactionContext#returns-1 "Direct link to Returns") `string` * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/TransactionContext#constructors) * [new TransactionContext(ref\_state, block\_context, whitelist)](https://docs.midnight.network/api-reference/ledger/classes/TransactionContext#new-transactioncontextref_state-block_context-whitelist) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/TransactionContext#methods) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/TransactionContext#tostring) --- # StateValue | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/StateValue#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / StateValue Class: StateValue ================= Represents the core of a contract's state, and recursively represents each of its components. There are different _classes_ of state values: * `null` * Cells of [AlignedValue](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) s * Maps from [AlignedValue](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) s to state values * Bounded Merkle trees containing [AlignedValue](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) leaves * Short (<= 15 element) arrays of state values State values are _immutable_, any operations that mutate states will return a new state instead. Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#constructors "Direct link to Constructors") ---------------------------------------------------------------------------------------------------------------------------------- ### new StateValue()[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#new-statevalue "Direct link to new StateValue()") private new StateValue(): StateValue #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#returns "Direct link to Returns") [`StateValue`](https://docs.midnight.network/api-reference/ledger/classes/StateValue) Methods[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------- ### arrayPush()[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#arraypush "Direct link to arrayPush()") arrayPush(value): StateValue #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#parameters "Direct link to Parameters") • **value**: [`StateValue`](https://docs.midnight.network/api-reference/ledger/classes/StateValue) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#returns-1 "Direct link to Returns") [`StateValue`](https://docs.midnight.network/api-reference/ledger/classes/StateValue) * * * ### asArray()[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#asarray "Direct link to asArray()") asArray(): undefined | StateValue[] #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#returns-2 "Direct link to Returns") `undefined` | [`StateValue`](https://docs.midnight.network/api-reference/ledger/classes/StateValue) \[\] * * * ### asBoundedMerkleTree()[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#asboundedmerkletree "Direct link to asBoundedMerkleTree()") asBoundedMerkleTree(): undefined | StateBoundedMerkleTree #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#returns-3 "Direct link to Returns") `undefined` | [`StateBoundedMerkleTree`](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree) * * * ### asCell()[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#ascell "Direct link to asCell()") asCell(): AlignedValue #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#returns-4 "Direct link to Returns") [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) * * * ### asMap()[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#asmap "Direct link to asMap()") asMap(): undefined | StateMap #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#returns-5 "Direct link to Returns") `undefined` | [`StateMap`](https://docs.midnight.network/api-reference/ledger/classes/StateMap) * * * ### encode()[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#encode "Direct link to encode()") `Internal` encode(): EncodedStateValue #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#returns-6 "Direct link to Returns") [`EncodedStateValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/EncodedStateValue) * * * ### logSize()[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#logsize "Direct link to logSize()") logSize(): number #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#returns-7 "Direct link to Returns") `number` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#returns-8 "Direct link to Returns") `string` * * * ### type()[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#type "Direct link to type()") type(): | "map" | "null" | "cell" | "array" | "boundedMerkleTree" #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#returns-9 "Direct link to Returns") | `"map"` | `"null"` | `"cell"` | `"array"` | `"boundedMerkleTree"` * * * ### decode()[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#decode "Direct link to decode()") `Internal` static decode(value): StateValue #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#parameters-2 "Direct link to Parameters") • **value**: [`EncodedStateValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/EncodedStateValue) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#returns-10 "Direct link to Returns") [`StateValue`](https://docs.midnight.network/api-reference/ledger/classes/StateValue) * * * ### newArray()[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#newarray "Direct link to newArray()") static newArray(): StateValue #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#returns-11 "Direct link to Returns") [`StateValue`](https://docs.midnight.network/api-reference/ledger/classes/StateValue) * * * ### newBoundedMerkleTree()[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#newboundedmerkletree "Direct link to newBoundedMerkleTree()") static newBoundedMerkleTree(tree): StateValue #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#parameters-3 "Direct link to Parameters") • **tree**: [`StateBoundedMerkleTree`](https://docs.midnight.network/api-reference/ledger/classes/StateBoundedMerkleTree) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#returns-12 "Direct link to Returns") [`StateValue`](https://docs.midnight.network/api-reference/ledger/classes/StateValue) * * * ### newCell()[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#newcell "Direct link to newCell()") static newCell(value): StateValue #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#parameters-4 "Direct link to Parameters") • **value**: [`AlignedValue`](https://docs.midnight.network/api-reference/ledger/type-aliases/AlignedValue) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#returns-13 "Direct link to Returns") [`StateValue`](https://docs.midnight.network/api-reference/ledger/classes/StateValue) * * * ### newMap()[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#newmap "Direct link to newMap()") static newMap(map): StateValue #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#parameters-5 "Direct link to Parameters") • **map**: [`StateMap`](https://docs.midnight.network/api-reference/ledger/classes/StateMap) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#returns-14 "Direct link to Returns") [`StateValue`](https://docs.midnight.network/api-reference/ledger/classes/StateValue) * * * ### newNull()[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#newnull "Direct link to newNull()") static newNull(): StateValue #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/StateValue#returns-15 "Direct link to Returns") [`StateValue`](https://docs.midnight.network/api-reference/ledger/classes/StateValue) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/StateValue#constructors) * [new StateValue()](https://docs.midnight.network/api-reference/ledger/classes/StateValue#new-statevalue) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/StateValue#methods) * [arrayPush()](https://docs.midnight.network/api-reference/ledger/classes/StateValue#arraypush) * [asArray()](https://docs.midnight.network/api-reference/ledger/classes/StateValue#asarray) * [asBoundedMerkleTree()](https://docs.midnight.network/api-reference/ledger/classes/StateValue#asboundedmerkletree) * [asCell()](https://docs.midnight.network/api-reference/ledger/classes/StateValue#ascell) * [asMap()](https://docs.midnight.network/api-reference/ledger/classes/StateValue#asmap) * [encode()](https://docs.midnight.network/api-reference/ledger/classes/StateValue#encode) * [logSize()](https://docs.midnight.network/api-reference/ledger/classes/StateValue#logsize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/StateValue#tostring) * [type()](https://docs.midnight.network/api-reference/ledger/classes/StateValue#type) * [decode()](https://docs.midnight.network/api-reference/ledger/classes/StateValue#decode) * [newArray()](https://docs.midnight.network/api-reference/ledger/classes/StateValue#newarray) * [newBoundedMerkleTree()](https://docs.midnight.network/api-reference/ledger/classes/StateValue#newboundedmerkletree) * [newCell()](https://docs.midnight.network/api-reference/ledger/classes/StateValue#newcell) * [newMap()](https://docs.midnight.network/api-reference/ledger/classes/StateValue#newmap) * [newNull()](https://docs.midnight.network/api-reference/ledger/classes/StateValue#newnull) --- # WellFormedStrictness | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/WellFormedStrictness#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / WellFormedStrictness Class: WellFormedStrictness =========================== Strictness criteria for evaluating transaction well-formedness, used for disabling parts of transaction validation for testing. Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/WellFormedStrictness#constructors "Direct link to Constructors") -------------------------------------------------------------------------------------------------------------------------------------------- ### new WellFormedStrictness()[​](https://docs.midnight.network/api-reference/ledger/classes/WellFormedStrictness#new-wellformedstrictness "Direct link to new WellFormedStrictness()") new WellFormedStrictness(): WellFormedStrictness #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/WellFormedStrictness#returns "Direct link to Returns") [`WellFormedStrictness`](https://docs.midnight.network/api-reference/ledger/classes/WellFormedStrictness) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/WellFormedStrictness#properties "Direct link to Properties") -------------------------------------------------------------------------------------------------------------------------------------- ### enforceBalancing[​](https://docs.midnight.network/api-reference/ledger/classes/WellFormedStrictness#enforcebalancing "Direct link to enforceBalancing") enforceBalancing: boolean; Whether to require the transaction to have a non-negative balance * * * ### verifyContractProofs[​](https://docs.midnight.network/api-reference/ledger/classes/WellFormedStrictness#verifycontractproofs "Direct link to verifyContractProofs") verifyContractProofs: boolean; Whether to validate contract proofs in the transaction * * * ### verifyNativeProofs[​](https://docs.midnight.network/api-reference/ledger/classes/WellFormedStrictness#verifynativeproofs "Direct link to verifyNativeProofs") verifyNativeProofs: boolean; Whether to validate Midnight-native (non-contract) proofs in the transaction * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/WellFormedStrictness#constructors) * [new WellFormedStrictness()](https://docs.midnight.network/api-reference/ledger/classes/WellFormedStrictness#new-wellformedstrictness) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/WellFormedStrictness#properties) * [enforceBalancing](https://docs.midnight.network/api-reference/ledger/classes/WellFormedStrictness#enforcebalancing) * [verifyContractProofs](https://docs.midnight.network/api-reference/ledger/classes/WellFormedStrictness#verifycontractproofs) * [verifyNativeProofs](https://docs.midnight.network/api-reference/ledger/classes/WellFormedStrictness#verifynativeproofs) --- # UnprovenOffer | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / UnprovenOffer Class: UnprovenOffer ==================== A [Offer](https://docs.midnight.network/api-reference/ledger/classes/Offer) , prior to being proven All "shielded" information in the offer can still be extracted at this stage! Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------- ### new UnprovenOffer()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#new-unprovenoffer "Direct link to new UnprovenOffer()") new UnprovenOffer(): UnprovenOffer #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#returns "Direct link to Returns") [`UnprovenOffer`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------- ### deltas[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#deltas "Direct link to deltas") readonly deltas: Map; The value of this offer for each token type; note that this may be negative This is input coin values - output coin values, for value vectors * * * ### inputs[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#inputs "Direct link to inputs") readonly inputs: UnprovenInput[]; The inputs this offer is composed of * * * ### outputs[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#outputs "Direct link to outputs") readonly outputs: UnprovenOutput[]; The outputs this offer is composed of * * * ### transient[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#transient "Direct link to transient") readonly transient: UnprovenTransient[]; The transients this offer is composed of Methods[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------- ### merge()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#merge "Direct link to merge()") merge(other): UnprovenOffer Combine this offer with another #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#parameters "Direct link to Parameters") • **other**: [`UnprovenOffer`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#returns-1 "Direct link to Returns") [`UnprovenOffer`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer) * * * ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#parameters-1 "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#returns-2 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#parameters-2 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#returns-3 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#deserialize "Direct link to deserialize()") static deserialize(raw, netid): UnprovenOffer #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#parameters-3 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#returns-4 "Direct link to Returns") [`UnprovenOffer`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer) * * * ### fromInput()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#frominput "Direct link to fromInput()") static fromInput( input, type_, value): UnprovenOffer Creates a singleton offer, from an [UnprovenInput](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput) and its value vector #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#parameters-4 "Direct link to Parameters") • **input**: [`UnprovenInput`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput) • **type\_**: `string` • **value**: `bigint` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#returns-5 "Direct link to Returns") [`UnprovenOffer`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer) * * * ### fromOutput()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#fromoutput "Direct link to fromOutput()") static fromOutput( output, type_, value): UnprovenOffer Creates a singleton offer, from an [UnprovenOutput](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput) and its value vector #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#parameters-5 "Direct link to Parameters") • **output**: [`UnprovenOutput`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput) • **type\_**: `string` • **value**: `bigint` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#returns-6 "Direct link to Returns") [`UnprovenOffer`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer) * * * ### fromTransient()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#fromtransient "Direct link to fromTransient()") static fromTransient(transient): UnprovenOffer Creates a singleton offer, from an [UnprovenTransient](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient) #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#parameters-6 "Direct link to Parameters") • **transient**: [`UnprovenTransient`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#returns-7 "Direct link to Returns") [`UnprovenOffer`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#constructors) * [new UnprovenOffer()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#new-unprovenoffer) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#properties) * [deltas](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#deltas) * [inputs](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#inputs) * [outputs](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#outputs) * [transient](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#transient) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#methods) * [merge()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#merge) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#deserialize) * [fromInput()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#frominput) * [fromOutput()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#fromoutput) * [fromTransient()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer#fromtransient) --- # UnprovenTransaction | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / UnprovenTransaction Class: UnprovenTransaction ========================== [Transaction](https://docs.midnight.network/api-reference/ledger/classes/Transaction) , prior to being proven All "shielded" information in the transaction can still be extracted at this stage! Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------------- ### new UnprovenTransaction(guaranteed, fallible, calls)[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#new-unproventransactionguaranteed-fallible-calls "Direct link to new UnprovenTransaction(guaranteed, fallible, calls)") new UnprovenTransaction( guaranteed, fallible?, calls?): UnprovenTransaction Creates the transaction from guaranteed/fallible [UnprovenOffer](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer) s, and a [ContractCallsPrototype](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype) . #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#parameters "Direct link to Parameters") • **guaranteed**: [`UnprovenOffer`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer) • **fallible?**: [`UnprovenOffer`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOffer) • **calls?**: [`ContractCallsPrototype`](https://docs.midnight.network/api-reference/ledger/classes/ContractCallsPrototype) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#returns "Direct link to Returns") [`UnprovenTransaction`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------------- ### contractCalls[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#contractcalls "Direct link to contractCalls") readonly contractCalls: ContractAction[]; The contract interactions contained in this transaction * * * ### fallibleCoins[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#falliblecoins "Direct link to fallibleCoins") readonly fallibleCoins: undefined | UnprovenOffer; The fallible Zswap offer * * * ### guaranteedCoins[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#guaranteedcoins "Direct link to guaranteedCoins") readonly guaranteedCoins: undefined | UnprovenOffer; The guaranteed Zswap offer * * * ### mint[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#mint "Direct link to mint") readonly mint: undefined | UnprovenAuthorizedMint; The mint this transaction represents, if applicable Methods[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------------- ### eraseProofs()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#eraseproofs "Direct link to eraseProofs()") eraseProofs(): ProofErasedTransaction Erases the proofs contained in this transaction #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#returns-1 "Direct link to Returns") [`ProofErasedTransaction`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction) * * * ### identifiers()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#identifiers "Direct link to identifiers()") identifiers(): string[] Returns the set of identifiers contained within this transaction. Any of these _may_ be used to watch for a specific transaction. #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#returns-2 "Direct link to Returns") `string`\[\] * * * ### imbalances()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#imbalances "Direct link to imbalances()") imbalances(guaranteed, fees?): Map For given fees, and a given section (guaranteed/fallible), what the surplus or deficit of this transaction in any token type is. #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#parameters-1 "Direct link to Parameters") • **guaranteed**: `boolean` • **fees?**: `bigint` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#returns-3 "Direct link to Returns") `Map`<`string`, `bigint`\> * * * ### merge()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#merge "Direct link to merge()") merge(other): UnprovenTransaction Merges this transaction with another #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#parameters-2 "Direct link to Parameters") • **other**: [`UnprovenTransaction`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#returns-4 "Direct link to Returns") [`UnprovenTransaction`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction) #### Throws[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#throws "Direct link to Throws") If both transactions have contract interactions, or they spend the same coins * * * ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#parameters-3 "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#returns-5 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#parameters-4 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#returns-6 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#deserialize "Direct link to deserialize()") static deserialize(raw, netid): UnprovenTransaction #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#parameters-5 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#returns-7 "Direct link to Returns") [`UnprovenTransaction`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction) * * * ### fromMint()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#frommint "Direct link to fromMint()") static fromMint(mint): UnprovenTransaction Creates a minting claim transaction, the funds claimed must have been legitimately minted previously. #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#parameters-6 "Direct link to Parameters") • **mint**: [`UnprovenAuthorizedMint`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenAuthorizedMint) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#returns-8 "Direct link to Returns") [`UnprovenTransaction`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#constructors) * [new UnprovenTransaction(guaranteed, fallible, calls)](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#new-unproventransactionguaranteed-fallible-calls) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#properties) * [contractCalls](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#contractcalls) * [fallibleCoins](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#falliblecoins) * [guaranteedCoins](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#guaranteedcoins) * [mint](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#mint) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#methods) * [eraseProofs()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#eraseproofs) * [identifiers()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#identifiers) * [imbalances()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#imbalances) * [merge()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#merge) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#deserialize) * [fromMint()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction#frommint) --- # UnprovenInput | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / UnprovenInput Class: UnprovenInput ==================== A [Input](https://docs.midnight.network/api-reference/ledger/classes/Input) , before being proven All "shielded" information in the input can still be extracted at this stage! Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#constructors "Direct link to Constructors") ------------------------------------------------------------------------------------------------------------------------------------- ### new UnprovenInput()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#new-unproveninput "Direct link to new UnprovenInput()") private new UnprovenInput(): UnprovenInput #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#returns "Direct link to Returns") [`UnprovenInput`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#properties "Direct link to Properties") ------------------------------------------------------------------------------------------------------------------------------- ### contractAddress[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#contractaddress "Direct link to contractAddress") readonly contractAddress: undefined | string; The contract address receiving the input, if the sender is a contract * * * ### nullifier[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#nullifier "Direct link to nullifier") readonly nullifier: string; The nullifier of the input Methods[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#methods "Direct link to Methods") ---------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#deserialize "Direct link to deserialize()") static deserialize(raw, netid): UnprovenInput #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#returns-3 "Direct link to Returns") [`UnprovenInput`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput) * * * ### newContractOwned()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#newcontractowned "Direct link to newContractOwned()") static newContractOwned( coin, contract, state): UnprovenInput Creates a new input, spending a specific coin from a smart contract, against a state which contains this coin. Note that inputs created in this way _also_ need to be authorized by the contract #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#parameters-3 "Direct link to Parameters") • **coin**: [`QualifiedCoinInfo`](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo) • **contract**: `string` • **state**: [`ZswapChainState`](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#returns-4 "Direct link to Returns") [`UnprovenInput`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#constructors) * [new UnprovenInput()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#new-unproveninput) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#properties) * [contractAddress](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#contractaddress) * [nullifier](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#nullifier) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#methods) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#deserialize) * [newContractOwned()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenInput#newcontractowned) --- # Transaction | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/Transaction#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / Transaction Class: Transaction ================== A Midnight transaction, consisting a section of [ContractAction](https://docs.midnight.network/api-reference/ledger/type-aliases/ContractAction) s, and a guaranteed and fallible [Offer](https://docs.midnight.network/api-reference/ledger/classes/Offer) . The guaranteed section are run first, and fee payment is taken during this part. If it succeeds, the fallible section is also run, and atomically rolled back if it fails. Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#constructors "Direct link to Constructors") ----------------------------------------------------------------------------------------------------------------------------------- ### new Transaction()[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#new-transaction "Direct link to new Transaction()") private new Transaction(): Transaction #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#returns "Direct link to Returns") [`Transaction`](https://docs.midnight.network/api-reference/ledger/classes/Transaction) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#properties "Direct link to Properties") ----------------------------------------------------------------------------------------------------------------------------- ### contractCalls[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#contractcalls "Direct link to contractCalls") readonly contractCalls: ContractAction[]; The contract interactions contained in this transaction * * * ### fallibleCoins[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#falliblecoins "Direct link to fallibleCoins") readonly fallibleCoins: undefined | Offer; The fallible Zswap offer * * * ### guaranteedCoins[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#guaranteedcoins "Direct link to guaranteedCoins") readonly guaranteedCoins: undefined | Offer; The guaranteed Zswap offer * * * ### mint[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#mint "Direct link to mint") readonly mint: undefined | AuthorizedMint; The mint this transaction represents, if applicable Methods[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#methods "Direct link to Methods") -------------------------------------------------------------------------------------------------------------------- ### eraseProofs()[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#eraseproofs "Direct link to eraseProofs()") eraseProofs(): ProofErasedTransaction Erases the proofs contained in this transaction #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#returns-1 "Direct link to Returns") [`ProofErasedTransaction`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedTransaction) * * * ### fees()[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#fees "Direct link to fees()") fees(params): bigint The cost of this transaction, in the atomic unit of the base token #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#parameters "Direct link to Parameters") • **params**: [`LedgerParameters`](https://docs.midnight.network/api-reference/ledger/classes/LedgerParameters) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#returns-2 "Direct link to Returns") `bigint` * * * ### identifiers()[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#identifiers "Direct link to identifiers()") identifiers(): string[] Returns the set of identifiers contained within this transaction. Any of these _may_ be used to watch for a specific transaction. #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#returns-3 "Direct link to Returns") `string`\[\] * * * ### imbalances()[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#imbalances "Direct link to imbalances()") imbalances(guaranteed, fees?): Map For given fees, and a given section (guaranteed/fallible), what the surplus or deficit of this transaction in any token type is. #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#parameters-1 "Direct link to Parameters") • **guaranteed**: `boolean` • **fees?**: `bigint` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#returns-4 "Direct link to Returns") `Map`<`string`, `bigint`\> * * * ### merge()[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#merge "Direct link to merge()") merge(other): Transaction Merges this transaction with another #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#parameters-2 "Direct link to Parameters") • **other**: [`Transaction`](https://docs.midnight.network/api-reference/ledger/classes/Transaction) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#returns-5 "Direct link to Returns") [`Transaction`](https://docs.midnight.network/api-reference/ledger/classes/Transaction) #### Throws[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#throws "Direct link to Throws") If both transactions have contract interactions, or they spend the same coins * * * ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#parameters-3 "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#returns-6 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#parameters-4 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#returns-7 "Direct link to Returns") `string` * * * ### transactionHash()[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#transactionhash "Direct link to transactionHash()") transactionHash(): string Returns the hash associated with this transaction. Due to the ability to merge transactions, this should not be used to watch for a specific transaction. #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#returns-8 "Direct link to Returns") `string` * * * ### wellFormed()[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#wellformed "Direct link to wellFormed()") wellFormed(ref_state, strictness): void Tests well-formedness criteria, optionally including transaction balancing #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#parameters-5 "Direct link to Parameters") • **ref\_state**: [`LedgerState`](https://docs.midnight.network/api-reference/ledger/classes/LedgerState) • **strictness**: [`WellFormedStrictness`](https://docs.midnight.network/api-reference/ledger/classes/WellFormedStrictness) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#returns-9 "Direct link to Returns") `void` #### Throws[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#throws-1 "Direct link to Throws") If the transaction is not well-formed for any reason * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#deserialize "Direct link to deserialize()") static deserialize(raw, netid): Transaction #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#parameters-6 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#returns-10 "Direct link to Returns") [`Transaction`](https://docs.midnight.network/api-reference/ledger/classes/Transaction) * * * ### fromUnproven()[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#fromunproven "Direct link to fromUnproven()") static fromUnproven(prove, unproven): Promise Type hint that you should use an external proving function, for instance via the proof server. #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#parameters-7 "Direct link to Parameters") • **prove** • **unproven**: [`UnprovenTransaction`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransaction) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/Transaction#returns-11 "Direct link to Returns") `Promise`<[`Transaction`](https://docs.midnight.network/api-reference/ledger/classes/Transaction) \> * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/Transaction#constructors) * [new Transaction()](https://docs.midnight.network/api-reference/ledger/classes/Transaction#new-transaction) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/Transaction#properties) * [contractCalls](https://docs.midnight.network/api-reference/ledger/classes/Transaction#contractcalls) * [fallibleCoins](https://docs.midnight.network/api-reference/ledger/classes/Transaction#falliblecoins) * [guaranteedCoins](https://docs.midnight.network/api-reference/ledger/classes/Transaction#guaranteedcoins) * [mint](https://docs.midnight.network/api-reference/ledger/classes/Transaction#mint) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/Transaction#methods) * [eraseProofs()](https://docs.midnight.network/api-reference/ledger/classes/Transaction#eraseproofs) * [fees()](https://docs.midnight.network/api-reference/ledger/classes/Transaction#fees) * [identifiers()](https://docs.midnight.network/api-reference/ledger/classes/Transaction#identifiers) * [imbalances()](https://docs.midnight.network/api-reference/ledger/classes/Transaction#imbalances) * [merge()](https://docs.midnight.network/api-reference/ledger/classes/Transaction#merge) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/Transaction#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/Transaction#tostring) * [transactionHash()](https://docs.midnight.network/api-reference/ledger/classes/Transaction#transactionhash) * [wellFormed()](https://docs.midnight.network/api-reference/ledger/classes/Transaction#wellformed) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/Transaction#deserialize) * [fromUnproven()](https://docs.midnight.network/api-reference/ledger/classes/Transaction#fromunproven) --- # UnprovenOutput | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / UnprovenOutput Class: UnprovenOutput ===================== An [Output](https://docs.midnight.network/api-reference/ledger/classes/Output) before being proven All "shielded" information in the output can still be extracted at this stage! Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#constructors "Direct link to Constructors") -------------------------------------------------------------------------------------------------------------------------------------- ### new UnprovenOutput()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#new-unprovenoutput "Direct link to new UnprovenOutput()") private new UnprovenOutput(): UnprovenOutput #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#returns "Direct link to Returns") [`UnprovenOutput`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#properties "Direct link to Properties") -------------------------------------------------------------------------------------------------------------------------------- ### commitment[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#commitment "Direct link to commitment") readonly commitment: string; The commitment of the output * * * ### contractAddress[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#contractaddress "Direct link to contractAddress") readonly contractAddress: undefined | string; The contract address receiving the output, if the recipient is a contract Methods[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#methods "Direct link to Methods") ----------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#deserialize "Direct link to deserialize()") static deserialize(raw, netid): UnprovenOutput #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#returns-3 "Direct link to Returns") [`UnprovenOutput`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput) * * * ### new()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#new "Direct link to new()") static new( coin, target_cpk, target_epk?): UnprovenOutput Creates a new output, targeted to a user's coin public key. Optionally the output contains a ciphertext encrypted to the user's encryption public key, which may be omitted _only_ if the [CoinInfo](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo) is transferred to the recipient another way #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#parameters-3 "Direct link to Parameters") • **coin**: [`CoinInfo`](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo) • **target\_cpk**: `string` • **target\_epk?**: `string` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#returns-4 "Direct link to Returns") [`UnprovenOutput`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput) * * * ### newContractOwned()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#newcontractowned "Direct link to newContractOwned()") static newContractOwned(coin, contract): UnprovenOutput Creates a new output, targeted to a smart contract A contract must _also_ explicitly receive a coin created in this way for the output to be valid #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#parameters-4 "Direct link to Parameters") • **coin**: [`CoinInfo`](https://docs.midnight.network/api-reference/ledger/type-aliases/CoinInfo) • **contract**: `string` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#returns-5 "Direct link to Returns") [`UnprovenOutput`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#constructors) * [new UnprovenOutput()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#new-unprovenoutput) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#properties) * [commitment](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#commitment) * [contractAddress](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#contractaddress) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#methods) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#deserialize) * [new()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#new) * [newContractOwned()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput#newcontractowned) --- # ZswapChainState | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / ZswapChainState Class: ZswapChainState ====================== The on-chain state of Zswap, consisting of a Merkle tree of coin commitments, a set of nullifiers, an index into the Merkle tree, and a set of valid past Merkle tree roots Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#constructors "Direct link to Constructors") --------------------------------------------------------------------------------------------------------------------------------------- ### new ZswapChainState()[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#new-zswapchainstate "Direct link to new ZswapChainState()") new ZswapChainState(): ZswapChainState #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#returns "Direct link to Returns") [`ZswapChainState`](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#properties "Direct link to Properties") --------------------------------------------------------------------------------------------------------------------------------- ### firstFree[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#firstfree "Direct link to firstFree") readonly firstFree: bigint; The first free index in the coin commitment tree Methods[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#methods "Direct link to Methods") ------------------------------------------------------------------------------------------------------------------------ ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#returns-2 "Direct link to Returns") `string` * * * ### tryApply()[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#tryapply "Direct link to tryApply()") tryApply(offer, whitelist?): [ZswapChainState, Map] Try to apply an [Offer](https://docs.midnight.network/api-reference/ledger/classes/Offer) to the state, returning the updated state and a map on newly inserted coin commitments to their inserted indices. #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#parameters-2 "Direct link to Parameters") • **offer**: [`Offer`](https://docs.midnight.network/api-reference/ledger/classes/Offer) • **whitelist?**: `Set`<`string`\> A set of contract addresses that are of interest. If set, _only_ these addresses are tracked, and all other information is discarded. #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#returns-3 "Direct link to Returns") \[[`ZswapChainState`](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState)\ , `Map`<`string`, `bigint`\>\] * * * ### tryApplyProofErased()[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#tryapplyprooferased "Direct link to tryApplyProofErased()") tryApplyProofErased(offer, whitelist?): [ZswapChainState, Map] [tryApply](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#tryapply) for [ProofErasedOffer](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer) s #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#parameters-3 "Direct link to Parameters") • **offer**: [`ProofErasedOffer`](https://docs.midnight.network/api-reference/ledger/classes/ProofErasedOffer) • **whitelist?**: `Set`<`string`\> #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#returns-4 "Direct link to Returns") \[[`ZswapChainState`](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState)\ , `Map`<`string`, `bigint`\>\] * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#deserialize "Direct link to deserialize()") static deserialize(raw, netid): ZswapChainState #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#parameters-4 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#returns-5 "Direct link to Returns") [`ZswapChainState`](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState) * * * ### deserializeFromLedgerState()[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#deserializefromledgerstate "Direct link to deserializeFromLedgerState()") static deserializeFromLedgerState(raw, netid): ZswapChainState Given a whole ledger serialized state, deserialize only the Zswap portion #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#parameters-5 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#returns-6 "Direct link to Returns") [`ZswapChainState`](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#constructors) * [new ZswapChainState()](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#new-zswapchainstate) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#properties) * [firstFree](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#firstfree) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#methods) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#tostring) * [tryApply()](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#tryapply) * [tryApplyProofErased()](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#tryapplyprooferased) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#deserialize) * [deserializeFromLedgerState()](https://docs.midnight.network/api-reference/ledger/classes/ZswapChainState#deserializefromledgerstate) --- # UnprovenTransient | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ **@midnight-ntwrk/ledger v3.0.2** • [Readme](https://docs.midnight.network/api-reference/ledger) | [API](https://docs.midnight.network/api-reference/ledger/globals) * * * [@midnight-ntwrk/ledger v3.0.2](https://docs.midnight.network/api-reference/ledger) / UnprovenTransient Class: UnprovenTransient ======================== A [Transient](https://docs.midnight.network/api-reference/ledger/classes/Transient) , before being proven All "shielded" information in the transient can still be extracted at this stage! Constructors[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#constructors "Direct link to Constructors") ----------------------------------------------------------------------------------------------------------------------------------------- ### new UnprovenTransient()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#new-unproventransient "Direct link to new UnprovenTransient()") private new UnprovenTransient(): UnprovenTransient #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#returns "Direct link to Returns") [`UnprovenTransient`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient) Properties[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#properties "Direct link to Properties") ----------------------------------------------------------------------------------------------------------------------------------- ### commitment[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#commitment "Direct link to commitment") readonly commitment: string; The commitment of the transient * * * ### contractAddress[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#contractaddress "Direct link to contractAddress") readonly contractAddress: undefined | string; The contract address creating the transient, if applicable * * * ### nullifier[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#nullifier "Direct link to nullifier") readonly nullifier: string; The nullifier of the transient Methods[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#methods "Direct link to Methods") -------------------------------------------------------------------------------------------------------------------------- ### serialize()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#serialize "Direct link to serialize()") serialize(netid): Uint8Array #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#parameters "Direct link to Parameters") • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#returns-1 "Direct link to Returns") `Uint8Array` * * * ### toString()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#tostring "Direct link to toString()") toString(compact?): string #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#parameters-1 "Direct link to Parameters") • **compact?**: `boolean` #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#returns-2 "Direct link to Returns") `string` * * * ### deserialize()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#deserialize "Direct link to deserialize()") static deserialize(raw, netid): UnprovenTransient #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#parameters-2 "Direct link to Parameters") • **raw**: `Uint8Array` • **netid**: [`NetworkId`](https://docs.midnight.network/api-reference/ledger/enumerations/NetworkId) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#returns-3 "Direct link to Returns") [`UnprovenTransient`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient) * * * ### newFromContractOwnedOutput()[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#newfromcontractownedoutput "Direct link to newFromContractOwnedOutput()") static newFromContractOwnedOutput(coin, output): UnprovenTransient Creates a new contract-owned transient, from a given output and its coin. The [QualifiedCoinInfo](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo) should have an `mt_index` of `0` #### Parameters[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#parameters-3 "Direct link to Parameters") • **coin**: [`QualifiedCoinInfo`](https://docs.midnight.network/api-reference/ledger/type-aliases/QualifiedCoinInfo) • **output**: [`UnprovenOutput`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenOutput) #### Returns[​](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#returns-4 "Direct link to Returns") [`UnprovenTransient`](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient) * [Constructors](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#constructors) * [new UnprovenTransient()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#new-unproventransient) * [Properties](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#properties) * [commitment](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#commitment) * [contractAddress](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#contractaddress) * [nullifier](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#nullifier) * [Methods](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#methods) * [serialize()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#serialize) * [toString()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#tostring) * [deserialize()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#deserialize) * [newFromContractOwnedOutput()](https://docs.midnight.network/api-reference/ledger/classes/UnprovenTransient#newfromcontractownedoutput) --- # addField | Midnight Docs [Skip to main content](https://docs.midnight.network/api-reference/compact-runtime/functions/addField#__docusaurus_skipToContent_fallback) On this page Explore with… ▾ [**@midnight-ntwrk/compact-runtime v0.14.0**](https://docs.midnight.network/api-reference/compact-runtime) * * * [@midnight-ntwrk/compact-runtime](https://docs.midnight.network/api-reference/compact-runtime/globals) / addField Function: addField() ==================== function addField(x, y): bigint; Field addition returns the result of adding x and y, wrapping if necessary x and y are assumed to be values in the range \[0, FIELD\_MODULUS)\ \ Parameters[​](https://docs.midnight.network/api-reference/compact-runtime/functions/addField#parameters "Direct link to Parameters")\ \ -------------------------------------------------------------------------------------------------------------------------------------\ \ ### x[​](https://docs.midnight.network/api-reference/compact-runtime/functions/addField#x "Direct link to x")\ \ `bigint`\ \ ### y[​](https://docs.midnight.network/api-reference/compact-runtime/functions/addField#y "Direct link to y")\ \ `bigint`\ \ Returns[​](https://docs.midnight.network/api-reference/compact-runtime/functions/addField#returns "Direct link to Returns")\ \ ----------------------------------------------------------------------------------------------------------------------------\ \ `bigint`\ \ * [Parameters](https://docs.midnight.network/api-reference/compact-runtime/functions/addField#parameters)\ * [x](https://docs.midnight.network/api-reference/compact-runtime/functions/addField#x)\ \ * [y](https://docs.midnight.network/api-reference/compact-runtime/functions/addField#y)\ \ * [Returns](https://docs.midnight.network/api-reference/compact-runtime/functions/addField#returns) ---