Skip to main content

Class: AccountUpdate

An AccountUpdate is a set of instructions for the Mina network. It includes Preconditions and a list of state updates, which need to be authorized by either a Signature or Proof.

Implements

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new AccountUpdate(body, authorization?)

Parameters

NameType
bodyBody
authorization?Object
authorization.proof?string
authorization.signature?string

Defined in

lib/account_update.ts:653

Properties

account

account: PreconditionClassType<AccountPrecondition>

Defined in

lib/account_update.ts:635


authorization

authorization: Object

Type declaration

NameType
proof?string
signature?string

Implementation of

Types.AccountUpdate.authorization

Defined in

lib/account_update.ts:632


body

body: Body

Implementation of

Types.AccountUpdate.body

Defined in

lib/account_update.ts:630


children

children: Object

Type declaration

NameType
accountUpdatesAccountUpdate[]
callsType{ type: "None" } | { type: "Witness" } | { type: "Equals" ; value: Field }

Defined in

lib/account_update.ts:637


id

id: number

Defined in

lib/account_update.ts:624


isDelegateCall

isDelegateCall: Bool

Defined in

lib/account_update.ts:631


isSelf

Private isSelf: boolean

Defined in

lib/account_update.ts:649


label

label: string = ''

A human-readable label for the account update, indicating how that update was created. Can be modified by applications to add richer information.

Defined in

lib/account_update.ts:629


lazyAuthorization

lazyAuthorization: undefined | LazySignature | LazyProof | LazyNone = undefined

Defined in

lib/account_update.ts:633


network

network: PreconditionClassType<{ blockchainLength: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; globalSlotSinceGenesis: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; globalSlotSinceHardFork: { 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 } } ; timestamp: { isSome: Bool ; value: { lower: UInt64 ; upper: UInt64 } } ; totalCurrency: { isSome: Bool ; value: { lower: UInt64 ; upper: UInt64 } } }>

Defined in

lib/account_update.ts:636


parent

parent: undefined | AccountUpdate = undefined

Defined in

lib/account_update.ts:647


Layout

Static Layout: Object

Describes the children of an account update, which are laid out in a tree.

The tree layout is described recursively by using a combination of AccountUpdate.Layout.NoChildren, AccountUpdate.Layout.StaticChildren(...) and AccountUpdate.Layout.AnyChildren.

  • NoChildren means an account update that can't have children
  • AnyChildren means an account update can have an arbitrary amount of children, which means you can't access those children in your circuit (because the circuit is static).
  • StaticChildren means the account update must have a certain static amount of children and expects as arguments a description of each of those children. As a shortcut, you can also pass StaticChildren a number, which means it has that amount of children but no grandchildren.

This is best understood by examples:

let { NoChildren, AnyChildren, StaticChildren } = AccounUpdate.Layout;

NoChildren // an account update with no children
AnyChildren // an account update with arbitrary children
StaticChildren(NoChildren) // an account update with 1 child, which doesn't have children itself
StaticChildren(1) // shortcut for StaticChildren(NoChildren)
StaticChildren(2) // shortcut for StaticChildren(NoChildren, NoChildren)
StaticChildren(0) // equivalent to NoChildren

// an update with 2 children, of which one has arbitrary children and the other has exactly 1 descendant
StaticChildren(AnyChildren, StaticChildren(1))

Type declaration

NameType
AnyChildren"AnyChildren"
NoChildrennumber
NoDelegation"NoDelegation"
StaticChildren(n: number) => AccountUpdatesLayout(...args: AccountUpdatesLayout[]) => AccountUpdatesLayout

Defined in

lib/account_update.ts:1270


SequenceEvents

Static SequenceEvents: Object = SequenceEvents

Type declaration

NameType
check(x: { data: Field[][] ; hash: Field }) => void
emptyValue?() => { data: Field[][] ; hash: Field }
fromFields(x: Field[], aux: any[]) => { data: Field[][] ; hash: Field }
fromJSON(x: string[][]) => { data: Field[][] ; hash: Field }
toAuxiliary(x?: { data: Field[][] ; hash: Field }) => any[]
toFields(x: { data: Field[][] ; hash: Field }) => Field[]
toInput(x: { data: Field[][] ; hash: Field }) => { fields?: Field[] ; packed?: [Field, number][] }
toJSON(x: { data: Field[][] ; hash: Field }) => string[][]
empty() => Events
emptySequenceState() => Field
hash(events: Event[]) => Field
pushEvent(sequenceEvents: Events, event: Event) => Events
sizeInFields() => number
updateSequenceState(state: Field, sequenceEventsHash: Field) => Field

Defined in

lib/account_update.ts:651


provable

Static Private provable: ProvableExtended<{ accountUpdate: AccountUpdate = Types.AccountUpdate; isDelegateCall: Bool = Bool }, { accountUpdate: AccountUpdate = Types.AccountUpdate; isDelegateCall: boolean = Bool }>

Defined in

lib/account_update.ts:1119


sizeInFields

Static sizeInFields: () => number = AccountUpdate.provable.sizeInFields

Type declaration

▸ (): number

Returns

number

Defined in

lib/account_update.ts:1127

Accessors

balance

get balance(): Object

Returns

Object

NameType
addInPlace(x: string | number | bigint | UInt64 | UInt32 | Int64) => void
subInPlace(x: string | number | bigint | UInt64 | UInt32 | Int64) => void

Defined in

lib/account_update.ts:828


publicKey

get publicKey(): PublicKey

Returns

PublicKey

Defined in

lib/account_update.ts:905


tokenId

get tokenId(): Field

Returns

Field

Defined in

lib/account_update.ts:772


tokenSymbol

get tokenSymbol(): Object

Returns

Object

NameType
set(tokenSymbol: string) => void

Defined in

lib/account_update.ts:776


update

get update(): Object

Returns

Object

NameType
appState{ isSome: Bool ; value: Field }[]
delegate{ isSome: Bool ; value: PublicKey }
delegate.isSomeBool
delegate.valuePublicKey
permissions{ isSome: Bool ; value: { editSequenceState: AuthRequired ; editState: AuthRequired ; incrementNonce: AuthRequired ; receive: AuthRequired ; send: AuthRequired ; setDelegate: AuthRequired ; setPermissions: AuthRequired ; setTokenSymbol: AuthRequired ; setVerificationKey: AuthRequired ; setVotingFor: AuthRequired ; setZkappUri: AuthRequired } }
permissions.isSomeBool
permissions.value{ editSequenceState: AuthRequired ; editState: AuthRequired ; incrementNonce: AuthRequired ; receive: AuthRequired ; send: AuthRequired ; setDelegate: AuthRequired ; setPermissions: AuthRequired ; setTokenSymbol: AuthRequired ; setVerificationKey: AuthRequired ; setVotingFor: AuthRequired ; setZkappUri: AuthRequired }
permissions.value.editSequenceStateAuthRequired
permissions.value.editStateAuthRequired
permissions.value.incrementNonceAuthRequired
permissions.value.receiveAuthRequired
permissions.value.sendAuthRequired
permissions.value.setDelegateAuthRequired
permissions.value.setPermissionsAuthRequired
permissions.value.setTokenSymbolAuthRequired
permissions.value.setVerificationKeyAuthRequired
permissions.value.setVotingForAuthRequired
permissions.value.setZkappUriAuthRequired
timing{ isSome: Bool ; value: { cliffAmount: UInt64 ; cliffTime: UInt32 ; initialMinimumBalance: UInt64 ; vestingIncrement: UInt64 ; vestingPeriod: UInt32 } }
timing.isSomeBool
timing.value{ cliffAmount: UInt64 ; cliffTime: UInt32 ; initialMinimumBalance: UInt64 ; vestingIncrement: UInt64 ; vestingPeriod: UInt32 }
timing.value.cliffAmountUInt64
timing.value.cliffTimeUInt32
timing.value.initialMinimumBalanceUInt64
timing.value.vestingIncrementUInt64
timing.value.vestingPeriodUInt32
tokenSymbol{ isSome: Bool ; value: TokenSymbol }
tokenSymbol.isSomeBool
tokenSymbol.valueTokenSymbol
verificationKey{ isSome: Bool ; value: { data: string ; hash: Field } }
verificationKey.isSomeBool
verificationKey.value{ data: string ; hash: Field }
verificationKey.value.datastring
verificationKey.value.hashField
votingFor{ isSome: Bool ; value: Field }
votingFor.isSomeBool
votingFor.valueField
zkappUri{ isSome: Bool ; value: { data: string ; hash: Field } }
zkappUri.isSomeBool
zkappUri.value{ data: string ; hash: Field }
zkappUri.value.datastring
zkappUri.value.hashField

Defined in

lib/account_update.ts:843

Methods

approve

approve(childUpdate, layout?): void

Makes an AccountUpdate a child-AccountUpdate of this and approves it.

Parameters

NameTypeDefault value
childUpdateAccountUpdateundefined
layoutAccountUpdatesLayoutAccountUpdate.Layout.NoDelegation

Returns

void

Defined in

lib/account_update.ts:819


hash

hash(): Field

Returns

Field

Defined in

lib/account_update.ts:992


isDummy

isDummy(): Bool

Returns

Bool

Defined in

lib/account_update.ts:1027


requireSignature

requireSignature(): void

Use this command if this account update should be signed by the account owner, instead of not having any authorization.

If you use this and are not relying on a wallet to sign your transaction, then you should use the following code before sending your transaction:

let tx = Mina.transaction(...); // create transaction as usual, using `requireSignature()` somewhere
tx.sign([privateKey]); // pass the private key of this account to `sign()`!

Note that an account's Permissions determine which updates have to be (can be) authorized by a signature.

Returns

void

Defined in

lib/account_update.ts:923


send

send(__namedParameters): void

Parameters

NameType
__namedParametersObject
__namedParameters.amountnumber | bigint | UInt64
__namedParameters.toPublicKey | AccountUpdate

Returns

void

Defined in

lib/account_update.ts:789


sign

sign(privateKey?): void

Deprecated

.sign() is deprecated in favor of .requireSignature()

Parameters

NameType
privateKey?PrivateKey

Returns

void

Defined in

lib/account_update.ts:932


toJSON

toJSON(): AccountUpdate

Returns

AccountUpdate

Defined in

lib/account_update.ts:981


toPretty

toPretty(): any

Returns a JSON representation of only the fields that differ from the default AccountUpdate.

Returns

any

Defined in

lib/account_update.ts:1286


toProvable

Private toProvable(): Object

Returns

Object

NameType
accountUpdateAccountUpdate
isDelegateCallBool

Defined in

lib/account_update.ts:1123


toPublicInput

toPublicInput(): ZkappPublicInput

Returns

ZkappPublicInput

Defined in

lib/account_update.ts:1010


token

token(): Object

Returns

Object

NameType
idField
parentTokenIdField
tokenOwnerPublicKey
burn(__namedParameters: { address: PublicKey ; amount: number | bigint | UInt64 }) => void
mint(__namedParameters: { address: PublicKey ; amount: number | bigint | UInt64 }) => AccountUpdate
send(__namedParameters: { amount: number | bigint | UInt64 ; from: PublicKey ; to: PublicKey }) => AccountUpdate

Defined in

lib/account_update.ts:687


assertBetween

Static assertBetween<T>(property, lower, upper): void

Constrain a property to lie between lower and upper bounds.

Type parameters

Name
T

Parameters

NameTypeDescription
propertyOrIgnore<ClosedInterval<T>>The property to constrain
lowerTThe lower bound
upperTThe upper bound Example: To constrain the account balance of a SmartContract to lie between 0 and 20 MINA, you can use ts \@method onlyRunsWhenBalanceIsLow() { let lower = UInt64.zero; let upper = UInt64.from(20e9); AccountUpdate.assertBetween(this.self.body.preconditions.account.balance, lower, upper); // ... }

Returns

void

Defined in

lib/account_update.ts:869


assertEquals

Static assertEquals<T>(property, value): void

Fix a property to a certain value.

Type parameters

Name
T

Parameters

NameTypeDescription
propertyOrIgnore<T | ClosedInterval<T>>The property to constrain
valueTThe value it is fixed to Example: To fix the account nonce of a SmartContract to 0, you can use ts \@method onlyRunsWhenNonceIsZero() { AccountUpdate.assertEquals(this.self.body.preconditions.account.nonce, UInt32.zero); // ... }

Returns

void

Defined in

lib/account_update.ts:895


attachToTransaction

Static attachToTransaction(accountUpdate): void

Parameters

NameType
accountUpdateAccountUpdate

Returns

void

Defined in

lib/account_update.ts:1058


check

Static check(a): void

Parameters

NameType
aAccountUpdate

Returns

void

Defined in

lib/account_update.ts:1153


clone

Static clone(accountUpdate): AccountUpdate

Clones the AccountUpdate.

Parameters

NameType
accountUpdateAccountUpdate

Returns

AccountUpdate

Defined in

lib/account_update.ts:667


create

Static create(publicKey, tokenId?): AccountUpdate

Parameters

NameType
publicKeyPublicKey
tokenId?Field

Returns

AccountUpdate

Defined in

lib/account_update.ts:1049


createSigned

Static createSigned(signer): AccountUpdate

Parameters

NameType
signerPrivateKey

Returns

AccountUpdate

Defined in

lib/account_update.ts:1075


defaultAccountUpdate

Static defaultAccountUpdate(address, tokenId?): AccountUpdate

Parameters

NameType
addressPublicKey
tokenId?Field

Returns

AccountUpdate

Defined in

lib/account_update.ts:1016


defaultFeePayer

Static defaultFeePayer(address, key, nonce): FeePayerUnsigned

Parameters

NameType
addressPublicKey
keyPrivateKey
nonceUInt32

Returns

FeePayerUnsigned

Defined in

lib/account_update.ts:1031


dummy

Static dummy(): AccountUpdate

Returns

AccountUpdate

Defined in

lib/account_update.ts:1024


dummyFeePayer

Static dummyFeePayer(): FeePayerUnsigned

Returns

FeePayerUnsigned

Defined in

lib/account_update.ts:1044


fromFields

Static fromFields(fields, __namedParameters): AccountUpdate

Parameters

NameType
fieldsField[]
__namedParametersany[]

Returns

AccountUpdate

Defined in

lib/account_update.ts:1156


fromJSON

Static fromJSON(json): AccountUpdate

Parameters

NameType
jsonAccountUpdate

Returns

AccountUpdate

Defined in

lib/account_update.ts:987


fundNewAccount

Static fundNewAccount(feePayerKey, initialBalance?): void

Use this method to pay the account creation fee for another account. Beware that you don't need to pass in the new account! Instead, the protocol will automatically identify accounts in your transaction that need funding.

If you provide an optional initialBalance, this will be subtracted from the fee-paying account as well, but you have to separately ensure that it's added to the new account's balance.

Parameters

NameTypeDescription
feePayerKeyPrivateKeythe private key of the account that pays the fee
initialBalanceObjectthe initial balance of the new account (default: 0)
initialBalance.initialBalanceundefined | string | number | UInt64-

Returns

void

Defined in

lib/account_update.ts:1106


getNonce

Static getNonce(accountUpdate): any

Parameters

NameType
accountUpdateAccountUpdate | FeePayerUnsigned

Returns

any

Defined in

lib/account_update.ts:948


getNonceUnchecked

Static Private getNonceUnchecked(update): UInt32

Parameters

NameType
updateAccountUpdate | FeePayerUnsigned

Returns

UInt32

Defined in

lib/account_update.ts:954


setValue

Static setValue<T>(maybeValue, value): void

Type parameters

Name
T

Parameters

NameType
maybeValueSetOrKeep<T>
valueT

Returns

void

Defined in

lib/account_update.ts:847


signFeePayerInPlace

Static signFeePayerInPlace(feePayer, privateKey?): void

Parameters

NameType
feePayerFeePayerUnsigned
privateKey?PrivateKey

Returns

void

Defined in

lib/account_update.ts:939


toAuxiliary

Static toAuxiliary(a?): (any[] | { children: { accountUpdates: AccountUpdate[] ; callsType: { type: "None" } | { type: "Witness" } | { type: "Equals" ; value: Field } } ; id: number ; label: string ; lazyAuthorization: undefined | LazySignature | LazyProof | LazyNone ; parent: undefined | AccountUpdate })[]

Parameters

NameType
a?AccountUpdate

Returns

(any[] | { children: { accountUpdates: AccountUpdate[] ; callsType: { type: "None" } | { type: "Witness" } | { type: "Equals" ; value: Field } } ; id: number ; label: string ; lazyAuthorization: undefined | LazySignature | LazyProof | LazyNone ; parent: undefined | AccountUpdate })[]

Defined in

lib/account_update.ts:1132


toFields

Static toFields(a): Field[]

Parameters

NameType
aAccountUpdate

Returns

Field[]

Defined in

lib/account_update.ts:1129


toInput

Static toInput(a): Object

Parameters

NameType
aAccountUpdate

Returns

Object

NameType
fields?Field[]
packed?[Field, number][]

Defined in

lib/account_update.ts:1150


toJSON

Static toJSON(a): AccountUpdate

Parameters

NameType
aAccountUpdate

Returns

AccountUpdate

Defined in

lib/account_update.ts:984


witness

Static witness<T>(type, compute, __namedParameters?): Object

Type parameters

Name
T

Parameters

NameType
typeProvable<T>
compute() => { accountUpdate: AccountUpdate ; result: T }
__namedParametersObject
__namedParameters.skipCheckundefined | boolean

Returns

Object

NameType
accountUpdateAccountUpdate
resultT

Defined in

lib/account_update.ts:1168


witnessChildren

Static witnessChildren(accountUpdate, childLayout, options?): void

Parameters

NameType
accountUpdateAccountUpdate
childLayoutAccountUpdatesLayout
options?Object
options.skipCheckboolean

Returns

void

Defined in

lib/account_update.ts:1184


witnessTree

Static witnessTree<T>(resultType, childLayout, compute, options?): Object

Like AccountUpdate.witness, but lets you specify a layout for the accountUpdate's children, which also get witnessed

Type parameters

Name
T

Parameters

NameType
resultTypeProvable<T>
childLayoutAccountUpdatesLayout
compute() => { accountUpdate: AccountUpdate ; result: T }
options?Object
options.skipCheckboolean

Returns

Object

NameType
accountUpdateAccountUpdate
resultT

Defined in

lib/account_update.ts:1228