Mina
Namespace: Mina
Table of contents
Interfaces
Type Aliases
Variables
Functions
- BerkeleyQANet
 - LocalBlockchain
 - Network
 - accountCreationFee
 - createTransaction
 - currentSlot
 - currentTransaction
 - faucet
 - fetchActions
 - fetchEvents
 - filterGroups
 - getAccount
 - getActions
 - getBalance
 - getNetworkState
 - getProofsEnabled
 - hasAccount
 - sendTransaction
 - sender
 - setActiveInstance
 - transaction
 - waitForFunding
 
Type Aliases
ActionStates
Ƭ ActionStates: Object
Type declaration
| Name | Type | 
|---|---|
endActionState? | Field | 
fromActionState? | Field | 
Defined in
CurrentTransaction
Ƭ CurrentTransaction: Object
Type declaration
| Name | Type | 
|---|---|
accountUpdates | AccountUpdate[] | 
fetchMode | FetchMode | 
isFinalRunOutsideCircuit | boolean | 
numberOfRuns | 0 | 1 | undefined | 
sender? | PublicKey | 
Defined in
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
Transaction
Ƭ Transaction: Object
Type declaration
| Name | Type | Description | 
|---|---|---|
transaction | ZkappCommand | Transaction 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[]) => Transaction | Signs all AccountUpdates included in the Transaction that require a signature. AccountUpdates that require a signature can be specified with {AccountUpdate\|SmartContract}.requireSignature(). | 
toGraphqlQuery | () => string | Returns the GraphQL query for the Mina daemon. | 
toJSON | () => string | Returns a JSON representation of the Transaction. | 
toPretty | () => any | Returns a pretty-printed JSON representation of the Transaction. | 
Defined in
Variables
Transaction
• Transaction: Object
Type declaration
| Name | Type | 
|---|---|
fromJSON | (json: ZkappCommand) => Transaction | 
Defined in
activeInstance
• activeInstance: Mina
Defined in
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
| Name | Type | 
|---|---|
graphqlEndpoint | string | 
Returns
Mina
Defined in
LocalBlockchain
▸ LocalBlockchain(«destructured»?): Object
A mock Mina blockchain running locally and useful for testing.
Parameters
| Name | Type | 
|---|---|
«destructured» | Object | 
› accountCreationFee | undefined | string | number | 
› enforceTransactionLimits | undefined | boolean | 
› proofsEnabled | undefined | boolean | 
Returns
Object
| Name | Type | 
|---|---|
accountCreationFee | () => UInt64 | 
addAccount | (publicKey: PublicKey, balance: string) => void | 
proofsEnabled | boolean | 
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
Network
▸ Network(graphqlEndpoint): Mina
Represents the Mina blockchain running on a real network
Parameters
| Name | Type | 
|---|---|
graphqlEndpoint | string | 
Returns
Mina
Defined in
▸ Network(endpoints): Mina
Parameters
| Name | Type | 
|---|---|
endpoints | Object | 
endpoints.archive? | string | string[] | 
endpoints.lightnetAccountManager? | string | 
endpoints.mina | string | string[] | 
Returns
Mina
Defined in
accountCreationFee
▸ accountCreationFee(): UInt64
Returns the default account creation fee.
Returns
Defined in
createTransaction
▸ createTransaction(feePayer, f, numberOfRuns, «destructured»?): Transaction
Parameters
| Name | Type | 
|---|---|
feePayer | DeprecatedFeePayerSpec | 
f | () => unknown | 
numberOfRuns | undefined | 0 | 1 | 
«destructured» | Object | 
› fetchMode | undefined | FetchMode | 
› isFinalRunOutsideCircuit | undefined | boolean | 
› proofsEnabled | undefined | boolean | 
Returns
Defined in
currentSlot
▸ currentSlot(): UInt32
Returns
The current slot number, according to the active Mina instance.
Defined in
currentTransaction
▸ currentTransaction(): undefined | CurrentTransaction
Returns
undefined | CurrentTransaction
Defined in
faucet
▸ faucet(pub, network?): Promise<void>
Requests the testnet faucet to fund a public key.
Parameters
| Name | Type | Default value | 
|---|---|---|
pub | PublicKey | undefined | 
network | string | 'berkeley-qanet' | 
Returns
Promise<void>
Defined in
fetchActions
▸ fetchActions(publicKey, actionStates?, tokenId?): Promise<{ actions: string[][] ; hash: string  }[] | { error: { statusCode: number = 404; statusText: string  }  }>
Parameters
| Name | Type | 
|---|---|
publicKey | PublicKey | 
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
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
| Name | Type | 
|---|---|
publicKey | PublicKey | 
tokenId | Field | 
filterOptions | EventActionFilterOptions | 
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
filterGroups
▸ filterGroups(xs): Object
Parameters
| Name | Type | 
|---|---|
xs | AuthorizationKind[] | 
Returns
Object
| Name | Type | 
|---|---|
proof | number | 
signedPair | number | 
signedSingle | number | 
Defined in
getAccount
▸ getAccount(publicKey, tokenId?): Account
Parameters
| Name | Type | 
|---|---|
publicKey | PublicKey | 
tokenId? | Field | 
Returns
Account
The account data associated to the given public key.
Defined in
getActions
▸ getActions(publicKey, actionStates?, tokenId?): { actions: string[][] ; hash: string  }[]
Parameters
| Name | Type | 
|---|---|
publicKey | PublicKey | 
actionStates? | ActionStates | 
tokenId? | Field | 
Returns
{ actions: string[][] ; hash: string  }[]
A list of emitted sequencing actions associated to the given public key.
Defined in
getBalance
▸ getBalance(publicKey, tokenId?): UInt64
Parameters
| Name | Type | 
|---|---|
publicKey | PublicKey | 
tokenId? | Field | 
Returns
The balance associated to the given public key.
Defined in
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
getProofsEnabled
▸ getProofsEnabled(): boolean
Returns
boolean
Defined in
hasAccount
▸ hasAccount(publicKey, tokenId?): boolean
Checks if an account exists within the ledger.
Parameters
| Name | Type | 
|---|---|
publicKey | PublicKey | 
tokenId? | Field | 
Returns
boolean
Defined in
sendTransaction
▸ sendTransaction(txn): Promise<TransactionId>
Parameters
| Name | Type | 
|---|---|
txn | Transaction | 
Returns
Promise<TransactionId>
Defined in
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
Defined in
setActiveInstance
▸ setActiveInstance(m): void
Set the currently used Mina instance.
Parameters
| Name | Type | 
|---|---|
m | Mina | 
Returns
void
Defined in
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
| Name | Type | 
|---|---|
sender | FeePayerSpec | 
f | () => void | 
Returns
Promise<Transaction>
A transaction that can subsequently be submitted to the chain.
Defined in
▸ transaction(f): Promise<Transaction>
Parameters
| Name | Type | 
|---|---|
f | () => void | 
Returns
Promise<Transaction>
Defined in
▸ 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
| Name | Type | 
|---|---|
sender | DeprecatedFeePayerSpec | 
f | () => void | 
Returns
Promise<Transaction>
Defined in
waitForFunding
▸ waitForFunding(address): Promise<void>
Parameters
| Name | Type | 
|---|---|
address | string | 
Returns
Promise<void>