AccountUpdate
Defined in: lib/mina/v1/account-update.ts:642
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
Defined in: lib/mina/v1/account-update.ts:661
Parameters
body
Body
authorization?
Returns
Properties
account
account: Account;
Defined in: lib/mina/v1/account-update.ts:652
authorization
authorization: {};
Defined in: lib/mina/v1/account-update.ts:650
Implementation of
Types.AccountUpdate.authorization
body
body: Body;
Defined in: lib/mina/v1/account-update.ts:649
Implementation of
Types.AccountUpdate.body
currentSlot
currentSlot: CurrentSlot;
Defined in: lib/mina/v1/account-update.ts:654
id
id: number;
Defined in: lib/mina/v1/account-update.ts:643
label
label: string = '';
Defined in: lib/mina/v1/account-update.ts:648
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:651
network
network: Network;
Defined in: lib/mina/v1/account-update.ts:653
Actions
static Actions: {
emptyActionState: Field;
fromList: Events;
hash: Field;
pushEvent: Events;
updateSequenceState: Field;
};
Defined in: lib/mina/v1/account-update.ts:658
emptyActionState()
Returns
fromList()
Parameters
events
Event
[]
Returns
Events
hash()
Parameters
events
Event
[]
Returns
pushEvent()
Parameters
actions
Events
action
Field
[]
Returns
Events
updateSequenceState()
Parameters
state
sequenceEventsHash
Returns
check()
static check: (x: AccountUpdate) => void = Types.AccountUpdate.check;
Defined in: lib/mina/v1/account-update.ts:1116
Parameters
x
AccountUpdate
Returns
void
Events
static Events: {
fromList: Events;
hash: Field;
pushEvent: Events;
};
Defined in: lib/mina/v1/account-update.ts:659
fromList()
Parameters
events
Event
[]
Returns
Events
hash()
Parameters
events
Event
[]
Returns
pushEvent()
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:1159
InheritFromParent
InheritFromParent: {
inheritFromParent: Bool;
parentsOwnToken: Bool;
};
InheritFromParent.inheritFromParent
inheritFromParent: Bool;
InheritFromParent.parentsOwnToken
parentsOwnToken: Bool;
isInheritFromParent()
isInheritFromParent: (a: AccountUpdate) => Bool;
Parameters
a
Returns
isNo()
isNo: (__namedParameters: AccountUpdate) => Bool;
Parameters
__namedParameters
Returns
isParentsOwnToken()
isParentsOwnToken: (a: AccountUpdate) => Bool;
Parameters
a
Returns
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:1103
Returns
number
toFields()
static toFields: (x: AccountUpdate) => Field[] = Types.AccountUpdate.toFields;
Defined in: lib/mina/v1/account-update.ts:1104
Parameters
x
AccountUpdate
Returns
Field
[]
toInput()
static toInput: (x: AccountUpdate) => {} = Types.AccountUpdate.toInput;
Defined in: lib/mina/v1/account-update.ts:1112
Parameters
x
AccountUpdate
Returns
{}
toValue()
static toValue: (x: AccountUpdate) => AccountUpdate = Types.AccountUpdate.toValue;
Defined in: lib/mina/v1/account-update.ts:1121
Parameters
x
AccountUpdate
Returns
AccountUpdate
Accessors
balance
Get Signature
get balance(): {
addInPlace: void;
subInPlace: void;
}
Defined in: lib/mina/v1/account-update.ts:743
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
balanceChange
Get Signature
get balanceChange(): Int64
Defined in: lib/mina/v1/account-update.ts:756
Returns
Set Signature
set balanceChange(x: Int64): void
Defined in: lib/mina/v1/account-update.ts:759
Parameters
x
Returns
void
publicKey
Get Signature
get publicKey(): PublicKey
Defined in: lib/mina/v1/account-update.ts:824
Returns
tokenId
Get Signature
get tokenId(): Field
Defined in: lib/mina/v1/account-update.ts:690
Returns
update
Get Signature
get update(): {}
Defined in: lib/mina/v1/account-update.ts:763
Returns
{}
Methods
approve()
approve(child:
| AccountUpdate
| AccountUpdateTree
| AccountUpdateForest): void
Defined in: lib/mina/v1/account-update.ts:731
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
extractTree()
extractTree(): AccountUpdateTree
Defined in: lib/mina/v1/account-update.ts:956
Returns
hash()
hash(): Field
Defined in: lib/mina/v1/account-update.ts:919
Returns
isDummy()
isDummy(): Bool
Defined in: lib/mina/v1/account-update.ts:981
Returns
requireSignature()
requireSignature(): void
Defined in: lib/mina/v1/account-update.ts:843
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:694
Parameters
__namedParameters
amount
number
| bigint
| UInt64
to
| PublicKey
| AccountUpdate
| SmartContract
Returns
toJSON()
toJSON(): AccountUpdate
Defined in: lib/mina/v1/account-update.ts:908
Returns
AccountUpdate
toPretty()
toPretty(): any
Defined in: lib/mina/v1/account-update.ts:1165
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:950
Returns
void
toPublicInput()
toPublicInput(__namedParameters: {
accountUpdates: AccountUpdate[];
}): ZkappPublicInput
Defined in: lib/mina/v1/account-update.ts:924
Parameters
__namedParameters
accountUpdates
Returns
assertBetween()
static assertBetween<T>(
property: OrIgnore<ClosedInterval<T>>,
lower: T,
upper: T): void
Defined in: lib/mina/v1/account-update.ts:791
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
assertEquals()
static assertEquals<T>(property: OrIgnore<T | ClosedInterval<T>>, value: T): void
Defined in: lib/mina/v1/account-update.ts:814
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
attachToTransaction()
static attachToTransaction(accountUpdate: AccountUpdate): void
Defined in: lib/mina/v1/account-update.ts:1039
Attach account update to the current transaction -- if in a smart contract, to its children
Parameters
accountUpdate
Returns
void
clone()
static clone(accountUpdate: AccountUpdate): AccountUpdate
Defined in: lib/mina/v1/account-update.ts:676
Clones the AccountUpdate.
Parameters
accountUpdate
Returns
create()
static create(publicKey: PublicKey, tokenId?: Field): AccountUpdate
Defined in: lib/mina/v1/account-update.ts:1006
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
tokenId?
Returns
createIf()
static createIf(
condition: Bool,
publicKey: PublicKey,
tokenId?: Field): AccountUpdate
Defined in: lib/mina/v1/account-update.ts:1026
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
publicKey
tokenId?
Returns
createSigned()
static createSigned(publicKey: PublicKey, tokenId?: Field): AccountUpdate
Defined in: lib/mina/v1/account-update.ts:1075
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
tokenId?
Returns
default()
static default(address: PublicKey, tokenId?: Field): AccountUpdate
Defined in: lib/mina/v1/account-update.ts:972
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
tokenId?
Returns
defaultFeePayer()
static defaultFeePayer(address: PublicKey, nonce: UInt32): FeePayerUnsigned
Defined in: lib/mina/v1/account-update.ts:985
Parameters
address
nonce
Returns
FeePayerUnsigned
dummy()
static dummy(): AccountUpdate
Defined in: lib/mina/v1/account-update.ts:976
Returns
dummyFeePayer()
static dummyFeePayer(): FeePayerUnsigned
Defined in: lib/mina/v1/account-update.ts:994
Returns
FeePayerUnsigned
empty()
static empty(): AccountUpdate
Defined in: lib/mina/v1/account-update.ts:1113
Returns
fromFields()
static fromFields(fields: Field[], __namedParameters: any[]): AccountUpdate
Defined in: lib/mina/v1/account-update.ts:1117
Parameters
fields
Field
[]
__namedParameters
any
[]
Returns
fromJSON()
static fromJSON(json: AccountUpdate): AccountUpdate
Defined in: lib/mina/v1/account-update.ts:914
Parameters
json
AccountUpdate
Returns
fromValue()
static fromValue(value: AccountUpdate | AccountUpdate | AccountUpdate): AccountUpdate
Defined in: lib/mina/v1/account-update.ts:1122
Parameters
value
AccountUpdate
| AccountUpdate
| AccountUpdate
Returns
fundNewAccount()
static fundNewAccount(feePayer: PublicKey, numberOfAccounts: number): AccountUpdate
Defined in: lib/mina/v1/account-update.ts:1093
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
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
getNonce()
static getNonce(accountUpdate: AccountUpdate | FeePayerUnsigned): UInt32
Defined in: lib/mina/v1/account-update.ts:867
Parameters
accountUpdate
AccountUpdate
| FeePayerUnsigned
Returns
setValue()
static setValue<T>(maybeValue: SetOrKeep<T>, value: T): void
Defined in: lib/mina/v1/account-update.ts:767
Type Parameters
• T
Parameters
maybeValue
SetOrKeep
<T
>
value
T
Returns
void
signFeePayerInPlace()
static signFeePayerInPlace(feePayer: FeePayerUnsigned): void
Defined in: lib/mina/v1/account-update.ts:861
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:1105
Parameters
a?
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:911
Parameters
a
Returns
AccountUpdate
unlink()
static unlink(accountUpdate: AccountUpdate): void
Defined in: lib/mina/v1/account-update.ts:1056
Disattach an account update from where it's currently located in the transaction
Parameters
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:1143
Type Parameters
• T
Parameters
resultType
compute
() => Promise
<{
accountUpdate
: AccountUpdate
;
result
: T
;
}>
__namedParameters
skipCheck
boolean
= false
Returns
Promise
<{
accountUpdate
: AccountUpdate
;
result
: T
;
}>