Skip to content

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 derivationderiveHiveKeys() (BIP44) and deriveHiveMasterPasswordKeys() 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 discoverydiscoverMetaMaskWallets(), fetchMultichainAddresses(), fetchEvmAddress() discover ETH, BNB, SOL, BTC addresses from MetaMask via window.ethereum and the Wallet Standard protocol.
  • Hive Snap utilitiesinstallHiveSnap() and getHivePublicKeys() interact with the @hiveio/metamask-snap for Hive key management inside MetaMask.
  • EVM transferssendEvmTransfer(), ensureEvmChain(), estimateEvmGas(), parseToWei(), formatWei() for sending ETH/BNB via MetaMask’s eth_sendTransaction.
  • SOL transferssendSolTransfer(), parseToLamports(), formatLamports() for sending SOL via MetaMask’s Wallet Standard solana:signAndSendTransaction feature.
  • Transfer mutation hookuseExternalTransfer(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

CurrencyBalance queryTransfer (MetaMask)Notes
BTCYesNoMetaMask BTC support coming soon
ETHYesYesVia eth_sendTransaction
BNBYesYesVia eth_sendTransaction + chain switch
SOLYesYesVia Wallet Standard signAndSendTransaction

Installation

Terminal window
pnpm add @ecency/wallets

Peer 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

discovery.ts
import {
discoverMetaMaskWallets,
installHiveSnap,
getHivePublicKeys
} from '@ecency/wallets';
// Discover ETH, BNB, SOL, BTC addresses from MetaMask
const addresses = await discoverMetaMaskWallets();
// { ETH: "0x...", BNB: "0x...", SOL: "7xyz...", BTC: "bc1..." }
// Install the Hive Snap and get Hive public keys
await installHiveSnap();
const hiveKeys = await getHivePublicKeys();
// [{ publicKey: "STM...", role: "owner" }, ...]

Example: send ETH via MetaMask

send-eth.tsx
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:

  1. Remove imports of useSeedPhrase, useWalletCreate, useImportWallet, getKeysFromSeed, useHiveKeysQuery, useWalletsCacheQuery.
  2. Remove imports of signExternalTx, buildExternalTx, getWallet.
  3. Remove @okxweb3/* and bip39 from your dependencies (they are no longer needed by the wallets package).
  4. For external chain transfers, use useExternalTransfer() which signs via MetaMask.
  5. For Hive key derivation from seed, deriveHiveKeys() and deriveHiveMasterPasswordKeys() still work as before — the only change is the BIP32 library switched from @okxweb3/crypto-lib to @scure/bip32.
  6. Guide users with existing seed-phrase wallets to the seed phrase migration guide.