# web3login

> 基于小狐狸钱包提供基础通用的web3登录及相关函数

Latest version **1.1.0** (published 2022-04-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install web3login
pnpm add web3login
yarn add web3login
bun add web3login
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2022-04-29 |
| First published | 2022-03-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 1.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | shiyouyuemu |
| Maintainers | shiyouyuemu |
| Keywords | web3, login, function, ethers |

## Links

- npm: https://www.npmjs.com/package/web3login
- Repository: https://github.com/shiyouyuemu/web3-login
- Homepage: https://github.com/shiyouyuemu/web3-login#readme
- Issues: https://github.com/shiyouyuemu/web3-login/issues
- npm.io page: https://npm.io/package/web3login

## Dependencies (1)

- [ethers](https://npm.io/package/ethers.md) ^5.5.4

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2022-04-29
- 1.0.9 — 2022-04-28
- 1.0.8 — 2022-04-28
- 1.0.7 — 2022-03-04
- 1.0.6 — 2022-03-03
- 1.0.5 — 2022-03-03
- 1.0.4 — 2022-03-03
- 1.0.3 — 2022-03-03
- 1.0.2 — 2022-03-03
- 1.0.1 — 2022-03-02
- 1.0.0 — 2022-03-02

## README

# Web3 Login
基于小狐狸钱包提供基础通用的web3登录及相关函数
### hasEthereum
```js
  if(hasEthereum()){
    //如果在有钱包的环境
  }
```

### requestAccount
```js
  //调起钱包授权
  await requestAccount();
```

### useWalletWatch
```js
  //钱包状态监控

  //切换账户后的处理
  let logOut = () => {

  }
  let userAddress = ""; //当前登录的钱包地址;（最好响应式处理）
  let isLogin = true; //当前登录状态;（最好响应式处理）
  useWalletWatch(logOut, userAddress, isLogin);
```

### signatureLogin
```js
  //调用钱包签名

  let address = "";
  let message = "";
  //签名成功后的回调函数
  let callback = (address, signature) => {

  }
  await signatureLogin(address, message, callback);
```

### getWalletData
```js
  //获取钱包当前信息(地址和链ID)
  let { address, chainId } = await getWalletData();
```

### web3Login
```js
  //基础签名登录
  web3Login({
    //无钱包环境时回调
    onErrorWithEthereum: ()=> {
      
    },//可选参数
    //异步返回 需要签名的信息
    getMessage: (address) => {
      return new Promise(() => {
        
      });
    },//必填参数
    //成功签名后回调
    onSuccessLogin: (address, signature) => {

    }, //必填参数
  });
```

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