Skip to main content
Version: 4.17.1

Signer

The Signer API allows you to sign transactions and messages, and also allows you to get the public key.

Creating an instance

new starknet.Signer(keyPair)

Methods

getPubKey()

signer.getPubKey() => Promise < string >

Returns the public key of the signer.


signTransaction()

signer.signTransaction(transactions, transactionsDetail [ , abi ]) => Promise < Signature >

Signs a transaction with the Starknet private key and returns the signature.

The transactions object for write methods may include any of:

  • transactions.contractAddress - the address of the contract
  • transactions.entrypoint - the entrypoint of the contract
  • transactions.calldata - (defaults to []) the calldata

abi - (optional) the abi of the contract for better displaying

Signature
string[]

signMessage()

signer.signMessage(typedData, accountAddress) => 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.

typedData - JSON object to be signed accountAddress - calldata to be passed in deploy constructor

Signature
string[]

signDeployAccountTransaction()

signer.signDeployAccountTransaction(transaction) => Promise < Signature >

Signs a DEPLOY_ACCOUNT transaction with the Starknet private key and returns the signature.

The transactions object for write methods may include any of:

  • transactions.contractAddress - the address of the contract
  • transactions.constructorCalldata - calldata to be passed in deploy constructor
  • transactions.addressSalt - contract address salt
  • transactions.chainId - the chainId to declare contract on
  • transactions.maxFee - maxFee for the declare transaction
  • transactions.version - transaction version
  • transactions.nonce - Nonce of the declare transaction
Signature
string[]

signDeclareTransaction()

signer.signDeclareTransaction(transaction, transactionsDetail [ , abi ]) => Promise < Signature >

Signs a DECLARE transaction with the Starknet private key and returns the signature.

The transaction object for write methods may include any of:

  • transactions.classHash - computed class hash. Will be replaced by ContractClass in future once class hash is present in CompiledContract
  • transactions.senderAddress - the address of the sender
  • transactions.chainId - the chainId to declare contract on
  • transactions.maxFee - maxFee for the declare transaction
  • transactions.version - transaction version
  • transactions.nonce - Nonce of the declare transaction
Signature
string[]