Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/snapshot-labs/lock
https://github.com/snapshot-labs/lock
Last synced: about 5 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/snapshot-labs/lock
- Owner: snapshot-labs
- License: mit
- Created: 2020-07-19T07:56:43.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-12-01T08:53:03.000Z (about 2 months ago)
- Last Synced: 2025-01-11T01:07:23.117Z (7 days ago)
- Language: TypeScript
- Size: 1.16 MB
- Stars: 31
- Watchers: 5
- Forks: 50
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lock.js
A lightweight JavaScript library for log in to Ethereum.
### Install
To install Lock.js, open your terminal and run:
```
npm install github:snapshot-labs/lock
```#### Browser
You can create an index.html file and include Lock.js with:
```html```
### Usage
```js
import { Lock } from '@snapshot-labs/lock';
import injected from '@snapshot-labs/lock/connectors/injected';
import walletconnect from '@snapshot-labs/lock/connectors/walletconnect';// Init Lock
const lock = new Lock();// Add injected connector
lock.addConnector({
key: 'injected',
connector: injected
});// Add WalletConnect connector
lock.addConnector({
key: 'walletconnect',
connector: walletconnect,
options: {
infuraId: 'c00cb721...'
}
});// Log in with injected web3
const connector = lock.getConnector('injected');
const provider = await connector.connect('injected');// Log out from WalletConnect
const connector = lock.getConnector('walletconnect');
await connector.logout();// Is logged in?
const isLoggedIn = await connector.isLoggedIn();
```## License
[MIT](LICENSE).