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

Properties

account

account: Account

Defined in

lib/account_update.ts:667


authorization

authorization: Object

Type declaration

NameType
proof?string
signature?string

Implementation of

Types.AccountUpdate.authorization

Defined in

lib/account_update.ts:664


body

body: Body

Implementation of

Types.AccountUpdate.body

Defined in

lib/account_update.ts:663


children

children: Object

Type declaration

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

Defined in

lib/account_update.ts:670


currentSlot

currentSlot: CurrentSlot

Defined in

lib/account_update.ts:669


id

id: number

Defined in

lib/account_update.ts:657


isSelf

Private isSelf: boolean

Defined in

lib/account_update.ts:682


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


lazyAuthorization

lazyAuthorization: undefined | LazySignature | LazyProof | LazyNone = undefined

Defined in

lib/account_update.ts:665


network

network: Network

Defined in

lib/account_update.ts:668


parent

parent: undefined | AccountUpdate = undefined

Defined in

lib/account_update.ts:680


Actions

Static Actions: Object = Actions

Type declaration

NameType
check(x: { data: Field[][] ; hash: Field }) => void
empty() => { 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[][]
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:684


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


check

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

Type declaration

▸ (value): void

Parameters
NameType
valueAccountUpdate
Returns

void

Defined in

lib/account_update.ts:1309


signingInfo

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

Defined in

lib/account_update.ts:1016


sizeInFields

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

Type declaration

▸ (): number

Returns

number

Defined in

lib/account_update.ts:1285


toFields

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

Type declaration

▸ (value): Field[]

Parameters
NameType
valueAccountUpdate
Returns

Field[]

Defined in

lib/account_update.ts:1286


toInput

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

Type declaration

▸ (value): HashInput

Parameters
NameType
valueAccountUpdate
Returns

HashInput

Defined in

lib/account_update.ts:1305

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


publicKey

get publicKey(): PublicKey

Returns

PublicKey

Defined in

lib/account_update.ts:960


tokenId

get tokenId(): Field

Returns

Field

Defined in

lib/account_update.ts:817


tokenSymbol

get tokenSymbol(): Object

Returns

Object

NameType
set(tokenSymbol: string) => void

Deprecated

use this.account.tokenSymbol

Defined in

lib/account_update.ts:824


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


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
typeProvablePureExtended\<{ 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:1439

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


hash

hash(): Field

Returns

Field

Defined in

lib/account_update.ts:1076


isDummy

isDummy(): Bool

Returns

Bool

Defined in

lib/account_update.ts:1131


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


send

send(«destructured»): AccountUpdate

Parameters

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

Returns

AccountUpdate

Defined in

lib/account_update.ts:834


sign

sign(privateKey?): void

Parameters

NameType
privateKey?PrivateKey

Returns

void

Deprecated

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

Defined in

lib/account_update.ts:985


toJSON

toJSON(): AccountUpdate

Returns

AccountUpdate

Defined in

lib/account_update.ts:1065


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


toPrettyLayout

toPrettyLayout(): string

Returns

string

Defined in

lib/account_update.ts:1099


toPublicInput

toPublicInput(): ZkappPublicInput

Returns

ZkappPublicInput

Defined in

lib/account_update.ts:1093


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


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


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


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


clone

Static clone(accountUpdate): AccountUpdate

Clones the AccountUpdate.

Parameters

NameType
accountUpdateAccountUpdate

Returns

AccountUpdate

Defined in

lib/account_update.ts:704


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


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

Static createSigned(signer, tokenId?): AccountUpdate

Parameters

NameType
signerPrivateKey
tokenId?Field

Returns

AccountUpdate

Deprecated

in favor of calling this function with a PublicKey as signer

Defined in

lib/account_update.ts:1226


defaultAccountUpdate

Static defaultAccountUpdate(address, tokenId?): AccountUpdate

Parameters

NameType
addressPublicKey
tokenId?Field

Returns

AccountUpdate

Defined in

lib/account_update.ts:1123


defaultFeePayer

Static defaultFeePayer(address, nonce): FeePayerUnsigned

Parameters

NameType
addressPublicKey
nonceUInt32

Returns

FeePayerUnsigned

Defined in

lib/account_update.ts:1135


dummy

Static dummy(): AccountUpdate

Returns

AccountUpdate

Defined in

lib/account_update.ts:1126


dummyFeePayer

Static dummyFeePayer(): FeePayerUnsigned

Returns

FeePayerUnsigned

Defined in

lib/account_update.ts:1144


empty

Static empty(): AccountUpdate

Returns

AccountUpdate

Defined in

lib/account_update.ts:1306


fromFields

Static fromFields(fields, «destructured»): AccountUpdate

Parameters

NameType
fieldsField[]
«destructured»any[]

Returns

AccountUpdate

Defined in

lib/account_update.ts:1310


fromJSON

Static fromJSON(json): AccountUpdate

Parameters

NameType
jsonAccountUpdate

Returns

AccountUpdate

Defined in

lib/account_update.ts:1071


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

Static fundNewAccount(feePayer, options?): AccountUpdate

Parameters

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

Returns

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 });

Defined in

lib/account_update.ts:1266


getNonce

Static getNonce(accountUpdate): UInt32

Parameters

NameType
accountUpdateAccountUpdate | FeePayerUnsigned

Returns

UInt32

Defined in

lib/account_update.ts:1012


getSigningInfo

Static Private getSigningInfo(accountUpdate): Object

Parameters

NameType
accountUpdateAccountUpdate | FeePayerUnsigned

Returns

Object

NameType
isSameAsFeePayerBool
nonceUInt32

Defined in

lib/account_update.ts:1021


getSigningInfoUnchecked

Static Private getSigningInfoUnchecked(update): Object

Parameters

NameType
updateAccountUpdate | FeePayerUnsigned

Returns

Object

NameType
isSameAsFeePayerBool
nonceUInt32

Defined in

lib/account_update.ts:1029


setValue

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

Type parameters

Name
T

Parameters

NameType
maybeValueSetOrKeep\<T>
valueT

Returns

void

Defined in

lib/account_update.ts:896


signFeePayerInPlace

Static signFeePayerInPlace(feePayer, privateKey?): void

Parameters

NameType
feePayerFeePayerUnsigned
privateKey?PrivateKey

Returns

void

Defined in

lib/account_update.ts:1003


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


toJSON

Static toJSON(a): AccountUpdate

Parameters

NameType
aAccountUpdate

Returns

AccountUpdate

Defined in

lib/account_update.ts:1068


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


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


witnessChildren

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

Parameters

NameType
accountUpdateAccountUpdate
childLayoutAccountUpdatesLayout
options?Object
options.skipCheckboolean

Returns

void

Defined in

lib/account_update.ts:1334


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