0.0.2 • Published 5 months ago

@swivel-finance/connect v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

connect

A flexible web3 connection service for swivel frontends and node scripting environments.

Features

  • Supports multiple browser wallet extensions through EIP-6963
  • Supports browser wallets, rpc providers, and mocked providers

Installation

npm install --save @swivel-finance/connect

Usage

import { WalletService } from '@swivel-finance/connect';
import { BrowserConnectionProvider } from '@swivel-finance/connect/connection/providers/browser/provider.js';

// create a wallet service instance, passing a compatible connection provider
// you could pass an rpc provider or a mock provider here as well
const walletService = new WalletService({
    connectionProvider: new BrowserConnectionProvider({
        chainId: 1,
    }),
});

// obtain a connection object by calling connect on the wallet service
// the connection object contains the following properties:
//
// interface Connection {
//     network: Network;
//     account: Account;
//     provider: Provider;
//     signer: Signer;
// }
const connection = await walletService.connect();

See more examples in the examples directory.

0.0.2

5 months ago

0.0.1

6 months ago