Since this is a server-side SDK, the wallets are not self-custodial.
Install the Backend SDK
npm install @chipi-stack/backend
Get your API Keys
- Go to your API Keys in the Chipi Dashboard
- Copy your Public Key (
pk_prod_xxxx) and Secret Key (sk_prod_xxxx)
Keep your Secret Key secure and never expose it in client-side code or version control.
Initialize the SDK
Create a new instance of the ChipiServerSDK with your API keys:import { ChipiServerSDK } from "@chipi-stack/backend";
const serverClient = new ChipiServerSDK({
apiPublicKey: "pk_prod_your_public_key",
apiSecretKey: "sk_prod_your_secret_key",
});
Create Your First Wallet
Now you can create a wallet for your users:const newWallet = await serverClient.createWallet({
params: {
encryptKey: "user-secure-pin",
externalUserId: "your-user-id-123",
},
});
console.log('New wallet created:', newWallet);
// Output: { wallet: { publicKey: "0x...", encryptedPrivateKey: "..." }, txHash: "0x..." }
Make Your First Transfer
Transfer tokens between wallets:const transferResult = await serverClient.transfer({
params: {
encryptKey: "user-secure-pin",
wallet: {
publicKey: newWallet.wallet.publicKey,
encryptedPrivateKey: newWallet.wallet.encryptedPrivateKey,
},
amount: "100",
token: "USDC",
recipient: "0x1234567890abcdef...",
},
});
console.log('Transfer completed:', transferResult);
Environment Variables (Recommended)
For production applications, store your API keys as environment variables:# .env
CHIPI_PUBLIC_KEY=pk_prod_your_public_key
CHIPI_SECRET_KEY=sk_prod_your_secret_key
Then initialize the SDK:const serverClient = new ChipiServerSDK({
apiPublicKey: process.env.CHIPI_PUBLIC_KEY!,
apiSecretKey: process.env.CHIPI_SECRET_KEY!,
});
Next Steps
Now that you have the basic setup working, explore more advanced features:
Security Best Practices
- Never expose your secret API key in client-side code
- Use environment variables for API keys in production
- Validate user inputs before making API calls
- Implement proper error handling and logging