AccountUpdate
o1js / Modules / AccountUpdate
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
- currentSlot
- id
- isSelf
- label
- lazyAuthorization
- network
- Actions
- check
- signingInfo
- sizeInFields
- toFields
- toInput
Accessors
Methods
- approve
- extractTree
- hash
- isDummy
- requireSignature
- send
- sign
- toJSON
- toPretty
- toPrettyLayout
- toPublicInput
- assertBetween
- assertEquals
- attachToTransaction
- clone
- create
- createSigned
- defaultAccountUpdate
- defaultFeePayer
- dummy
- dummyFeePayer
- empty
- fromFields
- fromJSON
- fundNewAccount
- getNonce
- getSigningInfo
- getSigningInfoUnchecked
- setValue
- signFeePayerInPlace
- toAuxiliary
- toJSON
- unlink
- witness
Constructors
constructor
• new AccountUpdate(body
, authorization?
)
Parameters
Name | Type |
---|---|
body | Body |
authorization? | Object |
authorization.proof? | string |
authorization.signature? | string |
Defined in
Properties
account
• account: Account
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
currentSlot
• currentSlot: CurrentSlot
Defined in
id
• id: number
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: Network
Defined in
Actions
▪ Static
Actions: Object
= Actions
Type declaration
Name | Type |
---|---|
check | (x : { data : Field [][] ; hash : Field }) => void |
empty | () => { 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 [][] |
emptyActionState | () => Field |
fromList | (events : Event []) => Events |
hash | (events : Event []) => Field |
pushEvent | (actions : Events , event : Event ) => Events |
sizeInFields | () => number |
updateSequenceState | (state : Field , sequenceEventsHash : Field ) => Field |
Defined in
check
▪ Static
check: (value
: AccountUpdate
) => void
= Types.AccountUpdate.check
Type declaration
▸ (value
): void
Parameters
Name | Type |
---|---|
value | AccountUpdate |
Returns
void
Defined in
signingInfo
▪ Static
Private
signingInfo: GenericProvableExtendedPure
\<{ isSameAsFeePayer
: Bool
= Bool; nonce
: UInt32
= UInt32 }, { isSameAsFeePayer
: boolean
= Bool; nonce
: string
= UInt32 }, Field
>
Defined in
sizeInFields
▪ Static
sizeInFields: () => number
= Types.AccountUpdate.sizeInFields
Type declaration
▸ (): number
Returns
number
Defined in
toFields
▪ Static
toFields: (value
: AccountUpdate
) => Field
[] = Types.AccountUpdate.toFields
Type declaration
▸ (value
): Field
[]
Parameters
Name | Type |
---|---|
value | AccountUpdate |
Returns
Field
[]
Defined in
toInput
▪ Static
toInput: (value
: AccountUpdate
) => HashInput
= Types.AccountUpdate.toInput
Type declaration
▸ (value
): HashInput
Parameters
Name | Type |
---|---|
value | AccountUpdate |
Returns
HashInput
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
balanceChange
• get
balanceChange(): Int64
Returns
Defined in
• set
balanceChange(x
): void
Parameters
Name | Type |
---|---|
x | Int64 |
Returns
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 |
Deprecated
use this.account.tokenSymbol
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 : { access : AuthRequired ; editActionState : AuthRequired ; editState : AuthRequired ; incrementNonce : AuthRequired ; receive : AuthRequired ; send : AuthRequired ; setDelegate : AuthRequired ; setPermissions : AuthRequired ; setTiming : AuthRequired ; setTokenSymbol : AuthRequired ; setVerificationKey : { auth : AuthRequired ; txnVersion : UInt32 } ; setVotingFor : AuthRequired ; setZkappUri : AuthRequired } } |
permissions.isSome | Bool |
permissions.value | { access : AuthRequired ; editActionState : AuthRequired ; editState : AuthRequired ; incrementNonce : AuthRequired ; receive : AuthRequired ; send : AuthRequired ; setDelegate : AuthRequired ; setPermissions : AuthRequired ; setTiming : AuthRequired ; setTokenSymbol : AuthRequired ; setVerificationKey : { auth : AuthRequired ; txnVersion : UInt32 } ; setVotingFor : AuthRequired ; setZkappUri : AuthRequired } |
permissions.value.access | AuthRequired |
permissions.value.editActionState | 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.setTiming | AuthRequired |
permissions.value.setTokenSymbol | AuthRequired |
permissions.value.setVerificationKey | { auth : AuthRequired ; txnVersion : UInt32 } |
permissions.value.setVerificationKey.auth | AuthRequired |
permissions.value.setVerificationKey.txnVersion | UInt32 |
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 : { field : Field ; symbol : string } } |
tokenSymbol.isSome | Bool |
tokenSymbol.value | { field : Field ; symbol : string } |
tokenSymbol.value.field | Field |
tokenSymbol.value.symbol | string |
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
MayUseToken
• Static
get
MayUseToken(): Object
Returns
Object
Name | Type |
---|---|
InheritFromParent | { inheritFromParent : Bool ; parentsOwnToken : Bool } |
InheritFromParent.inheritFromParent | Bool |
InheritFromParent.parentsOwnToken | Bool |
No | { inheritFromParent : Bool ; parentsOwnToken : Bool } |
No.inheritFromParent | Bool |
No.parentsOwnToken | Bool |
ParentsOwnToken | { inheritFromParent : Bool ; parentsOwnToken : Bool } |
ParentsOwnToken.inheritFromParent | Bool |
ParentsOwnToken.parentsOwnToken | Bool |
type | ProvablePureExtended \<{ inheritFromParent : Bool = Bool; parentsOwnToken : Bool = Bool }, { inheritFromParent : boolean = Bool; parentsOwnToken : boolean = Bool }> |
isInheritFromParent | (a : AccountUpdate ) => Bool |
isNo | (__namedParameters : AccountUpdate ) => Bool |
isParentsOwnToken | (a : AccountUpdate ) => Bool |
Defined in
Methods
approve
▸ approve(child
): 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
Name | Type |
---|---|
child | AccountUpdate | AccountUpdateTree | AccountUpdateForest |
Returns
void
Defined in
extractTree
▸ extractTree(): AccountUpdateTree
Returns
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(«destructured»
): AccountUpdate
Parameters
Name | Type |
---|---|
«destructured» | Object |
› amount | number | bigint | UInt64 |
› to | PublicKey | AccountUpdate | SmartContract |
Returns
Defined in
sign
▸ sign(privateKey?
): void
Parameters
Name | Type |
---|---|
privateKey? | PrivateKey |
Returns
void
Deprecated
.sign()
is deprecated in favor of .requireSignature()
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
toPrettyLayout
▸ toPrettyLayout(): void
Returns
void
Defined in
toPublicInput
▸ toPublicInput(«destructured»
): ZkappPublicInput
Parameters
Name | Type |
---|---|
«destructured» | Object |
› accountUpdates | AccountUpdate [] |
Returns
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 | Type |
---|---|
T | extends object |
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
Attach account update to the current transaction -- if in a smart contract, to its children
Parameters
Name | Type |
---|---|
accountUpdate | 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
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
Name | Type |
---|---|
publicKey | PublicKey |
tokenId? | Field |
Returns
Defined in
createSigned
▸ Static
createSigned(signer
, tokenId?
): AccountUpdate
Creates an account update, like 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 = 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
Name | Type |
---|---|
signer | PublicKey |
tokenId? | Field |
Returns
Defined in
▸ Static
createSigned(signer
, tokenId?
): AccountUpdate
Parameters
Name | Type |
---|---|
signer | PrivateKey |
tokenId? | Field |
Returns
Deprecated
in favor of calling this function with a PublicKey
as signer
Defined in
defaultAccountUpdate
▸ Static
defaultAccountUpdate(address
, tokenId?
): AccountUpdate
Parameters
Name | Type |
---|---|
address | PublicKey |
tokenId? | Field |
Returns
Defined in
defaultFeePayer
▸ Static
defaultFeePayer(address
, nonce
): FeePayerUnsigned
Parameters
Name | Type |
---|---|
address | PublicKey |
nonce | UInt32 |
Returns
FeePayerUnsigned
Defined in
dummy
▸ Static
dummy(): AccountUpdate
Returns
Defined in
dummyFeePayer
▸ Static
dummyFeePayer(): FeePayerUnsigned
Returns
FeePayerUnsigned
Defined in
empty
▸ Static
empty(): AccountUpdate
Returns
Defined in
fromFields
▸ Static
fromFields(fields
, «destructured»
): AccountUpdate
Parameters
Name | Type |
---|---|
fields | Field [] |
«destructured» | any [] |
Returns
Defined in
fromJSON
▸ Static
fromJSON(json
): AccountUpdate
Parameters
Name | Type |
---|---|
json | AccountUpdate |
Returns
Defined in
fundNewAccount
▸ Static
fundNewAccount(feePayer
, numberOfAccounts?
): 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
Name | Type | Description |
---|---|---|
feePayer | PublicKey | the address of the account that pays the fee |
numberOfAccounts? | number | the number of new accounts to fund (default: 1) |
Returns
they AccountUpdate for the account which pays the fee
Defined in
▸ Static
fundNewAccount(feePayer
, options?
): AccountUpdate
Parameters
Name | Type |
---|---|
feePayer | PrivateKey | PublicKey |
options? | number | { initialBalance : string | number | UInt64 } |
Returns
Deprecated
Call this function with a PublicKey
as feePayer
, and remove the initialBalance
option.
To send an initial balance to the new account, you can use the returned account update:
let feePayerUpdate = AccountUpdate.fundNewAccount(feePayer);
feePayerUpdate.send({ to: receiverAddress, amount: initialBalance });
Defined in
getNonce
▸ Static
getNonce(accountUpdate
): UInt32
Parameters
Name | Type |
---|---|
accountUpdate | AccountUpdate | FeePayerUnsigned |
Returns
Defined in
getSigningInfo
▸ Static
Private
getSigningInfo(accountUpdate
): Object
Parameters
Name | Type |
---|---|
accountUpdate | AccountUpdate | FeePayerUnsigned |
Returns
Object
Name | Type |
---|---|
isSameAsFeePayer | Bool |
nonce | UInt32 |
Defined in
getSigningInfoUnchecked
▸ Static
Private
getSigningInfoUnchecked(update
): Object
Parameters
Name | Type |
---|---|
update | AccountUpdate | FeePayerUnsigned |
Returns
Object
Name | Type |
---|---|
isSameAsFeePayer | Bool |
nonce | UInt32 |
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
[] | { id
: number
; label
: string
; lazyAuthorization
: undefined
| LazySignature
| LazyProof
| LazyNone
})[]
Parameters
Name | Type |
---|---|
a? | AccountUpdate |
Returns
(any
[] | { id
: number
; label
: string
; lazyAuthorization
: undefined
| LazySignature
| LazyProof
| LazyNone
})[]
Defined in
toJSON
▸ Static
toJSON(a
): AccountUpdate
Parameters
Name | Type |
---|---|
a | AccountUpdate |
Returns
Defined in
unlink
▸ Static
unlink(accountUpdate
): void
Disattach an account update from where it's currently located in the transaction
Parameters
Name | Type |
---|---|
accountUpdate | AccountUpdate |
Returns
void
Defined in
witness
▸ Static
witness\<T
>(type
, compute
, «destructured»?
): Object
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
type | FlexibleProvable \<T > |
compute | () => { accountUpdate : AccountUpdate ; result : T } |
«destructured» | Object |
› skipCheck | undefined | boolean |
Returns
Object
Name | Type |
---|---|
accountUpdate | AccountUpdate |
result | T |