Documentation Index
Fetch the complete documentation index at: https://docs.chipipay.com/llms.txt
Use this file to discover all available pages before exploring further.
Usage
import { ChipiBrowserSDK, Chain } from "@chipi-stack/backend";
const bearerToken = await getBearerToken(); // Your auth implementation
const newWallet = await browserClient.createWallet({
params: {
encryptKey: "user-secure-pin",
externalUserId: "your-user-id-123",
chain: Chain.STARKNET,
},
bearerToken: bearerToken,
});
Parameters
encryptKey (string): A user-defined code or password used to encrypt the wallet’s private key.
externalUserId (string): Your application’s unique identifier for the user
chain (Chain): The blockchain network for the wallet. Use Chain.STARKNET.
bearerToken (string): Bearer token for authentication
Return Value
Returns a Promise that resolves to CreateWalletResponse — a flat object with:
publicKey: The wallet’s public key / address
encryptedPrivateKey: The encrypted private key (store securely)
walletType: The wallet type ("CHIPI" or "READY")
chain: The blockchain network
isDeployed: Whether the wallet contract is deployed
normalizedPublicKey: Normalized form of the public key
apiPublicKey: The organization’s API public key
id, externalUserId, organizationId, createdAt, updatedAt
Example Implementation
import { ChipiBrowserSDK, Chain } from "@chipi-stack/backend";
const browserClient = new ChipiBrowserSDK({
apiPublicKey: process.env.VITE_CHIPI_PUBLIC_KEY, // or your framework's env var
});
async function createUserWallet(userId: string, userPin: string) {
try {
const bearerToken = await getBearerToken(); // Your auth implementation
const newWallet = await browserClient.createWallet({
params: {
encryptKey: userPin,
externalUserId: userId,
chain: Chain.STARKNET,
},
bearerToken: bearerToken,
});
console.log('Wallet created successfully!');
console.log('Address:', newWallet.publicKey);
// Store wallet data in your app state
saveWalletToState({
userId,
publicKey: newWallet.publicKey,
encryptedPrivateKey: newWallet.encryptedPrivateKey,
});
return newWallet;
} catch (error) {
console.error('Wallet creation failed:', error);
throw error;
}
}
// Usage example
async function onboardNewUser(userId: string, pin: string) {
const wallet = await createUserWallet(userId, pin);
// Verify deployment on StarkScan
const contractUrl = `https://starkscan.co/contract/${wallet.publicKey}`;
console.log('View contract:', contractUrl);
return wallet;
}
Related Methods
- getWallet - Retrieve existing wallet information
- transfer - Send tokens from the created wallet