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
AccountUpdate
Constructors
new AccountUpdate()
new AccountUpdate(body: Body, authorization?: {}): AccountUpdate
Parameters
• body: Body
• authorization?
Returns
Source
lib/mina/account-update.ts:703
Properties
account
account: Account;
Source
lib/mina/account-update.ts:694
authorization
authorization: {};
Implementation of
Types.AccountUpdate.authorization
Source
lib/mina/account-update.ts:691
body
body: Body;
Implementation of
Types.AccountUpdate.body
Source
lib/mina/account-update.ts:690
currentSlot
currentSlot: CurrentSlot;
Source
lib/mina/account-update.ts:696
id
id: number;
Source
lib/mina/account-update.ts:684
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.
Source
lib/mina/account-update.ts:689
lazyAuthorization
lazyAuthorization: undefined | LazySignature | LazyProof | LazyNone = undefined;
Source
lib/mina/account-update.ts:692
network
network: Network;
Source
lib/mina/account-update.ts:695
Actions
static Actions: {
"emptyActionState": Field;
"fromList": Events;
"hash": Field;
"pushEvent": Events;
"updateSequenceState": Field;
};
emptyActionState()
Returns
fromList()
Parameters
• events: Event
[]
Returns
Events
hash()
Parameters
• events: Event
[]
Returns
pushEvent()
Parameters
• actions: Events
• action: Field
[]
Returns
Events
updateSequenceState()
Parameters
• state: Field
• sequenceEventsHash: Field
Returns
Source
lib/mina/account-update.ts:700
Events
static Events: {
"fromList": Events;
"hash": Field;
"pushEvent": Events;
};
fromList()
Parameters
• events: Event
[]
Returns
Events
hash()
Parameters
• events: Event
[]
Returns
pushEvent()
Parameters
• events: Events
• event: Field
[]
Returns
Events
Source
lib/mina/account-update.ts:701
MayUseToken
static MayUseToken: {
"InheritFromParent": {
"inheritFromParent": Bool;
"parentsOwnToken": Bool;
};
"No": {
"inheritFromParent": Bool;
"parentsOwnToken": Bool;
};
"ParentsOwnToken": {
"inheritFromParent": Bool;
"parentsOwnToken": Bool;
};
"isInheritFromParent": (a: AccountUpdate) => Bool;
"isNo": (__namedParameters: AccountUpdate) => Bool;
"isParentsOwnToken": (a: AccountUpdate) => Bool;
"type": BaseMayUseToken;
};
InheritFromParent
InheritFromParent: {
"inheritFromParent": Bool;
"parentsOwnToken": Bool;
};
InheritFromParent.inheritFromParent
inheritFromParent: Bool;
InheritFromParent.parentsOwnToken
parentsOwnToken: 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;
isInheritFromParent()
isInheritFromParent: (a: AccountUpdate) => Bool;
Parameters
• a: AccountUpdate
Returns
isNo()
isNo: (__namedParameters: AccountUpdate) => Bool;
Parameters
• __namedParameters: AccountUpdate
Returns
isParentsOwnToken()
isParentsOwnToken: (a: AccountUpdate) => Bool;
Parameters
• a: AccountUpdate
Returns
type
type: {} = BaseMayUseToken;
Source
lib/mina/account-update.ts:1235
check()
static check: (x: AccountUpdate) => void = Types.AccountUpdate.check;
Parameters
• x: AccountUpdate
Returns
void
Source
lib/mina/account-update.ts:1187
sizeInFields()
static sizeInFields: () => number = Types.AccountUpdate.sizeInFields;
Returns
number
Source
lib/mina/account-update.ts:1174
toFields()
static toFields: (x: AccountUpdate) => Field[] = Types.AccountUpdate.toFields;
Parameters
• x: AccountUpdate
Returns
Field
[]
Source
lib/mina/account-update.ts:1175
toInput()
static toInput: (x: AccountUpdate) => {} = Types.AccountUpdate.toInput;
Parameters
• x: AccountUpdate
Returns
{}
Source
lib/mina/account-update.ts:1183
toValue()
static toValue: (x: AccountUpdate) => AccountUpdate = Types.AccountUpdate.toValue;
Parameters
• x: AccountUpdate
Returns
AccountUpdate
Source
lib/mina/account-update.ts:1195
Accessors
balance
get balance(): {
"addInPlace": void;
"subInPlace": void;
}
Returns
{
"addInPlace": void;
"subInPlace": void;
}
addInPlace()
Parameters
• x:
| string
| number
| bigint
| UInt64
| UInt32
| Int64
Returns
void
subInPlace()
Parameters
• x:
| string
| number
| bigint
| UInt64
| UInt32
| Int64
Returns
void
Source
lib/mina/account-update.ts:785
balanceChange
get balanceChange(): Int64
set balanceChange(x: Int64): void
Parameters
• x: Int64
Returns
Source
lib/mina/account-update.ts:800
publicKey
get publicKey(): PublicKey
Returns
Source
lib/mina/account-update.ts:875
tokenId
get tokenId(): Field
Returns
Source
lib/mina/account-update.ts:732
update
get update(): {}
Returns
{}
Source
lib/mina/account-update.ts:807
Methods
approve()
approve(child: AccountUpdate | AccountUpdateTree | AccountUpdateForest): 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
• child: AccountUpdate
| AccountUpdateTree
| AccountUpdateForest
Returns
void
Source
lib/mina/account-update.ts:773
extractTree()
extractTree(): AccountUpdateTree
Returns
Source
lib/mina/account-update.ts:1021
hash()
hash(): Field
Returns
Source
lib/mina/account-update.ts:977
isDummy()
isDummy(): Bool
Returns
Source
lib/mina/account-update.ts:1047
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 = 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
Source
lib/mina/account-update.ts:894
send()
send(__namedParameters: {
"amount": number | bigint | UInt64;
"to": PublicKey | AccountUpdate | SmartContract;
}): AccountUpdate
Parameters
• __namedParameters
• __namedParameters.amount: number
| bigint
| UInt64
• __namedParameters.to: PublicKey
| AccountUpdate
| SmartContract
Returns
Source
lib/mina/account-update.ts:736
toJSON()
toJSON(): AccountUpdate
Returns
AccountUpdate
Source
lib/mina/account-update.ts:966
toPretty()
toPretty(): any
Returns a JSON representation of only the fields that differ from the default AccountUpdate.
Returns
any
Source
lib/mina/account-update.ts:1241
toPrettyLayout()
toPrettyLayout(): void
Returns
void
Source
lib/mina/account-update.ts:1015
toPublicInput()
toPublicInput(__namedParameters: {
"accountUpdates": AccountUpdate[];
}): ZkappPublicInput
Parameters
• __namedParameters
• __namedParameters.accountUpdates: AccountUpdate
[]
Returns
Source
lib/mina/account-update.ts:985
assertBetween()
static assertBetween<T>(
property: OrIgnore<ClosedInterval<T>>,
lower: T,
upper: T): void
Constrain a property to lie between lower and upper bounds.
Type parameters
• 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
Source
lib/mina/account-update.ts:835
assertEquals()
static assertEquals<T>(property: OrIgnore<T | ClosedInterval<T>>, value: T): void
Fix a property to a certain value.
Type parameters
• 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
Source
lib/mina/account-update.ts:862
attachToTransaction()
static attachToTransaction(accountUpdate: AccountUpdate): void
Attach account update to the current transaction -- if in a smart contract, to its children
Parameters
• accountUpdate: AccountUpdate
Returns
void
Source
lib/mina/account-update.ts:1107
clone()
static clone(accountUpdate: AccountUpdate): AccountUpdate
Clones the AccountUpdate.
Parameters
• accountUpdate: AccountUpdate
Returns
Source
lib/mina/account-update.ts:718
create()
static create(publicKey: PublicKey, tokenId?: Field): 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
• publicKey: PublicKey
• tokenId?: Field
Returns
Source
lib/mina/account-update.ts:1072
createIf()
static createIf(
condition: Bool,
publicKey: PublicKey,
tokenId?: Field): AccountUpdate
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
Source
lib/mina/account-update.ts:1094
createSigned()
static createSigned(publicKey: PublicKey, tokenId?: Field): AccountUpdate
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
Source
lib/mina/account-update.ts:1143
default()
static default(address: PublicKey, tokenId?: Field): AccountUpdate
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
Source
lib/mina/account-update.ts:1038
defaultFeePayer()
static defaultFeePayer(address: PublicKey, nonce: UInt32): FeePayerUnsigned
Parameters
• address: PublicKey
• nonce: UInt32
Returns
FeePayerUnsigned
Source
lib/mina/account-update.ts:1051
dummy()
static dummy(): AccountUpdate
Returns
Source
lib/mina/account-update.ts:1042
dummyFeePayer()
static dummyFeePayer(): FeePayerUnsigned
Returns
FeePayerUnsigned
Source
lib/mina/account-update.ts:1060
empty()
static empty(): AccountUpdate
Returns
Source
lib/mina/account-update.ts:1184
fromFields()
static fromFields(fields: Field[], __namedParameters: any[]): AccountUpdate
Parameters
• fields: Field
[]
• __namedParameters: any
[]
Returns
Source
lib/mina/account-update.ts:1188
fromJSON()
static fromJSON(json: AccountUpdate): AccountUpdate
Parameters
• json: AccountUpdate
Returns
Source
lib/mina/account-update.ts:972
fromValue()
static fromValue(value: AccountUpdate | AccountUpdate | AccountUpdate): AccountUpdate
Parameters
• value: AccountUpdate
| AccountUpdate
| AccountUpdate
Returns
Source
lib/mina/account-update.ts:1196
fundNewAccount()
static fundNewAccount(feePayer: PublicKey, numberOfAccounts: number): 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
• feePayer: PublicKey
the address of the account that pays the fee
• numberOfAccounts: number
= 1
the number of new accounts to fund (default: 1)
Returns
they AccountUpdate for the account which pays the fee
Source
lib/mina/account-update.ts:1164
getNonce()
static getNonce(accountUpdate: FeePayerUnsigned | AccountUpdate): UInt32
Parameters
• accountUpdate: FeePayerUnsigned
| AccountUpdate
Returns
Source
lib/mina/account-update.ts:918
setValue()
static setValue<T>(maybeValue: SetOrKeep<T>, value: T): void
Type parameters
• T
Parameters
• maybeValue: SetOrKeep
\<T
>
• value: T
Returns
void
Source
lib/mina/account-update.ts:811
signFeePayerInPlace()
static signFeePayerInPlace(feePayer: FeePayerUnsigned): void
Parameters
• feePayer: FeePayerUnsigned
Returns
void
Source
lib/mina/account-update.ts:912
toAuxiliary()
static toAuxiliary(a?: AccountUpdate): (any[] | {
"id": number;
"label": string;
"lazyAuthorization": undefined | LazySignature | LazyProof | LazyNone;
})[]
Parameters
• a?: AccountUpdate
Returns
(any
[] | {
"id"
: number
;
"label"
: string
;
"lazyAuthorization"
: undefined
| LazySignature
| LazyProof
| LazyNone
;
})[]
Source
lib/mina/account-update.ts:1176
toJSON()
static toJSON(a: AccountUpdate): AccountUpdate
Parameters
• a: AccountUpdate
Returns
AccountUpdate
Source
lib/mina/account-update.ts:969
unlink()
static unlink(accountUpdate: AccountUpdate): void
Disattach an account update from where it's currently located in the transaction
Parameters
• accountUpdate: AccountUpdate
Returns
void
Source
lib/mina/account-update.ts:1124
witness()
static witness<T>(
resultType: FlexibleProvable<T>,
compute: () => Promise<{
"accountUpdate": AccountUpdate;
"result": T;
}>,
__namedParameters: {
"skipCheck": false;
}): Promise<{
"accountUpdate": AccountUpdate;
"result": T;
}>
Type parameters
• T
Parameters
• resultType: FlexibleProvable
\<T
>
• compute
• __namedParameters= {}
• __namedParameters.skipCheck: undefined
| boolean
= false
Returns
Promise
\<{
"accountUpdate"
: AccountUpdate
;
"result"
: T
;
}>
accountUpdate
accountUpdate: AccountUpdate;
result
result: T;