# @amnis_finance/aptos-wallet-adapter

> React `WalletProvider` supporting loads of aptos wallets.

Latest version **1.0.38** (published 2024-05-06) · 0 weekly downloads

## Install

```sh
npm install @amnis_finance/aptos-wallet-adapter
pnpm add @amnis_finance/aptos-wallet-adapter
yarn add @amnis_finance/aptos-wallet-adapter
bun add @amnis_finance/aptos-wallet-adapter
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.38 |
| Published | 2024-05-06 |
| First published | 2023-11-08 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 881.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | amnis_finance |

## Links

- npm: https://www.npmjs.com/package/@amnis_finance/aptos-wallet-adapter
- npm.io page: https://npm.io/package/@amnis_finance/aptos-wallet-adapter

## Dependencies (9)

- [js-sha3](https://npm.io/package/js-sha3.md) ^0.8.0
- [@blocto/sdk](https://npm.io/package/@blocto/sdk.md) ^0.3.1
- [@fewcha/web3](https://npm.io/package/@fewcha/web3.md) 0.1.32
- [eventemitter3](https://npm.io/package/eventemitter3.md) ^4.0.7
- [@aptos-labs/ts-sdk](https://npm.io/package/@aptos-labs/ts-sdk.md) ^1.2.0
- [@msafe/aptos-wallet](https://npm.io/package/@msafe/aptos-wallet.md) ^3.0.6
- [@openblockhq/dappsdk](https://npm.io/package/@openblockhq/dappsdk.md) ^5.0.2
- [@keystonehq/aptossnap-adapter](https://npm.io/package/@keystonehq/aptossnap-adapter.md) ^0.2.8
- [@aptos-labs/wallet-adapter-core](https://npm.io/package/@aptos-labs/wallet-adapter-core.md) ^3.2.1

## Recent versions

- 1.0.38 (latest) — 2024-05-06
- 1.0.37 — 2024-05-06
- 1.0.36 — 2024-05-06
- 1.0.35 — 2024-05-06
- 1.0.34 — 2024-05-06
- 1.0.33 — 2024-01-15
- 1.0.32 — 2024-01-15
- 1.0.31 — 2024-01-15
- 1.0.30 — 2024-01-15
- 1.0.29 — 2024-01-15
- 1.0.28 — 2024-01-15
- 1.0.27 — 2023-12-22
- 1.0.26 — 2023-12-21
- 1.0.25 — 2023-12-21
- 1.0.24 — 2023-12-21
- … 13 more at https://npm.io/package/@amnis_finance/aptos-wallet-adapter/versions

## README

# aptos-wallet-adapter

React `WalletProvider` supporting loads of aptos wallets.

Supports:

- [Aptos official wallet](https://github.com/aptos-labs/aptos-core/releases/tag/wallet-v0.1.1)
- [Martian wallet](https://martianwallet.xyz/)
- [Fewcha wallet](https://fewcha.app/)
- [Hippo wallet](https://github.com/hippospace/hippo-wallet)
- [Pontem Wallet](https://pontem.network/pontem-wallet)
- [Spika wallet](https://spika.app)
- [Rise Wallet](https://risewallet.io/)
- [Fletch wallet](http://fletchwallet.io/)
- [TokenPocket Wallet](https://tokenpocket.pro)
- [ONTO Wallet](https://onto.app)
- [Blocto wallet](https://portto.com/download)
- [Nightly Wallet](https://nightly.app/download)
- [FoxWallet](https://foxwallet.com)
- [Spacecy wallet](https://spacecywallet.com/)
# Installation

with `yarn`

```
yarn add @amnis_finance/aptos-wallet-adapter
```

with `npm`

```
npm install @amnis_finance/aptos-wallet-adapter
```

# Examples

## **Frontend Integration**

Here's an example of how we integrate the adapter into [amnis frontend](https://github.com/hippospace/hippo-frontend/blob/main/src/Providers.tsx):

### **Wallet integration**

Wallets source code [here](https://stake.amnis.finance).

# Use React Provider

```typescript
import React from 'react';
import {
  WalletProvider,
  HippoWalletAdapter,
  AptosWalletAdapter,
  HippoExtensionWalletAdapter,
  MartianWalletAdapter,
  FewchaWalletAdapter,
  PontemWalletAdapter,
  SpikaWalletAdapter,
  RiseWalletAdapter,
  FletchWalletAdapter,
  TokenPocketWalletAdapter,
  ONTOWalletAdapter,
  BloctoWalletAdapter,
  SafePalWalletAdapter,
  FoxWalletAdapter,
  CloverWalletAdapter,
  SpacecyWalletAdapter
} from '@amnis_finance/aptos-wallet-adapter';

const wallets = [
  new MartianWalletAdapter(),
  new AptosWalletAdapter(),
  new FewchaWalletAdapter(),
  new HippoExtensionWalletAdapter(),
  new PontemWalletAdapter(),
  new SpikaWalletAdapter(),
  new RiseWalletAdapter(),
  new FletchWalletAdapter(),
  new TokenPocketWalletAdapter(),
  new ONTOWalletAdapter(),
  new BloctoWalletAdapter({ bloctoAppId:'6d85f56e-5f2e-46cd-b5f2-5cf9695b4d46' }), /** Must provide bloctoAppId **/
  new SafePalWalletAdapter(),
  new FoxWalletAdapter(),
  new CloverWalletAdapter(),
  new SpacecyWalletAdapter()
];

const App: React.FC = () => {
  return (
    <WalletProvider
      wallets={wallets}
      autoConnect={true | false} /** allow auto wallet connection or not **/
      onError={(error: Error) => {
        console.log('Handle Error Message', error);
      }}>
      {/* your website */}
    </WalletProvider>
  );
};

export default App;
```

# Web3 Hook

```typescript
import { useWallet } from '@amnis_finance/aptos-wallet-adapter';

const { connected, account, network, ...rest } = useWallet();

/*
  ** Properties available: **

  wallets: Wallet[]; - Array of wallets
  wallet: Wallet | null; - Selected wallet
  account: AccountKeys | null; - Wallet info: address, 
  network: NetworkInfo - { name, chainId, api }
  publicKey, authKey
  connected: boolean; - check the website is connected yet
  connect(walletName: string): Promise<void>; - trigger connect popup
  disconnect(): Promise<void>; - trigger disconnect action
  signAndSubmitTransaction(
    transaction: TransactionPayload
  ): Promise<PendingTransaction>; - function to sign and submit the transaction to chain
*/
```

# Connect & Disconnect 

```typescript
import { AptosWalletName, useWallet } from "@amnis_finance/aptos-wallet-adapter"

...

const { connect, disconnect, connected } = useWallet();

/* No more manual connection required if you disable auto-connect mode while the previous select + connect will still work */

if (!connected) {
  return (
    <button
      onClick={() => {
        connect(walletName); // E.g. connecting to the Aptos official wallet
      }}
    >
      Connect
    </button>
  );
} else {
  return (
    <button
      onClick={() => {
        disconnect();
      }}
    >
      Disconnect
    </button>
  );
}
```

# Submit and sign transaction

**Request faucet**

```typescript
const { signAndSubmitTransaction } = useWallet();

const payload: Types.TransactionPayload = {
  type: 'entry_function_payload',
  function: `0x1::module_name::function_name`,
  type_arguments: [],
  arguments: [],
};
const result = await signAndSubmitTransaction(payload);
  if (result) {
    console.log('Transaction hash', result.hash)
    console.log('Transaction Success');
  }
```

---
_Source: https://npm.io/package/@amnis_finance/aptos-wallet-adapter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
