Skip to main content

Mina

o1js / Modules / Mina

Namespace: Mina

Table of contents

Interfaces

Type Aliases

Variables

Functions

Type Aliases

ActionStates

Ƭ ActionStates: Object

Type declaration

NameType
endActionState?Field
fromActionState?Field

Defined in

lib/mina.ts:166


CurrentTransaction

Ƭ CurrentTransaction: Object

Type declaration

NameType
accountUpdatesAccountUpdate[]
fetchModeFetchMode
isFinalRunOutsideCircuitboolean
numberOfRuns0 | 1 | undefined
sender?PublicKey

Defined in

lib/mina.ts:124


FeePayerSpec

Ƭ FeePayerSpec: PublicKey | { fee?: number | string | UInt64 ; memo?: string ; nonce?: number ; sender: PublicKey } | undefined

Allows you to specify information about the fee payer account and the transaction.

Defined in

lib/mina.ts:137


NetworkConstants

Ƭ NetworkConstants: Object

Type declaration

NameTypeDescription
accountCreationFeeUInt64-
genesisTimestampUInt64-
slotTimeUInt64Duration of 1 slot in milliseconds

Defined in

lib/mina.ts:171


Transaction

Ƭ Transaction: Object

Type declaration

NameTypeDescription
transactionZkappCommandTransaction structure used to describe a state transition on the Mina blockchain.
prove() => Promise\<(undefined | Proof\<ZkappPublicInput, undefined>)[]>Generates proofs for the Transaction. This can take some time.
send() => Promise\<TransactionId>Sends the Transaction to the network.
sign(additionalKeys?: PrivateKey[]) => TransactionSigns all AccountUpdates included in the Transaction that require a signature. AccountUpdates that require a signature can be specified with {AccountUpdate\|SmartContract}.requireSignature().
toGraphqlQuery() => stringReturns the GraphQL query for the Mina daemon.
toJSON() => stringReturns a JSON representation of the Transaction.
toPretty() => anyReturns a pretty-printed JSON representation of the Transaction.

Defined in

lib/mina.ts:79

lib/mina.ts:116

Variables

Transaction

Transaction: Object

Type declaration

NameType
fromJSON(json: ZkappCommand) => Transaction

Defined in

lib/mina.ts:79

lib/mina.ts:116


activeInstance

activeInstance: Mina

Defined in

lib/mina.ts:1029

Functions

BerkeleyQANet

BerkeleyQANet(graphqlEndpoint): Mina

Parameters

NameType
graphqlEndpointstring

Returns

Mina

Deprecated

This is deprecated in favor of Network, which is exactly the same function. The name BerkeleyQANet was misleading because it suggested that this is specific to a particular network.

Defined in

lib/mina.ts:1025


LocalBlockchain

LocalBlockchain(«destructured»?): Object

A mock Mina blockchain running locally and useful for testing.

Parameters

NameType
«destructured»Object
› enforceTransactionLimitsundefined | boolean
› networkIdundefined | NetworkId
› proofsEnabledundefined | boolean

Returns

Object

NameType
accountCreationFee() => UInt64
addAccount(publicKey: PublicKey, balance: string) => void
getNetworkId() => NetworkId
proofsEnabledboolean
testAccounts{ privateKey: PrivateKey ; publicKey: PublicKey }[]
applyJsonTransaction(json: string) => void
currentSlot() => UInt32
fetchActions(publicKey: PublicKey, actionStates?: ActionStates, tokenId: Field) => Promise\<{ actions: string[][] ; hash: string }[]>
fetchEvents(publicKey: PublicKey, tokenId: Field) => Promise\<any>
getAccount(publicKey: PublicKey, tokenId: Field) => Account
getActions(publicKey: PublicKey, actionStates?: ActionStates, tokenId: Field) => { actions: string[][] ; hash: string }[]
getNetworkConstants() => { accountCreationFee: UInt64 ; genesisTimestamp: UInt64 ; slotTime: UInt64 }
getNetworkState() => PreconditionBaseTypes\<{ blockchainLength: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; globalSlotSinceGenesis: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; minWindowDensity: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; nextEpochData: { epochLength: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; ledger: { hash: { isSome: Bool ; value: Field } ; totalCurrency: { isSome: Bool ; value: { lower: UInt64 ; upper: UInt64 } } } ; lockCheckpoint: { isSome: Bool ; value: Field } ; seed: { isSome: Bool ; value: Field } ; startCheckpoint: { isSome: Bool ; value: Field } } ; snarkedLedgerHash: { isSome: Bool ; value: Field } ; stakingEpochData: { epochLength: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; ledger: { hash: { isSome: Bool ; value: Field } ; totalCurrency: { isSome: Bool ; value: { lower: UInt64 ; upper: UInt64 } } } ; lockCheckpoint: { isSome: Bool ; value: Field } ; seed: { isSome: Bool ; value: Field } ; startCheckpoint: { isSome: Bool ; value: Field } } ; totalCurrency: { isSome: Bool ; value: { lower: UInt64 ; upper: UInt64 } } }>
hasAccount(publicKey: PublicKey, tokenId: Field) => boolean
incrementGlobalSlot(increment: number | UInt32) => void
sendTransaction(txn: Transaction) => Promise\<TransactionId>
setBlockchainLength(height: UInt32) => void
setGlobalSlot(slot: number | UInt32) => void
setProofsEnabled(newProofsEnabled: boolean) => void
setTotalCurrency(currency: UInt64) => void
transaction(sender: DeprecatedFeePayerSpec, f: () => void) => Promise\<Transaction>

Defined in

lib/mina.ts:392


Network

Network(graphqlEndpoint): Mina

Represents the Mina blockchain running on a real network

Parameters

NameType
graphqlEndpointstring

Returns

Mina

Defined in

lib/mina.ts:698

Network(options): Mina

Parameters

NameType
optionsObject
options.archive?string | string[]
options.lightnetAccountManager?string
options.minastring | string[]
options.networkId?NetworkId

Returns

Mina

Defined in

lib/mina.ts:699


accountCreationFee

accountCreationFee(): UInt64

Returns the default account creation fee.

Returns

UInt64

Deprecated

use getNetworkConstants

Defined in

lib/mina.ts:1249


createTransaction

createTransaction(feePayer, f, numberOfRuns, «destructured»?): Transaction

Parameters

NameType
feePayerDeprecatedFeePayerSpec
f() => unknown
numberOfRunsundefined | 0 | 1
«destructured»Object
› fetchModeundefined | FetchMode
› isFinalRunOutsideCircuitundefined | boolean
› proofsEnabledundefined | boolean

Returns

Transaction

Defined in

lib/mina.ts:188


currentSlot

currentSlot(): UInt32

Returns

UInt32

The current slot number, according to the active Mina instance.

Defined in

lib/mina.ts:1199


currentTransaction

currentTransaction(): undefined | CurrentTransaction

Returns

undefined | CurrentTransaction

Defined in

lib/global-context.ts:6


faucet

faucet(pub, network?): Promise\<void>

Requests the testnet faucet to fund a public key.

Parameters

NameTypeDefault value
pubPublicKeyundefined
networkstring'berkeley-qanet'

Returns

Promise\<void>

Defined in

lib/mina.ts:1630


fetchActions

fetchActions(publicKey, actionStates?, tokenId?): Promise\<{ actions: string[][] ; hash: string }[] | { error: { statusCode: number = 404; statusText: string } }>

Parameters

NameType
publicKeyPublicKey
actionStates?ActionStates
tokenId?Field

Returns

Promise\<{ actions: string[][] ; hash: string }[] | { error: { statusCode: number = 404; statusText: string } }>

A list of emitted sequencing actions associated to the given public key.

Defined in

lib/mina.ts:1271


fetchEvents

fetchEvents(publicKey, tokenId, filterOptions?): Promise\<{ blockHash: string = event.blockInfo.stateHash; blockHeight: UInt32 ; chainStatus: string = event.blockInfo.chainStatus; events: { data: string[] ; transactionInfo: { hash: string ; memo: string ; status: string } }[] ; globalSlot: UInt32 ; parentBlockHash: string = event.blockInfo.parentHash }[]>

Parameters

NameType
publicKeyPublicKey
tokenIdField
filterOptionsEventActionFilterOptions

Returns

Promise\<{ blockHash: string = event.blockInfo.stateHash; blockHeight: UInt32 ; chainStatus: string = event.blockInfo.chainStatus; events: { data: string[] ; transactionInfo: { hash: string ; memo: string ; status: string } }[] ; globalSlot: UInt32 ; parentBlockHash: string = event.blockInfo.parentHash }[]>

A list of emitted events associated to the given public key.

Defined in

lib/mina.ts:1260


filterGroups

filterGroups(xs): Object

Parameters

NameType
xsAuthorizationKind[]

Returns

Object

NameType
proofnumber
signedPairnumber
signedSinglenumber

Defined in

lib/mina.ts:1587


getAccount

getAccount(publicKey, tokenId?): Account

Parameters

NameType
publicKeyPublicKey
tokenId?Field

Returns

Account

The account data associated to the given public key.

Defined in

lib/mina.ts:1206


getActions

getActions(publicKey, actionStates?, tokenId?): { actions: string[][] ; hash: string }[]

Parameters

NameType
publicKeyPublicKey
actionStates?ActionStates
tokenId?Field

Returns

{ actions: string[][] ; hash: string }[]

A list of emitted sequencing actions associated to the given public key.

Defined in

lib/mina.ts:1282


getBalance

getBalance(publicKey, tokenId?): UInt64

Parameters

NameType
publicKeyPublicKey
tokenId?Field

Returns

UInt64

The balance associated to the given public key.

Defined in

lib/mina.ts:1241


getNetworkConstants

getNetworkConstants(): NetworkConstants

Returns

NetworkConstants

Data associated with the current Mina network constants.

Defined in

lib/mina.ts:1227


getNetworkId

getNetworkId(): NetworkId

Returns

NetworkId

The current Mina network ID.

Defined in

lib/mina.ts:1220


getNetworkState

getNetworkState(): PreconditionBaseTypes\<{ blockchainLength: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; globalSlotSinceGenesis: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; minWindowDensity: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; nextEpochData: { epochLength: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; ledger: { hash: { isSome: Bool ; value: Field } ; totalCurrency: { isSome: Bool ; value: { lower: UInt64 ; upper: UInt64 } } } ; lockCheckpoint: { isSome: Bool ; value: Field } ; seed: { isSome: Bool ; value: Field } ; startCheckpoint: { isSome: Bool ; value: Field } } ; snarkedLedgerHash: { isSome: Bool ; value: Field } ; stakingEpochData: { epochLength: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; ledger: { hash: { isSome: Bool ; value: Field } ; totalCurrency: { isSome: Bool ; value: { lower: UInt64 ; upper: UInt64 } } } ; lockCheckpoint: { isSome: Bool ; value: Field } ; seed: { isSome: Bool ; value: Field } ; startCheckpoint: { isSome: Bool ; value: Field } } ; totalCurrency: { isSome: Bool ; value: { lower: UInt64 ; upper: UInt64 } } }>

Returns

PreconditionBaseTypes\<{ blockchainLength: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; globalSlotSinceGenesis: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; minWindowDensity: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; nextEpochData: { epochLength: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; ledger: { hash: { isSome: Bool ; value: Field } ; totalCurrency: { isSome: Bool ; value: { lower: UInt64 ; upper: UInt64 } } } ; lockCheckpoint: { isSome: Bool ; value: Field } ; seed: { isSome: Bool ; value: Field } ; startCheckpoint: { isSome: Bool ; value: Field } } ; snarkedLedgerHash: { isSome: Bool ; value: Field } ; stakingEpochData: { epochLength: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; ledger: { hash: { isSome: Bool ; value: Field } ; totalCurrency: { isSome: Bool ; value: { lower: UInt64 ; upper: UInt64 } } } ; lockCheckpoint: { isSome: Bool ; value: Field } ; seed: { isSome: Bool ; value: Field } ; startCheckpoint: { isSome: Bool ; value: Field } } ; totalCurrency: { isSome: Bool ; value: { lower: UInt64 ; upper: UInt64 } } }>

Data associated with the current state of the Mina network.

Defined in

lib/mina.ts:1234


getProofsEnabled

getProofsEnabled(): boolean

Returns

boolean

Defined in

lib/mina.ts:1290


hasAccount

hasAccount(publicKey, tokenId?): boolean

Checks if an account exists within the ledger.

Parameters

NameType
publicKeyPublicKey
tokenId?Field

Returns

boolean

Defined in

lib/mina.ts:1213


sendTransaction

sendTransaction(txn): Promise\<TransactionId>

Parameters

NameType
txnTransaction

Returns

Promise\<TransactionId>

Defined in

lib/mina.ts:1253


sender

sender(): PublicKey

Returns the public key of the current transaction's sender account.

Throws an error if not inside a transaction, or the sender wasn't passed in.

Returns

PublicKey

Defined in

lib/mina.ts:1175


setActiveInstance

setActiveInstance(m): void

Set the currently used Mina instance.

Parameters

NameType
mMina

Returns

void

Defined in

lib/mina.ts:1115


transaction

transaction(sender, f): Promise\<Transaction>

Construct a smart contract transaction. Within the callback passed to this function, you can call into the methods of smart contracts.

let tx = await Mina.transaction(sender, () => {
myZkapp.update();
someOtherZkapp.someOtherMethod();
});

Parameters

NameType
senderFeePayerSpec
f() => void

Returns

Promise\<Transaction>

A transaction that can subsequently be submitted to the chain.

Defined in

lib/mina.ts:1132

transaction(f): Promise\<Transaction>

Parameters

NameType
f() => void

Returns

Promise\<Transaction>

Defined in

lib/mina.ts:1133

transaction(sender, f): Promise\<Transaction>

Parameters

NameType
senderDeprecatedFeePayerSpec
f() => void

Returns

Promise\<Transaction>

Deprecated

It's deprecated to pass in the fee payer's private key. Pass in the public key instead.

// good
Mina.transaction(publicKey, ...);
Mina.transaction({ sender: publicKey }, ...);

// deprecated
Mina.transaction(privateKey, ...);
Mina.transaction({ feePayerKey: privateKey }, ...);

Defined in

lib/mina.ts:1146


waitForFunding

waitForFunding(address): Promise\<void>

Parameters

NameType
addressstring

Returns

Promise\<void>

Defined in

lib/mina.ts:1606