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:679
Properties
account
account: Account;
Source
lib/mina/account-update.ts:670
authorization
authorization: {};
Implementation of
Types.AccountUpdate.authorization
Source
lib/mina/account-update.ts:667
body
body: Body;
Implementation of
Types.AccountUpdate.body
Source
lib/mina/account-update.ts:666
currentSlot
currentSlot: CurrentSlot;
Source
lib/mina/account-update.ts:672
id
id: number;
Source
lib/mina/account-update.ts:660
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:665
lazyAuthorization
lazyAuthorization: undefined | LazySignature | LazyProof | LazyNone = undefined;
Source
lib/mina/account-update.ts:668
network
network: Network;
Source
lib/mina/account-update.ts:671
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:676
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:677
check()
static check: (x: AccountUpdate) => void = Types.AccountUpdate.check;
Parameters
• x: AccountUpdate
Returns
void
Source
lib/mina/account-update.ts:1143
sizeInFields()
static sizeInFields: () => number = Types.AccountUpdate.sizeInFields;
Returns
number
Source
lib/mina/account-update.ts:1130
toFields()
static toFields: (x: AccountUpdate) => Field[] = Types.AccountUpdate.toFields;
Parameters
• x: AccountUpdate
Returns
Field
[]
Source
lib/mina/account-update.ts:1131
toInput()
static toInput: (x: AccountUpdate) => {} = Types.AccountUpdate.toInput;
Parameters
• x: AccountUpdate
Returns
{}
Source
lib/mina/account-update.ts:1139
toValue()
static toValue: (x: AccountUpdate) => AccountUpdate = Types.AccountUpdate.toValue;
Parameters
• x: AccountUpdate
Returns
AccountUpdate
Source
lib/mina/account-update.ts:1151
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:765
balanceChange
get balanceChange(): Int64
set balanceChange(x: Int64): void
Parameters
• x: Int64
Returns
Source
lib/mina/account-update.ts:780
publicKey
get publicKey(): PublicKey
Returns
Source
lib/mina/account-update.ts:855
tokenId
get tokenId(): Field
Returns
Source
lib/mina/account-update.ts:708
update
get update(): {}
Returns
{}
Source
lib/mina/account-update.ts:787
MayUseToken
get static MayUseToken(): {
"InheritFromParent": {
"inheritFromParent": Bool;
"parentsOwnToken": Bool;
};
"No": {
"inheritFromParent": Bool;
"parentsOwnToken": Bool;
};
"ParentsOwnToken": {
"inheritFromParent": Bool;
"parentsOwnToken": Bool;
};
"type": ProvablePureExtended<{
"inheritFromParent": Bool;
"parentsOwnToken": Bool;
}, {
"inheritFromParent": Bool;
"parentsOwnToken": Bool;
}, {
"inheritFromParent": Bool;
"parentsOwnToken": Bool;
}>;
"isInheritFromParent": Bool;
"isNo": Bool;
"isParentsOwnToken": Bool;
}
Returns
{
"InheritFromParent": {
"inheritFromParent": Bool;
"parentsOwnToken": Bool;
};
"No": {
"inheritFromParent": Bool;
"parentsOwnToken": Bool;
};
"ParentsOwnToken": {
"inheritFromParent": Bool;
"parentsOwnToken": Bool;
};
"type": ProvablePureExtended<{
"inheritFromParent": Bool;
"parentsOwnToken": Bool;
}, {
"inheritFromParent": Bool;
"parentsOwnToken": Bool;
}, {
"inheritFromParent": Bool;
"parentsOwnToken": Bool;
}>;
"isInheritFromParent": Bool;
"isNo": Bool;
"isParentsOwnToken": Bool;
}
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;
type
type: ProvablePureExtended<{
"inheritFromParent": Bool;
"parentsOwnToken": Bool;
}, {
"inheritFromParent": Bool;
"parentsOwnToken": Bool;
}, {
"inheritFromParent": Bool;
"parentsOwnToken": Bool;
}>;
Type declaration
inheritFromParent
inheritFromParent: Bool = Bool;
parentsOwnToken
parentsOwnToken: Bool = Bool;
isInheritFromParent()
Parameters
• a: AccountUpdate
Returns
isNo()
Parameters
• __namedParameters: AccountUpdate
Returns
isParentsOwnToken()
Parameters
• a: AccountUpdate
Returns
Source
lib/mina/account-update.ts:1176
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:753
extractTree()
extractTree(): AccountUpdateTree
Returns
Source
lib/mina/account-update.ts:1001
hash()
hash(): Field
Returns
Source
lib/mina/account-update.ts:957
isDummy()
isDummy(): Bool
Returns
Source
lib/mina/account-update.ts:1019
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:874
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:712
toJSON()
toJSON(): AccountUpdate
Returns
AccountUpdate
Source
lib/mina/account-update.ts:946
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:1208
toPrettyLayout()
toPrettyLayout(): void
Returns
void
Source
lib/mina/account-update.ts:995
toPublicInput()
toPublicInput(__namedParameters: {
"accountUpdates": AccountUpdate[];
}): ZkappPublicInput
Parameters
• __namedParameters
• __namedParameters.accountUpdates: AccountUpdate
[]
Returns
Source
lib/mina/account-update.ts:965
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:815
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:842
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:1063
clone()
static clone(accountUpdate: AccountUpdate): AccountUpdate
Clones the AccountUpdate.
Parameters
• accountUpdate: AccountUpdate
Returns
Source
lib/mina/account-update.ts:694
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:1044
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:1099
defaultAccountUpdate()
static defaultAccountUpdate(address: PublicKey, tokenId?: Field): AccountUpdate
Parameters
• address: PublicKey
• tokenId?: Field
Returns
Source
lib/mina/account-update.ts:1011
defaultFeePayer()
static defaultFeePayer(address: PublicKey, nonce: UInt32): FeePayerUnsigned
Parameters
• address: PublicKey
• nonce: UInt32
Returns
FeePayerUnsigned
Source
lib/mina/account-update.ts:1023
dummy()
static dummy(): AccountUpdate
Returns
Source
lib/mina/account-update.ts:1014
dummyFeePayer()
static dummyFeePayer(): FeePayerUnsigned
Returns
FeePayerUnsigned
Source
lib/mina/account-update.ts:1032
empty()
static empty(): AccountUpdate
Returns
Source
lib/mina/account-update.ts:1140
fromFields()
static fromFields(fields: Field[], __namedParameters: any[]): AccountUpdate
Parameters
• fields: Field
[]
• __namedParameters: any
[]
Returns
Source
lib/mina/account-update.ts:1144
fromJSON()
static fromJSON(json: AccountUpdate): AccountUpdate
Parameters
• json: AccountUpdate
Returns
Source
lib/mina/account-update.ts:952
fromValue()
static fromValue(value: AccountUpdate | AccountUpdate | AccountUpdate): AccountUpdate
Parameters
• value: AccountUpdate
| AccountUpdate
| AccountUpdate
Returns
Source
lib/mina/account-update.ts:1152
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:1120
getNonce()
static getNonce(accountUpdate: FeePayerUnsigned | AccountUpdate): UInt32
Parameters
• accountUpdate: FeePayerUnsigned
| AccountUpdate
Returns
Source
lib/mina/account-update.ts:898
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:791
signFeePayerInPlace()
static signFeePayerInPlace(feePayer: FeePayerUnsigned): void
Parameters
• feePayer: FeePayerUnsigned
Returns
void
Source
lib/mina/account-update.ts:892
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:1132
toJSON()
static toJSON(a: AccountUpdate): AccountUpdate
Parameters
• a: AccountUpdate
Returns
AccountUpdate
Source
lib/mina/account-update.ts:949
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:1080
witness()
static witness<T>(
type: FlexibleProvable<T>,
compute: () => Promise<{
"accountUpdate": AccountUpdate;
"result": T;
}>,
__namedParameters: {
"skipCheck": false;
}): Promise<{
"accountUpdate": AccountUpdate;
"result": T;
}>
Type parameters
• T
Parameters
• type: FlexibleProvable
\<T
>
• compute
• __namedParameters= {}
• __namedParameters.skipCheck: undefined
| boolean
= false
Returns
Promise
\<{
"accountUpdate"
: AccountUpdate
;
"result"
: T
;
}>
accountUpdate
accountUpdate: AccountUpdate;
result
result: T;