Skip to main content

AccountUpdate

o1js / Modules / AccountUpdate

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

Properties

account

account: Account

Defined in

lib/account_update.ts:670


authorization

authorization: Object

Type declaration

NameType
proof?string
signature?string

Implementation of

Types.AccountUpdate.authorization

Defined in

lib/account_update.ts:667


body

body: Body

Implementation of

Types.AccountUpdate.body

Defined in

lib/account_update.ts:666


children

children: Object

Type declaration

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

Defined in

lib/account_update.ts:673


currentSlot

currentSlot: CurrentSlot

Defined in

lib/account_update.ts:672


id

id: number

Defined in

lib/account_update.ts:660


isSelf

Private isSelf: boolean

Defined in

lib/account_update.ts:685


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


lazyAuthorization

lazyAuthorization: undefined | LazySignature | LazyProof | LazyNone = undefined

Defined in

lib/account_update.ts:668


network

network: Network

Defined in

lib/account_update.ts:671


parent

parent: undefined | AccountUpdate = undefined

Defined in

lib/account_update.ts:683


Actions

Static Actions: Object = Actions

Type declaration

NameType
check(x: { data: Field[][] ; hash: Field }) => void
emptyValue() => { data: Field[][] ; hash: Field } & () => { 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
emptyActionState() => Field
fromList(events: Event[]) => Events
hash(events: Event[]) => Field
pushEvent(actions: Events, event: Event) => Events
sizeInFields() => number
updateSequenceState(state: Field, sequenceEventsHash: Field) => Field

Defined in

lib/account_update.ts:687


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


check

Static check: (value: AccountUpdate) => void = Types.AccountUpdate.check

Type declaration

▸ (value): void

Parameters
NameType
valueAccountUpdate
Returns

void

Defined in

lib/account_update.ts:1283


signingInfo

Static Private signingInfo: ProvableExtended<{ isSameAsFeePayer: Bool = Bool; nonce: UInt32 = UInt32 }, { isSameAsFeePayer: boolean = Bool; nonce: string = UInt32 }>

Defined in

lib/account_update.ts:1019


sizeInFields

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

Type declaration

▸ (): number

Returns

number

Defined in

lib/account_update.ts:1262


toFields

Static toFields: (value: AccountUpdate) => Field[] = Types.AccountUpdate.toFields

Type declaration

▸ (value): Field[]

Parameters
NameType
valueAccountUpdate
Returns

Field[]

Defined in

lib/account_update.ts:1263


toInput

Static toInput: (value: AccountUpdate) => HashInput = Types.AccountUpdate.toInput

Type declaration

▸ (value): HashInput

Parameters
NameType
valueAccountUpdate
Returns

HashInput

Defined in

lib/account_update.ts:1282

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


publicKey

get publicKey(): PublicKey

Returns

PublicKey

Defined in

lib/account_update.ts:963


tokenId

get tokenId(): Field

Returns

Field

Defined in

lib/account_update.ts:820


tokenSymbol

get tokenSymbol(): Object

Deprecated

use this.account.tokenSymbol

Returns

Object

NameType
set(tokenSymbol: string) => void

Defined in

lib/account_update.ts:827


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: { access: AuthRequired ; editActionState: AuthRequired ; editState: AuthRequired ; incrementNonce: AuthRequired ; receive: AuthRequired ; send: AuthRequired ; setDelegate: AuthRequired ; setPermissions: AuthRequired ; setTiming: AuthRequired ; setTokenSymbol: AuthRequired ; setVerificationKey: AuthRequired ; setVotingFor: AuthRequired ; setZkappUri: AuthRequired } }
permissions.isSomeBool
permissions.value{ access: AuthRequired ; editActionState: AuthRequired ; editState: AuthRequired ; incrementNonce: AuthRequired ; receive: AuthRequired ; send: AuthRequired ; setDelegate: AuthRequired ; setPermissions: AuthRequired ; setTiming: AuthRequired ; setTokenSymbol: AuthRequired ; setVerificationKey: AuthRequired ; setVotingFor: AuthRequired ; setZkappUri: AuthRequired }
permissions.value.accessAuthRequired
permissions.value.editActionStateAuthRequired
permissions.value.editStateAuthRequired
permissions.value.incrementNonceAuthRequired
permissions.value.receiveAuthRequired
permissions.value.sendAuthRequired
permissions.value.setDelegateAuthRequired
permissions.value.setPermissionsAuthRequired
permissions.value.setTimingAuthRequired
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: { field: Field ; symbol: string } }
tokenSymbol.isSomeBool
tokenSymbol.value{ field: Field ; symbol: string }
tokenSymbol.value.fieldField
tokenSymbol.value.symbolstring
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:895


MayUseToken

Static get MayUseToken(): Object

Returns

Object

NameType
InheritFromParent{ inheritFromParent: Bool ; parentsOwnToken: Bool }
InheritFromParent.inheritFromParentBool
InheritFromParent.parentsOwnTokenBool
No{ inheritFromParent: Bool ; parentsOwnToken: Bool }
No.inheritFromParentBool
No.parentsOwnTokenBool
ParentsOwnToken{ inheritFromParent: Bool ; parentsOwnToken: Bool }
ParentsOwnToken.inheritFromParentBool
ParentsOwnToken.parentsOwnTokenBool
typeProvablePure<{ inheritFromParent: Bool = Bool; parentsOwnToken: Bool = Bool }> & ProvableExtension<{ inheritFromParent: Bool = Bool; parentsOwnToken: Bool = Bool }, { inheritFromParent: boolean = Bool; parentsOwnToken: boolean = Bool }>
isInheritFromParent(a: AccountUpdate) => Bool
isNo(__namedParameters: AccountUpdate) => Bool
isParentsOwnToken(a: AccountUpdate) => Bool

Defined in

lib/account_update.ts:1412

Methods

approve

approve(childUpdate, layout?): void

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

Parameters

NameTypeDefault value
childUpdateAccountUpdateundefined
layoutAccountUpdatesLayoutAccountUpdate.Layout.NoChildren

Returns

void

Defined in

lib/account_update.ts:872


hash

hash(): Field

Returns

Field

Defined in

lib/account_update.ts:1079


isDummy

isDummy(): Bool

Returns

Bool

Defined in

lib/account_update.ts:1108


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


send

send(«destructured»): AccountUpdate

Parameters

NameType
«destructured»Object
› amountnumber | bigint | UInt64
› toPublicKey | AccountUpdate | SmartContract

Returns

AccountUpdate

Defined in

lib/account_update.ts:837


sign

sign(privateKey?): void

Deprecated

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

Parameters

NameType
privateKey?PrivateKey

Returns

void

Defined in

lib/account_update.ts:988


toJSON

toJSON(): AccountUpdate

Returns

AccountUpdate

Defined in

lib/account_update.ts:1068


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


toPublicInput

toPublicInput(): ZkappPublicInput

Returns

ZkappPublicInput

Defined in

lib/account_update.ts:1096


token

token(): Object

Returns

Object

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

Defined in

lib/account_update.ts:726


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


assertEquals

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

Fix a property to a certain value.

Type parameters

NameType
Textends object

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


attachToTransaction

Static attachToTransaction(accountUpdate): void

Attach account update to the current transaction -- if in a smart contract, to its children

Parameters

NameType
accountUpdateAccountUpdate

Returns

void

Defined in

lib/account_update.ts:1152


clone

Static clone(accountUpdate): AccountUpdate

Clones the AccountUpdate.

Parameters

NameType
accountUpdateAccountUpdate

Returns

AccountUpdate

Defined in

lib/account_update.ts:707


create

Static create(publicKey, tokenId?): AccountUpdate

Creates an account update. If this is inside a transaction, the account update becomes part of the transaction. If this is inside a smart contract method, the account update will not only become part of the transaction, but also becomes available for the smart contract to modify, in a way that becomes part of the proof.

Parameters

NameType
publicKeyPublicKey
tokenId?Field

Returns

AccountUpdate

Defined in

lib/account_update.ts:1133


createSigned

Static createSigned(signer, tokenId?): AccountUpdate

Creates an account update, like create, but also makes sure this account update will be authorized with a signature.

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 `createSigned()` 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.

Parameters

NameType
signerPublicKey
tokenId?Field

Returns

AccountUpdate

Defined in

lib/account_update.ts:1199

Static createSigned(signer, tokenId?): AccountUpdate

Deprecated

in favor of calling this function with a PublicKey as signer

Parameters

NameType
signerPrivateKey
tokenId?Field

Returns

AccountUpdate

Defined in

lib/account_update.ts:1203


defaultAccountUpdate

Static defaultAccountUpdate(address, tokenId?): AccountUpdate

Parameters

NameType
addressPublicKey
tokenId?Field

Returns

AccountUpdate

Defined in

lib/account_update.ts:1102


defaultFeePayer

Static defaultFeePayer(address, nonce): FeePayerUnsigned

Parameters

NameType
addressPublicKey
nonceUInt32

Returns

FeePayerUnsigned

Defined in

lib/account_update.ts:1112


dummy

Static dummy(): AccountUpdate

Returns

AccountUpdate

Defined in

lib/account_update.ts:1105


dummyFeePayer

Static dummyFeePayer(): FeePayerUnsigned

Returns

FeePayerUnsigned

Defined in

lib/account_update.ts:1121


fromFields

Static fromFields(fields, «destructured»): AccountUpdate

Parameters

NameType
fieldsField[]
«destructured»any[]

Returns

AccountUpdate

Defined in

lib/account_update.ts:1284


fromJSON

Static fromJSON(json): AccountUpdate

Parameters

NameType
jsonAccountUpdate

Returns

AccountUpdate

Defined in

lib/account_update.ts:1074


fundNewAccount

Static fundNewAccount(feePayer, numberOfAccounts?): AccountUpdate

Use this method to pay the account creation fee for another account (or, multiple accounts using the optional second argument).

Beware that you don't need to specify the account that is created! Instead, the protocol will automatically identify that accounts need to be created, and require that the net balance change of the transaction covers the account creation fee.

Parameters

NameTypeDescription
feePayerPublicKeythe address of the account that pays the fee
numberOfAccounts?numberthe number of new accounts to fund (default: 1)

Returns

AccountUpdate

they AccountUpdate for the account which pays the fee

Defined in

lib/account_update.ts:1231

Static fundNewAccount(feePayer, options?): AccountUpdate

Deprecated

Call this function with a PublicKey as feePayer, and remove the initialBalance option. To send an initial balance to the new account, you can use the returned account update:

let feePayerUpdate = AccountUpdate.fundNewAccount(feePayer);
feePayerUpdate.send({ to: receiverAddress, amount: initialBalance });

Parameters

NameType
feePayerPrivateKey | PublicKey
options?number | { initialBalance: string | number | UInt64 }

Returns

AccountUpdate

Defined in

lib/account_update.ts:1243


getNonce

Static getNonce(accountUpdate): UInt32

Parameters

NameType
accountUpdateAccountUpdate | FeePayerUnsigned

Returns

UInt32

Defined in

lib/account_update.ts:1015


getSigningInfo

Static Private getSigningInfo(accountUpdate): Object

Parameters

NameType
accountUpdateAccountUpdate | FeePayerUnsigned

Returns

Object

NameType
isSameAsFeePayerBool
nonceUInt32

Defined in

lib/account_update.ts:1024


getSigningInfoUnchecked

Static Private getSigningInfoUnchecked(update): Object

Parameters

NameType
updateAccountUpdate | FeePayerUnsigned

Returns

Object

NameType
isSameAsFeePayerBool
nonceUInt32

Defined in

lib/account_update.ts:1032


setValue

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

Type parameters

Name
T

Parameters

NameType
maybeValueSetOrKeep<T>
valueT

Returns

void

Defined in

lib/account_update.ts:899


signFeePayerInPlace

Static signFeePayerInPlace(feePayer, privateKey?): void

Parameters

NameType
feePayerFeePayerUnsigned
privateKey?PrivateKey

Returns

void

Defined in

lib/account_update.ts:1006


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


toJSON

Static toJSON(a): AccountUpdate

Parameters

NameType
aAccountUpdate

Returns

AccountUpdate

Defined in

lib/account_update.ts:1071


Static unlink(accountUpdate): void

Disattach an account update from where it's currently located in the transaction

Parameters

NameType
accountUpdateAccountUpdate

Returns

void

Defined in

lib/account_update.ts:1172


witness

Static witness<T>(type, compute, «destructured»?): Object

Type parameters

Name
T

Parameters

NameType
typeFlexibleProvable<T>
compute() => { accountUpdate: AccountUpdate ; result: T }
«destructured»Object
› skipCheckundefined | boolean

Returns

Object

NameType
accountUpdateAccountUpdate
resultT

Defined in

lib/account_update.ts:1292


witnessChildren

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

Parameters

NameType
accountUpdateAccountUpdate
childLayoutAccountUpdatesLayout
options?Object
options.skipCheckboolean

Returns

void

Defined in

lib/account_update.ts:1308


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
resultTypeFlexibleProvable<T>
childLayoutAccountUpdatesLayout
compute() => { accountUpdate: AccountUpdate ; result: T }
options?Object
options.skipCheckboolean

Returns

Object

NameType
accountUpdateAccountUpdate
resultT

Defined in

lib/account_update.ts:1353