Class: 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
Table of contents
Constructors
Properties
- account
- authorization
- body
- children
- id
- isDelegateCall
- isSelf
- label
- lazyAuthorization
- network
- parent
- Layout
- SequenceEvents
- provable
- sizeInFields
Accessors
Methods
- approve
- hash
- isDummy
- requireSignature
- send
- sign
- toJSON
- toPretty
- toProvable
- toPublicInput
- token
- assertBetween
- assertEquals
- attachToTransaction
- check
- clone
- create
- createSigned
- defaultAccountUpdate
- defaultFeePayer
- dummy
- dummyFeePayer
- fromFields
- fromJSON
- fundNewAccount
- getNonce
- getNonceUnchecked
- setValue
- signFeePayerInPlace
- toAuxiliary
- toFields
- toInput
- toJSON
- witness
- witnessChildren
- witnessTree
Constructors
constructor
• new AccountUpdate(body, authorization?)
Parameters
| Name | Type |
|---|---|
body | Body |
authorization? | Object |
authorization.proof? | string |
authorization.signature? | string |
Defined in
Properties
account
• account: PreconditionClassType<AccountPrecondition>
Defined in
authorization
• authorization: Object
Type declaration
| Name | Type |
|---|---|
proof? | string |
signature? | string |
Implementation of
Types.AccountUpdate.authorization
Defined in
body
• body: Body
Implementation of
Types.AccountUpdate.body
Defined in
children
• children: Object
Type declaration
| Name | Type |
|---|---|
accountUpdates | AccountUpdate[] |
callsType | { type: "None" } | { type: "Witness" } | { type: "Equals" ; value: Field } |
Defined in
id
• id: number
Defined in
isDelegateCall
• isDelegateCall: Bool
Defined in
isSelf
• Private isSelf: boolean
Defined in
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.
Defined in
lazyAuthorization
• lazyAuthorization: undefined | LazySignature | LazyProof | LazyNone = undefined
Defined in
network
• network: PreconditionClassType<{ blockchainLength: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; globalSlotSinceGenesis: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; globalSlotSinceHardFork: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; minWindowDensity: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; nextEpochData: { epochLength: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; ledger: { hash: { isSome: Bool ; value: Field } ; totalCurrency: { isSome: Bool ; value: { lower: UInt64 ; upper: UInt64 } } } ; lockCheckpoint: { isSome: Bool ; value: Field } ; seed: { isSome: Bool ; value: Field } ; startCheckpoint: { isSome: Bool ; value: Field } } ; snarkedLedgerHash: { isSome: Bool ; value: Field } ; stakingEpochData: { epochLength: { isSome: Bool ; value: { lower: UInt32 ; upper: UInt32 } } ; ledger: { hash: { isSome: Bool ; value: Field } ; totalCurrency: { isSome: Bool ; value: { lower: UInt64 ; upper: UInt64 } } } ; lockCheckpoint: { isSome: Bool ; value: Field } ; seed: { isSome: Bool ; value: Field } ; startCheckpoint: { isSome: Bool ; value: Field } } ; timestamp: { isSome: Bool ; value: { lower: UInt64 ; upper: UInt64 } } ; totalCurrency: { isSome: Bool ; value: { lower: UInt64 ; upper: UInt64 } } }>
Defined in
parent
• parent: undefined | AccountUpdate = undefined
Defined in
Layout
▪ Static Layout: Object
Describes the children of an account update, which are laid out in a tree.
The tree layout is described recursively by using a combination of AccountUpdate.Layout.NoChildren, AccountUpdate.Layout.StaticChildren(...) and AccountUpdate.Layout.AnyChildren.
NoChildrenmeans an account update that can't have childrenAnyChildrenmeans an account update can have an arbitrary amount of children, which means you can't access those children in your circuit (because the circuit is static).StaticChildrenmeans the account update must have a certain static amount of children and expects as arguments a description of each of those children. As a shortcut, you can also passStaticChildrena number, which means it has that amount of children but no grandchildren.
This is best understood by examples:
let { NoChildren, AnyChildren, StaticChildren } = AccounUpdate.Layout;
NoChildren // an account update with no children
AnyChildren // an account update with arbitrary children
StaticChildren(NoChildren) // an account update with 1 child, which doesn't have children itself
StaticChildren(1) // shortcut for StaticChildren(NoChildren)
StaticChildren(2) // shortcut for StaticChildren(NoChildren, NoChildren)
StaticChildren(0) // equivalent to NoChildren
// an update with 2 children, of which one has arbitrary children and the other has exactly 1 descendant
StaticChildren(AnyChildren, StaticChildren(1))
Type declaration
| Name | Type |
|---|---|
AnyChildren | "AnyChildren" |
NoChildren | number |
NoDelegation | "NoDelegation" |
StaticChildren | (n: number) => AccountUpdatesLayout(...args: AccountUpdatesLayout[]) => AccountUpdatesLayout |
Defined in
SequenceEvents
▪ Static SequenceEvents: Object = SequenceEvents
Type declaration
| Name | Type |
|---|---|
check | (x: { data: Field[][] ; hash: Field }) => void |
emptyValue? | () => { data: Field[][] ; hash: Field } |
fromFields | (x: Field[], aux: any[]) => { data: Field[][] ; hash: Field } |
fromJSON | (x: string[][]) => { data: Field[][] ; hash: Field } |
toAuxiliary | (x?: { data: Field[][] ; hash: Field }) => any[] |
toFields | (x: { data: Field[][] ; hash: Field }) => Field[] |
toInput | (x: { data: Field[][] ; hash: Field }) => { fields?: Field[] ; packed?: [Field, number][] } |
toJSON | (x: { data: Field[][] ; hash: Field }) => string[][] |
empty | () => Events |
emptySequenceState | () => Field |
hash | (events: Event[]) => Field |
pushEvent | (sequenceEvents: Events, event: Event) => Events |
sizeInFields | () => number |
updateSequenceState | (state: Field, sequenceEventsHash: Field) => Field |
Defined in
provable
▪ Static Private provable: ProvableExtended<{ accountUpdate: AccountUpdate = Types.AccountUpdate; isDelegateCall: Bool = Bool }, { accountUpdate: AccountUpdate = Types.AccountUpdate; isDelegateCall: boolean = Bool }>
Defined in
sizeInFields
▪ Static sizeInFields: () => number = AccountUpdate.provable.sizeInFields
Type declaration
▸ (): number
Returns
number
Defined in
Accessors
balance
• get balance(): Object
Returns
Object
| Name | Type |
|---|---|
addInPlace | (x: string | number | bigint | UInt64 | UInt32 | Int64) => void |
subInPlace | (x: string | number | bigint | UInt64 | UInt32 | Int64) => void |
Defined in
publicKey
• get publicKey(): PublicKey
Returns
Defined in
tokenId
• get tokenId(): Field
Returns
Defined in
tokenSymbol
• get tokenSymbol(): Object
Returns
Object
| Name | Type |
|---|---|
set | (tokenSymbol: string) => void |
Defined in
update
• get update(): Object
Returns
Object
| Name | Type |
|---|---|
appState | { isSome: Bool ; value: Field }[] |
delegate | { isSome: Bool ; value: PublicKey } |
delegate.isSome | Bool |
delegate.value | PublicKey |
permissions | { isSome: Bool ; value: { editSequenceState: AuthRequired ; editState: AuthRequired ; incrementNonce: AuthRequired ; receive: AuthRequired ; send: AuthRequired ; setDelegate: AuthRequired ; setPermissions: AuthRequired ; setTokenSymbol: AuthRequired ; setVerificationKey: AuthRequired ; setVotingFor: AuthRequired ; setZkappUri: AuthRequired } } |
permissions.isSome | Bool |
permissions.value | { editSequenceState: AuthRequired ; editState: AuthRequired ; incrementNonce: AuthRequired ; receive: AuthRequired ; send: AuthRequired ; setDelegate: AuthRequired ; setPermissions: AuthRequired ; setTokenSymbol: AuthRequired ; setVerificationKey: AuthRequired ; setVotingFor: AuthRequired ; setZkappUri: AuthRequired } |
permissions.value.editSequenceState | AuthRequired |
permissions.value.editState | AuthRequired |
permissions.value.incrementNonce | AuthRequired |
permissions.value.receive | AuthRequired |
permissions.value.send | AuthRequired |
permissions.value.setDelegate | AuthRequired |
permissions.value.setPermissions | AuthRequired |
permissions.value.setTokenSymbol | AuthRequired |
permissions.value.setVerificationKey | AuthRequired |
permissions.value.setVotingFor | AuthRequired |
permissions.value.setZkappUri | AuthRequired |
timing | { isSome: Bool ; value: { cliffAmount: UInt64 ; cliffTime: UInt32 ; initialMinimumBalance: UInt64 ; vestingIncrement: UInt64 ; vestingPeriod: UInt32 } } |
timing.isSome | Bool |
timing.value | { cliffAmount: UInt64 ; cliffTime: UInt32 ; initialMinimumBalance: UInt64 ; vestingIncrement: UInt64 ; vestingPeriod: UInt32 } |
timing.value.cliffAmount | UInt64 |
timing.value.cliffTime | UInt32 |
timing.value.initialMinimumBalance | UInt64 |
timing.value.vestingIncrement | UInt64 |
timing.value.vestingPeriod | UInt32 |
tokenSymbol | { isSome: Bool ; value: TokenSymbol } |
tokenSymbol.isSome | Bool |
tokenSymbol.value | TokenSymbol |
verificationKey | { isSome: Bool ; value: { data: string ; hash: Field } } |
verificationKey.isSome | Bool |
verificationKey.value | { data: string ; hash: Field } |
verificationKey.value.data | string |
verificationKey.value.hash | Field |
votingFor | { isSome: Bool ; value: Field } |
votingFor.isSome | Bool |
votingFor.value | Field |
zkappUri | { isSome: Bool ; value: { data: string ; hash: Field } } |
zkappUri.isSome | Bool |
zkappUri.value | { data: string ; hash: Field } |
zkappUri.value.data | string |
zkappUri.value.hash | Field |
Defined in
Methods
approve
▸ approve(childUpdate, layout?): void
Makes an AccountUpdate a child-AccountUpdate of this and approves it.
Parameters
| Name | Type | Default value |
|---|---|---|
childUpdate | AccountUpdate | undefined |
layout | AccountUpdatesLayout | AccountUpdate.Layout.NoDelegation |
Returns
void
Defined in
hash
▸ hash(): Field
Returns
Defined in
isDummy
▸ isDummy(): Bool
Returns
Defined in
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 = 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
Defined in
send
▸ send(__namedParameters): void
Parameters
| Name | Type |
|---|---|
__namedParameters | Object |
__namedParameters.amount | number | bigint | UInt64 |
__namedParameters.to | PublicKey | AccountUpdate |
Returns
void
Defined in
sign
▸ sign(privateKey?): void
Deprecated
.sign() is deprecated in favor of .requireSignature()
Parameters
| Name | Type |
|---|---|
privateKey? | PrivateKey |
Returns
void
Defined in
toJSON
▸ toJSON(): AccountUpdate
Returns
Defined in
toPretty
▸ toPretty(): any
Returns a JSON representation of only the fields that differ from the default AccountUpdate.
Returns
any
Defined in
toProvable
▸ Private toProvable(): Object
Returns
Object
| Name | Type |
|---|---|
accountUpdate | AccountUpdate |
isDelegateCall | Bool |
Defined in
toPublicInput
▸ toPublicInput(): ZkappPublicInput
Returns
Defined in
token
▸ token(): Object
Returns
Object
| Name | Type |
|---|---|
id | Field |
parentTokenId | Field |
tokenOwner | PublicKey |
burn | (__namedParameters: { address: PublicKey ; amount: number | bigint | UInt64 }) => void |
mint | (__namedParameters: { address: PublicKey ; amount: number | bigint | UInt64 }) => AccountUpdate |
send | (__namedParameters: { amount: number | bigint | UInt64 ; from: PublicKey ; to: PublicKey }) => AccountUpdate |
Defined in
assertBetween
▸ Static assertBetween<T>(property, lower, upper): void
Constrain a property to lie between lower and upper bounds.
Type parameters
| Name |
|---|
T |
Parameters
| Name | Type | Description |
|---|---|---|
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 ts \@method onlyRunsWhenBalanceIsLow() { let lower = UInt64.zero; let upper = UInt64.from(20e9); AccountUpdate.assertBetween(this.self.body.preconditions.account.balance, lower, upper); // ... } |
Returns
void
Defined in
assertEquals
▸ Static assertEquals<T>(property, value): void
Fix a property to a certain value.
Type parameters
| Name |
|---|
T |
Parameters
| Name | Type | Description |
|---|---|---|
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 ts \@method onlyRunsWhenNonceIsZero() { AccountUpdate.assertEquals(this.self.body.preconditions.account.nonce, UInt32.zero); // ... } |
Returns
void
Defined in
attachToTransaction
▸ Static attachToTransaction(accountUpdate): void
Parameters
| Name | Type |
|---|---|
accountUpdate | AccountUpdate |
Returns
void
Defined in
check
▸ Static check(a): void
Parameters
| Name | Type |
|---|---|
a | AccountUpdate |
Returns
void
Defined in
clone
▸ Static clone(accountUpdate): AccountUpdate
Clones the AccountUpdate.
Parameters
| Name | Type |
|---|---|
accountUpdate | AccountUpdate |
Returns
Defined in
create
▸ Static create(publicKey, tokenId?): AccountUpdate
Parameters
| Name | Type |
|---|---|
publicKey | PublicKey |
tokenId? | Field |
Returns
Defined in
createSigned
▸ Static createSigned(signer): AccountUpdate
Parameters
| Name | Type |
|---|---|
signer | PrivateKey |
Returns
Defined in
defaultAccountUpdate
▸ Static defaultAccountUpdate(address, tokenId?): AccountUpdate
Parameters
| Name | Type |
|---|---|
address | PublicKey |
tokenId? | Field |
Returns
Defined in
defaultFeePayer
▸ Static defaultFeePayer(address, key, nonce): FeePayerUnsigned
Parameters
| Name | Type |
|---|---|
address | PublicKey |
key | PrivateKey |
nonce | UInt32 |
Returns
FeePayerUnsigned
Defined in
dummy
▸ Static dummy(): AccountUpdate
Returns
Defined in
dummyFeePayer
▸ Static dummyFeePayer(): FeePayerUnsigned
Returns
FeePayerUnsigned
Defined in
fromFields
▸ Static fromFields(fields, __namedParameters): AccountUpdate
Parameters
| Name | Type |
|---|---|
fields | Field[] |
__namedParameters | any[] |
Returns
Defined in
fromJSON
▸ Static fromJSON(json): AccountUpdate
Parameters
| Name | Type |
|---|---|
json | AccountUpdate |
Returns
Defined in
fundNewAccount
▸ Static fundNewAccount(feePayerKey, initialBalance?): void
Use this method to pay the account creation fee for another account. Beware that you don't need to pass in the new account! Instead, the protocol will automatically identify accounts in your transaction that need funding.
If you provide an optional initialBalance, this will be subtracted from the fee-paying account as well,
but you have to separately ensure that it's added to the new account's balance.
Parameters
| Name | Type | Description |
|---|---|---|
feePayerKey | PrivateKey | the private key of the account that pays the fee |
initialBalance | Object | the initial balance of the new account (default: 0) |
initialBalance.initialBalance | undefined | string | number | UInt64 | - |
Returns
void
Defined in
getNonce
▸ Static getNonce(accountUpdate): any
Parameters
| Name | Type |
|---|---|
accountUpdate | AccountUpdate | FeePayerUnsigned |
Returns
any
Defined in
getNonceUnchecked
▸ Static Private getNonceUnchecked(update): UInt32
Parameters
| Name | Type |
|---|---|
update | AccountUpdate | FeePayerUnsigned |
Returns
Defined in
setValue
▸ Static setValue<T>(maybeValue, value): void
Type parameters
| Name |
|---|
T |
Parameters
| Name | Type |
|---|---|
maybeValue | SetOrKeep<T> |
value | T |
Returns
void
Defined in
signFeePayerInPlace
▸ Static signFeePayerInPlace(feePayer, privateKey?): void
Parameters
| Name | Type |
|---|---|
feePayer | FeePayerUnsigned |
privateKey? | PrivateKey |
Returns
void
Defined in
toAuxiliary
▸ Static toAuxiliary(a?): (any[] | { children: { accountUpdates: AccountUpdate[] ; callsType: { type: "None" } | { type: "Witness" } | { type: "Equals" ; value: Field } } ; id: number ; label: string ; lazyAuthorization: undefined | LazySignature | LazyProof | LazyNone ; parent: undefined | AccountUpdate })[]
Parameters
| Name | Type |
|---|---|
a? | AccountUpdate |
Returns
(any[] | { children: { accountUpdates: AccountUpdate[] ; callsType: { type: "None" } | { type: "Witness" } | { type: "Equals" ; value: Field } } ; id: number ; label: string ; lazyAuthorization: undefined | LazySignature | LazyProof | LazyNone ; parent: undefined | AccountUpdate })[]
Defined in
toFields
▸ Static toFields(a): Field[]
Parameters
| Name | Type |
|---|---|
a | AccountUpdate |
Returns
Field[]
Defined in
toInput
▸ Static toInput(a): Object
Parameters
| Name | Type |
|---|---|
a | AccountUpdate |
Returns
Object
| Name | Type |
|---|---|
fields? | Field[] |
packed? | [Field, number][] |
Defined in
toJSON
▸ Static toJSON(a): AccountUpdate
Parameters
| Name | Type |
|---|---|
a | AccountUpdate |
Returns
Defined in
witness
▸ Static witness<T>(type, compute, __namedParameters?): Object
Type parameters
| Name |
|---|
T |
Parameters
| Name | Type |
|---|---|
type | Provable<T> |
compute | () => { accountUpdate: AccountUpdate ; result: T } |
__namedParameters | Object |
__namedParameters.skipCheck | undefined | boolean |
Returns
Object
| Name | Type |
|---|---|
accountUpdate | AccountUpdate |
result | T |
Defined in
witnessChildren
▸ Static witnessChildren(accountUpdate, childLayout, options?): void
Parameters
| Name | Type |
|---|---|
accountUpdate | AccountUpdate |
childLayout | AccountUpdatesLayout |
options? | Object |
options.skipCheck | boolean |
Returns
void
Defined in
witnessTree
▸ Static witnessTree<T>(resultType, childLayout, compute, options?): Object
Like AccountUpdate.witness, but lets you specify a layout for the accountUpdate's children, which also get witnessed
Type parameters
| Name |
|---|
T |
Parameters
| Name | Type |
|---|---|
resultType | Provable<T> |
childLayout | AccountUpdatesLayout |
compute | () => { accountUpdate: AccountUpdate ; result: T } |
options? | Object |
options.skipCheck | boolean |
Returns
Object
| Name | Type |
|---|---|
accountUpdate | AccountUpdate |
result | T |