Class: Account
Hierarchyβ
-
β³
Accountβ³β³
WalletAccount
Implementsβ
Constructorsβ
constructorβ
β’ new Account(providerOrOptions, address, pkOrSigner, cairoVersion?, transactionVersion?): Account
Parametersβ
| Name | Type |
|---|---|
providerOrOptions | ProviderOptions | ProviderInterface |
address | string |
pkOrSigner | string | Uint8Array | SignerInterface |
cairoVersion? | CairoVersion |
transactionVersion | "0x2" | "0x3" |
Returnsβ
Overridesβ
Defined inβ
Propertiesβ
signerβ
β’ signer: SignerInterface
Implementation ofβ
Defined inβ
addressβ
β’ address: string
Implementation ofβ
Defined inβ
cairoVersionβ
β’ cairoVersion: CairoVersion
Implementation ofβ
Defined inβ
transactionVersionβ
β’ Readonly transactionVersion: "0x2" | "0x3"
Defined inβ
deploySelfβ
β’ deploySelf: (__namedParameters: DeployAccountContractPayload, details: UniversalDetails) => Promise<DeployContractResponse>
Type declarationβ
βΈ (Β«destructuredΒ», details?): Promise<DeployContractResponse>
Parametersβ
| Name | Type |
|---|---|
Β«destructuredΒ» | DeployAccountContractPayload |
details | UniversalDetails |
Returnsβ
Promise<DeployContractResponse>
Defined inβ
responseParserβ
β’ responseParser: RPCResponseParser
Inherited fromβ
Defined inβ
channelβ
β’ channel: RpcChannel | RpcChannel
Implementation ofβ
Inherited fromβ
Defined inβ
getStateUpdateβ
β’ getStateUpdate: () => Promise<{ block_hash: never ; old_root: string ; state_diff: { storage_diffs: { address: string; storage_entries: { key: string; value: string; }[]; }[]; deprecated_declared_classes: string[]; declared_classes: { class_hash: string; compiled_class_hash: string; }[]; deployed_contracts: { ...; }[]; replaced_classes: { ...; }[]; nonces: { ...; }[]; } }>(blockIdentifier: "pending") => Promise<{ block_hash: never ; old_root: string ; state_diff: { storage_diffs: { address: string; storage_entries: { key: string; value: string; }[]; }[]; deprecated_declared_classes: string[]; declared_classes: { class_hash: string; compiled_class_hash: string; }[]; deployed_contracts: { ...; }[]; replaced_classes: { ...; }[]; nonces: { ...; }[]; } }>(blockIdentifier: "latest") => Promise<{ block_hash: string ; old_root: string ; new_root: string ; state_diff: { storage_diffs: { address: string; storage_entries: { key: string; value: string; }[]; }[]; deprecated_declared_classes: string[]; declared_classes: { class_hash: string; compiled_class_hash: string; }[]; deployed_contracts: { ...; }[]; replaced_classes: { ...; }[]; nonces: { ...; }[]; } }>(blockIdentifier?: BlockIdentifier) => Promise<StateUpdateResponse>
Type declarationβ
βΈ (): Promise<{ block_hash: never ; old_root: string ; state_diff: { storage_diffs: { address: string; storage_entries: { key: string; value: string; }[]; }[]; deprecated_declared_classes: string[]; declared_classes: { class_hash: string; compiled_class_hash: string; }[]; deployed_contracts: { ...; }[]; replaced_classes: { ...; }[]; nonces: { ...; }[]; } }>
Returnsβ
Promise<{ block_hash: never ; old_root: string ; state_diff: { storage_diffs: { address: string; storage_entries: { key: string; value: string; }[]; }[]; deprecated_declared_classes: string[]; declared_classes: { class_hash: string; compiled_class_hash: string; }[]; deployed_contracts: { ...; }[]; replaced_classes: { ...; }[]; nonces: { ...; }[]; } }>
βΈ (blockIdentifier): Promise<{ block_hash: never ; old_root: string ; state_diff: { storage_diffs: { address: string; storage_entries: { key: string; value: string; }[]; }[]; deprecated_declared_classes: string[]; declared_classes: { class_hash: string; compiled_class_hash: string; }[]; deployed_contracts: { ...; }[]; replaced_classes: { ...; }[]; nonces: { ...; }[]; } }>
Parametersβ
| Name | Type |
|---|---|
blockIdentifier | "pending" |
Returnsβ
Promise<{ block_hash: never ; old_root: string ; state_diff: { storage_diffs: { address: string; storage_entries: { key: string; value: string; }[]; }[]; deprecated_declared_classes: string[]; declared_classes: { class_hash: string; compiled_class_hash: string; }[]; deployed_contracts: { ...; }[]; replaced_classes: { ...; }[]; nonces: { ...; }[]; } }>
βΈ (blockIdentifier): Promise<{ block_hash: string ; old_root: string ; new_root: string ; state_diff: { storage_diffs: { address: string; storage_entries: { key: string; value: string; }[]; }[]; deprecated_declared_classes: string[]; declared_classes: { class_hash: string; compiled_class_hash: string; }[]; deployed_contracts: { ...; }[]; replaced_classes: { ...; }[]; nonces: { ...; }[]; } }>
Parametersβ
| Name | Type |
|---|---|
blockIdentifier | "latest" |
Returnsβ
Promise<{ block_hash: string ; old_root: string ; new_root: string ; state_diff: { storage_diffs: { address: string; storage_entries: { key: string; value: string; }[]; }[]; deprecated_declared_classes: string[]; declared_classes: { class_hash: string; compiled_class_hash: string; }[]; deployed_contracts: { ...; }[]; replaced_classes: { ...; }[]; nonces: { ...; }[]; } }>
βΈ (blockIdentifier?): Promise<StateUpdateResponse>
Parametersβ
| Name | Type |
|---|---|
blockIdentifier? | BlockIdentifier |
Returnsβ
Promise<StateUpdateResponse>
Implementation ofβ
AccountInterface.getStateUpdate
Inherited fromβ
Defined inβ
Methodsβ
getStarkNameβ
βΈ getStarkName(provider, address, StarknetIdContract?): Promise<string>
Parametersβ
| Name | Type |
|---|---|
provider | ProviderInterface |
address | BigNumberish |
StarknetIdContract? | string |
Returnsβ
Promise<string>
Inherited fromβ
Defined inβ
src/provider/extensions/starknetId.ts:62
getAddressFromStarkNameβ
βΈ getAddressFromStarkName(provider, name, StarknetIdContract?): Promise<string>
Parametersβ
| Name | Type |
|---|---|
provider | ProviderInterface |
name | string |
StarknetIdContract? | string |
Returnsβ
Promise<string>
Inherited fromβ
Provider.getAddressFromStarkName
Defined inβ
src/provider/extensions/starknetId.ts:96
getStarkProfileβ
βΈ getStarkProfile(provider, address, StarknetIdContract?, StarknetIdIdentityContract?, StarknetIdVerifierContract?, StarknetIdPfpContract?, StarknetIdPopContract?, StarknetIdMulticallContract?): Promise<StarkProfile>
Parametersβ
| Name | Type |
|---|---|
provider | ProviderInterface |
address | BigNumberish |
StarknetIdContract? | string |
StarknetIdIdentityContract? | string |
StarknetIdVerifierContract? | string |
StarknetIdPfpContract? | string |
StarknetIdPopContract? | string |
StarknetIdMulticallContract? | string |
Returnsβ
Promise<StarkProfile>
Inherited fromβ
Defined inβ
src/provider/extensions/starknetId.ts:128
getPreferredVersionβ
βΈ getPreferredVersion(type12, type3): ETransactionVersion
Parametersβ
| Name | Type |
|---|---|
type12 | ETransactionVersion |
type3 | ETransactionVersion |
Returnsβ
Defined inβ
getNonceβ
βΈ getNonce(blockIdentifier?): Promise<string>
Gets the nonce of the account with respect to a specific block
Parametersβ
| Name | Type | Description |
|---|---|---|
blockIdentifier? | BlockIdentifier | optional blockIdentifier. Defaults to 'pending' |
Returnsβ
Promise<string>
nonce of the account
Implementation ofβ
Defined inβ
getNonceSafeβ
βΈ getNonceSafe(nonce?): Promise<bigint>
Parametersβ
| Name | Type |
|---|---|
nonce? | BigNumberish |
Returnsβ
Promise<bigint>
Defined inβ
getCairoVersionβ
βΈ getCairoVersion(classHash?): Promise<CairoVersion>
Retrieves the Cairo version from the network and sets cairoVersion if not already set in the constructor.
Parametersβ
| Name | Type | Description |
|---|---|---|
classHash? | string | if provided detects Cairo version from classHash, otherwise from the account address |
Returnsβ
Promise<CairoVersion>
Defined inβ
estimateFeeβ
βΈ estimateFee(calls, estimateFeeDetails?): Promise<EstimateFee>
Parametersβ
| Name | Type |
|---|---|
calls | AllowArray<Call> |
estimateFeeDetails | UniversalDetails |
Returnsβ
Promise<EstimateFee>
Defined inβ
estimateInvokeFeeβ
βΈ estimateInvokeFee(calls, details?): Promise<EstimateFee>
Estimate Fee for executing an INVOKE transaction on starknet
Parametersβ
| Name | Type | Description |
|---|---|---|
calls | AllowArray<Call> | the invocation object containing: - contractAddress - the address of the contract - entrypoint - the entrypoint of the contract - calldata? - (defaults to []) the calldata |
details | UniversalDetails | blockIdentifier? - nonce? = 0 - skipValidate? - default true - tip? - prioritize order of transactions in the mempool. - accountDeploymentData? - deploy an account contract (substitution for deploy account transaction) - paymasterData? - entity other than the transaction sender to pay the transaction fees(EIP-4337) - nonceDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition) - feeDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition) - version? - specify ETransactionVersion - V3 Transactions fee is in fri, oldV transactions fee is in wei |
Returnsβ
Promise<EstimateFee>
response from estimate_fee
Implementation ofβ
AccountInterface.estimateInvokeFee
Defined inβ
estimateDeclareFeeβ
βΈ estimateDeclareFee(payload, details?): Promise<EstimateFee>
Estimate Fee for executing a DECLARE transaction on starknet
Parametersβ
| Name | Type | Description |
|---|---|---|
payload | DeclareContractPayload | the payload object containing: - contract - the compiled contract to be declared - casm? - compiled cairo assembly. Cairo1(casm or compiledClassHash are required) - classHash? - the class hash of the compiled contract. Precalculate for faster execution. - compiledClassHash?: class hash of the cairo assembly. Cairo1(casm or compiledClassHash are required) |
details | UniversalDetails | blockIdentifier? - nonce? = 0 - skipValidate? - default true - tip? - prioritize order of transactions in the mempool. - accountDeploymentData? - deploy an account contract (substitution for deploy account transaction) - paymasterData? - entity other than the transaction sender to pay the transaction fees(EIP-4337) - nonceDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition) - feeDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition) - version? - specify ETransactionVersion - V3 Transactions fee is in fri, oldV transactions fee is in wei |
Returnsβ
Promise<EstimateFee>
response from estimate_fee
Implementation ofβ
AccountInterface.estimateDeclareFee
Defined inβ
estimateAccountDeployFeeβ
βΈ estimateAccountDeployFee(Β«destructuredΒ», details?): Promise<EstimateFee>
Estimate Fee for executing a DEPLOY_ACCOUNT transaction on starknet
Parametersβ
| Name | Type | Description |
|---|---|---|
Β«destructuredΒ» | DeployAccountContractPayload | classHash - the class hash of the compiled contract. - constructorCalldata? - constructor data; - contractAddress? - future account contract address. Precalculate for faster execution. - addressSalt? - salt used for calculation of the contractAddress. Required if contractAddress is provided. |
details | UniversalDetails | blockIdentifier? - nonce? = 0 - skipValidate? - default true - tip? - prioritize order of transactions in the mempool. - paymasterData? - entity other than the transaction sender to pay the transaction fees(EIP-4337) - nonceDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition) - feeDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition) - version? - specify ETransactionVersion - V3 Transactions fee is in fri, oldV transactions fee is in wei |
Returnsβ
Promise<EstimateFee>
response from estimate_fee
Implementation ofβ
AccountInterface.estimateAccountDeployFee
Defined inβ
estimateDeployFeeβ
βΈ estimateDeployFee(payload, details?): Promise<EstimateFee>
Estimate Fee for executing a UDC DEPLOY transaction on starknet This is different from the normal DEPLOY transaction as it goes through the Universal Deployer Contract (UDC)
Parametersβ
| Name | Type | Description |
|---|---|---|
payload | UniversalDeployerContractPayload | UniversalDeployerContractPayload[] | array or singular - classHash: computed class hash of compiled contract - salt: address salt - unique: bool if true ensure unique salt - constructorCalldata: constructor calldata |
details | UniversalDetails | blockIdentifier? - nonce? - skipValidate? - default true - tip? - prioritize order of transactions in the mempool. - accountDeploymentData? - deploy an account contract (substitution for deploy account transaction) - paymasterData? - entity other than the transaction sender to pay the transaction fees(EIP-4337) - nonceDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition) - feeDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition) - version? - specify ETransactionVersion - V3 Transactions fee is in fri, oldV transactions fee is in wei |
Returnsβ
Promise<EstimateFee>
Implementation ofβ
AccountInterface.estimateDeployFee
Defined inβ
estimateFeeBulkβ
βΈ estimateFeeBulk(invocations, details?): Promise<EstimateFeeBulk>
Estimate Fee for executing a list of transactions on starknet Contract must be deployed for fee estimation to be possible
Parametersβ
| Name | Type | Description |
|---|---|---|
invocations | Invocations | array of transaction object containing : - type - the type of transaction : 'DECLARE' | (multi)'DEPLOY' | (multi)'INVOKE_FUNCTION' | 'DEPLOY_ACCOUNT' - payload - the payload of the transaction |
details | UniversalDetails | blockIdentifier? - nonce? - skipValidate? - default true - tip? - prioritize order of transactions in the mempool. - accountDeploymentData? - deploy an account contract (substitution for deploy account transaction) - paymasterData? - entity other than the transaction sender to pay the transaction fees(EIP-4337) - nonceDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition) - feeDataAvailabilityMode? - allows users to choose their preferred data availability mode (Volition) - version? - specify ETransactionVersion - V3 Transactions fee is in fri, oldV transactions fee is in wei |
Returnsβ
Promise<EstimateFeeBulk>
response from estimate_fee
Implementation ofβ
AccountInterface.estimateFeeBulk
Defined inβ
simulateTransactionβ
βΈ simulateTransaction(invocations, details?): Promise<SimulateTransactionResponse>
Simulates an array of transaction and returns an array of transaction trace and estimated fee.
Parametersβ
| Name | Type | Description |
|---|---|---|
invocations | Invocations | Invocations containing: - type - transaction type: DECLARE, (multi)DEPLOY, DEPLOY_ACCOUNT, (multi)INVOKE_FUNCTION |
details | SimulateTransactionDetails | SimulateTransactionDetails |
Returnsβ
Promise<SimulateTransactionResponse>
response from simulate_transaction
Implementation ofβ
AccountInterface.simulateTransaction
Defined inβ
executeβ
βΈ execute(transactions, transactionsDetail?): Promise<{ transaction_hash: string }>
Invoke execute function in account contract
Parametersβ
| Name | Type | Description |
|---|---|---|
transactions | AllowArray<Call> | the invocation object or an array of them, containing: - contractAddress - the address of the contract - entrypoint - the entrypoint of the contract - calldata - (defaults to []) the calldata - signature - (defaults to []) the signature |
transactionsDetail? | UniversalDetails | Additional optional parameters for the transaction |
Returnsβ
Promise<{ transaction_hash: string }>
response from addTransaction
Implementation ofβ
Defined inβ
βΈ execute(transactions, abis?, transactionsDetail?): Promise<{ transaction_hash: string }>
Parametersβ
| Name | Type | Description |
|---|---|---|
transactions | AllowArray<Call> | the invocation object or an array of them, containing: - contractAddress - the address of the contract - entrypoint - the entrypoint of the contract - calldata - (defaults to []) the calldata - signature - (defaults to []) the signature |
abis? | Abi[] | (optional) the abi of the contract for better displaying |
transactionsDetail? | UniversalDetails | Additional optional parameters for the transaction * |
Returnsβ
Promise<{ transaction_hash: string }>
response from addTransaction
Deprecated
Implementation ofβ
Defined inβ
declareIfNotβ
βΈ declareIfNot(payload, transactionsDetail?): Promise<{ class_hash: string ; transaction_hash: string }>
First check if contract is already declared, if not declare it If contract already declared returned transaction_hash is ''. Method will pass even if contract is already declared
Parametersβ
| Name | Type | Description |
|---|---|---|
payload | DeclareContractPayload | - |
transactionsDetail | UniversalDetails | (optional) |
Returnsβ
Promise<{ class_hash: string ; transaction_hash: string }>
Defined inβ
declareβ
βΈ declare(payload, details?): Promise<{ class_hash: string ; transaction_hash: string }>
Declares a given compiled contract (json) to starknet
Parametersβ
| Name | Type | Description |
|---|---|---|
payload | DeclareContractPayload | transaction payload to be deployed containing: - contract: compiled contract code - (optional) classHash: computed class hash of compiled contract. Pre-compute it for faster execution. - (required for Cairo1 without compiledClassHash) casm: CompiledContract | string; - (optional for Cairo1 with casm) compiledClassHash: compiled class hash from casm. Pre-compute it for faster execution. |
details | UniversalDetails | InvocationsDetails |
Returnsβ
Promise<{ class_hash: string ; transaction_hash: string }>
a confirmation of sending a transaction on the starknet contract
Implementation ofβ
Defined inβ
deployβ
βΈ deploy(payload, details?): Promise<MultiDeployContractResponse>
Deploys a declared contract to starknet - using Universal Deployer Contract (UDC) support multicall
Parametersβ
| Name | Type | Description |
|---|---|---|
payload | UniversalDeployerContractPayload | UniversalDeployerContractPayload[] | classHash: computed class hash of compiled contract - [constructorCalldata] contract constructor calldata - [salt=pseudorandom] deploy address salt - [unique=true] ensure unique salt |
details | UniversalDetails | InvocationsDetails |
Returnsβ
Promise<MultiDeployContractResponse>
- contract_address[]
- transaction_hash
Implementation ofβ
Defined inβ
deployContractβ
βΈ deployContract(payload, details?): Promise<DeployContractUDCResponse>
Simplify deploy simulating old DeployContract with same response + UDC specific response Internal wait for L2 transaction, support multicall
Parametersβ
| Name | Type | Description |
|---|---|---|
payload | UniversalDeployerContractPayload | UniversalDeployerContractPayload[] | classHash: computed class hash of compiled contract - [constructorCalldata] contract constructor calldata - [salt=pseudorandom] deploy address salt - [unique=true] ensure unique salt |
details | UniversalDetails | InvocationsDetails |
Returnsβ
Promise<DeployContractUDCResponse>
- contract_address
- transaction_hash
- address
- deployer
- unique
- classHash
- calldata_len
- calldata
- salt
Implementation ofβ
AccountInterface.deployContract
Defined inβ
declareAndDeployβ
βΈ declareAndDeploy(payload, details?): Promise<DeclareDeployUDCResponse>
Declares and Deploy a given compiled contract (json) to starknet using UDC Internal wait for L2 transaction, do not support multicall Method will pass even if contract is already declared (internal using DeclareIfNot)
Parametersβ
| Name | Type | Description |
|---|---|---|
payload | DeclareAndDeployContractPayload | contract: compiled contract code - [casm=cairo1]: CairoAssembly | undefined; - [compiledClassHash]: string | undefined; - [classHash]: computed class hash of compiled contract - [constructorCalldata] contract constructor calldata - [salt=pseudorandom] deploy address salt - [unique=true] ensure unique salt |
details | UniversalDetails | InvocationsDetails |
Returnsβ
Promise<DeclareDeployUDCResponse>
- declare
- transaction_hash
- deploy
- contract_address
- transaction_hash
- address
- deployer
- unique
- classHash
- calldata_len
- calldata
- salt
Implementation ofβ
AccountInterface.declareAndDeploy
Defined inβ
deployAccountβ
βΈ deployAccount(Β«destructuredΒ», details?): Promise<DeployContractResponse>
Deploy the account on Starknet
Parametersβ
| Name | Type | Description |
|---|---|---|
Β«destructuredΒ» | DeployAccountContractPayload | transaction payload to be deployed containing: - classHash: computed class hash of compiled contract - optional constructor calldata - optional address salt - optional contractAddress |
details | UniversalDetails | InvocationsDetails |
Returnsβ
Promise<DeployContractResponse>
a confirmation of sending a transaction on the starknet contract
Implementation ofβ
AccountInterface.deployAccount
Defined inβ
signMessageβ
βΈ signMessage(typedData): Promise<Signature>
Signs a TypedData object for off-chain usage with the Starknet private key and returns the signature This adds a message prefix so it can't be interchanged with transactions
Parametersβ
| Name | Type | Description |
|---|---|---|
typedData | TypedData | TypedData object to be signed |
Returnsβ
Promise<Signature>
the signature of the TypedData object
Throws
if typedData is not a valid TypedData
Implementation ofβ
Defined inβ
hashMessageβ
βΈ hashMessage(typedData): Promise<string>
Hash a TypedData object with Pedersen hash and return the hash This adds a message prefix so it can't be interchanged with transactions
Parametersβ
| Name | Type | Description |
|---|---|---|
typedData | TypedData | TypedData object to be hashed |
Returnsβ
Promise<string>
the hash of the TypedData object
Throws
if typedData is not a valid TypedData
Implementation ofβ
Defined inβ
verifyMessageHashβ
βΈ verifyMessageHash(hash, signature, signatureVerificationFunctionName?, signatureVerificationResponse?): Promise<boolean>
Parametersβ
| Name | Type |
|---|---|
hash | BigNumberish |
signature | Signature |
signatureVerificationFunctionName? | string |
signatureVerificationResponse? | Object |
signatureVerificationResponse.okResponse | string[] |
signatureVerificationResponse.nokResponse | string[] |
signatureVerificationResponse.error | string[] |
Returnsβ
Promise<boolean>
Deprecated
To replace by myRpcProvider.verifyMessageInStarknet()
Defined inβ
verifyMessageβ
βΈ verifyMessage(typedData, signature, signatureVerificationFunctionName?, signatureVerificationResponse?): Promise<boolean>
Parametersβ
| Name | Type |
|---|---|
typedData | TypedData |
signature | Signature |
signatureVerificationFunctionName? | string |
signatureVerificationResponse? | Object |
signatureVerificationResponse.okResponse | string[] |
signatureVerificationResponse.nokResponse | string[] |
signatureVerificationResponse.error | string[] |
Returnsβ
Promise<boolean>
Deprecated
To replace by myRpcProvider.verifyMessageInStarknet()
Defined inβ
getSnip9Versionβ
βΈ getSnip9Version(): Promise<OutsideExecutionVersion>
Verify if an account is compatible with SNIP-9 outside execution, and with which version of this standard.
Returnsβ
Promise<OutsideExecutionVersion>
Not compatible, V1, V2.
Example
const result = myAccount.getSnip9Version();
// result = "V1"
Defined inβ
isValidSnip9Nonceβ
βΈ isValidSnip9Nonce(nonce): Promise<boolean>
Verify if a SNIP-9 nonce has not yet been used by the account.
Parametersβ
| Name | Type | Description |
|---|---|---|
nonce | BigNumberish | SNIP-9 nonce to test. |
Returnsβ
Promise<boolean>
true if SNIP-9 nonce not yet used.
Example
const result = myAccount.isValidSnip9Nonce(1234);
// result = true
Defined inβ
getSnip9Nonceβ
βΈ getSnip9Nonce(): Promise<string>
Outside transaction needs a specific SNIP-9 nonce, that we get in this function. A SNIP-9 nonce can be any number not yet used ; no ordering is needed.
Returnsβ
Promise<string>
an Hex string of a SNIP-9 nonce.
Example
const result = myAccount.getSnip9Nonce();
// result = "0x28a612590dbc36927933c8ee0f357eee639c8b22b3d3aa86949eed3ada4ac55"
Defined inβ
getOutsideTransactionβ
βΈ getOutsideTransaction(options, calls, version?, nonce?): Promise<OutsideTransaction>
Creates an object containing transaction(s) that can be executed by an other account with Account.executeFromOutside(), called Outside Transaction.
Parametersβ
| Name | Type | Description |
|---|---|---|
options | OutsideExecutionOptions | Parameters of the transaction(s). |
calls | AllowArray<Call> | Transaction(s) to execute. |
version? | OutsideExecutionVersion | SNIP-9 version of the Account that creates the outside transaction. |
nonce? | BigNumberish | Outside Nonce. |
Returnsβ
Promise<OutsideTransaction>
and object that can be used in Account.executeFromOutside()
Example
const now_seconds = Math.floor(Date.now() / 1000);
const callOptions: OutsideExecutionOptions = {
caller: executorAccount.address,
execute_after: now_seconds - 3600,
execute_before: now_seconds + 3600,
};
const call1: Call = {
contractAddress: ethAddress,
entrypoint: 'transfer',
calldata: {
recipient: recipientAccount.address,
amount: cairo.uint256(100),
},
};
const outsideTransaction1: OutsideTransaction = await signerAccount.getOutsideTransaction(
callOptions,
call3
);
// result = {
// outsideExecution: {
// caller: '0x64b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691',
// nonce: '0x28a612590dbc36927933c8ee0f357eee639c8b22b3d3aa86949eed3ada4ac55',
// execute_after: 1723650229, execute_before: 1723704229, calls: [[Object]] },
// signature: Signature {
// r: 67518627037915514985321278857825384106482999609634873287406612756843916814n,
// s: 737198738569840639192844101690009498983611654458636624293579534560862067709n, recovery: 0 },
// signerAddress: '0x655f8fd7c4013c07cf12a92184aa6c314d181443913e21f7e209a18f0c78492',
// version: '2'
// }
Defined inβ
executeFromOutsideβ
βΈ executeFromOutside(outsideTransaction, opts?): Promise<{ transaction_hash: string }>
An account B executes a transaction that has been signed by an account A. Fees are paid by B.
Parametersβ
| Name | Type | Description |
|---|---|---|
outsideTransaction | AllowArray<OutsideTransaction> | the signed transaction generated by Account.getOutsideTransaction(). |
opts? | UniversalDetails | same options than Account.execute(). |
Returnsβ
Promise<{ transaction_hash: string }>
same response than Account.execute().
Example
const outsideTransaction1: OutsideTransaction = await signerAccount.getOutsideTransaction(
callOptions,
call1
);
const outsideTransaction2: OutsideTransaction = await signerAccount.getOutsideTransaction(
callOptions4,
call4
);
const result = await myAccount.executeFromOutside([outsideTransaction1, outsideTransaction2]);
// result = { transaction_hash: '0x11233...`}
Defined inβ
getUniversalSuggestedFeeβ
βΈ getUniversalSuggestedFee(version, Β«destructuredΒ», details): Promise<UniversalSuggestedFee>
Parametersβ
| Name | Type |
|---|---|
version | ETransactionVersion |
Β«destructuredΒ» | EstimateFeeAction |
details | UniversalDetails |
Returnsβ
Promise<UniversalSuggestedFee>
Defined inβ
getSuggestedFeeβ
βΈ getSuggestedFee(Β«destructuredΒ», details): Promise<EstimateFee>
Gets Suggested Max Fee based on the transaction type
Parametersβ
| Name | Type |
|---|---|
Β«destructuredΒ» | EstimateFeeAction |
details | UniversalDetails |
Returnsβ
Promise<EstimateFee>
EstimateFee (...response, resourceBounds, suggestedMaxFee)
Implementation ofβ
AccountInterface.getSuggestedFee
Defined inβ
buildInvocationβ
βΈ buildInvocation(call, details): Promise<Invocation>
Parametersβ
| Name | Type |
|---|---|
call | Call[] |
details | InvocationsSignerDetails |
Returnsβ
Promise<Invocation>
Defined inβ
buildDeclarePayloadβ
βΈ buildDeclarePayload(payload, details): Promise<DeclareContractTransaction>
Parametersβ
| Name | Type |
|---|---|
payload | DeclareContractPayload |
details | InvocationsSignerDetails |
Returnsβ
Promise<DeclareContractTransaction>
Defined inβ
buildAccountDeployPayloadβ
βΈ buildAccountDeployPayload(Β«destructuredΒ», details): Promise<DeployAccountContractTransaction>
Parametersβ
| Name | Type |
|---|---|
Β«destructuredΒ» | DeployAccountContractPayload |
details | InvocationsSignerDetails |
Returnsβ
Promise<DeployAccountContractTransaction>
Defined inβ
buildUDCContractPayloadβ
βΈ buildUDCContractPayload(payload): Call[]
Parametersβ
| Name | Type |
|---|---|
payload | UniversalDeployerContractPayload | UniversalDeployerContractPayload[] |
Returnsβ
Call[]
Defined inβ
accountInvocationsFactoryβ
βΈ accountInvocationsFactory(invocations, details): Promise<AccountInvocations>
Parametersβ
| Name | Type |
|---|---|
invocations | Invocations |
details | AccountInvocationsFactoryDetails |
Returnsβ
Promise<AccountInvocations>
Defined inβ
getStarkNameβ
βΈ getStarkName(address?, StarknetIdContract?): Promise<string>
Parametersβ
| Name | Type |
|---|---|
address | BigNumberish |
StarknetIdContract? | string |
Returnsβ
Promise<string>
Overridesβ
Defined inβ
fetchβ
βΈ fetch(method, params?, id?): Promise<Response>
Parametersβ
| Name | Type | Default value |
|---|---|---|
method | string | undefined |
params? | object | undefined |
id | string | number | 0 |
Returnsβ
Promise<Response>
Inherited fromβ
Defined inβ
getChainIdβ
βΈ getChainId(): Promise<StarknetChainId>
Gets the Starknet chain Id
Returnsβ
Promise<StarknetChainId>
the chain Id
Implementation ofβ
Inherited fromβ
Defined inβ
getSpecVersionβ
βΈ getSpecVersion(): Promise<string>
Returnsβ
Promise<string>
Inherited fromβ
Defined inβ
getNonceForAddressβ
βΈ getNonceForAddress(contractAddress, blockIdentifier?): Promise<string>
Returns the nonce associated with the given address in the given block
Parametersβ
| Name | Type | Description |
|---|---|---|
contractAddress | BigNumberish | contract address |
blockIdentifier? | BlockIdentifier | - |
Returnsβ
Promise<string>
the hex nonce
Implementation ofβ
AccountInterface.getNonceForAddress
Inherited fromβ
Defined inβ
getBlockβ
βΈ getBlock(): Promise<PendingBlock>
Gets the block information
Returnsβ
Promise<PendingBlock>
the block object
Implementation ofβ
Inherited fromβ
Defined inβ
βΈ getBlock(blockIdentifier): Promise<PendingBlock>
Parametersβ
| Name | Type |
|---|---|
blockIdentifier | "pending" |
Returnsβ
Promise<PendingBlock>
Implementation ofβ
Inherited fromβ
Defined inβ
βΈ getBlock(blockIdentifier): Promise<Block>
Parametersβ
| Name | Type |
|---|---|
blockIdentifier | "latest" |
Returnsβ
Promise<Block>
Implementation ofβ
Inherited fromβ
Defined inβ
βΈ getBlock(blockIdentifier?): Promise<GetBlockResponse>
Parametersβ
| Name | Type |
|---|---|
blockIdentifier? | BlockIdentifier |
Returnsβ
Promise<GetBlockResponse>
Implementation ofβ
AccountInterface.getBlock
Inherited fromβ
Defined inβ
getBlockLatestAcceptedβ
βΈ getBlockLatestAccepted(): Promise<BlockHashAndNumber>
Get the most recent accepted block hash and number
Returnsβ
Promise<BlockHashAndNumber>
Inherited fromβ
Provider.getBlockLatestAccepted
Defined inβ
getBlockNumberβ
βΈ getBlockNumber(): Promise<number>
Get the most recent accepted block number redundant use getBlockLatestAccepted();
Returnsβ
Promise<number>
Number of the latest block
Inherited fromβ
Defined inβ
getBlockWithTxHashesβ
βΈ getBlockWithTxHashes(blockIdentifier?): Promise<BlockWithTxHashes>
Parametersβ
| Name | Type |
|---|---|
blockIdentifier? | BlockIdentifier |
Returnsβ
Promise<BlockWithTxHashes>
Inherited fromβ
Defined inβ
getBlockWithTxsβ
βΈ getBlockWithTxs(blockIdentifier?): Promise<BlockWithTxs>
Parametersβ
| Name | Type |
|---|---|
blockIdentifier? | BlockIdentifier |
Returnsβ
Promise<BlockWithTxs>
Inherited fromβ
Defined inβ
waitForBlockβ
βΈ waitForBlock(blockIdentifier?, retryInterval?): Promise<void>
Pause the execution of the script until a specified block is created.
Parametersβ
| Name | Type | Default value | Description |
|---|---|---|---|
blockIdentifier | BlockIdentifier | 'pending' | bloc number (BigNumberish) or 'pending' or 'latest'. Use of 'latest" or of a block already created will generate no pause. |
retryInterval? | number | 5000 | number of milliseconds between 2 requests to the node |
Returnsβ
Promise<void>
Example
await myProvider.waitForBlock();
// wait the creation of the pending block
Inherited fromβ
Defined inβ
getL1GasPriceβ
βΈ getL1GasPrice(blockIdentifier?): Promise<string>
Gets the price of l1 gas in the block
Parametersβ
| Name | Type | Description |
|---|---|---|
blockIdentifier? | BlockIdentifier | block identifier |
Returnsβ
Promise<string>
gas price of the block
Implementation ofβ
AccountInterface.getL1GasPrice
Inherited fromβ
Defined inβ
getL1MessageHashβ
βΈ getL1MessageHash(l2TxHash): Promise<string>
Get L1 message hash from L2 transaction hash
Parametersβ
| Name | Type | Description |
|---|---|---|
l2TxHash | BigNumberish | L2 transaction hash |
Returnsβ
Promise<string>
Hex string of L1 message hash
Example
In Sepolia Testnet :
const result = provider.getL1MessageHash(
'0x28dfc05eb4f261b37ddad451ff22f1d08d4e3c24dc646af0ec69fa20e096819'
);
// result = '0x55b3f8b6e607fffd9b4d843dfe8f9b5c05822cd94fcad8797deb01d77805532a'
Implementation ofβ
AccountInterface.getL1MessageHash
Inherited fromβ
Defined inβ
getBlockWithReceiptsβ
βΈ getBlockWithReceipts(blockIdentifier?): Promise<BlockWithTxReceipts>
Parametersβ
| Name | Type |
|---|---|
blockIdentifier? | BlockIdentifier |
Returnsβ
Promise<BlockWithTxReceipts>
Inherited fromβ
Defined inβ
getBlockStateUpdateβ
βΈ getBlockStateUpdate(): Promise<{ block_hash: never ; old_root: string ; state_diff: { storage_diffs: { address: string; storage_entries: { key: string; value: string; }[]; }[]; deprecated_declared_classes: string[]; declared_classes: { class_hash: string; compiled_class_hash: string; }[]; deployed_contracts: { ...; }[]; replaced_classes: { ...; }[]; nonces: { ...; }[]; } }>
Returnsβ
Promise<{ block_hash: never ; old_root: string ; state_diff: { storage_diffs: { address: string; storage_entries: { key: string; value: string; }[]; }[]; deprecated_declared_classes: string[]; declared_classes: { class_hash: string; compiled_class_hash: string; }[]; deployed_contracts: { ...; }[]; replaced_classes: { ...; }[]; nonces: { ...; }[]; } }>
Inherited fromβ
Defined inβ
βΈ getBlockStateUpdate(blockIdentifier): Promise<{ block_hash: never ; old_root: string ; state_diff: { storage_diffs: { address: string; storage_entries: { key: string; value: string; }[]; }[]; deprecated_declared_classes: string[]; declared_classes: { class_hash: string; compiled_class_hash: string; }[]; deployed_contracts: { ...; }[]; replaced_classes: { ...; }[]; nonces: { ...; }[]; } }>
Parametersβ
| Name | Type |
|---|---|
blockIdentifier | "pending" |
Returnsβ
Promise<{ block_hash: never ; old_root: string ; state_diff: { storage_diffs: { address: string; storage_entries: { key: string; value: string; }[]; }[]; deprecated_declared_classes: string[]; declared_classes: { class_hash: string; compiled_class_hash: string; }[]; deployed_contracts: { ...; }[]; replaced_classes: { ...; }[]; nonces: { ...; }[]; } }>
Inherited fromβ
Defined inβ
βΈ getBlockStateUpdate(blockIdentifier): Promise<{ block_hash: string ; old_root: string ; new_root: string ; state_diff: { storage_diffs: { address: string; storage_entries: { key: string; value: string; }[]; }[]; deprecated_declared_classes: string[]; declared_classes: { class_hash: string; compiled_class_hash: string; }[]; deployed_contracts: { ...; }[]; replaced_classes: { ...; }[]; nonces: { ...; }[]; } }>
Parametersβ
| Name | Type |
|---|---|
blockIdentifier | "latest" |
Returnsβ
Promise<{ block_hash: string ; old_root: string ; new_root: string ; state_diff: { storage_diffs: { address: string; storage_entries: { key: string; value: string; }[]; }[]; deprecated_declared_classes: string[]; declared_classes: { class_hash: string; compiled_class_hash: string; }[]; deployed_contracts: { ...; }[]; replaced_classes: { ...; }[]; nonces: { ...; }[]; } }>
Inherited fromβ
Defined inβ
βΈ getBlockStateUpdate(blockIdentifier?): Promise<StateUpdateResponse>
Parametersβ
| Name | Type |
|---|---|
blockIdentifier? | BlockIdentifier |
Returnsβ
Promise<StateUpdateResponse>
Inherited fromβ
Defined inβ
getBlockTransactionsTracesβ
βΈ getBlockTransactionsTraces(blockIdentifier?): Promise<BlockTransactionsTraces>
Parametersβ
| Name | Type |
|---|---|
blockIdentifier? | BlockIdentifier |
Returnsβ
Promise<BlockTransactionsTraces>
Inherited fromβ
Provider.getBlockTransactionsTraces