Skip to content
This repository was archived by the owner on Oct 12, 2025. It is now read-only.

Commit f305cb9

Browse files
committed
readme updated
1 parent 6274b26 commit f305cb9

File tree

6 files changed

+143
-5
lines changed

6 files changed

+143
-5
lines changed

Readme.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,41 @@ npm install @ecency/sdk
2323
1. Install `react @tanstack/react-query @hiveio/dhive`
2424
2. Use!
2525

26+
## SDK
27+
28+
`@ecency/sdk` bundles React Query helpers for the Hive blockchain:
29+
30+
- Accounts, posts, operations, communities, games, analytics, and keychain modules
31+
- Query and mutation option builders
32+
- Customisable Hive RPC clients via the `CONFIG` object
33+
34+
See [packages/core/README.md](packages/core/README.md) for detailed usage.
35+
2636
## Wallets
2737

28-
This package built on top of [@hiveio/dhive](https://www.npmjs.com/package/@hiveio/dhive) and [okweb3](http://okx.github.io/) packages.
38+
This package is built on top of [@hiveio/dhive](https://www.npmjs.com/package/@hiveio/dhive) and [okweb3](http://okx.github.io/) packages.
2939

3040
Main functionality is creating wallets based on seed phrase([BIP39](https://www.npmjs.com/package/bip39)) and generating addresses with keys on device. Seed phrases and private keys are never sent to any API, all operations happen locally.
3141

32-
Supportings tokens: BTC, ETH, SOL, TRX, TON, ATOM, APT – theoretically all child tokens of these systems. Make forks for it.
42+
Supported tokens: BTC, ETH, SOL, TRX, TON, ATOM, APT – theoretically all child tokens of these systems. Make forks for it.
43+
Use `useGetExternalWalletBalanceQuery` to fetch balances for these chains.
44+
45+
### Hive helpers
46+
47+
`@ecency/wallets` also exposes helpers for interacting with the Hive blockchain:
48+
49+
- `signDigest` – create a signature for an arbitrary digest
50+
- `signTx` – sign a transaction with an optional custom chain ID
51+
- `signTxAndBroadcast` – sign a transaction and immediately broadcast it
52+
- `encryptMemoWithKeys` / `decryptMemoWithKeys` – encrypt or decrypt memos with explicit keys
53+
- `encryptMemoWithAccounts` / `decryptMemoWithAccounts` – encrypt or decrypt memos by looking up account memo keys
54+
55+
See [packages/wallets/README.md](packages/wallets/README.md) for usage examples.
3356

3457
## Roadmap
3558

3659
- Add more Hive wallets operations
37-
- Allow to sign transactions with external wallets
38-
- Allow to import existing wallets by phrase or private keys
60+
- Allow signing transactions with external wallets
61+
- Allow importing existing wallets by phrase or private keys
3962
- Support of DASH
4063
- Support of DOGE

packages/core/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# @ecency/sdk
2+
3+
Utilities for building Hive applications with React and TypeScript.
4+
5+
## Features
6+
7+
- Query and mutation option builders powered by [@tanstack/react-query](https://tanstack.com/query)
8+
- Modules for accounts, posts, operations, communities, games, analytics, keychain integrations, and more
9+
- Configurable Hive RPC client and storage via the `CONFIG` object
10+
11+
## Installation
12+
13+
```sh
14+
yarn add @ecency/sdk
15+
# or
16+
npm install @ecency/sdk
17+
```
18+
19+
## Usage
20+
21+
```ts
22+
import { getAccountFullQueryOptions, ConfigManager } from '@ecency/sdk';
23+
import { useQuery } from '@tanstack/react-query';
24+
25+
// optionally provide a custom QueryClient
26+
// ConfigManager.setQueryClient(myQueryClient);
27+
28+
const { data } = useQuery(getAccountFullQueryOptions('ecency'));
29+
```
30+

packages/wallets/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# @ecency/wallets
2+
3+
Utilities for managing Hive blockchain wallets and external cryptocurrency wallets within the Ecency ecosystem.
4+
5+
## Features
6+
7+
- Create wallets from BIP39 seed phrases
8+
- `signDigest` – create a signature for an arbitrary digest
9+
- `signTx` – sign a transaction with an optional custom chain ID
10+
- `signTxAndBroadcast` – sign a transaction and immediately broadcast it
11+
- `encryptMemoWithKeys` / `decryptMemoWithKeys` – encrypt or decrypt memos using explicit keys
12+
- `encryptMemoWithAccounts` / `decryptMemoWithAccounts` – encrypt or decrypt memos by looking up account memo keys
13+
- `useGetExternalWalletBalanceQuery` – retrieve balances for external wallets such as BTC, ETH, SOL, TRX, TON, ATOM, or APT
14+
15+
## Installation
16+
17+
```sh
18+
yarn add @ecency/wallets
19+
# or
20+
npm install @ecency/wallets
21+
```
22+
23+
## Usage
24+
25+
```ts
26+
import {
27+
signDigest,
28+
signTx,
29+
signTxAndBroadcast,
30+
encryptMemoWithKeys,
31+
encryptMemoWithAccounts,
32+
decryptMemoWithKeys,
33+
decryptMemoWithAccounts,
34+
EcencyWalletCurrency,
35+
useGetExternalWalletBalanceQuery,
36+
} from '@ecency/wallets';
37+
import { Client } from '@hiveio/dhive';
38+
39+
const client = new Client('https://api.hive.blog');
40+
41+
const signature = signDigest('deadbeef', privateWif);
42+
const signedTx = signTx(tx, privateWif, customChainId);
43+
await signTxAndBroadcast(client, tx, privateWif);
44+
45+
const encrypted = await encryptMemoWithAccounts(client, privateWif, 'alice', '#hello');
46+
const memo = decryptMemoWithKeys(privateWif, encrypted);
47+
48+
// query an external wallet balance (e.g., BTC)
49+
const { data: btcBalance } = useGetExternalWalletBalanceQuery(
50+
EcencyWalletCurrency.BTC,
51+
'1BitcoinAddress...'
52+
);
53+
```
54+

packages/wallets/src/modules/wallets/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ export * from "./mutations";
33
export * from "./queries";
44
export * from "./types";
55
export * from "./utils";
6+
export * from "./utils";
7+
export * from "./utils";

packages/wallets/src/modules/wallets/utils/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,11 @@ export * from "./sign-digest";
88
export * from "./sign-transaction";
99
export * from "./encrypt-memo";
1010
export * from "./decrypt-memo";
11+
export * from "./sign-digest";
12+
export * from "./sign-transaction";
13+
export * from "./encrypt-memo";
14+
export * from "./decrypt-memo";
15+
export * from "./sign-digest";
16+
export * from "./sign-transaction";
17+
export * from "./encrypt-memo";
18+
export * from "./decrypt-memo";

packages/wallets/src/modules/wallets/utils/sign-transaction.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { PrivateKey } from "@hiveio/dhive";
1+
import { PrivateKey, Client } from "@hiveio/dhive";
22
import type {
33
Transaction,
44
SignedTransaction,
5+
TransactionConfirmation,
56
} from "@hiveio/dhive/lib/chain/transaction";
67
import { cryptoUtils } from "@hiveio/dhive/lib/crypto";
78

@@ -24,3 +25,23 @@ export function signTx(
2425
return cryptoUtils.signTransaction(tx, key, chain);
2526
}
2627

28+
/**
29+
* Sign a transaction and broadcast it to the network.
30+
* Optionally a custom chain id can be provided.
31+
*
32+
* @param client Hive client instance used for broadcasting.
33+
* @param tx Transaction to sign.
34+
* @param privateKey Private key in WIF format.
35+
* @param chainId Optional chain id as a hex string.
36+
* @returns Broadcast confirmation.
37+
*/
38+
export async function signTxAndBroadcast(
39+
client: Client,
40+
tx: Transaction,
41+
privateKey: string,
42+
chainId?: string
43+
): Promise<TransactionConfirmation> {
44+
const signed = signTx(tx, privateKey, chainId);
45+
return client.broadcast.send(signed);
46+
}
47+

0 commit comments

Comments
 (0)