Skip to main content
Version: Next

Class: AccountInterface

Hierarchy

Implemented by

Constructors

constructor

new AccountInterface()

Inherited from

ProviderInterface.constructor

Properties

address

Abstract address: string

Defined in

src/account/interface.ts:34


signer

Abstract signer: SignerInterface

Defined in

src/account/interface.ts:36


cairoVersion

Abstract cairoVersion: CairoVersion

Defined in

src/account/interface.ts:38

Methods

estimateInvokeFee

Abstract estimateInvokeFee(calls, estimateFeeDetails?): Promise<EstimateFeeResponse>

Estimate Fee for executing an INVOKE transaction on starknet

Parameters

NameTypeDescription
callsAllowArray<Call>the invocation object containing: - contractAddress - the address of the contract - entrypoint - the entrypoint of the contract - calldata - (defaults to []) the calldata
estimateFeeDetails?EstimateFeeDetails-

Returns

Promise<EstimateFeeResponse>

response from estimate_fee

Defined in

src/account/interface.ts:50


estimateDeclareFee

Abstract estimateDeclareFee(contractPayload, estimateFeeDetails?): Promise<EstimateFeeResponse>

Estimate Fee for executing a DECLARE transaction on starknet

Parameters

NameTypeDescription
contractPayloadDeclareContractPayloadthe payload object containing: - contract - the compiled contract to be declared - classHash - the class hash of the compiled contract. This can be obtained by using starknet-cli.
estimateFeeDetails?EstimateFeeDetails-

Returns

Promise<EstimateFeeResponse>

response from estimate_fee

Defined in

src/account/interface.ts:64


estimateAccountDeployFee

Abstract estimateAccountDeployFee(contractPayload, estimateFeeDetails?): Promise<EstimateFeeResponse>

Estimate Fee for executing a DEPLOY_ACCOUNT transaction on starknet

Parameters

NameTypeDescription
contractPayloadDeployAccountContractPayloadcontract - the compiled contract to be deployed - classHash - the class hash of the compiled contract. This can be obtained by using starknet-cli.
estimateFeeDetails?EstimateFeeDetailsoptional blockIdentifier - constant nonce = 0

Returns

Promise<EstimateFeeResponse>

response from estimate_fee

Defined in

src/account/interface.ts:80


estimateDeployFee

Abstract estimateDeployFee(deployContractPayload, transactionsDetail?): Promise<EstimateFeeResponse>

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

NameTypeDescription
deployContractPayloadUniversalDeployerContractPayload | UniversalDeployerContractPayload[]containing - classHash: computed class hash of compiled contract - salt: address salt - unique: bool if true ensure unique salt - calldata: constructor calldata
transactionsDetail?InvocationsDetailsInvocation Details containing: - optional nonce - optional version - optional maxFee

Returns

Promise<EstimateFeeResponse>

Defined in

src/account/interface.ts:100


estimateFeeBulk

Abstract estimateFeeBulk(invocations, details?): Promise<EstimateFeeResponseBulk>

Estimate Fee for executing a list of transactions on starknet Contract must be deployed for fee estimation to be possible

Parameters

NameType
invocationsInvocations
details?EstimateFeeDetails

Returns

Promise<EstimateFeeResponseBulk>

response from estimate_fee

Defined in

src/account/interface.ts:115


execute

Abstract execute(transactions, abis?, transactionsDetail?): Promise<InvokeFunctionResponse>

Invoke execute function in account contract

Parameters

NameTypeDescription
transactionsAllowArray<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[]-
transactionsDetail?InvocationsDetails-

Returns

Promise<InvokeFunctionResponse>

response from addTransaction

Defined in

src/account/interface.ts:132


declare

Abstract declare(contractPayload, transactionsDetail?): Promise<DeclareContractResponse>

Declares a given compiled contract (json) to starknet

Parameters

NameTypeDescription
contractPayloadDeclareContractPayloadtransaction 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.
transactionsDetail?InvocationsDetailsInvocation Details containing: - optional nonce - optional version - optional maxFee

Returns

Promise<DeclareContractResponse>

a confirmation of sending a transaction on the starknet contract

Defined in

src/account/interface.ts:152


deploy

Abstract deploy(payload, details?): Promise<MultiDeployContractResponse>

Deploys a declared contract to starknet - using Universal Deployer Contract (UDC) support multicall

Parameters

NameTypeDescription
payloadUniversalDeployerContractPayload | UniversalDeployerContractPayload[]classHash: computed class hash of compiled contract - [constructorCalldata] contract constructor calldata - [salt=pseudorandom] deploy address salt - [unique=true] ensure unique salt
details?InvocationsDetails[nonce=getNonce] - [version=transactionVersion] - [maxFee=getSuggestedMaxFee]

Returns

Promise<MultiDeployContractResponse>

  • contract_address[]
  • transaction_hash

Defined in

src/account/interface.ts:174


deployContract

Abstract deployContract(payload, details?): Promise<DeployContractUDCResponse>

Simplify deploy simulating old DeployContract with same response + UDC specific response Internal wait for L2 transaction, support multicall

Parameters

NameTypeDescription
payloadUniversalDeployerContractPayload | UniversalDeployerContractPayload[]classHash: computed class hash of compiled contract - [constructorCalldata] contract constructor calldata - [salt=pseudorandom] deploy address salt - [unique=true] ensure unique salt
details?InvocationsDetails[nonce=getNonce] - [version=transactionVersion] - [maxFee=getSuggestedMaxFee]

Returns

Promise<DeployContractUDCResponse>

  • contract_address
  • transaction_hash
  • address
  • deployer
  • unique
  • classHash
  • calldata_len
  • calldata
  • salt

Defined in

src/account/interface.ts:203


declareAndDeploy

Abstract 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

NameTypeDescription
payloadDeclareAndDeployContractPayloadcontract: 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?InvocationsDetails[nonce=getNonce] - [version=transactionVersion] - [maxFee=getSuggestedMaxFee]

Returns

Promise<DeclareDeployUDCResponse>

  • declare
    • transaction_hash
  • deploy
    • contract_address
    • transaction_hash
    • address
    • deployer
    • unique
    • classHash
    • calldata_len
    • calldata
    • salt

Defined in

src/account/interface.ts:239


deployAccount

Abstract deployAccount(contractPayload, transactionsDetail?): Promise<DeployContractResponse>

Deploy the account on Starknet

Parameters

NameTypeDescription
contractPayloadDeployAccountContractPayloadtransaction payload to be deployed containing: - classHash: computed class hash of compiled contract - optional constructor calldata - optional address salt - optional contractAddress
transactionsDetail?InvocationsDetailsInvocation Details containing: - constant nonce = 0 - optional version - optional maxFee

Returns

Promise<DeployContractResponse>

a confirmation of sending a transaction on the starknet contract

Defined in

src/account/interface.ts:258


signMessage

Abstract signMessage(typedData): Promise<Signature>

Sign an JSON object for off-chain usage with the starknet private key and return the signature This adds a message prefix so it cant be interchanged with transactions

Throws

if the JSON object is not a valid JSON

Parameters

NameType
typedDataTypedData

Returns

Promise<Signature>

the signature of the JSON object

Defined in

src/account/interface.ts:271


hashMessage

Abstract hashMessage(typedData): Promise<string>

Hash a JSON object with pederson hash and return the hash This adds a message prefix so it cant be interchanged with transactions

Throws

if the JSON object is not a valid JSON

Parameters

NameType
typedDataTypedData

Returns

Promise<string>

the hash of the JSON object

Defined in

src/account/interface.ts:281


verifyMessage

Abstract verifyMessage(typedData, signature): Promise<boolean>

Verify a signature of a JSON object

Throws

if the JSON object is not a valid JSON or the signature is not a valid signature

Parameters

NameTypeDescription
typedDataTypedDataJSON object to be verified
signatureSignaturesignature of the JSON object

Returns

Promise<boolean>

true if the signature is valid, false otherwise

Defined in

src/account/interface.ts:291


verifyMessageHash

Abstract verifyMessageHash(hash, signature): Promise<boolean>

Verify a signature of a given hash

Warning

This method is not recommended, use verifyMessage instead

Throws

if the signature is not a valid signature

Parameters

NameTypeDescription
hashBigNumberishhash to be verified
signatureSignaturesignature of the hash

Returns

Promise<boolean>

true if the signature is valid, false otherwise

Defined in

src/account/interface.ts:302


getNonce

Abstract getNonce(blockIdentifier?): Promise<string>

Gets the nonce of the account with respect to a specific block

Parameters

NameTypeDescription
blockIdentifier?BlockIdentifieroptional blockIdentifier. Defaults to 'pending'

Returns

Promise<string>

nonce of the account

Defined in

src/account/interface.ts:310


getSuggestedMaxFee

Abstract getSuggestedMaxFee(estimateFeeAction, details): Promise<bigint>

Gets Suggested Max Fee based on the transaction type

Parameters

NameType
estimateFeeActionEstimateFeeAction
detailsEstimateFeeDetails

Returns

Promise<bigint>

suggestedMaxFee

Defined in

src/account/interface.ts:319


simulateTransaction

Abstract simulateTransaction(invocations, details?): Promise<SimulateTransactionResponse>

Simulates an array of transaction and returns an array of transaction trace and estimated fee.

Parameters

NameTypeDescription
invocationsInvocationsInvocations containing: - type - transaction type: DECLARE, (multi)DEPLOY, DEPLOY_ACCOUNT, (multi)INVOKE_FUNCTION
details?SimulateTransactionDetailsSimulateTransactionDetails

Returns

Promise<SimulateTransactionResponse>

response from simulate_transaction

Defined in

src/account/interface.ts:333


getChainId

Abstract getChainId(): Promise<StarknetChainId>

Gets the Starknet chain Id

Returns

Promise<StarknetChainId>

the chain Id

Inherited from

ProviderInterface.getChainId

Defined in

src/provider/interface.ts:38


callContract

Abstract callContract(call, blockIdentifier?): Promise<CallContractResponse>

Calls a function on the Starknet contract.

Parameters

NameTypeDescription
callCalltransaction to be called
blockIdentifier?BlockIdentifierblock identifier

Returns

Promise<CallContractResponse>

the result of the function on the smart contract.

Inherited from

ProviderInterface.callContract

Defined in

src/provider/interface.ts:47


getBlock

Abstract getBlock(blockIdentifier): Promise<GetBlockResponse>

Gets the block information

Parameters

NameTypeDescription
blockIdentifierBlockIdentifierblock identifier

Returns

Promise<GetBlockResponse>

the block object

Inherited from

ProviderInterface.getBlock

Defined in

src/provider/interface.ts:58


getCode

Abstract getCode(contractAddress, blockIdentifier?): Promise<GetCodeResponse>

Deprecated

The method should not be used

Parameters

NameType
contractAddressstring
blockIdentifier?BlockIdentifier

Returns

Promise<GetCodeResponse>

Inherited from

ProviderInterface.getCode

Defined in

src/provider/interface.ts:63


getClassAt

Abstract getClassAt(contractAddress, blockIdentifier?): Promise<ContractClassResponse>

Gets the contract class of the deployed contract.

Parameters

NameTypeDescription
contractAddressstringcontract address
blockIdentifier?BlockIdentifierblock identifier

Returns

Promise<ContractClassResponse>

Contract class of compiled contract

Inherited from

ProviderInterface.getClassAt

Defined in

src/provider/interface.ts:75


getClassHashAt

Abstract getClassHashAt(contractAddress, blockIdentifier?): Promise<string>

Returns the class hash deployed under the given address.

Parameters

NameTypeDescription
contractAddressstringcontract address
blockIdentifier?BlockIdentifierblock identifier

Returns

Promise<string>

Class hash

Inherited from

ProviderInterface.getClassHashAt

Defined in

src/provider/interface.ts:87


getClassByHash

Abstract getClassByHash(classHash): Promise<ContractClassResponse>

Returns the contract class deployed under the given class hash.

Parameters

NameTypeDescription
classHashstringclass hash

Returns

Promise<ContractClassResponse>

Contract class of compiled contract

Inherited from

ProviderInterface.getClassByHash

Defined in

src/provider/interface.ts:98


getNonceForAddress

Abstract getNonceForAddress(contractAddress, blockIdentifier?): Promise<string>

Gets the nonce of a contract with respect to a specific block

Parameters

NameTypeDescription
contractAddressstringcontract address
blockIdentifier?BlockIdentifier-

Returns

Promise<string>

the hex nonce

Inherited from

ProviderInterface.getNonceForAddress

Defined in

src/provider/interface.ts:106


getStorageAt

Abstract getStorageAt(contractAddress, key, blockIdentifier?): Promise<string>

Gets the contract's storage variable at a specific key.

Parameters

NameTypeDescription
contractAddressstring
keyBigNumberishfrom getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)
blockIdentifier?BlockIdentifierblock identifier

Returns

Promise<string>

the value of the storage variable

Inherited from

ProviderInterface.getStorageAt

Defined in

src/provider/interface.ts:119


getTransaction

Abstract getTransaction(transactionHash): Promise<GetTransactionResponse>

Gets the transaction information from a tx id.

Parameters

NameType
transactionHashBigNumberish

Returns

Promise<GetTransactionResponse>

the transaction object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }

Inherited from

ProviderInterface.getTransaction

Defined in

src/provider/interface.ts:131


getTransactionReceipt

Abstract getTransactionReceipt(transactionHash): Promise<GetTransactionReceiptResponse>

Gets the transaction receipt from a tx hash.

Parameters

NameType
transactionHashBigNumberish

Returns

Promise<GetTransactionReceiptResponse>

the transaction receipt object

Inherited from

ProviderInterface.getTransactionReceipt

Defined in

src/provider/interface.ts:139


deployAccountContract

Abstract deployAccountContract(payload, details): Promise<DeployContractResponse>

Deploys a given compiled Account contract (json) to starknet

Parameters

NameTypeDescription
payloadDeployAccountContractPayloadpayload to be deployed containing: - compiled contract code - constructor calldata - address salt
detailsInvocationsDetailsWithNonce-

Returns

Promise<DeployContractResponse>

a confirmation of sending a transaction on the starknet contract

Inherited from

ProviderInterface.deployAccountContract

Defined in

src/provider/interface.ts:152


invokeFunction

Abstract invokeFunction(invocation, details): Promise<InvokeFunctionResponse>

Invokes a function on starknet

Deprecated

This method wont be supported as soon as fees are mandatory. Should not be used outside of Account class

Parameters

NameTypeDescription
invocationInvocationthe invocation object containing: - contractAddress - the address of the contract - entrypoint - the entrypoint of the contract - calldata - (defaults to []) the calldata - signature - (defaults to []) the signature
detailsInvocationsDetailsWithNonceoptional details containing: - nonce - optional nonce - version - optional version - maxFee - optional maxFee

Returns

Promise<InvokeFunctionResponse>

response from addTransaction

Inherited from

ProviderInterface.invokeFunction

Defined in

src/provider/interface.ts:172


declareContract

Abstract declareContract(transaction, details): Promise<DeclareContractResponse>

Declares a given compiled contract (json) to starknet

Parameters

NameTypeDescription
transactionDeclareContractTransactiontransaction payload to be deployed containing: - compiled contract code - sender address - signature
detailsInvocationsDetailsWithNonceInvocation Details containing: - nonce - optional version - optional maxFee

Returns

Promise<DeclareContractResponse>

a confirmation of sending a transaction on the starknet contract

Inherited from

ProviderInterface.declareContract

Defined in

src/provider/interface.ts:189


getEstimateFee

Abstract getEstimateFee(invocation, details, blockIdentifier, skipValidate?): Promise<EstimateFeeResponse>

Estimates the fee for a given INVOKE transaction

Deprecated

Please use getInvokeEstimateFee or getDeclareEstimateFee instead. Should not be used outside of Account class

Parameters

NameTypeDescription
invocationInvocationthe invocation object containing: - contractAddress - the address of the contract - entrypoint - the entrypoint of the contract - calldata - (defaults to []) the calldata - signature - (defaults to []) the signature
detailsInvocationsDetailsWithNonceoptional details containing: - nonce - optional nonce - version - optional version
blockIdentifierBlockIdentifier(optional) block identifier
skipValidate?boolean(optional) skip cairo validate method

Returns

Promise<EstimateFeeResponse>

the estimated fee

Inherited from

ProviderInterface.getEstimateFee

Defined in

src/provider/interface.ts:210


getInvokeEstimateFee

Abstract getInvokeEstimateFee(invocation, details, blockIdentifier?, skipValidate?): Promise<EstimateFeeResponse>

Estimates the fee for a given INVOKE transaction

Parameters

NameTypeDescription
invocationInvocationthe invocation object containing: - contractAddress - the address of the contract - entrypoint - the entrypoint of the contract - calldata - (defaults to []) the calldata - signature - (defaults to []) the signature
detailsInvocationsDetailsWithNonceoptional details containing: - nonce - optional nonce - version - optional version
blockIdentifier?BlockIdentifier(optional) block identifier
skipValidate?boolean(optional) skip cairo validate method

Returns

Promise<EstimateFeeResponse>

the estimated fee

Inherited from

ProviderInterface.getInvokeEstimateFee

Defined in

src/provider/interface.ts:232


getDeclareEstimateFee

Abstract getDeclareEstimateFee(transaction, details, blockIdentifier?, skipValidate?): Promise<EstimateFeeResponse>

Estimates the fee for a given DECLARE transaction

Parameters

NameTypeDescription
transactionDeclareContractTransactiontransaction payload to be declared containing: - compiled contract code - sender address - signature - (defaults to []) the signature
detailsInvocationsDetailsWithNonceoptional details containing: - nonce - version - optional version - optional maxFee
blockIdentifier?BlockIdentifier(optional) block identifier
skipValidate?boolean(optional) skip cairo validate method

Returns

Promise<EstimateFeeResponse>

the estimated fee

Inherited from

ProviderInterface.getDeclareEstimateFee

Defined in

src/provider/interface.ts:254


getDeployAccountEstimateFee

Abstract getDeployAccountEstimateFee(transaction, details, blockIdentifier?, skipValidate?): Promise<EstimateFeeResponse>

Estimates the fee for a given DEPLOY_ACCOUNT transaction

Parameters

NameTypeDescription
transactionDeployAccountContractTransactiontransaction payload to be deployed containing: - classHash - constructorCalldata - addressSalt - signature - (defaults to []) the signature
detailsInvocationsDetailsWithNonceoptional details containing: - nonce - version - optional version - optional maxFee
blockIdentifier?BlockIdentifier(optional) block identifier
skipValidate?boolean(optional) skip cairo validate method

Returns

Promise<EstimateFeeResponse>

the estimated fee

Inherited from

ProviderInterface.getDeployAccountEstimateFee

Defined in

src/provider/interface.ts:277


getEstimateFeeBulk

Abstract getEstimateFeeBulk(invocations, options?): Promise<EstimateFeeResponseBulk>

Estimates the fee for a list of INVOKE transaction

Parameters

NameTypeDescription
invocationsAccountInvocationsAccountInvocations - Complete invocations array with account details
options?getEstimateFeeBulkOptionsgetEstimateFeeBulkOptions - (optional) blockIdentifier - BlockIdentifier - (optional) skipValidate - boolean (default false)

Returns

Promise<EstimateFeeResponseBulk>

the estimated fee

Inherited from

ProviderInterface.getEstimateFeeBulk

Defined in

src/provider/interface.ts:293


waitForTransaction

Abstract waitForTransaction(txHash, options?): Promise<GetTransactionReceiptResponse>

Wait for the transaction to be accepted

Parameters

NameTypeDescription
txHashBigNumberishtransaction hash
options?waitForTransactionOptionswaitForTransactionOptions - (optional) retryInterval: number | undefined; - (optional) successStates: TransactionStatus[] | undefined;

Returns

Promise<GetTransactionReceiptResponse>

GetTransactionReceiptResponse

Inherited from

ProviderInterface.waitForTransaction

Defined in

src/provider/interface.ts:306


getSimulateTransaction

Abstract getSimulateTransaction(invocations, options?): Promise<SimulateTransactionResponse>

Simulates the transaction and returns the transaction trace and estimated fee.

Parameters

NameTypeDescription
invocationsAccountInvocationsAccountInvocations - Complete invocations array with account details
options?getSimulateTransactionOptionsgetSimulateTransactionOptions - (optional) blockIdentifier - block identifier - (optional) skipValidate - skip cairo validate method - (optional) skipExecute - skip cairo execute method

Returns

Promise<SimulateTransactionResponse>

an array of transaction trace and estimated fee

Inherited from

ProviderInterface.getSimulateTransaction

Defined in

src/provider/interface.ts:321


getStateUpdate

Abstract getStateUpdate(blockIdentifier?): Promise<StateUpdateResponse>

Gets the state changes in a specific block

Parameters

NameTypeDescription
blockIdentifier?BlockIdentifierblock identifier

Returns

Promise<StateUpdateResponse>

StateUpdateResponse

Inherited from

ProviderInterface.getStateUpdate

Defined in

src/provider/interface.ts:332