Compass Docs
  • Collections
    • ๐Ÿš€Trending
    • ๐ŸŒฑMinting Now
    • ๐Ÿ“ƒCollection Watchlists
    • ๐Ÿ–ผ๏ธToken Window
    • โ†”๏ธCollection Activity
    • ๐Ÿ†Collection Profit Leaderboard
    • ๐ŸŽจCollection Tokens
    • ๐Ÿ‹Collection Top Holders
    • โ›๏ธCollection Mint History
    • ๐Ÿ”Collection Analytics
  • Wallets
    • ๐Ÿš€Getting started with Wallets
    • ๐Ÿ‘›Wallet overview
    • ๐Ÿ”Wallet Activity with Filtering
    • ๐Ÿ™‹Own Wallets
    • ๐ŸฅžFlips
    • ๐Ÿ‘ฅWallet Groups
    • ๐Ÿ”—Related Wallets
  • Pulse
    • ๐Ÿฅ‡Profit leaderboard
    • ๐Ÿ“ˆCompass Pulse
  • Alerts
    • โฐGetting Started with Alerts
  • Automations
    • ๐Ÿš€Getting Started with Automations
    • ๐Ÿ’ฐWallets
    • ๐Ÿ“˜Key Terms in Automations
    • ๐Ÿ”€Inputs/Outputs
    • ๐ŸงชTesting Automations
    • ๐Ÿš€Set Up Your First Listing Alert
    • ๐Ÿ”ซTriggers
      • Token Received
      • Token Sent
      • Token Bought
      • Token Sold
      • Token Minted
      • Webhook
      • Repeat
      • Token Listed
      • Telegram
      • Trigger Advanced Settings
    • ๐Ÿ’ณPricing
    • โšกCustom Actions
      • @compass/http
      • @compass/api
      • @compass/cache
      • @compass/utils
      • @compass/variables
      • @compass/wallet
Powered by GitBook
On this page
  • Usage
  • API Reference
  • Examples
  1. Automations
  2. Custom Actions

@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

import Wallet from "@compass/wallet";

API Reference

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:

import Wallet from "@compass/wallet";

export default function() {
    const address = '0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B';
    const wallet = new Wallet(address);
    return { wallet };
}

To sign a message with the wallet:

import Wallet from "@compass/wallet";

export default async function() {
    const address = '0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B';
    const wallet = new Wallet(address);
    const message = 'Hello, World!';
    const signedMessage = await wallet.signMessage(message);
    return { signedMessage };
}

To sign typed data with the wallet:

import Wallet from "@compass/wallet";

export default async function() {
    const address = '0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B';
    const wallet = new Wallet(address);
    const domain = {/* ... */};
    const types = {/* ... */};
    const value = {/* ... */};
    const signedData = await wallet.signTypedData(domain, types, value);
    return { signedData };
}

To send a transaction with the wallet:

import Wallet from "@compass/wallet";

export default async function() {
    const address = '0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B';
    const wallet = new Wallet(address);
    const transaction = {/* ... */};
    const transactionReceipt = await wallet.sendTransaction(transaction);
    return { transactionReceipt };
}
Previous@compass/variables

Last updated 1 year ago

โšก