Class: AccountInterface
Interface for interacting with Starknet account contracts
Extends ProviderInterface to provide account-specific functionality including:
- Transaction execution and signing
- Fee estimation for various transaction types
- Contract deployment through UDC (Universal Deployer Contract)
- Paymaster support for sponsored transactions
- EIP-712 message signing
Remarks
Implementations of this interface typically handle the complexities of:
- Nonce management
- Transaction signing with the account's private key
- Interaction with the account contract's execute entrypoint
Hierarchy
-
↳
AccountInterface
Implemented by
Constructors
constructor
• new AccountInterface(): AccountInterface
Returns
Inherited from
Properties
address
• Abstract address: string
The address of the account contract on Starknet
Defined in
signer
• Abstract signer: SignerInterface
Signer instance for signing transactions and messages
Defined in
cairoVersion
• Abstract cairoVersion: CairoVersion
Cairo version of the account contract implementation
Defined in
deployer
• Optional Abstract deployer: DeployerInterface
Optional deployer instance for custom contract deployment logic
Default
Uses default UDC (Universal Deployer Contract) if not specified
Defined in
channel
• Abstract channel: RpcChannel | RpcChannel
Inherited from
Defined in
responseParser
• Abstract responseParser: RPCResponseParser
Inherited from
ProviderInterface.responseParser
Defined in
Methods
estimateInvokeFee
▸ estimateInvokeFee(calls, estimateFeeDetails?): Promise<EstimateFeeResponseOverhead>
Estimate fee for executing an INVOKE transaction on Starknet
Parameters
| Name | Type | Description |
|---|---|---|
calls | AllowArray<Call> | Single call or array of calls to estimate fees for |
estimateFeeDetails? | UniversalDetails | Optional details for fee estimation |
Returns
Promise<EstimateFeeResponseOverhead>
Fee estimation including overall_fee and resourceBounds
Example
const fee = await account.estimateInvokeFee({
contractAddress: '0x123...',
entrypoint: 'transfer',
calldata: [recipient, amount],
});
Defined in
estimateDeclareFee
▸ estimateDeclareFee(contractPayload, estimateFeeDetails?): Promise<EstimateFeeResponseOverhead>
Estimate fee for executing a DECLARE transaction on Starknet
Parameters
| Name | Type | Description |
|---|---|---|
contractPayload | DeclareContractPayload | Contract declaration payload |
estimateFeeDetails? | UniversalDetails | Optional details for fee estimation |
Returns
Promise<EstimateFeeResponseOverhead>
Fee estimation including overall_fee and resourceBounds
Example
const fee = await account.estimateDeclareFee({
contract: compiledContract,
casm: compiledCasm,
});
Defined in
estimateAccountDeployFee
▸ estimateAccountDeployFee(contractPayload, estimateFeeDetails?): Promise<EstimateFeeResponseOverhead>
Estimate fee for executing an INVOKE transaction on Starknet
Parameters
| Name | Type | Description |
|---|---|---|
contractPayload | DeployAccountContractPayload | Single call or array of calls to estimate fees for |
estimateFeeDetails? | UniversalDetails | Optional details for fee estimation |
Returns
Promise<EstimateFeeResponseOverhead>
Fee estimation including overall_fee and resourceBounds
Fee estimation including overall_fee and resourceBounds
Example
const fee = await account.estimateAccountDeployFee({
classHash: accountClassHash,
constructorCalldata: { publicKey },
addressSalt: publicKey,
});
Defined in
estimateDeployFee
▸ estimateDeployFee(deployContractPayload, estimateFeeDetails?): Promise<EstimateFeeResponseOverhead>
Estimate fee for executing an INVOKE transaction on Starknet
Parameters
| Name | Type | Description |
|---|---|---|
deployContractPayload | UniversalDeployerContractPayload | UniversalDeployerContractPayload[] | Single call or array of calls to estimate fees for |
estimateFeeDetails? | UniversalDetails | Optional details for fee estimation |
Returns
Promise<EstimateFeeResponseOverhead>
Fee estimation for the deployment transaction
Fee estimation including overall_fee and resourceBounds
Example
const fee = await account.estimateDeployFee({
classHash: contractClassHash,
constructorCalldata: [param1, param2],
unique: true,
});
Defined in
estimateFeeBulk
▸ estimateFeeBulk(invocations, details?): Promise<EstimateFeeResponseBulkOverhead>
Estimate fee for executing an INVOKE transaction on Starknet
Parameters
| Name | Type | Description |
|---|---|---|
invocations | Invocations | Single call or array of calls to estimate fees for |
details? | UniversalDetails | Optional details for fee estimation |
Returns
Promise<EstimateFeeResponseBulkOverhead>
Array of fee estimations for each transaction
Fee estimation including overall_fee and resourceBounds
Example
const fees = await account.estimateFeeBulk([
{ type: 'INVOKE', payload: { contractAddress, entrypoint, calldata } },
{ type: 'DECLARE', payload: { contract, casm } },
]);
Defined in
execute
▸ execute(transactions, transactionsDetail?): Promise<{ transaction_hash: string }>
Execute one or multiple calls through the account contract
Parameters
| Name | Type | Description |
|---|---|---|
transactions | AllowArray<Call> | Single call or array of calls to execute |
transactionsDetail? | InvocationsDetails | Transaction execution options |
Returns
Promise<{ transaction_hash: string }>
Transaction hash and response
Example
const result = await account.execute([
{ contractAddress: token, entrypoint: 'transfer', calldata: [to, amount] },
{ contractAddress: nft, entrypoint: 'mint', calldata: [recipient] },
]);
Defined in
estimatePaymasterTransactionFee
▸ estimatePaymasterTransactionFee(calls, paymasterDetails): Promise<PaymasterFeeEstimate>
Estimate fees for a paymaster-sponsored transaction
Parameters
| Name | Type | Description |
|---|---|---|
calls | Call[] | Array of calls to be sponsored |
paymasterDetails | PaymasterDetails | Paymaster configuration |
Returns
Promise<PaymasterFeeEstimate>
Fee estimates in both STRK and gas token
Example
const fees = await account.estimatePaymasterTransactionFee(
[{ contractAddress, entrypoint, calldata }],
{ feeMode: { mode: 'sponsored' } }
);
Defined in
buildPaymasterTransaction
▸ buildPaymasterTransaction(calls, paymasterDetails): Promise<PreparedTransaction>
Estimate fees for a paymaster-sponsored transaction
Parameters
| Name | Type | Description |
|---|---|---|
calls | Call[] | Array of calls to be sponsored |
paymasterDetails | PaymasterDetails | Paymaster configuration |
Returns
Promise<PreparedTransaction>
Prepared transaction with typed data for signing
Fee estimates in both STRK and gas token
Example
const prepared = await account.buildPaymasterTransaction(calls, {
feeMode: { mode: 'default', gasToken: ETH_ADDRESS },
});
Defined in
executePaymasterTransaction
▸ executePaymasterTransaction(calls, paymasterDetails, maxFeeInGasToken?): Promise<{ transaction_hash: string }>
Execute a paymaster-sponsored transaction
Parameters
| Name | Type | Description |
|---|---|---|
calls | Call[] | Array of calls to execute |
paymasterDetails | PaymasterDetails | Paymaster configuration |
maxFeeInGasToken? | BigNumberish | Maximum acceptable fee in gas token |
Returns
Promise<{ transaction_hash: string }>
Transaction hash if successful
Throws
If gas token price exceeds maxFeeInGasToken
Throws
If transaction parameters are modified by paymaster
Example
const txHash = await account.executePaymasterTransaction(
calls,
{ feeMode: { mode: 'sponsored' }, timeBounds: { executeBefore: Date.now() / 1000 + 3600 } },
maxFeeETH
);
Defined in
declare
▸ declare(contractPayload, transactionsDetail?): Promise<{ class_hash: string ; transaction_hash: string }>
Execute one or multiple calls through the account contract
Parameters
| Name | Type | Description |
|---|---|---|
contractPayload | DeclareContractPayload | Single call or array of calls to execute |
transactionsDetail? | InvocationsDetails | Transaction execution options |
Returns
Promise<{ class_hash: string ; transaction_hash: string }>
Declaration transaction hash and class hash
Transaction hash and response
Example
const declareResult = await account.declare({
contract: compiledSierra,
casm: compiledCasm,
});
Defined in
deploy
▸ deploy(payload, details?): Promise<MultiDeployContractResponse>
Execute one or multiple calls through the account contract
Parameters
| Name | Type | Description |
|---|---|---|
payload | UniversalDeployerContractPayload | UniversalDeployerContractPayload[] | Single call or array of calls to execute |
details? | InvocationsDetails | Transaction execution options |
Returns
Promise<MultiDeployContractResponse>
Deployed contract addresses and transaction hash
Transaction hash and response
Example
const deployment = await account.deploy([
{ classHash: erc20ClassHash, constructorCalldata: [name, symbol] },
{ classHash: nftClassHash, unique: true },
]);
Defined in
deployContract
▸ deployContract(payload, details?): Promise<DeployContractUDCResponse>
Execute one or multiple calls through the account contract
Parameters
| Name | Type | Description |
|---|---|---|
payload | UniversalDeployerContractPayload | UniversalDeployerContractPayload[] | Single call or array of calls to execute |
details? | InvocationsDetails | Transaction execution options |
Returns
Promise<DeployContractUDCResponse>
Deployment result with contract address and UDC event details
Deployed contract addresses and transaction hash
Remarks
This method waits for transaction confirmation before returning
Example
const result = await account.deployContract({
classHash: contractClassHash,
constructorCalldata: params,
});
console.log('Deployed at:', result.address);
Defined in
declareAndDeploy
▸ declareAndDeploy(payload, details?): Promise<DeclareDeployUDCResponse>
Execute one or multiple calls through the account contract
Parameters
| Name | Type | Description |
|---|---|---|
payload | DeclareAndDeployContractPayload | Single call or array of calls to execute |
details? | InvocationsDetails | Transaction execution options |
Returns
Promise<DeclareDeployUDCResponse>
Declaration and deployment results
Transaction hash and response
Remarks
- Automatically skips declaration if contract is already declared
- Waits for both transactions to complete
- Does not support batch operations
Example
const result = await account.declareAndDeploy({
contract: compiledContract,
casm: compiledCasm,
constructorCalldata: [param1, param2],
});
Defined in
deployAccount
▸ deployAccount(contractPayload, transactionsDetail?): Promise<DeployContractResponse>
Execute one or multiple calls through the account contract
Parameters
| Name | Type | Description |
|---|---|---|
contractPayload | DeployAccountContractPayload | Single call or array of calls to execute |
transactionsDetail? | InvocationsDetails | Transaction execution options |
Returns
Promise<DeployContractResponse>
Deployment transaction hash and contract address
Transaction hash and response
Remarks
Used for deploying the account contract when using a pre-funded address
Example
const deployment = await account.deployAccount({
classHash: accountClassHash,
constructorCalldata: { publicKey: pubKey },
addressSalt: pubKey,
});
Defined in
signMessage
▸ signMessage(typedData): Promise<Signature>
Sign a typed data message for off-chain verification
Parameters
| Name | Type | Description |
|---|---|---|
typedData | TypedData | EIP-712 style typed data structure |
Returns
Promise<Signature>
Signature array [r, s]
Remarks
- Includes domain separation to prevent signature reuse
- Compatible with Starknet's signature verification
- Cannot be used to sign transactions
Example
const signature = await account.signMessage({
domain: { name: 'MyDapp', chainId: 'SN_MAIN' },
types: { ... },
primaryType: 'Message',
message: { content: 'Hello Starknet!' }
});
Defined in
hashMessage
▸ hashMessage(typedData): Promise<string>
Hash a typed data message using Pedersen hash
Parameters
| Name | Type | Description |
|---|---|---|
typedData | TypedData | EIP-712 style typed data structure |
Returns
Promise<string>
Message hash as hex string
Remarks
- Uses Pedersen hash function (not Keccak)
- Includes domain separation
- Result can be used for signature verification
Example
const messageHash = await account.hashMessage(typedData);
Defined in
getNonce
▸ getNonce(blockIdentifier?): Promise<string>
Get the current nonce of the account
Parameters
| Name | Type | Description |
|---|---|---|
blockIdentifier? | BlockIdentifier | Block to query nonce at (default: 'pending') |
Returns
Promise<string>
Account nonce as hex string
Example
const nonce = await account.getNonce();
const historicalNonce = await account.getNonce('latest');
Defined in
declareIfNot
▸ declareIfNot(contractPayload, transactionsDetail?): Promise<{ class_hash: string ; transaction_hash: string }>
Declare a contract class if not already declared
Parameters
| Name | Type | Description |
|---|---|---|
contractPayload | DeclareContractPayload | Contract declaration payload |
transactionsDetail? | InvocationsDetails | Transaction execution options |
Returns
Promise<{ class_hash: string ; transaction_hash: string }>
Declaration result (with empty transaction_hash if already declared)
Example
const result = await account.declareIfNot({
contract: compiledContract,
casm: compiledCasm,
});
Defined in
getChainId
▸ getChainId(): Promise<"0x534e5f4d41494e" | "0x534e5f5345504f4c4941">
Gets the Starknet chain Id
Returns
Promise<"0x534e5f4d41494e" | "0x534e5f5345504f4c4941">
the chain Id
Inherited from
Defined in
callContract
▸ callContract(call, blockIdentifier?): Promise<CallContractResponse>
Calls a function on the Starknet contract.
Parameters
| Name | Type | Description |
|---|---|---|
call | Call | transaction to be called |
blockIdentifier? | BlockIdentifier | block identifier |
Returns
Promise<CallContractResponse>
the result of the function on the smart contract.
Inherited from
ProviderInterface.callContract
Defined in
getBlock
▸ getBlock(): Promise<{ transactions: string[] ; parent_hash: string ; timestamp: number ; sequencer_address: string ; l1_gas_price: RESOURCE_PRICE ; l2_gas_price: RESOURCE_PRICE ; l1_data_gas_price: RESOURCE_PRICE ; l1_da_mode: L1_DA_MODE ; starknet_version: string }>
Gets the block information
Returns
Promise<{ transactions: string[] ; parent_hash: string ; timestamp: number ; sequencer_address: string ; l1_gas_price: RESOURCE_PRICE ; l2_gas_price: RESOURCE_PRICE ; l1_data_gas_price: RESOURCE_PRICE ; l1_da_mode: L1_DA_MODE ; starknet_version: string }>
the block object
Inherited from
Defined in
▸ getBlock(blockIdentifier): Promise<{ transactions: string[] ; parent_hash: string ; timestamp: number ; sequencer_address: string ; l1_gas_price: RESOURCE_PRICE ; l2_gas_price: RESOURCE_PRICE ; l1_data_gas_price: RESOURCE_PRICE ; l1_da_mode: L1_DA_MODE ; starknet_version: string }>
Parameters
| Name | Type |
|---|---|
blockIdentifier | "pre_confirmed" |
Returns
Promise<{ transactions: string[] ; parent_hash: string ; timestamp: number ; sequencer_address: string ; l1_gas_price: RESOURCE_PRICE ; l2_gas_price: RESOURCE_PRICE ; l1_data_gas_price: RESOURCE_PRICE ; l1_da_mode: L1_DA_MODE ; starknet_version: string }>
Inherited from
Defined in
▸ getBlock(blockIdentifier): Promise<{ status: EBlockStatus ; block_hash: string ; parent_hash: string ; block_number: number ; new_root: string ; timestamp: number ; sequencer_address: string ; l1_gas_price: RESOURCE_PRICE ; l2_gas_price: RESOURCE_PRICE ; l1_data_gas_price: RESOURCE_PRICE ; l1_da_mode: L1_DA_MODE ; starknet_version: string ; transactions: string[] }>
Parameters
| Name | Type |
|---|---|
blockIdentifier | "latest" |
Returns
Promise<{ status: EBlockStatus ; block_hash: string ; parent_hash: string ; block_number: number ; new_root: string ; timestamp: number ; sequencer_address: string ; l1_gas_price: RESOURCE_PRICE ; l2_gas_price: RESOURCE_PRICE ; l1_data_gas_price: RESOURCE_PRICE ; l1_da_mode: L1_DA_MODE ; starknet_version: string ; transactions: string[] }>
Inherited from
Defined in
▸ getBlock(blockIdentifier): Promise<GetBlockResponse>
Parameters
| Name | Type |
|---|---|
blockIdentifier | BlockIdentifier |
Returns
Promise<GetBlockResponse>
Inherited from
Defined in
getClassAt
▸ getClassAt(contractAddress, blockIdentifier?): Promise<ContractClassResponse>
Gets the contract class of the deployed contract.
Parameters
| Name | Type | Description |
|---|---|---|
contractAddress | BigNumberish | contract address |
blockIdentifier? | BlockIdentifier | block identifier |
Returns
Promise<ContractClassResponse>
Contract class of compiled contract
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
Inherited from
ProviderInterface.getL1GasPrice
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'
Inherited from
ProviderInterface.getL1MessageHash
Defined in
getClassHashAt
▸ getClassHashAt(contractAddress, blockIdentifier?): Promise<string>
Returns the contract class hash in the given block for the contract deployed at the given address
Parameters
| Name | Type | Description |
|---|---|---|
contractAddress | BigNumberish | contract address |
blockIdentifier? | BlockIdentifier | block identifier |
Returns
Promise<string>
Class hash
Inherited from
ProviderInterface.getClassHashAt
Defined in
getClassByHash
▸ getClassByHash(classHash): Promise<ContractClassResponse>
Returns the contract class deployed under the given class hash.
Parameters
| Name | Type | Description |
|---|---|---|
classHash | BigNumberish | class hash |
Returns
Promise<ContractClassResponse>
Contract class of compiled contract
Inherited from
ProviderInterface.getClassByHash
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
Inherited from
ProviderInterface.getNonceForAddress
Defined in
getStorageAt
▸ getStorageAt(contractAddress, key, blockIdentifier?): Promise<string>
Get the value of the storage (contract's variable) at the given address and key
Parameters
| Name | Type | Description |
|---|---|---|
contractAddress | BigNumberish | |
key | BigNumberish | from getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP) |
blockIdentifier? | BlockIdentifier | block identifier |
Returns
Promise<string>
the value of the storage variable
Inherited from
ProviderInterface.getStorageAt