Ecency wallets
The @ecency/wallets package (v2.0) provides wallet-related queries, MetaMask
integration utilities, and Hive key derivation for the Ecency web and mobile apps.
What’s in v2.0
Version 2.0 is a major cleanup that removes seed-phrase-based wallet creation
and replaces external chain signing with MetaMask. The package is now
significantly smaller (~37 KB vs ~131 KB in v1.x) after dropping all @okxweb3
dependencies.
Kept
- External wallet balance queries — fetch balances for BTC, ETH, BNB, SOL from the Ecency private API.
- Token price queries — market data for supported currencies.
- Hive key derivation —
deriveHiveKeys()(BIP44) andderiveHiveMasterPasswordKeys()for login and permissions flows. - Wallet metadata — save/read external wallet addresses from Hive account
posting_json_metadata. - Private API mutations — create accounts with wallets, update wallet info, check wallet existence.
Added
- MetaMask multichain discovery —
discoverMetaMaskWallets(),fetchMultichainAddresses(),fetchEvmAddress()discover ETH, BNB, SOL, BTC addresses from MetaMask viawindow.ethereumand the Wallet Standard protocol. - Hive Snap utilities —
installHiveSnap()andgetHivePublicKeys()interact with the@hiveio/metamask-snapfor Hive key management inside MetaMask. - EVM transfers —
sendEvmTransfer(),ensureEvmChain(),estimateEvmGas(),parseToWei(),formatWei()for sending ETH/BNB via MetaMask’seth_sendTransaction. - SOL transfers —
sendSolTransfer(),parseToLamports(),formatLamports()for sending SOL via MetaMask’s Wallet Standardsolana:signAndSendTransactionfeature. - Transfer mutation hook —
useExternalTransfer(currency)React Query mutation that routes to the correct chain signing method.
Removed
- Mnemonic/seed phrase generation (
useSeedPhrase,mnemonicToSeedBip39) - okxweb3 wallet factory and signing (
getWallet,signExternalTx,buildExternalTx) - Seed-based wallet creation (
useWalletCreate,useImportWallet,getKeysFromSeed) - Hive keys from seed query (
useHiveKeysQuery) - Wallets cache query (
useWalletsCacheQuery) - Memo encryption/decryption (
encryptMemo,decryptMemo) - Direct Hive transaction signing (
signTx,signDigest) - TRON, TON, APT currencies and their balance/info queries
Supported currencies
| Currency | Balance query | Transfer (MetaMask) | Notes |
|---|---|---|---|
| BTC | Yes | No | MetaMask BTC support coming soon |
| ETH | Yes | Yes | Via eth_sendTransaction |
| BNB | Yes | Yes | Via eth_sendTransaction + chain switch |
| SOL | Yes | Yes | Via Wallet Standard signAndSendTransaction |
Installation
pnpm add @ecency/walletsPeer dependencies:
{ "@ecency/sdk": "workspace:*", "@hiveio/dhive": "^1.3.5", "hivesigner": "^3.3.4", "react": ">=18", "@tanstack/react-query": ">=5", "@wallet-standard/app": ">=1", "@solana/web3.js": ">=1"}@wallet-standard/app and @solana/web3.js are optional — only needed if
using MetaMask multichain discovery or SOL transfers.
Example: MetaMask wallet discovery
import { discoverMetaMaskWallets, installHiveSnap, getHivePublicKeys} from '@ecency/wallets';
// Discover ETH, BNB, SOL, BTC addresses from MetaMaskconst addresses = await discoverMetaMaskWallets();// { ETH: "0x...", BNB: "0x...", SOL: "7xyz...", BTC: "bc1..." }
// Install the Hive Snap and get Hive public keysawait installHiveSnap();const hiveKeys = await getHivePublicKeys();// [{ publicKey: "STM...", role: "owner" }, ...]Example: send ETH via MetaMask
import { useExternalTransfer, EcencyWalletCurrency } from '@ecency/wallets';
function SendEthButton() { const transfer = useExternalTransfer(EcencyWalletCurrency.ETH);
const handleSend = async () => { const result = await transfer.mutateAsync({ to: "0xRecipientAddress...", amount: "0.05" }); console.log("Tx hash:", result.txHash); };
return <button onClick={handleSend}>Send 0.05 ETH</button>;}Migration from v1.x
If you were using the seed-phrase-based wallet creation flow:
- Remove imports of
useSeedPhrase,useWalletCreate,useImportWallet,getKeysFromSeed,useHiveKeysQuery,useWalletsCacheQuery. - Remove imports of
signExternalTx,buildExternalTx,getWallet. - Remove
@okxweb3/*andbip39from your dependencies (they are no longer needed by the wallets package). - For external chain transfers, use
useExternalTransfer()which signs via MetaMask. - For Hive key derivation from seed,
deriveHiveKeys()andderiveHiveMasterPasswordKeys()still work as before — the only change is the BIP32 library switched from@okxweb3/crypto-libto@scure/bip32. - Guide users with existing seed-phrase wallets to the seed phrase migration guide.