Skip to main content

Account

An Account extends Provider and inherits all of its methods.

It also introduces new methods that allow Accounts to create and verify signatures with a custom Signer.

This API is the primary way to interact with an account contract on StarkNet.

Creating an instance

To create a new instance of the Account, first an account contract must be deployed. Also there needs to be a Provider instance that will be passed in the constructor and key pair for the account.

new starknet.Account(Provider, address, starkKeyPair)

Properties

account.address => string

The address of the account contract.

Methods

account.getNonce() => Promise < BigNumberish >

Gets the new Nonce of the connected account for the next transaction.


account.estimateFee(calls [ , options ]) => Promise < EstimateFeeResponse >

Gets the estimated fee for the call(s).

The options object may include any of:

  • options.blockIdentifier - Block Identifier for the transaction
  • options.nonce - Nonce for the transaction
EstimateFeeResponse
{
overall_fee: BN;
gas_consumed?: BN;
gas_price?: BN;
}

account.execute(calls [ , abi , transactionsDetail ]) => Promise < AddTransactionResponse >

Executes one or multiple calls using the account contract.

The transactionsDetail object may include any of:

  • transactionsDetail.maxFee - Max Fee that that will be used to execute the call(s)
  • transactionsDetail.nonce - Nonce for the transaction
  • transactionsDetail.version - Version for the transaction (default is 1)
AddTransactionResponse
{
transaction_hash: string;
};

account.signMessage(typedData) => Promise < Signature >

Creates a signature from the passed data.

Signature
string[];

account.hashMessage(typedData) => Promise < string >

Creates a hash from the passed data.


account.verifyMessageHash(hash, signature) => Promise < boolean >

Verify a signature of a given hash.

WARNING

This method is not recommended, use verifyMessage instead


account.verifyMessage(typedData, signature) => Promise < boolean >

Verify a signature of a JSON object.