DeBox DApp
DeBox DApp
Developer-facing DApp integration guide (current version).
1. What is a DApp
A DeBox DApp is an H5 app running inside the DeBox built-in browser.
You can:
- Reuse existing web pages for fast integration
- Use injected wallet objects for on-chain interactions
- Call DeBox OpenAPI from your backend for messaging/user/group features
2. Quick start
- Create an app on DeBox Open Platform and get
API Key. - Prepare a publicly reachable HTTPS web app.
- Implement DeBox environment detection and wallet flows.
- Keep OpenAPI calls on your backend (never expose secrets in frontend).
3. Runtime detection
const isDeBoxUA = !!window?.navigator?.userAgent?.includes("DeBox")
const hasDeBoxWallet = typeof window?.deboxWallet !== "undefined"
const hasEthereum = typeof window?.ethereum !== "undefined"
const hasSolana = typeof window?.solana !== "undefined"
Recommendation:
- Use
hasDeBoxWallet || hasEthereumas your EVM capability check. - Add graceful fallback for non-DeBox runtime.
4. Wallet and user-info capabilities
Primary entry is window.deboxWallet (EVM-compatible).
4.1 Request permissions
await window.deboxWallet.request({
method: "wallet_requestPermissions",
params: [{ eth_accounts: { debox_getUserInfo: {} } }],
})
4.2 Get public user profile
const userInfo = await window.deboxWallet.request({
method: "debox_getUserInfo",
params: [],
})
Example response (fields may vary by client version):
{
"uid": "jkdi123",
"address": "0xa56b4f0c7622bd076c2ba48b17d1e8d3fbf5303e",
"name": "Alice",
"avatar": "https://...png"
}
5. Backend OpenAPI integration (recommended)
Security baseline:
- Frontend calls your backend only.
X-API-KEY, signature params, and app secret stay server-side.
Primary API reference:
6. Message sending (current API)
Use POST /openapi/bot/sendMessage:
curl -X POST "https://open.debox.pro/openapi/bot/sendMessage" \
-H "Content-Type: application/json" \
-H "X-API-KEY: YOUR_APP_KEY" \
-d '{
"chat_id": "cc0onr82",
"chat_type": "group",
"content": "Hello from DApp",
"parse_mode": "richtext"
}'
Field notes:
chat_type:group|privatechat_id:- group ->
gid - private -> user
user_id
- group ->
content: message bodyparse_mode: defaultrichtext
7. Production checklist
- HTTPS and mobile adaptation are complete.
- Runtime detection + fallback path are verified.
- Wallet permission flow handles reject/cancel/success.
- OpenAPI calls are backend-only.
- Logs contain request id, user identity, endpoint, and error code.
8. FAQ
- OpenAPI fails when called directly in browser:
- Expected; move calls to backend.
- Message send failures:
- Check
chat_type/chat_idmapping. - Check non-empty
contentand validparse_mode.
- Wallet object missing:
- Not in DeBox runtime or unsupported client version.