Mina
Namespace: Mina
Table of contents
Type Aliases
- ActionStates
- FeePayerSpec
- IncludedTransaction
- NetworkConstants
- PendingTransaction
- PendingTransactionStatus
- RejectedTransaction
- Transaction
Variables
Functions
- BerkeleyQANet
- LocalBlockchain
- Network
- accountCreationFee
- currentSlot
- currentTransaction
- faucet
- fetchActions
- fetchEvents
- filterGroups
- getAccount
- getActions
- getBalance
- getNetworkConstants
- getNetworkId
- getNetworkState
- getProofsEnabled
- hasAccount
- sender
- setActiveInstance
- transaction
- waitForFunding
Type Aliases
ActionStates
Ƭ ActionStates: Object
Type declaration
Name | Type |
---|---|
endActionState? | Field |
fromActionState? | Field |
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
IncludedTransaction
Ƭ IncludedTransaction: Pick
\<PendingTransaction
, "transaction"
| "toJSON"
| "toPretty"
| "hash"
| "data"
> & { status
: "included"
}
Represents a transaction that has been successfully included in a block.
Defined in
NetworkConstants
Ƭ NetworkConstants: Object
Type declaration
Name | Type | Description |
---|---|---|
accountCreationFee | UInt64 | - |
genesisTimestamp | UInt64 | - |
slotTime | UInt64 | Duration of 1 slot in millisecondw |
Defined in
PendingTransaction
Ƭ PendingTransaction: Pick
\<Transaction
, "transaction"
| "toJSON"
| "toPretty"
> & { data?
: SendZkAppResponse
; errors
: string
[] ; hash
: string
; status
: PendingTransactionStatus
; safeWait
: (options?
: { interval?
: number
; maxAttempts?
: number
}) => Promise
\<RejectedTransaction
| IncludedTransaction
> ; wait
: (options?
: { interval?
: number
; maxAttempts?
: number
}) => Promise
\<IncludedTransaction
> }
Represents a transaction that has been submitted to the blockchain but has not yet reached a final state. The PendingTransaction type extends certain functionalities from the base Transaction type, adding methods to monitor the transaction's progress towards being finalized (either included in a block or rejected).
Defined in
PendingTransactionStatus
Ƭ PendingTransactionStatus: "pending"
| "rejected"
Defined in
RejectedTransaction
Ƭ RejectedTransaction: Pick
\<PendingTransaction
, "transaction"
| "toJSON"
| "toPretty"
| "hash"
| "data"
> & { errors
: string
[] ; status
: "rejected"
}
Represents a transaction that has been rejected and not included in a blockchain block.
Defined in
Transaction
Ƭ Transaction: Object
Defines the structure and operations associated with a transaction. This type encompasses methods for serializing the transaction, signing it, generating proofs, and submitting it to the network.
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 >)[]> | Initiates the proof generation process for the Transaction. This asynchronous operation is crucial for zero-knowledge-based transactions, where proofs are required to validate state transitions. This can take some time. Example ts await transaction.prove(); |
safeSend | () => Promise \<PendingTransaction | RejectedTransaction > | Sends the Transaction to the network. Unlike the standard send, this function does not throw an error if internal errors are detected. Instead, it returns a PendingTransaction if the transaction is successfully sent for processing or a RejectedTransaction if it encounters errors during processing or is outright rejected by the Mina daemon. Example ts const result = await transaction.safeSend(); if (result.status === 'pending') { console.log('Transaction sent successfully to the Mina daemon.'); } else if (result.status === 'rejected') { console.error('Transaction failed with errors:', result.errors); } |
send | () => Promise \<PendingTransaction > | Submits the Transaction to the network. This method asynchronously sends the transaction for processing. If successful, it returns a PendingTransaction instance, which can be used to monitor the transaction's progress. If the transaction submission fails, this method throws an error that should be caught and handled appropriately. Throws An error if the transaction cannot be sent or processed by the network, containing details about the failure. Example ts try { const pendingTransaction = await transaction.send(); console.log('Transaction sent successfully to the Mina daemon.'); } catch (error) { console.error('Failed to send transaction to the Mina daemon:', error); } |
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() . Example ts const signedTx = transaction.sign([userPrivateKey]); console.log('Transaction signed successfully.'); |
toGraphqlQuery | () => string | Constructs the GraphQL query string used for submitting the transaction to a Mina daemon. |
toJSON | () => string | Serializes the transaction to a JSON string. |
toPretty | () => any | Produces a pretty-printed JSON representation of the Transaction. |
Defined in
Variables
activeInstance
• activeInstance: Mina
Defined in
Functions
BerkeleyQANet
▸ BerkeleyQANet(graphqlEndpoint
): Mina
Parameters
Name | Type |
---|---|
graphqlEndpoint | string |
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
LocalBlockchain
▸ LocalBlockchain(«destructured»?
): Object
A mock Mina blockchain running locally and useful for testing.
Parameters
Name | Type |
---|---|
«destructured» | Object |
› enforceTransactionLimits | undefined | boolean |
› networkId | undefined | NetworkId |
› proofsEnabled | undefined | boolean |
Returns
Object
Name | Type |
---|---|
accountCreationFee | () => UInt64 |
addAccount | (publicKey : PublicKey , balance : string ) => void |
getNetworkId | () => NetworkId |
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 \<PendingTransaction > |
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/local-blockchain.ts:45
Network
▸ Network(graphqlEndpoint
): Mina
Represents the Mina blockchain running on a real network
Parameters
Name | Type |
---|---|
graphqlEndpoint | string |
Returns
Mina
Defined in
▸ Network(options
): Mina
Parameters
Name | Type |
---|---|
options | Object |
options.archive? | string | string [] |
options.lightnetAccountManager? | string |
options.mina | string | string [] |
options.networkId? | NetworkId |
Returns
Mina
Defined in
accountCreationFee
▸ accountCreationFee(): UInt64
Returns the default account creation fee.
Returns
Deprecated
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
lib/mina/transaction-validation.ts:130
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
getNetworkConstants
▸ getNetworkConstants(): NetworkConstants
Returns
Data associated with the current Mina network constants.
Defined in
getNetworkId
▸ getNetworkId(): NetworkId
Returns
NetworkId
The current Mina network ID.
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
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
>
Parameters
Name | Type |
---|---|
sender | DeprecatedFeePayerSpec |
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
waitForFunding
▸ waitForFunding(address
): Promise
\<void
>
Parameters
Name | Type |
---|---|
address | string |
Returns
Promise
\<void
>