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(body, authorization)
new AccountUpdate(body: Body, authorization?: {}): AccountUpdate
Parameters
• body: Body
• authorization?
Returns
Source
lib/mina/account-update.ts:598
Properties
account
account: Account;
Source
lib/mina/account-update.ts:589
authorization
authorization: {};
Implementation of
Types.AccountUpdate.authorization
Source
lib/mina/account-update.ts:586
body
body: Body;
Implementation of
Types.AccountUpdate.body
Source
lib/mina/account-update.ts:585
currentSlot
currentSlot: CurrentSlot;
Source
lib/mina/account-update.ts:591
id
id: number;
Source
lib/mina/account-update.ts:579
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:584
lazyAuthorization
lazyAuthorization: undefined | LazySignature | LazyProof | LazyNone = undefined;
Source
lib/mina/account-update.ts:587
network
network: Network;
Source
lib/mina/account-update.ts:590
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
• event: Event
Returns
Events
updateSequenceState()
Parameters
• state: Field
• sequenceEventsHash: Field
Returns
Source
lib/mina/account-update.ts:595
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: Event
Returns
Events
Source
lib/mina/account-update.ts:596
check()
static check: (x: AccountUpdate) => void = Types.AccountUpdate.check;
Parameters
• x: AccountUpdate
Returns
void
Source
lib/mina/account-update.ts:1062
sizeInFields()
static sizeInFields: () => number = Types.AccountUpdate.sizeInFields;
Returns
number
Source
lib/mina/account-update.ts:1049
toFields()
static toFields: (x: AccountUpdate) => Field[] = Types.AccountUpdate.toFields;
Parameters
• x: AccountUpdate
Returns
Field
[]
Source
lib/mina/account-update.ts:1050
toInput()
static toInput: (x: AccountUpdate) => {} = Types.AccountUpdate.toInput;
Parameters
• x: AccountUpdate
Returns
{}
Source
lib/mina/account-update.ts:1058
toValue()
static toValue: (x: AccountUpdate) => AccountUpdate = Types.AccountUpdate.toValue;
Parameters
• x: AccountUpdate
Returns
AccountUpdate
Source
lib/mina/account-update.ts:1070
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:684
balanceChange
get balanceChange(): Int64
set balanceChange(x: Int64): void
Parameters
• x: Int64
Returns
Source
lib/mina/account-update.ts:699
publicKey
get publicKey(): PublicKey
Returns
Source
lib/mina/account-update.ts:774
tokenId
get tokenId(): Field
Returns
Source
lib/mina/account-update.ts:627
update
get update(): {}
Returns
{}
Source
lib/mina/account-update.ts:706
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;
}, any>;
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;
}, any>;
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;
}, any>;
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:1095
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:672
extractTree()
extractTree(): AccountUpdateTree
Returns
Source
lib/mina/account-update.ts:920
hash()
hash(): Field
Returns
Source
lib/mina/account-update.ts:876
isDummy()
isDummy(): Bool
Returns
Source
lib/mina/account-update.ts:938
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:793
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:631
toJSON()
toJSON(): AccountUpdate
Returns
AccountUpdate
Source
lib/mina/account-update.ts:865
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:1127
toPrettyLayout()
toPrettyLayout(): void
Returns
void
Source
lib/mina/account-update.ts:914
toPublicInput()
toPublicInput(__namedParameters: {
accountUpdates: AccountUpdate[];
}): ZkappPublicInput
Parameters
• __namedParameters
• __namedParameters.accountUpdates: AccountUpdate
[]
Returns
Source
lib/mina/account-update.ts:884
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:734
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:761
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:982
clone()
static clone(accountUpdate: AccountUpdate): AccountUpdate
Clones the AccountUpdate.
Parameters
• accountUpdate: AccountUpdate
Returns
Source
lib/mina/account-update.ts:613
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:963
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:1018
defaultAccountUpdate()
static defaultAccountUpdate(address: PublicKey, tokenId?: Field): AccountUpdate
Parameters
• address: PublicKey
• tokenId?: Field
Returns
Source
lib/mina/account-update.ts:930
defaultFeePayer()
static defaultFeePayer(address: PublicKey, nonce: UInt32): FeePayerUnsigned
Parameters
• address: PublicKey
• nonce: UInt32
Returns
FeePayerUnsigned
Source
lib/mina/account-update.ts:942
dummy()
static dummy(): AccountUpdate
Returns
Source
lib/mina/account-update.ts:933
dummyFeePayer()
static dummyFeePayer(): FeePayerUnsigned
Returns
FeePayerUnsigned
Source
lib/mina/account-update.ts:951
empty()
static empty(): AccountUpdate
Returns
Source
lib/mina/account-update.ts:1059
fromFields()
static fromFields(fields: Field[], __namedParameters: any[]): AccountUpdate
Parameters
• fields: Field
[]
• __namedParameters: any
[]
Returns
Source
lib/mina/account-update.ts:1063
fromJSON()
static fromJSON(json: AccountUpdate): AccountUpdate
Parameters
• json: AccountUpdate
Returns
Source
lib/mina/account-update.ts:871
fromValue()
static fromValue(value: AccountUpdate | AccountUpdate | AccountUpdate): AccountUpdate
Parameters
• value: AccountUpdate
| AccountUpdate
| AccountUpdate
Returns
Source
lib/mina/account-update.ts:1071
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:1039
getNonce()
static getNonce(accountUpdate: FeePayerUnsigned | AccountUpdate): UInt32
Parameters
• accountUpdate: FeePayerUnsigned
| AccountUpdate
Returns
Source
lib/mina/account-update.ts:817
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:710
signFeePayerInPlace()
static signFeePayerInPlace(feePayer: FeePayerUnsigned): void
Parameters
• feePayer: FeePayerUnsigned
Returns
void
Source
lib/mina/account-update.ts:811
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:1051
toJSON()
static toJSON(a: AccountUpdate): AccountUpdate
Parameters
• a: AccountUpdate
Returns
AccountUpdate
Source
lib/mina/account-update.ts:868
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:999
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;