StarknetKit
Docs v1.1.9
Starknet.js 101
Signer

Signer

The Signer API simply allows you to sign transactions and messages, and also retrieve a public key.

Instantiation

To instantiate a signer, you need a keypair:

new starknet.Signer(keyPair)

Methods

  1. signer.getPubKey() => Promise < string >

Returns the public key of the signer.

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

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

Where 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

  1. signer.signMessage(typedData, accountAddress) => Promise < Signature >

Sign a JSON object for off-chain usage with the starknet private key and return the signature. This adds a message prefix so it can't be interchanged with transactions.

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

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

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

Where 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
  1. signer.signDeclareTransaction(transaction, transactionsDetail [ , abi ]) => Promise < Signature >

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

Where the transaction object for write methods may include any of:

  • transactions.classHash - computed class hash. Will be replaced by ContractClass in the future once the 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