
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@lfi-cloudx/wallet-services
Advanced tools
This service provides a flexible solution for managing both centralized and decentralized wallet systems. It supports the creation of user wallets, feed wallets, and the integration of hot wallets within the system.
Perform basic Web3 operations on both user and feed wallets, such as:
To manage and interact with tokens using the generated wallets, tokens must be added to the system. This is done by providing:
To install the package, run:
npm install wallet-services
Follow these steps to create a Provider instance, connect to the database, and add default blockchain networks to the system.
const { Provider } = require("wallet-services");
// Create 'provider' instance
const walletServiceProvider = new Provider({
MONGO_URI: "mongodb://127.0.0.1:27017/wallet-service", // MongoDB connection string
WALLET_ENCRYPT_PASSWORD: "your_password", // Password to encrypt wallet data
API_KEY_ENCRYPT_PASSWORD: "your_password", // Password to encrypt API keys
ALCHEMY_API_KEY: "your_alchemyApiKey", // Alchemy API key for blockchain interactions
PROD_MODE: true, // Use true for mainnet; default is false for testnets
});
// Initialize 'provider' to connect to DB and add default chains
/*
Default Chains:
Testnet:
- 11155111: Sepolia
- 97: BNB Smart Chain Testnet
- 80001: Mumbai
Mainnet (PROD_MODE):
- 1: Ethereum Mainnet
- 56: BNB Smart Chain Mainnet
- 137: Polygon Mainnet
*/
await walletServiceProvider.init();
The init method connects to the database and sets up the default blockchain networks that the service will interact with.
Use this function to add a new blockchain network to the service. This is essential for enabling wallet operations on different blockchain networks.
const chain = await walletServiceProvider.Chain.create({
chainId: 1,
coinType: "ERC20",
testnet: false,
});
1 for Ethereum mainnet."ERC20" indicates that the chain supports ERC20 tokens.This example adds the Ethereum mainnet as a supported chain in the wallet service provider.
Use this function to create a new partner entity within the wallet service. Partners are used to identify and manage different entities within the same application.
const partner = await walletServiceProvider.Partner.create({
name: "Partner Name",
email: "partner@gmail.com",
});
This example creates a partner named "Partner Name" with the email "partner@gmail.com". Partners allow for the organization and management of multiple entities, each with its own set of wallets and configurations.
Use this function to configure a specific blockchain network (chain) for a partner. This configuration includes necessary details like the scanner API and RPC URL required for blockchain interactions.
const chainConfig = await walletServiceProvider.ChainConfig.create({
chainId: chain._id,
partnerId: partner._id,
scannerAPIEndpoint: "https://api.etherscan.io/api",
scannerAPIKey: "your_scanner_api_key",
rpcUrl: "https://mainnet.infura.io/v3/your_infura_project_id",
});
This example creates a chain configuration for a partner, specifying the scanner API endpoint, API key, and RPC URL required to interact with the Ethereum mainnet.
Use this function to add a new token to the system for a specific blockchain network and partner. This enables wallet operations involving this token, such as checking balances and making transfers.
const token = await walletServiceProvider.Token.create({
chainId: 97,
address: "token_address",
partnerId: partner._id,
});
97 for the BNB Smart Chain testnet.This example adds a token to the BNB Smart Chain testnet for a specific partner, allowing that partner to manage and interact with this token within their wallets.
Use this function to create a new user wallet on a specific blockchain network for a partner. User wallets are essential for storing and managing users' cryptocurrency assets.
const userWallet = await walletServiceProvider.UserWallet.create({
chainId: chain._id,
partnerId: partner._id,
});
This example creates a user wallet on a specified blockchain network (identified by chain._id) for a particular partner (identified by partner._id). This wallet can then be used to store, transfer, and manage the partner's users' cryptocurrency assets.
Use this function to create a new feed wallet on a specific blockchain network for a partner. Feed wallets are specialized wallets that can be used for specific purposes, such as handling particular types of transactions or managing specific funds.
const feedWallet = await walletServiceProvider.FeedWallet.create({
chainId: chain._id,
partnerId: partner._id,
tokenId: token._id,
});
This example creates a feed wallet on a specified blockchain network (identified by chain._id) for a particular partner (identified by partner._id). The feed wallet is associated with a specific token (identified by token._id), enabling it to manage and interact with that token within the wallet service.
This function creates a hot wallet, which is a cryptocurrency wallet that is connected to the internet and used for managing funds in real-time operations. Hot wallets are often used for operational convenience, such as facilitating frequent transactions.
const hotWallet = await walletServiceProvider.HotWallet.create({
chainId: chain._id,
partnerId: partner._id,
tokenId: token._id,
address: "hot_wallet_address",
});
This example creates a hot wallet on a specified blockchain network (identified by chain._id) for a particular partner (identified by partner._id). The hot wallet is associated with a specific token (identified by token._id), enabling it to manage and interact with that token within the wallet service.
These functions allow you to perform various Web3 operations on feed or user wallets, such as checking token balances, transferring tokens, and retrieving native token balances.
Use this function to retrieve the balance of a specific token for a given user wallet.
const tokenBalance = await walletServiceProvider.UserWallet.getTokenBalance({
tokenId: token._id,
walletAddress: userWallet.address,
partnerId: userWallet.partner,
});
Transfer tokens from a user wallet to another address.
const res = await walletServiceProvider.UserWallet.transferTokens({
tokenId: token._id,
walletAddress: userWallet.address,
partnerId: userWallet.partner,
amount: "0.001",
to: "recipient_address",
});
Retrieve the native token balance of a user wallet.
const res = await walletServiceProvider.UserWallet.getBalance({
tokenId: token._id,
walletAddress: userWallet.address,
partnerId: userWallet.partner,
});
These functions enable you to perform essential Web3 operations on user wallets, facilitating token management and transactions within the wallet service.
This function allows you to transfer native tokens (the primary cryptocurrency of the blockchain network) from a user wallet to another address.
const res = await walletServiceProvider.UserWallet.transferNativeTokens({
chainId: chain._id,
walletAddress: userWallet.address,
partnerId: userWallet.partner,
amount: "0.001",
to: "recipient_address",
});
This function is useful for transferring the primary cryptocurrency of the blockchain network, such as Ether for Ethereum or BNB for Binance Smart Chain.
Retrieve the receipt of a transaction by providing its hash.
const receipt = await walletServiceProvider.Transaction.getTransactionReceipt({
transactionHash: "txhash",
chainId: chain.chainId,
partnerId: partner._id,
});
This function allows you to obtain detailed information about a transaction, such as its status, gas used, and block number, providing insights into its execution on the blockchain network.
This function creates a webhook, allowing you to configure real-time notifications and updates for wallet addresses.
const response = await walletServiceProvider.Webhook.create({
addresses: ["address1", "address2"],
webhookUrl: "webhook_url",
partnerId: partner._id,
chainId: 11155111,
});
This function enables you to set up custom webhook configurations, allowing your application to receive real-time updates about wallet activities, such as incoming transactions or token transfers.
FAQs
wallet service for partners
We found that @lfi-cloudx/wallet-services demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.