Class: WalletAccount
Defined in: src/wallet/account.ts:41
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
Extends
Constructors
Constructor
new WalletAccount(
options):WalletAccount
Defined in: src/wallet/account.ts:44
Parameters
options
WalletAccountV4Options
Returns
WalletAccount
Overrides
Properties
walletProvider
walletProvider:
StarknetWalletProvider
Defined in: src/wallet/account.ts:42
provider
provider:
RpcProvider
Defined in: src/account/default.ts:106
Provider instance for blockchain interaction
Inherited from
signer
signer:
SignerInterface
Defined in: src/account/default.ts:108
Signer instance for signing transactions and messages
Inherited from
address
address:
string
Defined in: src/account/default.ts:110
The address of the account contract on Starknet
Inherited from
cairoVersion
cairoVersion:
CairoVersion
Defined in: src/account/default.ts:112
Cairo version of the account contract implementation
Inherited from
transactionVersion
readonlytransactionVersion:"0x3"
Defined in: src/account/default.ts:114
Inherited from
paymaster
paymaster:
PaymasterInterface
Defined in: src/account/default.ts:116
Inherited from
deployer
deployer:
Deployer
Defined in: src/account/default.ts:118
Optional deployer instance for custom contract deployment logic
Default
Uses default UDC (Universal Deployer Contract) if not specified
Inherited from
defaultTipType
defaultTipType:
TipType
Defined in: src/account/default.ts:120
Inherited from
accountPluginManager
readonlyaccountPluginManager:PluginManager
Defined in: src/account/default.ts:123
Internal
Account-level plugin management
Inherited from
deploySelf
deploySelf: (
contractPayload,details) =>Promise<DeployContractResponse>
Defined in: src/account/default.ts:559
ACCOUNT METHODS
Parameters
contractPayload
details?
UniversalDetails = {}
Returns
Promise<DeployContractResponse>
Example
const deployment = await account.deployAccount({
classHash: accountClassHash,
constructorCalldata: { publicKey: pubKey },
addressSalt: pubKey
});
Inherited from
Methods
connect()
staticconnect(provider,walletProvider,cairoVersion?,paymaster?,silentMode?):Promise<WalletAccount>
Defined in: src/wallet/account.ts:159
Parameters
provider
ProviderInterface | ProviderOptions
walletProvider
StarknetWalletProvider
cairoVersion?
paymaster?
PaymasterOptions | PaymasterInterface
silentMode?
boolean = false
Returns
Promise<WalletAccount>
connectSilent()
staticconnectSilent(provider,walletProvider,cairoVersion?,paymaster?):Promise<WalletAccount>
Defined in: src/wallet/account.ts:176
Parameters
provider
ProviderInterface | ProviderOptions
walletProvider
StarknetWalletProvider
cairoVersion?
paymaster?
PaymasterOptions | PaymasterInterface
Returns
Promise<WalletAccount>
onAccountChange()
onAccountChange(
callback):void
Defined in: src/wallet/account.ts:66
WALLET EVENTS
Parameters
callback
Returns
void
onNetworkChanged()
onNetworkChanged(
callback):void
Defined in: src/wallet/account.ts:70
Parameters
callback
Returns
void
requestAccounts()
requestAccounts(
silentMode?):Promise<string[]>
Defined in: src/wallet/account.ts:77
WALLET SPECIFIC METHODS
Parameters
silentMode?
boolean = false
Returns
Promise<string[]>
getPermissions()
getPermissions():
Promise<"accounts"[]>
Defined in: src/wallet/account.ts:81
Returns
Promise<"accounts"[]>
switchStarknetChain()
switchStarknetChain(
chainId):Promise<boolean>
Defined in: src/wallet/account.ts:85
Parameters
chainId
"0x534e5f4d41494e" | "0x534e5f5345504f4c4941"
Returns
Promise<boolean>
watchAsset()
watchAsset(
asset):Promise<boolean>
Defined in: src/wallet/account.ts:89
Parameters
asset
Returns
Promise<boolean>
addStarknetChain()
addStarknetChain(
chain):Promise<boolean>
Defined in: src/wallet/account.ts:93
Parameters
chain
Returns
Promise<boolean>
execute()
execute(
calls):Promise<AddInvokeTransactionResult>
Defined in: src/wallet/account.ts:100
ACCOUNT METHODS
Parameters
calls
Returns
Promise<AddInvokeTransactionResult>
Overrides
declare()
declare(
payload):Promise<AddDeclareTransactionResult>
Defined in: src/wallet/account.ts:117
ACCOUNT METHODS
Parameters
payload
Returns
Promise<AddDeclareTransactionResult>
Example
const declareResult = await account.declare({
contract: compiledSierra,
casm: compiledCasm
});
Overrides
deploy()
deploy(
payload):Promise<MultiDeployContractResponse>
Defined in: src/wallet/account.ts:143
ACCOUNT METHODS
Parameters
payload
UniversalDeployerContractPayload | UniversalDeployerContractPayload[]
Returns
Promise<MultiDeployContractResponse>
Example
const deployment = await account.deploy([
{ classHash: erc20ClassHash, constructorCalldata: [name, symbol] },
{ classHash: nftClassHash, unique: true }
]);
Overrides
signMessage()
signMessage(
typedData):Promise<SIGNATURE>
Defined in: src/wallet/account.ts:155
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!' }
});
Overrides
getNonce()
getNonce(
blockIdentifier?):Promise<string>
Defined in: src/account/default.ts:161
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');
Inherited from
getNonceSafe()
protectedgetNonceSafe(nonce?):Promise<bigint>
Defined in: src/account/default.ts:165
Parameters
nonce?
Returns
Promise<bigint>
Inherited from
getCairoVersion()
getCairoVersion(
classHash?):Promise<CairoVersion>
Defined in: src/account/default.ts:178
Retrieves the Cairo version from the network and sets cairoVersion if not already set in the constructor.
Parameters
classHash?
string
if provided detects Cairo version from classHash, otherwise from the account address
Returns
Promise<CairoVersion>
Inherited from
estimateInvokeFee()
estimateInvokeFee(
calls,details?):Promise<EstimateFeeResponseOverhead>
Defined in: src/account/default.ts:188
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 [])
details?
UniversalDetails = {}
Returns
Promise<EstimateFeeResponseOverhead>
Fee estimation including overall_fee and resourceBounds
Example
const fee = await account.estimateInvokeFee({
contractAddress: '0x123...',
entrypoint: 'transfer',
calldata: [recipient, amount]
});
Inherited from
estimateDeclareFee()
estimateDeclareFee(
payload,details?):Promise<EstimateFeeResponseOverhead>
Defined in: src/account/default.ts:198
Estimate fee for executing a DECLARE transaction on Starknet
Parameters
payload
details?
UniversalDetails = {}
Returns
Promise<EstimateFeeResponseOverhead>
Fee estimation including overall_fee and resourceBounds
Example
const fee = await account.estimateDeclareFee({
contract: compiledContract,
casm: compiledCasm
});
Inherited from
estimateAccountDeployFee()
estimateAccountDeployFee(
contractPayload,details?):Promise<EstimateFeeResponseOverhead>
Defined in: src/account/default.ts:217
Estimate fee for executing an INVOKE transaction on Starknet
Parameters
contractPayload
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 [])
details?
UniversalDetails = {}
Returns
Promise<EstimateFeeResponseOverhead>
Fee estimation including overall_fee and resourceBounds
Example
const fee = await account.estimateAccountDeployFee({
classHash: accountClassHash,
constructorCalldata: { publicKey },
addressSalt: publicKey
});
Inherited from
Account.estimateAccountDeployFee
estimateDeployFee()
estimateDeployFee(
payload,details?):Promise<EstimateFeeResponseOverhead>
Defined in: src/account/default.ts:247
Estimate fee for executing an INVOKE transaction on Starknet
Parameters
payload
UniversalDeployerContractPayload | UniversalDeployerContractPayload[]
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 [])
details?
UniversalDetails = {}
Returns
Promise<EstimateFeeResponseOverhead>
Fee estimation including overall_fee and resourceBounds
Example
const fee = await account.estimateDeployFee({
classHash: contractClassHash,
constructorCalldata: [param1, param2],
unique: true
});
Inherited from
estimateFeeBulk()
estimateFeeBulk(
invocations,details?):Promise<EstimateFeeBulk>
Defined in: src/account/default.ts:255
Estimate fee for executing an INVOKE transaction on Starknet
Parameters
invocations
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 [])
details?
UniversalDetails = {}
Returns
Promise<EstimateFeeBulk>
Fee estimation including overall_fee and resourceBounds
Example
const fees = await account.estimateFeeBulk([
{ type: 'INVOKE', payload: { contractAddress, entrypoint, calldata } },
{ type: 'DECLARE', payload: { contract, casm } }
]);
Inherited from
simulateTransaction()
simulateTransaction(
invocations,details?):Promise<SimulateTransactionOverheadResponse>
Defined in: src/account/default.ts:285
Parameters
invocations
details?
SimulateTransactionDetails = {}
Returns
Promise<SimulateTransactionOverheadResponse>
Inherited from
getSignedTransaction()
getSignedTransaction(
transactions,transactionsDetail?):Promise<INVOKE_TXN_V3>
Defined in: src/account/default.ts:420
Build a signed INVOKE_TXN_V3 transaction without submitting it to the network.
Produces a fully signed transaction object that can be inspected, stored,
or submitted later via provider.channel.sendTransaction().
Main usage is to send a virtual transaction to a proof server.
Fees are estimated automatically if not provided.
Parameters
transactions
Single call or array of calls to include in the transaction
transactionsDetail?
UniversalDetails = {}
Transaction execution options
Returns
Promise<INVOKE_TXN_V3>
A fully signed RPC.INVOKE_TXN_V3 object, ready to broadcast
Remarks
- Unlike
execute(), this method does not submit the transaction ; the account nonce is unchanged after the call. - The
afterExecuteplugin hook is intentionally not triggered. - The returned object can be broadcast with
provider.channel.sendTransaction().
Example
const signedTx = await account.getSignedTransaction(
{ contractAddress: erc20Address, entrypoint: 'transfer', calldata: [recipient, amount, 0] }
);
Inherited from
declareIfNot()
declareIfNot(
payload,transactionsDetail?):Promise<{class_hash:string;transaction_hash:string; }>
Defined in: src/account/default.ts:451
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
payload
transactionsDetail?
UniversalDetails = {}
(optional)
Returns
Promise<{ class_hash: string; transaction_hash: string; }>
Inherited from
deployContract()
deployContract(
payload,details?):Promise<DeployContractUDCResponse>
Defined in: src/account/default.ts:532
ACCOUNT METHODS
Parameters
payload
UniversalDeployerContractPayload | UniversalDeployerContractPayload[]
details?
UniversalDetails & waitForTransactionOptions = {}
Transaction execution options
Returns
Promise<DeployContractUDCResponse>
Example
const result = await account.deployContract({
classHash: contractClassHash,
constructorCalldata: params
});
console.log('Deployed at:', result.address);