@abstract-foundation/web3-react-agw
TypeScript icon, indicating that this package has built-in type declarations

1.5.2 • Public • Published

@abstract-foundation/web3-react-agw

The @abstract-foundation/web3-react-agw package implements a web3-react connector for Abstract Global Wallet (AGW).

Abstract Global Wallet (AGW)

Abstract Global Wallet (AGW) is a cross-application smart contract wallet that users can be used to interact with any application built on Abstract, powered by Abstract's native account abstraction.

Installation

Install the connector via NPM:

npm install @abstract-foundation/web3-react-agw

Quick Start

Importing

import { AbstractGlobalWallet } from '@abstract-foundation/web3-react-agw';

Initializing the connector

// connector.tsx
import { initializeConnector } from '@web3-react/core';
import { AbstractGlobalWallet } from '@abstract-foundation/web3-react-agw';

export const [agw, hooks] = initializeConnector<AbstractGlobalWallet>(
  (actions) => new AbstractGlobalWallet({ actions }),
);

Using the connector

import React from 'react';
import { agw, hooks } from './connector';

const { useIsActive } = hooks;

export default function App() {
  const isActive = useIsActive();
  useEffect(() => {
    void agw.connectEagerly().catch(() => {
      console.debug('Failed to connect eagerly to agw');
    });
  }, []);

  const login = () => {
    void agw.activate();
  };

  const logout = () => {
    void agw.deactivate();
  };

  return (
    <div>
      {isActive ? (
        <button onClick={logout}>Disconnect</button>
      ) : (
        <button onClick={login}>Sign in with Abstract</button>
      )}
    </div>
  );
}

API Reference

AbstractGlobalWallet

Creates an AbstractGlobalWallet connector, extending the web3-react Connector to support the Abstract Global Wallet.

Documentation

For detailed documentation, please refer to the Abstract Global Wallet Documentation.

Package Sidebar

Install

npm i @abstract-foundation/web3-react-agw

Weekly Downloads

31

Version

1.5.2

License

MIT

Unpacked Size

703 kB

Total Files

13

Last publish

Collaborators

  • cygaardev
  • coffeexcoin
  • jarrodwatts