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

Properties

account

account: Account

Defined in

lib/account-update.ts:613


authorization

authorization: Object

Type declaration

NameType
proof?string
signature?string

Implementation of

Types.AccountUpdate.authorization

Defined in

lib/account-update.ts:610


body

body: Body

Implementation of

Types.AccountUpdate.body

Defined in

lib/account-update.ts:609


currentSlot

currentSlot: CurrentSlot

Defined in

lib/account-update.ts:615


id

id: number

Defined in

lib/account-update.ts:603


isSelf

Private isSelf: boolean

Defined in

lib/account-update.ts:617


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


lazyAuthorization

lazyAuthorization: undefined | LazySignature | LazyProof | LazyNone = undefined

Defined in

lib/account-update.ts:611


network

network: Network

Defined in

lib/account-update.ts:614


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


check

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

Type declaration

▸ (value): void

Parameters
NameType
valueAccountUpdate
Returns

void

Defined in

lib/account-update.ts:1156


signingInfo

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

Defined in

lib/account-update.ts:866


sizeInFields

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

Type declaration

▸ (): number

Returns

number

Defined in

lib/account-update.ts:1143


toFields

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

Type declaration

▸ (value): Field[]

Parameters
NameType
valueAccountUpdate
Returns

Field[]

Defined in

lib/account-update.ts:1144


toInput

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

Type declaration

▸ (value): HashInput

Parameters
NameType
valueAccountUpdate
Returns

HashInput

Defined in

lib/account-update.ts:1152

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


balanceChange

get balanceChange(): Int64

Returns

Int64

Defined in

lib/account-update.ts:735

set balanceChange(x): void

Parameters

NameType
xInt64

Returns

void

Defined in

lib/account-update.ts:738


publicKey

get publicKey(): PublicKey

Returns

PublicKey

Defined in

lib/account-update.ts:810


tokenId

get tokenId(): Field

Returns

Field

Defined in

lib/account-update.ts:650


tokenSymbol

get tokenSymbol(): Object

Returns

Object

NameType
set(tokenSymbol: string) => void

Deprecated

use this.account.tokenSymbol

Defined in

lib/account-update.ts:657


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: { auth: AuthRequired ; txnVersion: UInt32 } ; 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: { auth: AuthRequired ; txnVersion: UInt32 } ; 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.setVerificationKey{ auth: AuthRequired ; txnVersion: UInt32 }
permissions.value.setVerificationKey.authAuthRequired
permissions.value.setVerificationKey.txnVersionUInt32
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:742


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

Methods

approve

approve(child): void

Makes another AccountUpdate a child of this one.

The parent-child relationship means that the child becomes part of the "statement" of the parent, and goes into the commitment that is authorized by either a signature or a proof.

For a proof in particular, child account updates are contained in the public input of the proof that authorizes the parent account update.

Parameters

NameType
childAccountUpdate | AccountUpdateTree | AccountUpdateForest

Returns

void

Defined in

lib/account-update.ts:708


extractTree

extractTree(): AccountUpdateTree

Returns

AccountUpdateTree

Defined in

lib/account-update.ts:982


hash

hash(): Field

Returns

Field

Defined in

lib/account-update.ts:921


isDummy

isDummy(): Bool

Returns

Bool

Defined in

lib/account-update.ts:1000


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


send

send(«destructured»): AccountUpdate

Parameters

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

Returns

AccountUpdate

Defined in

lib/account-update.ts:667


sign

sign(privateKey?): void

Parameters

NameType
privateKey?PrivateKey

Returns

void

Deprecated

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

Defined in

lib/account-update.ts:835


toJSON

toJSON(): AccountUpdate

Returns

AccountUpdate

Defined in

lib/account-update.ts:910


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


toPrettyLayout

toPrettyLayout(): void

Returns

void

Defined in

lib/account-update.ts:976


toPublicInput

toPublicInput(«destructured»): ZkappPublicInput

Parameters

NameType
«destructured»Object
› accountUpdatesAccountUpdate[]

Returns

ZkappPublicInput

Defined in

lib/account-update.ts:946


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


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


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


clone

Static clone(accountUpdate): AccountUpdate

Clones the AccountUpdate.

Parameters

NameType
accountUpdateAccountUpdate

Returns

AccountUpdate

Defined in

lib/account-update.ts:636


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


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

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


defaultAccountUpdate

Static defaultAccountUpdate(address, tokenId?): AccountUpdate

Parameters

NameType
addressPublicKey
tokenId?Field

Returns

AccountUpdate

Defined in

lib/account-update.ts:992


defaultFeePayer

Static defaultFeePayer(address, nonce): FeePayerUnsigned

Parameters

NameType
addressPublicKey
nonceUInt32

Returns

FeePayerUnsigned

Defined in

lib/account-update.ts:1004


dummy

Static dummy(): AccountUpdate

Returns

AccountUpdate

Defined in

lib/account-update.ts:995


dummyFeePayer

Static dummyFeePayer(): FeePayerUnsigned

Returns

FeePayerUnsigned

Defined in

lib/account-update.ts:1013


empty

Static empty(): AccountUpdate

Returns

AccountUpdate

Defined in

lib/account-update.ts:1153


fromFields

Static fromFields(fields, «destructured»): AccountUpdate

Parameters

NameType
fieldsField[]
«destructured»any[]

Returns

AccountUpdate

Defined in

lib/account-update.ts:1157


fromJSON

Static fromJSON(json): AccountUpdate

Parameters

NameType
jsonAccountUpdate

Returns

AccountUpdate

Defined in

lib/account-update.ts:916


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

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


getNonce

Static getNonce(accountUpdate): UInt32

Parameters

NameType
accountUpdateAccountUpdate | FeePayerUnsigned

Returns

UInt32

Defined in

lib/account-update.ts:862


getSigningInfo

Static Private getSigningInfo(accountUpdate): Object

Parameters

NameType
accountUpdateAccountUpdate | FeePayerUnsigned

Returns

Object

NameType
isSameAsFeePayerBool
nonceUInt32

Defined in

lib/account-update.ts:871


getSigningInfoUnchecked

Static Private getSigningInfoUnchecked(update): Object

Parameters

NameType
updateAccountUpdate | FeePayerUnsigned

Returns

Object

NameType
isSameAsFeePayerBool
nonceUInt32

Defined in

lib/account-update.ts:879


setValue

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

Type parameters

Name
T

Parameters

NameType
maybeValueSetOrKeep\<T>
valueT

Returns

void

Defined in

lib/account-update.ts:746


signFeePayerInPlace

Static signFeePayerInPlace(feePayer, privateKey?): void

Parameters

NameType
feePayerFeePayerUnsigned
privateKey?PrivateKey

Returns

void

Defined in

lib/account-update.ts:853


toAuxiliary

Static toAuxiliary(a?): (any[] | { id: number ; label: string ; lazyAuthorization: undefined | LazySignature | LazyProof | LazyNone })[]

Parameters

NameType
a?AccountUpdate

Returns

(any[] | { id: number ; label: string ; lazyAuthorization: undefined | LazySignature | LazyProof | LazyNone })[]

Defined in

lib/account-update.ts:1145


toJSON

Static toJSON(a): AccountUpdate

Parameters

NameType
aAccountUpdate

Returns

AccountUpdate

Defined in

lib/account-update.ts:913


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


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