Installation
TypeScript/JavaScript SDK
Prerequisites
- Node.js 18.x or higher
- npm, yarn, or pnpm
- A Dial API key (get one here )
Installation
npm install @dial/sdkOr with your preferred package manager:
# Yarn
yarn add @dial/sdk
# pnpm
pnpm add @dial/sdkAuthentication Dependencies
For secure wallet authentication, install the appropriate library for your chain:
For Ethereum/EVM chains (SIWE - Sign-In with Ethereum):
npm install siwe
# or
pnpm add siweFor Solana (SIWS - Sign-In with Solana):
npm install @solana/wallet-standard-util bs58
# or
pnpm add @solana/wallet-standard-util bs58Optional Wallet Integration Libraries
Ethereum:
# ethers.js
npm install ethers
# or wagmi (React)
npm install wagmi viemSolana:
npm install @solana/wallet-adapter-react @solana/wallet-adapter-walletsQuick Setup
1. Initialize the Universal Client
import { DialClient } from '@dial/sdk';
const dial = new DialClient({
apiKey: process.env.DIAL_API_KEY,
network: 'mainnet' // or 'testnet'
});2. Authenticate with SIWE (Ethereum)
import { SiweMessage } from 'siwe';
// Get nonce from Dial
const nonce = await dial.auth.getNonce();
// Create SIWE message
const siweMessage = new SiweMessage({
domain: 'dial.wtf',
address: walletAddress,
statement: 'Sign in to Dial',
uri: 'https://dial.wtf',
version: '1',
chainId: 1,
nonce,
issuedAt: new Date().toISOString(),
});
// Sign and authenticate
const message = siweMessage.prepareMessage();
const signature = await wallet.signMessage(message);
const userDialer = await dial.asUser({
siwe: { message, signature }
});3. Make Your First Call
const call = await userDialer.calls.start({
to: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
type: 'audio'
});
console.log('Call started:', call.id);Environment Variables
Create a .env file in your project root:
DIAL_API_KEY=your_api_key_here
DIAL_NETWORK=mainnetWebpack Configuration (React)
If you’re using Create React App or a custom Webpack setup, you may need to add polyfills:
// webpack.config.js
module.exports = {
resolve: {
fallback: {
"stream": require.resolve("stream-browserify"),
"crypto": require.resolve("crypto-browserify")
}
}
};Next.js Configuration
For Next.js projects, add to your next.config.js:
module.exports = {
webpack: (config) => {
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
net: false,
tls: false,
};
return config;
},
};Verification
Verify your installation:
import { DialClient } from '@dial/sdk';
console.log('Dial SDK version:', DialClient.version);Next Steps
Last updated on