Embedded Wallets SDK for Node.js
Overview
The MetaMask Embedded Wallets Node.js SDK is a backend solution designed for server-side authentication and key management. This SDK enables seamless integration of Web3 authentication into backend applications, AI agents, and programmatic use cases.
Unlike frontend SDKs, the Node.js SDK is stateless and sessionless, making it ideal for:
- Backend AI agents
- Server-side wallet operations
- Programmatic blockchain interactions
- Custodial wallet services, without key management and recovery worries.
Key Features
- Stateless Architecture: No session management required
- Multi-Chain Support: EVM chains, Solana, and other blockchains
- Custom Authentication: Mandatory custom auth with single key share
- Private Key Access: Direct access to private keys for any blockchain
- Backend-Optimized: Designed specifically for server environments
Requirements
- Node.js 18+
- Custom authentication setup (mandatory)
- Web3Auth Dashboard project configuration
Installation
Install the Web3Auth Node SDK
- npm
- Yarn
- pnpm
- Bun
npm install --save @web3auth/node-sdk
yarn add @web3auth/node-sdk
pnpm add @web3auth/node-sdk
bun add @web3auth/node-sdk
Setup
Before you start, make sure you have:
- Registered on the Web3Auth Dashboard
- Set up a project with a custom Auth Connection (mandatory for Node.js SDK)
1. Custom Authentication Setup (Required)
The Node.js SDK only supports custom authentication. You must create a custom auth connection in the Web3Auth Dashboard:
- Go to Web3Auth Dashboard
- Select your project
- Navigate to Authentication → Custom Connections
- Click Create connections
- Configure your auth connection with your custom JWT details
You can refer to the Custom JWT Setup guide to learn more.
2. SDK Configuration
Create a Web3Auth instance with your client ID, web3auth network name, and chain information:
const { Web3Auth } = require('@web3auth/node-sdk')
const web3auth = new Web3Auth({
clientId: 'YOUR_WEB3AUTH_CLIENT_ID', // Pass your Web3Auth Client ID, ideally using an environment variable // Get your Client ID from Web3Auth Dashboard
web3AuthNetwork: 'sapphire_mainnet', // or 'sapphire_devnet'
})
The chain information is optional and will be used to setup the provider for connecting to the chain. If not provided, the first chain in the list will be used.