Skip to main content

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

signer.getPubKey() => Promise < string >

Returns the public key of the signer.


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[]

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[]

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[]

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[]