@compass/wallet
This package provides an easy to use wallet class for signing messages and sending transactions with a connected wallet. The wallet class requires an address to initialize and provides methods for signing and transactions.
Usage
API Reference
class Wallet
class Wallet
Main class of the module, representing a wallet instance.
constructor(address: string)
Create a new wallet instance.
address
(required, string): The address of the wallet.
Returns a new wallet instance.
wallet.signMessage(message: string)
Sign a message with the wallet.
message
(required, string): Message to sign.
Returns a Promise that resolves with the signed message.
wallet.signTypedData(domain: any, types: any, value: any)
Sign typed data with the wallet. (v4)
domain
(required, any): The domain of the typed data.types
(required, any): The types of the typed data.value
(required, any): The value of the typed data.
Returns a Promise that resolves with the signed typed data.
wallet.sendTransaction(transaction: any)
Send a transaction with the wallet.
transaction
(required, any): Transaction to send.
Returns a Promise that resolves with the transaction receipt.
Examples
To create a new wallet instance:
To sign a message with the wallet:
To sign typed data with the wallet:
To send a transaction with the wallet:
Last updated