Skip to main content

AccountUpdate

Defined in: lib/mina/v1/account-update.ts:648

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​

  • AccountUpdate

Constructors​

Constructor​

new AccountUpdate(body: Body, authorization?: {
}): AccountUpdate;

Defined in: lib/mina/v1/account-update.ts:667

Parameters​

body​

Body

authorization?​

Returns​

AccountUpdate

Properties​

account​

account: Account;

Defined in: lib/mina/v1/account-update.ts:658


authorization​

authorization: {
};

Defined in: lib/mina/v1/account-update.ts:656

Implementation of​

Types.AccountUpdate.authorization

body​

body: Body;

Defined in: lib/mina/v1/account-update.ts:655

Implementation of​

Types.AccountUpdate.body

currentSlot​

currentSlot: CurrentSlot;

Defined in: lib/mina/v1/account-update.ts:660


id​

id: number;

Defined in: lib/mina/v1/account-update.ts:649


label​

label: string = '';

Defined in: lib/mina/v1/account-update.ts:654

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


lazyAuthorization​

lazyAuthorization: undefined | LazySignature | LazyProof | LazyNone = undefined;

Defined in: lib/mina/v1/account-update.ts:657


network​

network: Network;

Defined in: lib/mina/v1/account-update.ts:659


Actions​

static Actions: {
emptyActionState: Field;
fromList: Events;
hash: Field;
pushEvent: Events;
updateSequenceState: Field;
};

Defined in: lib/mina/v1/account-update.ts:664

emptyActionState()​

emptyActionState(): Field;
Returns​

Field

fromList()​

fromList(events: Event[]): Events;
Parameters​
events​

Event[]

Returns​

Events

hash()​

hash(events: Event[]): Field;
Parameters​
events​

Event[]

Returns​

Field

pushEvent()​

pushEvent(actions: Events, action: Field[]): Events;
Parameters​
actions​

Events

action​

Field[]

Returns​

Events

updateSequenceState()​

updateSequenceState(state: Field, sequenceEventsHash: Field): Field;
Parameters​
state​

Field

sequenceEventsHash​

Field

Returns​

Field


check()​

static check: (x: AccountUpdate) => void = Types.AccountUpdate.check;

Defined in: lib/mina/v1/account-update.ts:1122

Parameters​

x​

AccountUpdate

Returns​

void


Events​

static Events: {
fromList: Events;
hash: Field;
pushEvent: Events;
};

Defined in: lib/mina/v1/account-update.ts:665

fromList()​

fromList(events: Event[]): Events;
Parameters​
events​

Event[]

Returns​

Events

hash()​

hash(events: Event[]): Field;
Parameters​
events​

Event[]

Returns​

Field

pushEvent()​

pushEvent(events: Events, event: Field[]): Events;
Parameters​
events​

Events

event​

Field[]

Returns​

Events


MayUseToken​

static MayUseToken: {
InheritFromParent: {
inheritFromParent: Bool;
parentsOwnToken: Bool;
};
isInheritFromParent: (a: AccountUpdate) => Bool;
isNo: (__namedParameters: AccountUpdate) => Bool;
isParentsOwnToken: (a: AccountUpdate) => Bool;
No: {
inheritFromParent: Bool;
parentsOwnToken: Bool;
};
ParentsOwnToken: {
inheritFromParent: Bool;
parentsOwnToken: Bool;
};
type: {
};
};

Defined in: lib/mina/v1/account-update.ts:1165

InheritFromParent​

InheritFromParent: {
inheritFromParent: Bool;
parentsOwnToken: Bool;
};
InheritFromParent.inheritFromParent​
inheritFromParent: Bool;
InheritFromParent.parentsOwnToken​
parentsOwnToken: Bool;

isInheritFromParent()​

isInheritFromParent: (a: AccountUpdate) => Bool;
Parameters​
a​

AccountUpdate

Returns​

Bool

isNo()​

isNo: (__namedParameters: AccountUpdate) => Bool;
Parameters​
__namedParameters​

AccountUpdate

Returns​

Bool

isParentsOwnToken()​

isParentsOwnToken: (a: AccountUpdate) => Bool;
Parameters​
a​

AccountUpdate

Returns​

Bool

No​

No: {
inheritFromParent: Bool;
parentsOwnToken: Bool;
};
No.inheritFromParent​
inheritFromParent: Bool;
No.parentsOwnToken​
parentsOwnToken: Bool;

ParentsOwnToken​

ParentsOwnToken: {
inheritFromParent: Bool;
parentsOwnToken: Bool;
};
ParentsOwnToken.inheritFromParent​
inheritFromParent: Bool;
ParentsOwnToken.parentsOwnToken​
parentsOwnToken: Bool;

type​

type: {
} = BaseMayUseToken;

sizeInFields()​

static sizeInFields: () => number = Types.AccountUpdate.sizeInFields;

Defined in: lib/mina/v1/account-update.ts:1109

Returns​

number


toFields()​

static toFields: (x: AccountUpdate) => Field[] = Types.AccountUpdate.toFields;

Defined in: lib/mina/v1/account-update.ts:1110

Parameters​

x​

AccountUpdate

Returns​

Field[]


toInput()​

static toInput: (x: AccountUpdate) => {
} = Types.AccountUpdate.toInput;

Defined in: lib/mina/v1/account-update.ts:1118

Parameters​

x​

AccountUpdate

Returns​

{
}

toValue()​

static toValue: (x: AccountUpdate) => AccountUpdate = Types.AccountUpdate.toValue;

Defined in: lib/mina/v1/account-update.ts:1127

Parameters​

x​

AccountUpdate

Returns​

AccountUpdate

Accessors​

balance​

Get Signature​

get balance(): {
addInPlace: void;
subInPlace: void;
};

Defined in: lib/mina/v1/account-update.ts:749

Returns​
{
addInPlace: void;
subInPlace: void;
}
addInPlace()​
addInPlace(x: 
| string
| number
| bigint
| UInt64
| UInt32
| Int64): void;
Parameters​
x​

string | number | bigint | UInt64 | UInt32 | Int64

Returns​

void

subInPlace()​
subInPlace(x: 
| string
| number
| bigint
| UInt64
| UInt32
| Int64): void;
Parameters​
x​

string | number | bigint | UInt64 | UInt32 | Int64

Returns​

void


balanceChange​

Get Signature​

get balanceChange(): Int64;

Defined in: lib/mina/v1/account-update.ts:762

Returns​

Int64

Set Signature​

set balanceChange(x: Int64): void;

Defined in: lib/mina/v1/account-update.ts:765

Parameters​
x​

Int64

Returns​

void


publicKey​

Get Signature​

get publicKey(): PublicKey;

Defined in: lib/mina/v1/account-update.ts:830

Returns​

PublicKey


tokenId​

Get Signature​

get tokenId(): Field;

Defined in: lib/mina/v1/account-update.ts:696

Returns​

Field


update​

Get Signature​

get update(): {
};

Defined in: lib/mina/v1/account-update.ts:769

Returns​
{
}

Methods​

approve()​

approve(child: 
| AccountUpdate
| AccountUpdateForest
| AccountUpdateTree): void;

Defined in: lib/mina/v1/account-update.ts:737

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​

child​

AccountUpdate | AccountUpdateForest | AccountUpdateTree

Returns​

void


extractTree()​

extractTree(): AccountUpdateTree;

Defined in: lib/mina/v1/account-update.ts:962

Returns​

AccountUpdateTree


hash()​

hash(): Field;

Defined in: lib/mina/v1/account-update.ts:925

Returns​

Field


isDummy()​

isDummy(): Bool;

Defined in: lib/mina/v1/account-update.ts:987

Returns​

Bool


requireSignature()​

requireSignature(): void;

Defined in: lib/mina/v1/account-update.ts:849

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 = await 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


send()​

send(__namedParameters: {
amount: number | bigint | UInt64;
to: | PublicKey
| AccountUpdate
| SmartContract;
}): AccountUpdate;

Defined in: lib/mina/v1/account-update.ts:700

Parameters​

__namedParameters​
amount​

number | bigint | UInt64

to​

| PublicKey | AccountUpdate | SmartContract

Returns​

AccountUpdate


toJSON()​

toJSON(): AccountUpdate;

Defined in: lib/mina/v1/account-update.ts:914

Returns​

AccountUpdate


toPretty()​

toPretty(): any;

Defined in: lib/mina/v1/account-update.ts:1171

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

Returns​

any


toPrettyLayout()​

toPrettyLayout(): void;

Defined in: lib/mina/v1/account-update.ts:956

Returns​

void


toPublicInput()​

toPublicInput(__namedParameters: {
accountUpdates: AccountUpdate[];
}): ZkappPublicInput;

Defined in: lib/mina/v1/account-update.ts:930

Parameters​

__namedParameters​
accountUpdates​

AccountUpdate[]

Returns​

ZkappPublicInput


assertBetween()​

static assertBetween<T>(
property: OrIgnore<ClosedInterval<T>>,
lower: T,
upper: T): void;

Defined in: lib/mina/v1/account-update.ts:797

Constrain a property to lie between lower and upper bounds.

Type Parameters​

T​

T

Parameters​

property​

OrIgnore<ClosedInterval<T>>

The property to constrain

lower​

T

The lower bound

upper​

T

The upper bound

Example: To constrain the account balance of a SmartContract to lie between 0 and 20 MINA, you can use

\@method onlyRunsWhenBalanceIsLow() {
let lower = UInt64.zero;
let upper = UInt64.from(20e9);
AccountUpdate.assertBetween(this.self.body.preconditions.account.balance, lower, upper);
// ...
}

Returns​

void


assertEquals()​

static assertEquals<T>(property: OrIgnore<T | ClosedInterval<T>>, value: T): void;

Defined in: lib/mina/v1/account-update.ts:820

Fix a property to a certain value.

Type Parameters​

T​

T extends object

Parameters​

property​

OrIgnore<T | ClosedInterval<T>>

The property to constrain

value​

T

The value it is fixed to

Example: To fix the account nonce of a SmartContract to 0, you can use

\@method onlyRunsWhenNonceIsZero() {
AccountUpdate.assertEquals(this.self.body.preconditions.account.nonce, UInt32.zero);
// ...
}

Returns​

void


attachToTransaction()​

static attachToTransaction(accountUpdate: AccountUpdate): void;

Defined in: lib/mina/v1/account-update.ts:1045

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

Parameters​

accountUpdate​

AccountUpdate

Returns​

void


clone()​

static clone(accountUpdate: AccountUpdate): AccountUpdate;

Defined in: lib/mina/v1/account-update.ts:682

Clones the AccountUpdate.

Parameters​

accountUpdate​

AccountUpdate

Returns​

AccountUpdate


create()​

static create(publicKey: PublicKey, tokenId?: Field): AccountUpdate;

Defined in: lib/mina/v1/account-update.ts:1012

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​

publicKey​

PublicKey

tokenId?​

Field

Returns​

AccountUpdate


createIf()​

static createIf(
condition: Bool,
publicKey: PublicKey,
tokenId?: Field): AccountUpdate;

Defined in: lib/mina/v1/account-update.ts:1032

Create an account update that is added to the transaction only if a condition is met.

See AccountUpdate.create for more information. In this method, you can pass in a condition that determines whether the account update should be added to the transaction.

Parameters​

condition​

Bool

publicKey​

PublicKey

tokenId?​

Field

Returns​

AccountUpdate


createSigned()​

static createSigned(publicKey: PublicKey, tokenId?: Field): AccountUpdate;

Defined in: lib/mina/v1/account-update.ts:1081

Creates an account update, like AccountUpdate.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 = await 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​

publicKey​

PublicKey

tokenId?​

Field

Returns​

AccountUpdate


default()​

static default(address: PublicKey, tokenId?: Field): AccountUpdate;

Defined in: lib/mina/v1/account-update.ts:978

Create an account update from a public key and an optional token id.

Important: This method is different from AccountUpdate.create(), in that it really just creates the account update object. It does not attach the update to the current transaction or smart contract. Use this method for lower-level operations with account updates.

Parameters​

address​

PublicKey

tokenId?​

Field

Returns​

AccountUpdate


defaultFeePayer()​

static defaultFeePayer(address: PublicKey, nonce: UInt32): FeePayerUnsigned;

Defined in: lib/mina/v1/account-update.ts:991

Parameters​

address​

PublicKey

nonce​

UInt32

Returns​

FeePayerUnsigned


dummy()​

static dummy(): AccountUpdate;

Defined in: lib/mina/v1/account-update.ts:982

Returns​

AccountUpdate


dummyFeePayer()​

static dummyFeePayer(): FeePayerUnsigned;

Defined in: lib/mina/v1/account-update.ts:1000

Returns​

FeePayerUnsigned


empty()​

static empty(): AccountUpdate;

Defined in: lib/mina/v1/account-update.ts:1119

Returns​

AccountUpdate


fromFields()​

static fromFields(fields: Field[], __namedParameters: any[]): AccountUpdate;

Defined in: lib/mina/v1/account-update.ts:1123

Parameters​

fields​

Field[]

__namedParameters​

any[]

Returns​

AccountUpdate


fromJSON()​

static fromJSON(json: AccountUpdate): AccountUpdate;

Defined in: lib/mina/v1/account-update.ts:920

Parameters​

json​

AccountUpdate

Returns​

AccountUpdate


fromValue()​

static fromValue(value: AccountUpdate | AccountUpdate | AccountUpdate): AccountUpdate;

Defined in: lib/mina/v1/account-update.ts:1128

Parameters​

value​

AccountUpdate | AccountUpdate | AccountUpdate

Returns​

AccountUpdate


fundNewAccount()​

static fundNewAccount(feePayer: PublicKey, numberOfAccounts: number): AccountUpdate;

Defined in: lib/mina/v1/account-update.ts:1099

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​

feePayer​

PublicKey

the address of the account that pays the fee

numberOfAccounts​

number = 1

the number of new accounts to fund (default: 1)

Returns​

AccountUpdate

they AccountUpdate for the account which pays the fee


getNonce()​

static getNonce(accountUpdate: AccountUpdate | FeePayerUnsigned): UInt32;

Defined in: lib/mina/v1/account-update.ts:873

Parameters​

accountUpdate​

AccountUpdate | FeePayerUnsigned

Returns​

UInt32


setValue()​

static setValue<T>(maybeValue: SetOrKeep<T>, value: T): void;

Defined in: lib/mina/v1/account-update.ts:773

Type Parameters​

T​

T

Parameters​

maybeValue​

SetOrKeep<T>

value​

T

Returns​

void


signFeePayerInPlace()​

static signFeePayerInPlace(feePayer: FeePayerUnsigned): void;

Defined in: lib/mina/v1/account-update.ts:867

Parameters​

feePayer​

FeePayerUnsigned

Returns​

void


toAuxiliary()​

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

Defined in: lib/mina/v1/account-update.ts:1111

Parameters​

a?​

AccountUpdate

Returns​

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


toJSON()​

static toJSON(a: AccountUpdate): AccountUpdate;

Defined in: lib/mina/v1/account-update.ts:917

Parameters​

a​

AccountUpdate

Returns​

AccountUpdate


static unlink(accountUpdate: AccountUpdate): void;

Defined in: lib/mina/v1/account-update.ts:1062

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

Parameters​

accountUpdate​

AccountUpdate

Returns​

void


witness()​

static witness<T>(
resultType: FlexibleProvable<T>,
compute: () => Promise<{
accountUpdate: AccountUpdate;
result: T;
}>,
__namedParameters: {
skipCheck?: boolean;
}): Promise<{
accountUpdate: AccountUpdate;
result: T;
}>;

Defined in: lib/mina/v1/account-update.ts:1149

Type Parameters​

T​

T

Parameters​

resultType​

FlexibleProvable<T>

compute​

() => Promise<{ accountUpdate: AccountUpdate; result: T; }>

__namedParameters​
skipCheck?​

boolean = false

Returns​

Promise<{ accountUpdate: AccountUpdate; result: T; }>