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:161


CurrentTransaction

Ƭ CurrentTransaction: Object

Type declaration

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

Defined in

lib/mina.ts:119


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:132


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:74

lib/mina.ts:111

Variables

Transaction

Transaction: Object

Type declaration

NameType
fromJSON(json: ZkappCommand) => Transaction

Defined in

lib/mina.ts:74

lib/mina.ts:111


activeInstance

activeInstance: Mina

Defined in

lib/mina.ts:996

Functions

BerkeleyQANet

BerkeleyQANet(graphqlEndpoint): 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.

Parameters

NameType
graphqlEndpointstring

Returns

Mina

Defined in

lib/mina.ts:992


LocalBlockchain

LocalBlockchain(«destructured»?): Object

A mock Mina blockchain running locally and useful for testing.

Parameters

NameType
«destructured»Object
› accountCreationFeeundefined | string | number
› enforceTransactionLimitsundefined | boolean
› proofsEnabledundefined | boolean

Returns

Object

NameType
accountCreationFee() => UInt64
addAccount(publicKey: PublicKey, balance: string) => void
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:376


Network

Network(graphqlEndpoint): Mina

Represents the Mina blockchain running on a real network

Parameters

NameType
graphqlEndpointstring

Returns

Mina

Defined in

lib/mina.ts:679

Network(endpoints): Mina

Parameters

NameType
endpointsObject
endpoints.archive?string | string[]
endpoints.lightnetAccountManager?string
endpoints.minastring | string[]

Returns

Mina

Defined in

lib/mina.ts:680


accountCreationFee

accountCreationFee(): UInt64

Returns the default account creation fee.

Returns

UInt64

Defined in

lib/mina.ts:1197


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:174


currentSlot

currentSlot(): UInt32

Returns

UInt32

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

Defined in

lib/mina.ts:1162


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:1577


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:1219


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:1208


filterGroups

filterGroups(xs): Object

Parameters

NameType
xsAuthorizationKind[]

Returns

Object

NameType
proofnumber
signedPairnumber
signedSinglenumber

Defined in

lib/mina.ts:1534


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:1169


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:1230


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:1190


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:1183


getProofsEnabled

getProofsEnabled(): boolean

Returns

boolean

Defined in

lib/mina.ts:1238


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:1176


sendTransaction

sendTransaction(txn): Promise<TransactionId>

Parameters

NameType
txnTransaction

Returns

Promise<TransactionId>

Defined in

lib/mina.ts:1201


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:1138


setActiveInstance

setActiveInstance(m): void

Set the currently used Mina instance.

Parameters

NameType
mMina

Returns

void

Defined in

lib/mina.ts:1078


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:1095

transaction(f): Promise<Transaction>

Parameters

NameType
f() => void

Returns

Promise<Transaction>

Defined in

lib/mina.ts:1096

transaction(sender, f): 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 }, ...);

Parameters

NameType
senderDeprecatedFeePayerSpec
f() => void

Returns

Promise<Transaction>

Defined in

lib/mina.ts:1109


waitForFunding

waitForFunding(address): Promise<void>

Parameters

NameType
addressstring

Returns

Promise<void>

Defined in

lib/mina.ts:1553