Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pedrouid/caip-wallet
CAIP Blockchain JSON-RPC Signers and Authenticators
https://github.com/pedrouid/caip-wallet
Last synced: about 2 months ago
JSON representation
CAIP Blockchain JSON-RPC Signers and Authenticators
- Host: GitHub
- URL: https://github.com/pedrouid/caip-wallet
- Owner: pedrouid
- License: mit
- Created: 2020-11-26T17:51:48.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-08-06T13:01:07.000Z (over 3 years ago)
- Last Synced: 2024-11-02T12:11:45.748Z (about 2 months ago)
- Language: TypeScript
- Size: 2.03 MB
- Stars: 6
- Watchers: 3
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# caip-wallet [![npm version](https://badge.fury.io/js/caip-wallet.svg)](https://badge.fury.io/js/caip-wallet)
CAIP-compatible Multi-Blockchain Wallet
## Quick Start
```typescript
import CaipWallet from "caip-wallet";// Initiate Wallet with target chains
const wallet = await CaipWallet.init({
chains: ["eip155:1"],
mnemonic:
"basic guard spider horse civil trumpet into chalk basket month cabbage walk",
});// Subscribe to pending user approval event
wallet.on("pending_approval", ({ chainId, request }) => {
// Display Request with ChainID for user approval
if (userApproved) {
wallet.approve(request, chainId);
} else {
wallet.reject(request, chainId);
}
});// Resolve incoming JSON-RPC requests
const request = {
id: 1,
jsonrpc: "2.0",
method: "personal_sign",
params: [
toHex("Test Message")
"0xa89Df33a6f26c29ea23A9Ff582E865C03132b140"
]
}
const response = await wallet.resolve(request, chainId)
// (resolved automatically unless required user approval for authentication)
```## API
```typescript
export abstract class ICaipWallet extends IEvents {
public abstract chains: ChainAuthenticatorsMap;
public abstract jsonrpc: ChainJsonRpcMap;
public abstract mnemonic: string;constructor(config: CaipWalletConfig) {
super();
}public abstract getChains(): Promise;
public abstract getAccounts(chainId: string): Promise;
public abstract approve(
request: JsonRpcRequest,
chainId: string
): Promise;public abstract reject(
request: JsonRpcRequest,
chainId: string
): Promise;public abstract resolve(
request: JsonRpcRequest,
chainId: string
): Promise;
}
```