Class: SignerInterface
Implemented by​
Constructors​
constructor​
• new SignerInterface(): SignerInterface
Returns​
Methods​
getPubKey​
â–¸ getPubKey(): Promise<string>
Method to get the public key of the signer
Returns​
Promise<string>
hex-string
Example
const mySigner = new Signer('0x123');
const result = await mySigner.getPubKey();
// result = "0x566d69d8c99f62bc71118399bab25c1f03719463eab8d6a444cd11ece131616"
Defined in​
signMessage​
â–¸ signMessage(typedData, accountAddress): Promise<Signature>
Signs a JSON object for off-chain usage with the private key and returns the signature. This adds a message prefix so it can't be interchanged with transactions
Parameters​
| Name | Type | Description |
|---|---|---|
typedData | TypedData | JSON object to be signed |
accountAddress | string | Hex string of the account's address |
Returns​
Promise<Signature>
the signature of the message
Example
const mySigner = new Signer('0x123');
const myTypedData: TypedData = {
domain: { name: 'Example DApp', chainId: constants.StarknetChainId.SN_SEPOLIA, version: '0.0.3' },
types: {
StarkNetDomain: [
{ name: 'name', type: 'string' },
{ name: 'chainId', type: 'felt' },
{ name: 'version', type: 'string' },
],
Message: [{ name: 'message', type: 'felt' }],
},
primaryType: 'Message',
message: { message: '1234' },
};
const result = await mySigner.signMessage(
myTypedData,
'0x5d08a4e9188429da4e993c9bf25aafe5cd491ee2b501505d4d059f0c938f82d'
);
// result = Signature {r: 684915484701699003335398790608214855489903651271362390249153620883122231253n,
// s: 1399150959912500412309102776989465580949387575375484933432871778355496929189n, recovery: 1}
Defined in​
signTransaction​
â–¸ signTransaction(transactions, transactionsDetail): Promise<Signature>
Signs transactions with the private key and returns the signature