Abstract Class: AccountInterface
Defined in: src/account/interface.ts:56
Interface for interacting with Starknet account contracts
Provides 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
Constructors
Constructor
new AccountInterface():
AccountInterface
Returns
AccountInterface
Properties
provider
abstractprovider:ProviderInterface
Defined in: src/account/interface.ts:60
Provider instance for blockchain interaction
address
abstractaddress:string
Defined in: src/account/interface.ts:65
The address of the account contract on Starknet
signer
abstractsigner:SignerInterface
Defined in: src/account/interface.ts:70
Signer instance for signing transactions and messages
cairoVersion
abstractcairoVersion:CairoVersion
Defined in: src/account/interface.ts:77
Cairo version of the account contract implementation
deployer?
abstractoptionaldeployer?:DeployerInterface
Defined in: src/account/interface.ts:83
Optional deployer instance for custom contract deployment logic
Default
Uses default UDC (Universal Deployer Contract) if not specified
Methods
estimateInvokeFee()
abstractestimateInvokeFee(calls,estimateFeeDetails?):Promise<EstimateFeeResponseOverhead>
Defined in: src/account/interface.ts:115
Estimate fee for executing an INVOKE transaction on Starknet
Parameters
calls
Single call or array of calls to estimate fees for
- .contractAddress - The address of the contract to invoke
- .entrypoint - The function selector of the contract method
- .calldata - The serialized function parameters (defaults to [])
estimateFeeDetails?
Optional details for fee estimation
- .blockIdentifier - Block to estimate against
- .nonce - Account nonce (defaults to current nonce)
- .skipValidate - Skip account validation (default: true)
- .tip - Priority fee tip in fri/wei for faster inclusion
- .accountDeploymentData - Include account deployment
- .paymasterData - Paymaster sponsorship data
- .nonceDataAvailabilityMode - DA mode for nonce
- .feeDataAvailabilityMode - DA mode for fee
- .version - Transaction version (v3 uses fri, v1/v2 use wei)
- .resourceBounds - Resource limits for v3 transactions
Returns
Promise<EstimateFeeResponseOverhead>
Fee estimation including overall_fee and resourceBounds
Example
const fee = await account.estimateInvokeFee({
contractAddress: '0x123...',
entrypoint: 'transfer',
calldata: [recipient, amount]
});
estimateDeclareFee()
abstractestimateDeclareFee(contractPayload,estimateFeeDetails?):Promise<EstimateFeeResponseOverhead>
Defined in: src/account/interface.ts:146
Estimate fee for executing a DECLARE transaction on Starknet
Parameters
contractPayload
Contract declaration payload.
- .contract - Compiled contract (Sierra JSON).
- .casm - Compiled Cairo assembly (required for Cairo 1).
- .classHash - Pre-computed class hash (optional optimization).
- .compiledClassHash - Pre-computed CASM hash (alternative to casm).
estimateFeeDetails?
Optional details for fee estimation.
- .blockIdentifier - Block to estimate against.
- .nonce - Account nonce (defaults to current nonce)
- .skipValidate - Skip account validation (default: true)
- .tip - Priority fee tip for faster inclusion
- .version - Transaction version (v3 uses fri, v1/v2 use wei)
Returns
Promise<EstimateFeeResponseOverhead>
Fee estimation including overall_fee and resourceBounds
Example
const fee = await account.estimateDeclareFee({
contract: compiledContract,
casm: compiledCasm
});
estimateAccountDeployFee()
abstractestimateAccountDeployFee(contractPayload,estimateFeeDetails?):Promise<EstimateFeeResponseOverhead>
Defined in: src/account/interface.ts:173
Estimate fee for executing a DEPLOY_ACCOUNT transaction on Starknet
Parameters
contractPayload
DeployAccountContractPayload & object
Account deployment payload
- .classHash - Class hash of the account contract
- .constructorCalldata - Constructor parameters
- .contractAddress - Pre-computed account address
- .addressSalt - Salt for address generation
- .abi - Abi of the account contract (optional): the constructor calldata is checked against it
estimateFeeDetails?
Optional details for fee estimation
Returns
Promise<EstimateFeeResponseOverhead>
Fee estimation including overall_fee and resourceBounds
Example
const fee = await account.estimateAccountDeployFee({
classHash: accountClassHash,
constructorCalldata: { publicKey },
addressSalt: publicKey
});
estimateDeployFee()
abstractestimateDeployFee(deployContractPayload,estimateFeeDetails?):Promise<EstimateFeeResponseOverhead>
Defined in: src/account/interface.ts:199
Estimate fee for deploying contract(s) through the Universal Deployer Contract (UDC)
Parameters
deployContractPayload
UniversalDeployerContractPayload | UniversalDeployerContractPayload[]
Single or array of deployment payloads
- .classHash - Class hash of contract to deploy
- .salt - Deployment salt (optional)
- .unique - Ensure unique deployment address
- .constructorCalldata - Constructor parameters
estimateFeeDetails?
Optional details for fee estimation
Returns
Promise<EstimateFeeResponseOverhead>
Fee estimation for the deployment transaction
Example
const fee = await account.estimateDeployFee({
classHash: contractClassHash,
constructorCalldata: [param1, param2],
unique: true
});
estimateFeeBulk()
abstractestimateFeeBulk(invocations,details?):Promise<EstimateFeeResponseBulkOverhead>
Defined in: src/account/interface.ts:222
Estimate fees for executing multiple transactions in a single request
Parameters
invocations
Array of transactions to estimate
- .type - Transaction type: DECLARE, DEPLOY, INVOKE, DEPLOY_ACCOUNT
- .payload - Transaction-specific payload
details?
Optional details for fee estimation
Returns
Promise<EstimateFeeResponseBulkOverhead>
Array of fee estimations for each transaction
Example
const fees = await account.estimateFeeBulk([
{ type: 'INVOKE', payload: { contractAddress, entrypoint, calldata } },
{ type: 'DECLARE', payload: { contract, casm } }
]);
execute()
abstractexecute(transactions,transactionsDetail?):Promise<{transaction_hash:string; }>
Defined in: src/account/interface.ts:250
Execute one or multiple calls through the account contract
Parameters
transactions
Single call or array of calls to execute
- .contractAddress - Target contract address
- .entrypoint - Function to invoke on the contract
- .calldata - Function parameters
transactionsDetail?
Transaction execution options
- .nonce - Override account nonce
- .resourceBounds - Resource limits for the transaction
- .tip - Priority fee tip
- .version - Force specific transaction version
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] }
]);
estimatePaymasterTransactionFee()
abstractestimatePaymasterTransactionFee(calls,paymasterDetails):Promise<PaymasterFeeEstimate>
Defined in: src/account/interface.ts:277
Estimate fees for a paymaster-sponsored transaction
Parameters
calls
Call[]
Array of calls to be sponsored
- .contractAddress - Target contract address
- .entrypoint - Function to invoke
- .calldata - Function parameters
paymasterDetails
Paymaster configuration
- .feeMode - Sponsorship mode: 'sponsored' or gas token
- .deploymentData - Account deployment data if needed
- .timeBounds - Valid execution time window
Returns
Promise<PaymasterFeeEstimate>
Fee estimates in both STRK and gas token
Example
const fees = await account.estimatePaymasterTransactionFee(
[{ contractAddress, entrypoint, calldata }],
{ feeMode: { mode: 'sponsored' } }
);
buildPaymasterTransaction()
abstractbuildPaymasterTransaction(calls,paymasterDetails):Promise<PreparedTransaction>
Defined in: src/account/interface.ts:297
Build a transaction for paymaster execution
Parameters
calls
Call[]
Array of calls to be sponsored
paymasterDetails
Paymaster configuration
Returns
Promise<PreparedTransaction>
Prepared transaction with typed data for signing
Example
const prepared = await account.buildPaymasterTransaction(
calls,
{ feeMode: { mode: 'default', gasToken: ETH_ADDRESS } }
);
executePaymasterTransaction()
abstractexecutePaymasterTransaction(calls,paymasterDetails,maxFeeInGasToken?):Promise<{transaction_hash:string; }>
Defined in: src/account/interface.ts:325
Execute a paymaster-sponsored transaction
Parameters
calls
Call[]
Array of calls to execute
paymasterDetails
Paymaster configuration
- .feeMode - 'sponsored' or gas token payment
- .deploymentData - Deploy account if needed
- .timeBounds - Execution validity window (UNIX timestamps)
maxFeeInGasToken?
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
);
declare()
abstractdeclare(contractPayload,transactionsDetail?):Promise<{class_hash:string;transaction_hash:string; }>
Defined in: src/account/interface.ts:351
Declare a contract class on Starknet
Parameters
contractPayload
Contract declaration payload
- .contract - Compiled Sierra contract
- .classHash - Pre-computed class hash (optional), used as is: it is not checked against .contract
- .casm - Compiled CASM (required for Cairo 1)
- .compiledClassHash - Pre-computed CASM hash
transactionsDetail?
Transaction execution options
Returns
Promise<{ class_hash: string; transaction_hash: string; }>
Declaration transaction hash and class hash
Example
const declareResult = await account.declare({
contract: compiledSierra,
casm: compiledCasm
});
deploy()
abstractdeploy(payload,details?):Promise<MultiDeployContractResponse>
Defined in: src/account/interface.ts:378
Deploy contract(s) using the Universal Deployer Contract (UDC)
Parameters
payload
UniversalDeployerContractPayload | UniversalDeployerContractPayload[]
Single or multiple deployment configurations.
- .classHash - Class hash of declared contract.
- .constructorCalldata - Constructor parameters.
- .salt - Deployment salt (random if not specified).
- .unique - Modify salt for unique address (default: true).
- .abi - Abi of the contract (optional): the constructor calldata is checked against it. Without it, the calldata is flattened as given, with no check.
details?
Transaction execution options
Returns
Promise<MultiDeployContractResponse>
Deployed contract addresses and transaction hash
Example
const deployment = await account.deploy([
{ classHash: erc20ClassHash, constructorCalldata: [name, symbol] },
{ classHash: nftClassHash, unique: true }
]);
deployContract()
abstractdeployContract(payload,details?):Promise<DeployContractUDCResponse>
Defined in: src/account/interface.ts:402
Deploy and wait for a contract deployment to complete
Parameters
payload
UniversalDeployerContractPayload | UniversalDeployerContractPayload[]
Deployment configuration(s)
details?
Transaction execution options
Returns
Promise<DeployContractUDCResponse>
Deployment result with contract address and UDC event details
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);
declareAndDeploy()
abstractdeclareAndDeploy(payload,details?):Promise<DeclareDeployUDCResponse>
Defined in: src/account/interface.ts:439
Declare and deploy a contract in a single method
Parameters
payload
DeclareAndDeployContractPayload
Combined declare and deploy configuration
- .contract - Compiled Sierra contract
- .casm - Compiled CASM (required for Cairo 1)
- .compiledClassHash - Pre-computed CASM hash
- .classHash - Pre-computed class hash, checked against .contract: a wrong one is refused
- .constructorCalldata - Constructor parameters, or felts already compiled
- .salt - Deployment salt
- .unique - Ensure unique deployment address
details?
Transaction execution options
Returns
Promise<DeclareDeployUDCResponse>
Declaration and deployment results
Remarks
- Before declaring, checks the constructor calldata against the abi of
contract(felts already compiled are read back with it), and a givenclassHashagainstcontract: a mismatch fails before any transaction is sent - Automatically skips declaration if contract is already declared
- With a given
nonce, the deployment uses the next one when a declaration is sent - Waits for both transactions to complete
- Does not support batch operations
Example
const result = await account.declareAndDeploy({
contract: compiledContract,
casm: compiledCasm,
constructorCalldata: [param1, param2]
});
deployAccount()
abstractdeployAccount(contractPayload,transactionsDetail?):Promise<DeployContractResponse>
Defined in: src/account/interface.ts:468
Deploy the account contract itself on Starknet
Parameters
contractPayload
DeployAccountContractPayload & object
Account deployment configuration
- .classHash - Account contract class hash
- .constructorCalldata - Constructor parameters
- .addressSalt - Salt for address generation
- .contractAddress - Pre-computed address
- .abi - Abi of the account contract (optional): the constructor calldata is checked against it
transactionsDetail?
Transaction execution options
Returns
Promise<DeployContractResponse>
Deployment transaction hash and contract address
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
});
signMessage()
abstractsignMessage(typedData):Promise<Signature>
Defined in: src/account/interface.ts:492
Sign a typed data message for off-chain verification
Parameters
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!' }
});
hashMessage()
abstracthashMessage(typedData):Promise<string>
Defined in: src/account/interface.ts:508
Hash a typed data message using Pedersen hash
Parameters
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);
getNonce()
abstractgetNonce(blockIdentifier?):Promise<string>
Defined in: src/account/interface.ts:521
Get the current nonce of the account
Parameters
blockIdentifier?
Block to query nonce at (default: 'latest' tag)
Returns
Promise<string>
Account nonce as hex string
Example
const nonce = await account.getNonce();
const historicalNonce = await account.getNonce('latest');
declareIfNot()
abstractdeclareIfNot(contractPayload,transactionsDetail?):Promise<{class_hash:string;transaction_hash:string; }>
Defined in: src/account/interface.ts:540
Declare a contract class if not already declared
A given classHash is used as is to look for the class on the node, without being checked
against contract, to save time.
Parameters
contractPayload
Contract declaration payload
transactionsDetail?
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
});