E-TALK Authentication API
Add "Login with E-TALK" to your platform in minutes
Quick Start - Add to Your Login Page
Copy and paste this entire code block into your login page HTML.
SECURITY NOTE: Never expose your API Secret in frontend code. Always proxy API calls through your backend. See "Secure Backend Proxy" section below.
<!-- Add this to your login page -->
<div id="etalk-login-container">
<h3>Login with Web3 Identity</h3>
<div class="etalk-input-group">
<input type="text" id="etalk-identifier" placeholder="yourname.etk or 0x..." style="width: 100%; padding: 12px; margin: 10px 0;">
<button id="etalk-request-btn" style="width: 100%; padding: 12px; background: #ff6a00; color: white; border: none; border-radius: 8px; font-weight: 600; cursor: pointer;">
Continue with E-TALK
</button>
</div>
<div id="etalk-otp-section" style="display: none; margin-top: 15px;">
<input type="text" id="etalk-otp" placeholder="Enter 6-digit code" style="width: 100%; padding: 12px; margin: 10px 0;">
<button id="etalk-verify-btn" style="width: 100%; padding: 12px; background: #ff6a00; color: white; border: none; border-radius: 8px; font-weight: 600; cursor: pointer;">
Verify & Login
</button>
</div>
<div id="etalk-message" style="margin-top: 10px; font-size: 12px;"></div>
</div>
<script>
// IMPORTANT: Never put API Secret in frontend code!
// Create backend proxy endpoints instead (see documentation)
const ETALK_API_URL = 'https://rpc.webchain.e-talk.xyz';
const ETALK_API_KEY = 'YOUR_API_KEY';
// API SECRET stays on your server - never in browser!
let currentIdentifier = '';
document.getElementById('etalk-request-btn').onclick = async () => {
const identifier = document.getElementById('etalk-identifier').value.trim();
if (!identifier) {
document.getElementById('etalk-message').innerHTML = '<span style="color: #ff6a00;">Please enter your .etk name or wallet address</span>';
return;
}
currentIdentifier = identifier;
document.getElementById('etalk-message').innerHTML = '<span style="color: #ff6a00;">Sending verification code...</span>';
// Call YOUR backend proxy (not E-TALK directly)
const response = await fetch('/api/etalk/request-otp', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ identifier: identifier })
});
const result = await response.json();
if (result.success) {
document.getElementById('etalk-message').innerHTML = '<span style="color: #4CAF50;">✓ Verification code sent to your email</span>';
document.getElementById('etalk-otp-section').style.display = 'block';
} else {
document.getElementById('etalk-message').innerHTML = `<span style="color: #ff6a00;">Error: ${result.error}</span>`;
}
};
document.getElementById('etalk-verify-btn').onclick = async () => {
const otp = document.getElementById('etalk-otp').value.trim();
if (!otp) {
document.getElementById('etalk-message').innerHTML = '<span style="color: #ff6a00;">Please enter the verification code</span>';
return;
}
document.getElementById('etalk-message').innerHTML = '<span style="color: #ff6a00;">Verifying...</span>';
// Call YOUR backend proxy
const response = await fetch('/api/etalk/verify-otp', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ otp: otp })
});
const result = await response.json();
if (result.success && result.verified) {
document.getElementById('etalk-message').innerHTML = '<span style="color: #4CAF50;">✓ Verified! Redirecting...</span>';
// Send to your backend to create/login user
const user = result.user;
const loginResponse = await fetch('/api/auth/etalk', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
user_id: user.user_id,
display_name: user.display_name,
etk_name: user.etk_name,
wallet_address: user.wallet_address,
profile_image: user.profile_image
})
});
if (loginResponse.ok) {
window.location.href = '/dashboard';
}
} else {
document.getElementById('etalk-message').innerHTML = `<span style="color: #ff6a00;">Invalid code: ${result.error}</span>`;
}
};
</script>
Important: Replace
YOUR_API_KEY with your actual API key. Create backend proxy endpoints at /api/etalk/request-otp and /api/etalk/verify-otp to keep your API Secret secure.
Secure Backend Proxy (Required)
Create these endpoints on YOUR server to keep the API Secret secure.
// Node.js/Express backend proxy (your server)
// API Secret stays here - NEVER exposed to browser
const express = require('express');
const axios = require('axios');
const app = express();
const ETALK_API_URL = 'https://rpc.webchain.e-talk.xyz';
const ETALK_API_KEY = 'YOUR_API_KEY';
const ETALK_API_SECRET = 'YOUR_API_SECRET'; // ← SECURE, never exposed
// Proxy: Request OTP
app.post('/api/etalk/request-otp', async (req, res) => {
const { identifier } = req.body;
const response = await axios.post(`${ETALK_API_URL}/auth/request-otp`, {
api_key: ETALK_API_KEY,
api_secret: ETALK_API_SECRET,
identifier: identifier
});
res.json(response.data);
});
// Proxy: Verify OTP
app.post('/api/etalk/verify-otp', async (req, res) => {
const { otp } = req.body;
const response = await axios.post(`${ETALK_API_URL}/auth/verify-otp`, {
api_key: ETALK_API_KEY,
api_secret: ETALK_API_SECRET,
otp: otp
});
res.json(response.data);
});
Backend Integration (Node.js Example)
Create this endpoint on your server to handle the user creation/login.
// Node.js/Express backend endpoint
app.post('/api/auth/etalk', async (req, res) => {
const { user_id, display_name, etk_name, wallet_address, profile_image } = req.body;
try {
// Find or create user in your database
let user = await User.findOne({ where: { etalk_id: user_id } });
if (!user) {
user = await User.create({
etalk_id: user_id,
username: etk_name || display_name,
display_name: display_name,
wallet_address: wallet_address,
avatar: profile_image,
created_at: new Date()
});
}
// Update last login
user.last_login = new Date();
await user.save();
// Create session
req.session.userId = user.id;
res.json({ success: true, redirect: '/dashboard' });
} catch (error) {
res.status(500).json({ error: error.message });
}
});
Python (Flask) Example
@app.route('/api/auth/etalk', methods=['POST'])
def etalk_auth():
data = request.json
user = User.query.filter_by(etalk_id=data['user_id']).first()
if not user:
user = User(
etalk_id=data['user_id'],
username=data['etk_name'] or data['display_name'],
display_name=data['display_name'],
wallet_address=data['wallet_address'],
avatar=data['profile_image']
)
db.session.add(user)
db.session.commit()
login_user(user)
return jsonify({'success': True, 'redirect': '/dashboard'})
WordPress (PHP) Example - Complete
<?php
/**
* Complete WordPress Integration for E-TALK Login
* Add this to your theme's functions.php
*/
// 1. Create REST API endpoints
add_action('rest_api_init', function() {
register_rest_route('etalk/v1', '/request-otp', [
'methods' => 'POST',
'callback' => 'etalk_proxy_request_otp',
'permission_callback' => '__return_true'
]);
register_rest_route('etalk/v1', '/verify-otp', [
'methods' => 'POST',
'callback' => 'etalk_proxy_verify_otp',
'permission_callback' => '__return_true'
]);
});
// 2. Your E-TALK credentials
define('ETALK_API_KEY', 'YOUR_API_KEY');
define('ETALK_API_SECRET', 'YOUR_API_SECRET');
define('ETALK_API_URL', 'https://rpc.webchain.e-talk.xyz');
// 3. Proxy: Request OTP
function etalk_proxy_request_otp($request) {
$params = $request->get_json_params();
$identifier = isset($params['identifier']) ? sanitize_text_field($params['identifier']) : '';
if (empty($identifier)) {
return new WP_REST_Response(['error' => 'Identifier required'], 400);
}
$response = wp_remote_post(ETALK_API_URL . '/auth/request-otp', [
'headers' => ['Content-Type' => 'application/json'],
'body' => json_encode([
'api_key' => ETALK_API_KEY,
'api_secret' => ETALK_API_SECRET,
'identifier' => $identifier
])
]);
$body = json_decode(wp_remote_retrieve_body($response), true);
return new WP_REST_Response($body, wp_remote_retrieve_response_code($response));
}
// 4. Proxy: Verify OTP & Create WordPress User
function etalk_proxy_verify_otp($request) {
$params = $request->get_json_params();
$otp = isset($params['otp']) ? sanitize_text_field($params['otp']) : '';
if (empty($otp)) {
return new WP_REST_Response(['error' => 'OTP required'], 400);
}
$response = wp_remote_post(ETALK_API_URL . '/auth/verify-otp', [
'headers' => ['Content-Type' => 'application/json'],
'body' => json_encode([
'api_key' => ETALK_API_KEY,
'api_secret' => ETALK_API_SECRET,
'otp' => $otp
])
]);
$body = json_decode(wp_remote_retrieve_body($response), true);
// If verified, create/login WordPress user
if ($body['success'] && $body['verified']) {
$user_data = $body['user'];
$user_id = etalk_create_wordpress_user($user_data);
if ($user_id) {
wp_set_current_user($user_id);
wp_set_auth_cookie($user_id);
$body['redirect'] = home_url('/dashboard');
$body['wp_user_id'] = $user_id;
}
}
return new WP_REST_Response($body, wp_remote_retrieve_response_code($response));
}
// 5. Create or login WordPress user
function etalk_create_wordpress_user($user_data) {
// Check if user exists by E-TALK ID
$existing = get_users([
'meta_key' => 'etalk_user_id',
'meta_value' => $user_data['user_id'],
'number' => 1,
'fields' => 'ID'
]);
if (!empty($existing)) {
return $existing[0];
}
// Create new user
$username = str_replace('.etk', '', $user_data['etk_name']) ?: 'user_' . $user_data['user_id'];
$email = $user_data['email'] ?? $user_data['user_id'] . '@etalk.user';
$user_id = wp_create_user($username, wp_generate_password(), $email);
if (!is_wp_error($user_id)) {
wp_update_user(['ID' => $user_id, 'display_name' => $user_data['display_name']]);
update_user_meta($user_id, 'etalk_user_id', $user_data['user_id']);
update_user_meta($user_id, 'etalk_etk_name', $user_data['etk_name']);
update_user_meta($user_id, 'etalk_wallet', $user_data['wallet_address']);
}
return $user_id;
}
// 6. Shortcode for login button
add_shortcode('etalk_login', function() {
if (is_user_logged_in()) {
return '<p>Welcome! <a href="' . wp_logout_url(home_url()) . '">Logout</a></p>';
}
$rest_url = get_rest_url(null, 'etalk/v1');
ob_start();
?>
<div id="etalk-login">
<input type="text" id="etalk-id" placeholder="yourname.etk">
<button id="etalk-request">Continue</button>
<div id="etalk-otp-box" style="display:none">
<input type="text" id="etalk-code" placeholder="Enter 6-digit code">
<button id="etalk-verify">Login</button>
</div>
<div id="etalk-msg"></div>
</div>
<script>
const API_URL = '<?php echo $rest_url; ?>';
document.getElementById('etalk-request').onclick = async () => {
const id = document.getElementById('etalk-id').value;
const res = await fetch(API_URL + '/request-otp', {
method: 'POST',
body: JSON.stringify({ identifier: id }),
headers: {'Content-Type': 'application/json'}
});
const data = await res.json();
if (data.success) {
document.getElementById('etalk-otp-box').style.display = 'block';
document.getElementById('etalk-msg').innerHTML = '<span style="color:#4CAF50">✓ Code sent</span>';
} else {
document.getElementById('etalk-msg').innerHTML = '<span style="color:#ff6a00">Error: ' + data.error + '</span>';
}
};
document.getElementById('etalk-verify').onclick = async () => {
const code = document.getElementById('etalk-code').value;
const res = await fetch(API_URL + '/verify-otp', {
method: 'POST',
body: JSON.stringify({ otp: code }),
headers: {'Content-Type': 'application/json'}
});
const data = await res.json();
if (data.success && data.verified) {
window.location.href = data.redirect || window.location.href;
} else {
document.getElementById('etalk-msg').innerHTML = '<span style="color:#ff6a00">Invalid code</span>';
}
};
</script>
<?php
return ob_get_clean();
});
Usage: Add
[etalk_login] shortcode to any page. Replace YOUR_API_KEY and YOUR_API_SECRET with your credentials.
🎨 Styled "Login with E-TALK" Button
Copy this ready-to-use styled button for your login page.
<button onclick="showETALKModal()" style="display: flex; align-items: center; gap: 12px; background: #1a1a1a; color: #ff6a00; border: 2px solid #ff6a00; border-radius: 50px; padding: 14px 28px; font-size: 16px; font-weight: 600; cursor: pointer;">
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>
<path d="M7 11V7a5 5 0 0110 0v4"/>
</svg>
Login with E-TALK
</button>
Test Your Integration
API Reference
Base URL:
https://rpc.webchain.e-talk.xyz1. Request OTP
POST /auth/request-otp
Content-Type: application/json
{
"api_key": "YOUR_API_KEY",
"api_secret": "YOUR_API_SECRET", // ← Keep on server!
"identifier": "yourname.etk"
}
2. Verify OTP
POST /auth/verify-otp
Content-Type: application/json
{
"api_key": "YOUR_API_KEY",
"api_secret": "YOUR_API_SECRET", // ← Keep on server!
"otp": "123456"
}
Response
{
"success": true,
"verified": true,
"user": {
"user_id": 12345,
"display_name": "John Doe",
"etk_name": "john.etk",
"premium_etk": "john-premium.etk",
"wallet_address": "0x...",
"wx_wallet": "wx...",
"profile_image": "https://..."
}
}
Sign in
No account yet?
Create an Account























