Class: Ledger
Represents the Mina ledger.
Table of contents
Constructors
Properties
Methods
- addAccount
- applyJsonTransaction
- getAccount
- checkAccountUpdateSignature
- create
- createTokenAccount
- customTokenId
- customTokenIdChecked
- dummySignature
- fieldOfBase58
- fieldToBase58
- fieldsOfJson
- hashAccountUpdateFromFields
- hashAccountUpdateFromJson
- memoHashBase58
- memoToBase58
- privateKeyOfString
- privateKeyToString
- publicKeyOfString
- publicKeyToString
- signFeePayer
- signFieldElement
- signOtherAccountUpdate
- transactionCommitments
- zkappPublicInput
Constructors
constructor
• new Ledger()
Properties
encoding
▪ Static
encoding: Object
Type declaration
Name | Type |
---|---|
versionBytes | Record <"tokenIdKey" | "receiptChainHash" | "ledgerHash" | "epochSeed" | "stateHash" | "publicKey" | "userCommandMemo" , number > |
ofBase58 | (base58 : string , versionByte : number ) => MlBytes |
toBase58 | (s : MlBytes , versionByte : number ) => string |
Defined in
hashInputFromJson
▪ Static
hashInputFromJson: Object
Type declaration
Name | Type |
---|---|
accountPrecondition | (json : String ) => OcamlInput |
body | (json : String ) => OcamlInput |
networkPrecondition | (json : String ) => OcamlInput |
packInput | (input : OcamlInput ) => Field [] |
permissions | (json : String ) => OcamlInput |
timing | (json : String ) => OcamlInput |
update | (json : String ) => OcamlInput |
Defined in
Methods
addAccount
▸ addAccount(publicKey
, balance
): void
Adds an account and its balance to the ledger.
Parameters
Name | Type |
---|---|
publicKey | PublicKey_ |
balance | string |
Returns
void
Defined in
applyJsonTransaction
▸ applyJsonTransaction(txJson
, accountCreationFee
, networkState
): void
Applies a JSON transaction to the ledger.
Parameters
Name | Type |
---|---|
txJson | string |
accountCreationFee | string |
networkState | string |
Returns
void
Defined in
getAccount
▸ getAccount(publicKey
, tokenId
): undefined
| Account
Returns an account.
Parameters
Name | Type |
---|---|
publicKey | PublicKey_ |
tokenId | Field |
Returns
undefined
| Account
Defined in
checkAccountUpdateSignature
▸ Static
checkAccountUpdateSignature(updateJson
, commitment
): boolean
Parameters
Name | Type |
---|---|
updateJson | string |
commitment | Field |
Returns
boolean
Defined in
create
▸ Static
create(genesisAccounts
): Ledger
Creates a fresh ledger.
Parameters
Name | Type |
---|---|
genesisAccounts | { balance : string ; publicKey : PublicKey_ }[] |
Returns
Defined in
createTokenAccount
▸ Static
createTokenAccount(publicKey
, tokenId
): string
Parameters
Name | Type |
---|---|
publicKey | PublicKey_ |
tokenId | Field |
Returns
string
Defined in
customTokenId
▸ Static
customTokenId(publicKey
, tokenId
): Field
Parameters
Name | Type |
---|---|
publicKey | PublicKey_ |
tokenId | Field |
Returns
Defined in
customTokenIdChecked
▸ Static
customTokenIdChecked(publicKey
, tokenId
): Field
Parameters
Name | Type |
---|---|
publicKey | PublicKey_ |
tokenId | Field |
Returns
Defined in
dummySignature
▸ Static
dummySignature(): string
Returns a dummy signature.
Returns
string
Defined in
fieldOfBase58
▸ Static
fieldOfBase58(fieldBase58
): Field
Parameters
Name | Type |
---|---|
fieldBase58 | string |
Returns
Defined in
fieldToBase58
▸ Static
fieldToBase58(field
): string
Parameters
Name | Type |
---|---|
field | Field |
Returns
string
Defined in
fieldsOfJson
▸ Static
fieldsOfJson(json
): Field
[]
Parameters
Name | Type |
---|---|
json | string |
Returns
Field
[]
Defined in
hashAccountUpdateFromFields
▸ Static
hashAccountUpdateFromFields(fields
): Field
Parameters
Name | Type |
---|---|
fields | Field [] |
Returns
Defined in
hashAccountUpdateFromJson
▸ Static
hashAccountUpdateFromJson(json
): Field
Parameters
Name | Type |
---|---|
json | string |
Returns
Defined in
memoHashBase58
▸ Static
memoHashBase58(memoBase58
): Field
Parameters
Name | Type |
---|---|
memoBase58 | string |
Returns
Defined in
memoToBase58
▸ Static
memoToBase58(memoString
): string
Parameters
Name | Type |
---|---|
memoString | string |
Returns
string
Defined in
privateKeyOfString
▸ Static
privateKeyOfString(privateKeyBase58
): Scalar
Parameters
Name | Type |
---|---|
privateKeyBase58 | string |
Returns
Defined in
privateKeyToString
▸ Static
privateKeyToString(privateKey
): string
Parameters
Name | Type |
---|---|
privateKey | Object |
privateKey.s | Scalar |
Returns
string
Defined in
publicKeyOfString
▸ Static
publicKeyOfString(publicKeyBase58
): PublicKey_
Parameters
Name | Type |
---|---|
publicKeyBase58 | string |
Returns
PublicKey_
Defined in
publicKeyToString
▸ Static
publicKeyToString(publicKey
): string
Parameters
Name | Type |
---|---|
publicKey | PublicKey_ |
Returns
string
Defined in
signFeePayer
▸ Static
signFeePayer(txJson
, privateKey
): string
Signs a transaction as the fee payer.
Parameters
Name | Type |
---|---|
txJson | string |
privateKey | Object |
privateKey.s | Scalar |
Returns
string
Defined in
signFieldElement
▸ Static
signFieldElement(messageHash
, privateKey
, isMainnet
): string
Signs a Field element.
Parameters
Name | Type |
---|---|
messageHash | Field |
privateKey | Object |
privateKey.s | Scalar |
isMainnet | boolean |
Returns
string
Defined in
signOtherAccountUpdate
▸ Static
signOtherAccountUpdate(txJson
, privateKey
, i
): string
Signs an account update.
Parameters
Name | Type |
---|---|
txJson | string |
privateKey | Object |
privateKey.s | Scalar |
i | number |
Returns
string
Defined in
transactionCommitments
▸ Static
transactionCommitments(txJson
): Object
Returns the commitment of a JSON transaction.
Parameters
Name | Type |
---|---|
txJson | string |
Returns
Object
Name | Type |
---|---|
commitment | Field |
feePayerHash | Field |
fullCommitment | Field |
Defined in
zkappPublicInput
▸ Static
zkappPublicInput(txJson
, accountUpdateIndex
): Object
Returns the public input of a zkApp transaction.
Parameters
Name | Type |
---|---|
txJson | string |
accountUpdateIndex | number |
Returns
Object
Name | Type |
---|---|
accountUpdate | Field |
calls | Field |