# DeBox Developer Documentation > DeBox developer documentation: bot OpenAPI, Go / Node.js / Python SDKs, open platform capabilities and FAQ. This file follows the llmstxt.org standard and contains the complete DeBox developer documentation in Markdown, suitable for full-context indexing or offline reference. To locate pages by section instead, use the smaller index at https://docs.debox.pro/en/llms.txt. ## DeBox User Guide ![Docs Version Dropdown](https://docs.debox.pro/en/assets/images/banner_en-d455f49e7177040a961b004f73e90b07.jpg) ## What Can DeBox Do For Me? **DeBox is an all-in-one Web3 community management tool designed to establish a trustworthy data ecosystem. By logging in with a Web3 wallet, you can engage in private chats, small group chats, Club chats, DAO/NFT chats (Token-gated chats), post updates, view everyone’s updates, and see on-chain updates from those you follow.** :::tip Get Started - **Official Website** - **Web App** - **Beginner Community** ::: :::info Technical Support - Feel free to join the DeBox technical discussion group: Click to Join - Issue Feedback: 【My】- Top Right 【Settings】-【Feedback】to submit ::: ## What NFTs Has DeBox Officially Issued? ### DeBox Guardians Penguin (DGP) > Nickname: Penguin > Penguins are OGs with significant governance rights and influence in the community. ### DeBox Guardians Eagle (DGE) > Nickname: Eagle > Eagles are enforcers who oversee and manage the community to ensure members follow the rules and guidelines. ### DeBox Guardians Rabbit (DGR) > Nickname: Rabbit > Rabbits are builders who drive community development, often serving as developers. ### DeBox Guardians Cobra (DGC) > Nickname: Cobra > Cobras represent the foundation, driving community growth and governance, enhancing users' premium Web3 social experience. ### DeBox Guardians Shark (DGS) > Nickname: Shark > Sharks are pioneers, brave and powerful. They explore the boundaries of DeBox and enhance the robustness of the entire DeBox ecosystem. ![Docs Version Dropdown](https://docs.debox.pro/en/assets/images/En12-15f552c7a6c0734025b87238c23d87d1.jpg) ## How to Log into DeBox? DeBox offers two wallet login methods: login with a local wallet 【Recommended】 or connect with a wallet app; ### Create a Wallet if You Don’t Have One App top left 【Accounts】-【Add】-【Create Wallet】- Set password - Successfully created - Backup personal mnemonic. Note that the DeBox server does not save your private key. Be sure to back up your mnemonic and keep your mnemonic and private key safe to ensure asset security. ![Docs Version Dropdown](https://docs.debox.pro/en/assets/images/En3-1-804ae90b7ca820b42f35926b3c6b088b.jpg) ### Import an Existing Wallet App top left 【Add Wallet】-【Import Wallet】- Copy private key or mnemonic - Set password -【Import】 ![Docs Version Dropdown](https://docs.debox.pro/en/assets/images/En3-2-d78297858b57b4c177779c633c92b04e.jpg) ### If You Don’t Want to Import a Private Key Top left 【Add Wallet】- Choose WalletConnect or TokenPocket - Jump to authorization confirmation, which requires network service support. If authorization and jump fail, check your network or use a local wallet login. ![Docs Version Dropdown](https://docs.debox.pro/en/assets/images/En3-3-3eb8ed06b421af97100c7fcd382592d0.jpg) ## How to Set Your NFT as Your Avatar? ### How to Set Your NFT as Your Avatar? 【Personal Profile】-【Edit】- Avatar - Choose owned NFT -【Save】. ![Docs Version Dropdown](https://docs.debox.pro/en/assets/images/En4-1-948524e6df097d95f71c3b8f9a2a0ed7.jpg) ### How to Set Your Domain Name as a Nickname? 【Personal Profile】-【Edit】- Click 【DID】- Choose DID -【Save】. ![Docs Version Dropdown](https://docs.debox.pro/en/assets/images/En4-2-727812ec0b3b3f9446cb793e2ed8a5fb.jpg) ## How Do I Send Private Messages to My Friends? ### How Do I Send Private Messages to My Friends? Click on 【The Other Party’s Avatar】- The 【Chat Button】 next to the follow button. If you cannot chat, it means the other party has not enabled private messaging permissions for you. To change your private message settings, go to 【My】-【Settings】-【Privacy】-【Private Message Permissions】. By default, 【Only people I follow can message me】 to avoid spam. You can choose 【Anyone can message me】 or 【No one can message me】. ![Docs Version Dropdown](https://docs.debox.pro/en/assets/images/En5-1-256da5b610f654f4fe91fecc4e26bde3.jpg) ## How Do I Create a Group? Small groups are multi-person chats with up to 500 people. You can invite multiple friends for small group chats. Discover various popular activities in the Events section and join corresponding chat groups for real-time discussions. ### How to Create? Bottom 【Chat】- Top right 【+】-【Create Small Group】-【Select Members】-【Create Now】. If the number of people reaches the limit, go to the Web App 【Community】-【Manage】- Upgrade to Club Chat - Increase the number of people. ![Docs Version Dropdown](https://docs.debox.pro/en/assets/images/En6-1-762edd7ed20bac30dfc38aed08c8f520.jpg) ## How to Create/Join a Club? A Club is a group chat with over 500 people, where the Club owner and administrators have access to community tools. ### Create a Club 【Web APP】-【Community】-【Create】-【Create Club】-Please select NFT to stake - Please input club name, icon and type - 【Create】 (this process requires gas fees). ### Join a Club 【Community】- select 【Club】 to join. Some Clubs have specific joining requirements set by the owner. Applications may need review, assets, or payment. ![Docs Version Dropdown](https://docs.debox.pro/en/assets/images/En7-1-a84229f5c1de46a82851fc6b4d9e073e.jpg) ## What is Token-gated Chat? Token-gated chat requires users to hold corresponding Tokens/NFTs to join the group. ### Join DAO/NFT 【Community】- Choose DAO/NFT to join. ![Docs Version Dropdown](https://docs.debox.pro/en/assets/images/En8-1-4503ffb99d43d44a607a92a981311dbc.jpg) ### Create DAO/NFT 【Chat】 - 【+】 - 【Create DAO】 - Choose Token/NFT - Set Name and Avatar - 【Create】 ![Docs Version Dropdown](https://docs.debox.pro/en/assets/images/En8-2-5be701402afa8a82e475a15a4184f775.jpg) ## What Fun Community Tools Are Available? ### What Fun Community Tools Are Available? Enter the community - bottom 【+】 - 【Vote】 【Giveaway】 【Meetup】 - Participate/Send; you can also participate in the community through a message card, Or participate in the floating window on the right. ![Docs Version Dropdown](https://docs.debox.pro/en/assets/images/En9-adb01ed60b4a279b23be81c16ca0670f.jpg) ## What Content Can I See on the Discover Page? On the Discover page, you can post updates, browse updates, comment, and follow other users. ### View Everyone's Updates In 【Discover Page】-【Explore】, browse everyone’s updates. The platform recommends high-quality updates based on your preferences. ### View Updates from People You Follow Switch from 【Explore】 to 【Following】. You can browse real-time updates and on-chain updates from people you follow, discover trading behaviors, understand trading strategies, investment trends, and projects they are involved in. ![Docs Version Dropdown](https://docs.debox.pro/en/assets/images/En10-daccd38d0c31247d86c419bfada96f91.jpg) View More --- ## DeBox Open Capabilities DeBox provides a practical developer surface for building bots, DApps, and ecosystem integrations around communities and Web3 user interactions. ## Capability Map ### 1. DeBox DApp - Build in-app Web experiences inside DeBox. - Use injected wallet providers (`window.deboxWallet`, `window.ethereum`, `window.solana`) for Web3 interactions. - Read DApp runtime and permission flow in [DeBox DApp](/MiniApp). ### 2. OpenClaw DeBox Plugin - Connect OpenClaw workflows with DeBox bot channels. - Suitable for teams already operating OpenClaw multi-channel automation. - Installation and setup: [OpenClaw DeBox Plugin](/APIs/OpenClaw-Plugin-Install). ### 3. DeBox Shares Protocol - Integrate permissionless automated revenue sharing into product payments. - Supports on-chain payment split patterns and settlement workflows. - Integration guide: [DeBox Shares Protocol](/Shares). ### 4. DeBox Grant Program - Apply for ecosystem support if your project is actively integrated with DeBox capabilities. - Program details and application path: [DeBox Grant Program](/OpenPlatformGrant). ## Recommended Integration Path 1. Define your product path: bot, DApp, or both. 2. Complete bot capability onboarding via [DeBox Bot Guide](/APIs/BotGuide). 3. Integrate APIs using [DeBox Developer OpenAPI](/ApiOnePage). 4. For Go stacks, choose either [Go SDK Long Polling](/GO-SDK) or [Go SDK Webhook](/GO-SDK-Webhook) based on message receive mode. 5. If needed, add Shares and Grant participation after core capability is stable. ## Support - Developer portal: [developer.debox.pro](https://developer.debox.pro) - Developer troubleshooting: [Developer FAQ / Troubleshooting](/APIQA) --- ## 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 1. Create an app on [DeBox Open Platform](https://developer.debox.pro) and get `API Key`. 2. Prepare a publicly reachable HTTPS web app. 3. Implement DeBox environment detection and wallet flows. 4. Keep OpenAPI calls on your backend (never expose secrets in frontend). ## 3. Runtime detection ```js 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 || hasEthereum` as 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 ```js await window.deboxWallet.request({ method: "wallet_requestPermissions", params: [{ eth_accounts: { debox_getUserInfo: {} } }], }) ``` ### 4.2 Get public user profile ```js const userInfo = await window.deboxWallet.request({ method: "debox_getUserInfo", params: [], }) ``` Example response (fields may vary by client version): ```json { "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: - [DeBox Developer OpenAPI](/ApiOnePage) ## 6. Message sending (current API) Use `POST /openapi/bot/sendMessage`: ```bash 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` | `private` - `chat_id`: - group -> `gid` - private -> user `user_id` - `content`: message body - `parse_mode`: default `richtext` ## 7. Production checklist 1. HTTPS and mobile adaptation are complete. 2. Runtime detection + fallback path are verified. 3. Wallet permission flow handles reject/cancel/success. 4. OpenAPI calls are backend-only. 5. Logs contain request id, user identity, endpoint, and error code. ## 8. FAQ 1. OpenAPI fails when called directly in browser: - Expected; move calls to backend. 2. Message send failures: - Check `chat_type/chat_id` mapping. - Check non-empty `content` and valid `parse_mode`. 3. Wallet object missing: - Not in DeBox runtime or unsupported client version. ## 9. Related docs - [DeBox Developer OpenAPI](/ApiOnePage) - [DeBox Chat Bot Guide](/APIs/BotGuide) - [DeBox Bot Go SDK](/GO-SDK) - [DeBox Bot Go SDK Webhook](/GO-SDK-Webhook) --- ## OpenClaw DeBox Plugin # Install DeBox Plugin on OpenClaw This guide explains how to install and enable the official DeBox plugin on OpenClaw. ## Prerequisite - You already have OpenClaw installed. - You already created a DeBox Bot with **BotMother**. - `yourDeBoxBotToken` is the **API Key** of that bot from BotMother. ## Step 1: Install plugin ```bash openclaw plugins install @descartes_1/debox@latest ``` ## Step 2: Add DeBox channel with bot token ```bash openclaw channels add --channel debox --token "yourDeBoxBotToken" ``` ## Step 3: Restart gateway ```bash openclaw gateway restart ``` ## Verify Run: ```bash openclaw channels list ``` If configured correctly, you should see DeBox channel/account in the output. --- ## DeBox Permissionless Shares Protocol :::tip Shares V2 🎉 The DeBox Shares V2 protocol is now live! ⚡ If you have previously integrated Shares V1, no code changes are required!      Automatically upgrade to V2, enjoying higher commissions, enhanced features, and a better experience! 🚀 Start integrating the DeBox Shares protocol now and unlock a new revenue model! ::: ## DeBox Shares Introduction ### 1. What is DeBox Shares? - DeBox Shares is an underlying revenue-sharing protocol uniquely developed based on the DeBox product, connecting project parties with DeBox groups. - It operates through DeBox's product and social relationships. - Project parties can integrate without permission—simple and fast, completing the process in just 10 minutes. - Groups and inviters can receive instant rebates of up to 80% from project parties. Based on the DeBox Shares protocol and DeBox group functionalities, everyone can open a decentralized exchange after universal on-chain assetization. - The DeBox Shares protocol is a permissionless and decentralized protocol. The DeBox platform does not and will not endorse any projects integrated with DeBox Shares. ### 2. What are the benefits for project owners activating DeBox Shares? - Through DeBox Shares, projects can reach 10 million real users and 300,000 private community groups. Promoting a project in any group can gain recognition and support from group administrators. ## What participation methods does Shares support? 1. Supports on-chain Token payments: Call the DeBox-Shares contract and slightly adjust the DAPP's payment contract code; 2. Supports multiple networks: Currently supports ETH, Arbitrum, Base, BSC, OP, Polygon network assets (continuously updating). ## How to integrate Shares? ### 1. Integrate Shares - The DeBox Shares protocol is an automated revenue-sharing tool specifically designed for developers to simplify the transaction distribution process. - When developing programs on the DeBox platform, developers only need to set the distribution ratio. There is no need to handle complex logic involving sharers, invitation codes, etc., as the DeBox Shares protocol automatically completes the revenue distribution for each transaction. - Developers can use the DeBox SDK to create various functionalities and encourage users to promote and use these programs through revenue sharing. When users open a mini-program via a shared link and complete a transaction, the protocol automatically allocates the revenue according to the predefined ratio. - The Box payment process includes two main steps: connecting the wallet and obtaining authorization, and calling the payment API to complete the payment. After the payment is completed, you can view the payment details. Here are the detailed steps and usage methods: #### 1.1 Connect Wallet and Request Authorization - DAPP can connect to the user's wallet and obtain the required user information through the DeBox Wallet SDK. > The DeBox Wallet SDK is a tool for DAPP to connect and interact with the DeBox wallet. When users open the webpage through the DeBox client, DeBox will automatically inject the `window.deboxWallet` object into the webpage (it can also be accessed through the alias `window.ethereum`). DAPP can use this object to detect whether the DeBox wallet is installed and call the corresponding API methods for operation. > - The following methods can be used for this process:
**eth_requestAccounts**: This method requests user wallet authorization to connect. - [Common wallet methods](https://docs.metamask.io/wallet/reference/eth_requestaccounts/), extended by DeBox. - Internally, this method calls `debox_getUserInfo` to request user information permissions. - This method will pop up a window asking the user to authorize the connection to the DAPP and obtain the wallet address. **Request:** ```jsx await window.deboxWallet.request({ "method": "eth_requestAccounts", "params": [], }); ``` **Parameters:** - None **Response:** - Returns the user's wallet address upon success. ```jsx [ "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" ] ```
**wallet_requestPermissions**: This method requests user approval for DAPP access permissions. - Methods that require prior user authorization include: `debox_getUserInfo` (to get user public information). 1. Permission request information parameters are empty. By default, it will request user approval for the `debox_getUserInfo` method. **Request:** ```jsx await window.deboxWallet.request({ "method": "wallet_requestPermissions", "params": [{ eth_accounts: {} }], }); ``` **Parameters:** - `eth_accounts`: Its value is an empty object `{}`, indicating a request for default permissions (i.e., `debox_getUserInfo`). **Response:** - Returns upon success: ```jsx [ { "parentCapability": "eth_accounts", "invoker": "https://connect-nu-one.vercel.app/", "caveats": [ { "type": "restrictReturnedAccounts", "value": [ "0xa56b4f0c7622bd076c2ba48b17d1e8d3fbf5303e" ] }, { "type": "debox_getUserInfo", "value": { "uid":"jkdi123", "address":"0xa56b4f0c7622bd076c2ba48b17d1e8d3fbf5303e", "name":"Tom", "avatar":"https://debox......png" } }, ], "date": 1728348403194 }, ] ``` 2. Permission request information with parameters. At this time, the user will be asked to approve the permissions specified by the developer: **Request:** ```jsx await window.deboxWallet.request({ "method": "wallet_requestPermissions", "params": [{ eth_accounts: { "debox_getUserInfo": {}, } }], }); ``` **Parameters:** - `eth_accounts` property, with a value of an object specifying two permissions: - `"debox_getUserInfo"`: Request permission to get user information (e.g., avatar, nickname), with an empty object `{}` as the value. **Response:** - Returns upon success: ```jsx [ { "id": "QbOgSTaFmS3UK1qS6pese", "parentCapability": "eth_accounts", "invoker": "https://connect-nu-one.vercel.app/", "caveats": [ { "type": "restrictReturnedAccounts", "value": [ "0xa56b4f0c7622bd076c2ba48b17d1e8d3fbf5303e" ] }, { "type": "debox_getUserInfo", "value": { "uid":"jkdi123", "address":"0xa56b4f0c7622bd076c2ba48b17d1e8d3fbf5303e", "name":"张三", "avatar":"https://debox......png" } }, ], "date": 1728348403194 }, ] ```
**debox_getUserInfo**: This method retrieves the user's public information, such as user ID, wallet address, nickname, and avatar. - **Prerequisite:** The user has approved access to `debox_getUserInfo` via `wallet_requestPermissions`, otherwise service is denied. - If the user has not authorized access to `debox_getUserInfo`, a confirmation box will pop up asking for authorization, or service will be denied. **Request:** ```jsx await window.deboxWallet.request({ "method": "debox_getUserInfo", "params": [], }); ``` **Parameters:** - None **Response:** - Returns the user's basic information (ID, address, nickname, avatar) upon success if the user has authorized access. ```jsx { "address":"0xa56b4f0c7622bd076c2ba48b17d1e8d3fbf5303e", "name":"Tom", "avatar":"https://debox......png", "uid":"jkdi123" } ```
**Error Codes** 1. When the user has not authorized the method call ```jsx { "code": 4100, "message": "The requested account and/or method has not been authorized by the user." } ``` 2. When the user rejects the request ```jsx { "code": 4001, "message": "User rejected the request." } ```
#### 1.2 Deployment and Interaction Example: https://connect-nu-one.vercel.app/ (Open in DeBox) Click each button to call the corresponding method, and observe the execution results in the "vConsole" at the bottom right.
Example Code: ```jsx // test the availability of deboxWallet if (typeof window.deboxWallet !== "undefined") { window.ethersProvider = new ethers.providers.Web3Provider( window.deboxWallet ); console.log("deboxWallet is available"); } else { console.error("deboxWallet is not installed!"); } console.log( "window.ethersProvider ethers provider:", window.ethersProvider ); // eth_requestAccounts async function connectWallet() { console.log("window.deboxWallet", window.deboxWallet); if (typeof window.deboxWallet !== "undefined") { // connectButton.addEventListener("click", async () => { try { // Request account access if needed const accounts = await window.deboxWallet.request({ method: "eth_requestAccounts", }); console.log("eth_requestAccounts: ", accounts, typeof accounts); // Display the connected wallet address walletAddress.innerText = `Connected Wallet: ${accounts[0].slice( 0, 6 )}...${accounts[0].slice(-4)}`; errorMessage.innerText = ""; requestPermissions(); } catch (error) { // Handle error (e.g., user denied account access) errorMessage.innerText = "Error connecting wallet: " + error.message; } } else { // If no wallet is installed errorMessage.innerText = "No Ethereum wallet found. Please install DeBoxWallet."; } } // wallet_requestPermissions async function requestPermissions() { console.log("testSDK run wallet_requestPermissions"); if (typeof window.deboxWallet !== "undefined") { try { window.deboxWallet .request({ method: "wallet_requestPermissions", params: [ { eth_accounts: {}, }, ], }) .then((response) => { console.log( "wallet_requestPermissions: ", response, typeof response ); }); } catch (error) { console.error(error); alert(error.message); } } else { // If no wallet is installed errorMessage.innerText = "No Ethereum wallet found. Please install DeBoxWallet."; } } // requestPermissionsParams async function requestPermissionsParams() { console.log("testSDK run wallet_requestPermissions"); if (typeof window.deboxWallet !== "undefined") { try { window.deboxWallet .request({ method: "wallet_requestPermissions", params: [ { eth_accounts: { debox_getUserInfo: {}, }, }, ], }) .then((response) => { console.log( "wallet_requestPermissions_params: ", response, typeof response ); const item = response[0]; // [] const deboxUserInfo = item.caveats.find( (caveat) => caveat.type === "debox_user_public_info" ); if (deboxUserInfo) { const avatar = deboxUserInfo ? deboxUserInfo.value.avatar : null; const name = deboxUserInfo ? deboxUserInfo.value.name : null; const address = deboxUserInfo ? deboxUserInfo.value.address : null; const uid = deboxUserInfo ? deboxUserInfo.value.uid : null; console.log( "wallet_requestPermissions_params data", response?.[0]?.caveats?.[1] ); const imgElement = document.getElementById("walletAvatar"); imgElement.src = avatar; walletNickName.innerText = `NickName: ${name}`; walletAddress.innerText = `Connected Wallet: ${address?.slice( 0, 6 )}...${address?.slice(-4)}`; walletUid.innerText = `uid: ${uid}`; errorMessage.innerText = ""; } }); } catch (error) { console.error(error); alert(error.message); } } else { // If no wallet is installed errorMessage.innerText = "No Ethereum wallet found. Please install DeBoxWallet."; } } // debox_getUserInfo async function getUserInfo() { console.log("testSDK run debox_getUserInfo"); window.deboxWallet .request({ method: "debox_getUserInfo", params: [], }) .then((response) => { console.log("debox_getUserInfo", response, typeof response); if (response) { const imgElement = document.getElementById("walletAvatarUser"); imgElement.src = response?.avatar; walletNickNameUser.innerText = `NickName: ${response?.name}`; walletAddressUser.innerText = `Connected Wallet: ${response?.address?.slice( 0, 6 )}...${response?.address?.slice(-4)}`; walletUidUser.innerText = `uid: ${response?.uid}`; errorMessage.innerText = ""; } }) .catch((error) => { console.error(error); alert(error.message); }); } ```
### 2. On-Chain Payment Integration with Shares On-chain payment is a real-time shares distribution method. When users make payments using tokens, a portion of the payment amount is automatically donated to the DeBox Shares protocol for shares distribution, completing the revenue sharing process. #### 2.1 On-Chain Payment Shares Process There are two types of on-chain payment shares: native token (ETH) payment shares and ERC20 token payment shares: **2.1.1 Native Token (ETH) Payment Shares** The native token (ETH) payment shares involves two steps: calculating the shares amount and calling the contract's donation function to trigger subsequent processing. 1. **Calculate the Shares Amount** - The Dapp calculates the shares amount to be distributed through the DeBox Shares protocol based on the business design. 2. **Call the `donationToShares` Method with the Shares Amount to Trigger Subsequent Logic:** - After calculating the shares amount, the Dapp calls the DeBox Shares contract's `donationToShares` method to officially distribute the calculated amount. ```jsx // ... uint256 donatedAmountETH = amountAcquiredETH / 10; // Calculate the shares amount doxShares.donationToShares{ value: donatedAmountETH }(); // Trigger subsequent shares logic // ... ``` 3. **Example Contract Logic** - Example of a Dapp contract integrating the Shares protocol: ```solidity // SPDX-License-Identifier: Apache License 2.0 pragma solidity ^0.8.22; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { IDeBoxShares } from "@debox/deboxdapp/interfaces/facets/IShares.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; contract PlayGameWithShares { IDeBoxShares public doxShares; event GamePlayed(address player, IERC20 token, uint256 amount); constructor(IDeBoxShares _doxShares) { doxShares = _doxShares; } // ETH payment function integrated with the Shares protocol in the Dapp function playGameWithETH() external payable { uint256 amount = msg.value; uint256 donatedAmount = amount / 10; if (donatedAmount > 0) { doxShares.donationToShares{ value: donatedAmount }(); } emit GamePlayed(msg.sender, IERC20(address(0)), amount); } } ``` **2.1.2 ERC20 Token Payment Shares** The ERC20 token payment shares involves two steps: calculating the shares amount and authorizing the DeBox Shares contract, and calling the contract's donation function to trigger subsequent processing. 1. **Calculate the Shares Amount and Authorize the DeBox Shares Contract** - First, the Dapp transfers the user's payment tokens to the Dapp contract and calculates the shares amount to be distributed through the DeBox Shares protocol based on the business design. - Then, the contract calls the `safeIncreaseAllowance` method to authorize the DeBox Shares contract address to use the shares amount. ```solidity // ... SafeERC20.safeTransferFrom(token, msg.sender, address(this), amount); // Transfer the user's payment tokens to the Dapp contract uint256 donatedAmount = amountAcquired / 10; // Calculate the shares amount to be distributed through the DeBox Shares protocol SafeERC20.safeIncreaseAllowance(token, address(doxShares), donatedAmount); // Authorize the DeBox Shares contract to use the shares amount // ... ``` 2. **Call the `donationToShares` Method to Trigger Subsequent Shares Logic** - After authorizing the shares amount, the contract calls the DeBox Shares contract's `donationToShares` method to officially distribute the calculated amount. - This method triggers the subsequent processing logic of the DeBox Shares protocol, transferring the shares amount to the DAO asset pool or distributing it to beneficiaries. ```solidity // ... // The above logic for calculating the shares amount and authorizing the contract // ... doxShares.donationToShares(token, donatedAmount); // Trigger subsequent shares logic // ... ``` 3. **Example Contract Logic** - Example of a Dapp contract integrating the Shares protocol: ```solidity // SPDX-License-Identifier: Apache License 2.0 pragma solidity ^0.8.22; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { IDeBoxShares } from "@debox/deboxdapp/interfaces/facets/IShares.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; contract PlayGameWithShares { IDeBoxShares public doxShares; event GamePlayed(address player, IERC20 token, uint256 amount); constructor(IDeBoxShares _doxShares) { doxShares = _doxShares; } // ERC20 token payment function integrated with the Shares protocol in the Dapp function playGame(IERC20 token, uint256 amount) external { SafeERC20.safeTransferFrom(token, msg.sender, address(this), amount); uint256 donatedAmount = amount / 10; if (donatedAmount > 0) { SafeERC20.safeIncreaseAllowance(token, address(doxShares), donatedAmount); doxShares.donationToShares(address(token), donatedAmount); } emit GamePlayed(msg.sender, token, amount); } ``` #### 2.2 Shares Contract Interface: - DeBox-Shares contract interface: ```solidity // SPDX-License-Identifier: Apache License 2.0 pragma solidity ^0.8.22; interface IDeBoxShares { event DonationToShares(address indexed contributor, address indexed token, uint256 amount); event SharesConfigSet(address vault, address weth); /** * @notice Donate tokens to the shares protocol. * @dev The donated tokens will be transferred to the vault. * before the donation, the caller must approve me to spend the token. * @param token The token to donate. must be a valid ERC20 token. * @param amount The amount of `token` to donate. must be greater than 0. */ function donationToShares(address token, uint256 amount) external; /** * @notice Donate Native coin (ETH) to the shares protocol. */ function donationToShares() external payable; function getSharesConfig() external view returns (address vault, address weth); } ``` #### 2.3 DeBox-Shares Contract Deployment Addresses: | Network | Contract Address | | --- | --- | | Ethereum | 0x2e6168f9ca3fe204a2110c4613ce18985f3fbf39 | | Arbitrum One | 0x509Ca4ff42cECAA1FF4988514211b26e72BDa840 | | Base | 0x2f8Ae1cC4ab784f7b9E07A61F714ecDe18A4A6d2 | | BSC | 0x32303FFcb9B6564C2b8a373433A043a7f17E4B37 | | Optimism | 0x18574E5a838B3FE16948653873386DD114ba1D7C | | Polygon | 0xb8Af0Fa3E38E8Cb95870091b0d4e32CA232b780D | #### 2.4 Simplified On-Chain Shares Interface For Dapps without complex business logic, DeBox provides a simplified on-chain shares interface that supports shares distribution during on-chain native token payments and ERC20 token payments. ##### Supported Methods: 1. **payAndShareWithETH**: This method is used for shares distribution during ETH payments. - Contract Method: ```solidity /** * @notice Pay with ETH and distribute shares, the recipient address and shares amount can be specified. * @param recipient The target address receiving the ETH payment. * @param shareAmount The amount of ETH used for Shares, a part of the total ETH payment. */ function payAndShareWithETH(address payable recipient, uint256 shareAmount) external payable; ``` - Contract Method Request Example: ```solidity contract Example { function examplePayAndShare(address payable recipient) external payable { // Assume paying 1 ETH, with 0.2 ETH for shares payAndShareWithETH{value: 1 ether}(recipient, 0.2 ether); // After the transaction, the recipient receives 0.8 ETH, and 0.2 ETH is distributed through the Shares protocol } } ``` - ABI Specification: ```json [ { "type": "function", "name": "payAndShareWithETH", "inputs": [ { "name": "recipient", "type": "address", "internalType": "address payable" }, { "name": "shareAmount", "type": "uint256", "internalType": "uint256" } ], "outputs": [], "stateMutability": "payable" } ] ``` - ABI Call Example (based on ethers.js) ```JavaScript const { ethers } = require("ethers"); // Assume contract address and ABI const contractAddress = "SimplifiedSharesContractDeploymentAddress"; const abi = [ { "type": "function", "name": "payAndShareWithETH", "inputs": [ { "name": "recipient", "type": "address" }, { "name": "shareAmount", "type": "uint256" } ], "outputs": [], "stateMutability": "payable" } ]; // Set up Provider and Signer const provider = new ethers.providers.JsonRpcProvider("https://your-rpc-url"); const signer = provider.getSigner(); const contract = new ethers.Contract(contractAddress, abi, signer); // Call method async function callPayAndShare() { const recipient = "0xRecipientAddress"; const shareAmount = ethers.utils.parseEther("0.2"); const totalAmount = ethers.utils.parseEther("1.0"); const tx = await contract.payAndShareWithETH(recipient, shareAmount, { value: totalAmount }); console.log("Transaction sent:", tx.hash); // Wait for transaction to complete const receipt = await tx.wait(); console.log("Transaction mined:", receipt.transactionHash); } callPayAndShare(); ``` 2. **payAndShareWithERC20**: This method is used for shares distribution during ERC20 token payments. - Contract Method: ```solidity /** * @notice Pay with ERC20 tokens and distribute shares, specifying the recipient address, token address, and shares amount. * @param recipient The target address receiving the ERC20 token payment. * @param tokenAddress The contract address of the ERC20 token used for payment. * @param amount The total amount of ERC20 tokens to be paid. * @param shareAmount The amount of ERC20 tokens, used for Shares, a part of the total payment. */ function payAndShareWithERC20(address recipient, address tokenAddress, uint256 amount, uint256 shareAmount) external; ``` - Contract Method Request Example: ```solidity contract Example { function examplePayAndShareWithERC20(address recipient, address tokenAddress) external { // Assume paying 1000 tokens, with 200 tokens for shares payAndShareWithERC20(recipient, tokenAddress, 1000, 200); // After the transaction, the recipient receives 800 tokens, and 200 tokens are distributed through the Shares protocol } } ``` - ABI Specification: ```json [ { "type": "function", "name": "payAndShareWithERC20", "inputs": [ { "name": "recipient", "type": "address", "internalType": "address" }, { "name": "tokenAddress", "type": "address", "internalType": "address" }, { "name": "amount", "type": "uint256", "internalType": "uint256" }, { "name": "shareAmount", "type": "uint256", "internalType": "uint256" } ], "outputs": [], "stateMutability": "nonpayable" } ] ``` - ABI Call Example (based on ethers.js) ```JavaScript const { ethers } = require("ethers"); // Contract address and ABI const contractAddress = "SimplifiedSharesContractDeploymentAddress"; const abi = [ { "type": "function", "name": "payAndShareWithERC20", "inputs": [ { "name": "recipient", "type": "address" }, { "name": "tokenAddress", "type": "address" }, { "name": "amount", "type": "uint256" }, { "name": "shareAmount", "type": "uint256" } ], "outputs": [], "stateMutability": "nonpayable" } ]; // Initialize Provider and Signer const provider = new ethers.providers.JsonRpcProvider("https://your-rpc-url"); const signer = provider.getSigner(); const contract = new ethers.Contract(contractAddress, abi, signer); async function callPayAndShareWithERC20() { const recipient = "0xRecipientAddress"; const tokenAddress = "0xTokenAddress"; const amount = ethers.utils.parseUnits("1000", 18); // Assume the token has 18 decimals const shareAmount = ethers.utils.parseUnits("200", 18); const tx = await contract.payAndShareWithERC20( recipient, tokenAddress, amount, shareAmount ); console.log("Transaction sent:", tx.hash); // Wait for transaction to complete const receipt = await tx.wait(); console.log("Transaction mined:", receipt.transactionHash); } callPayAndShareWithERC20(); ``` ##### Simplified Shares Contract Deployment Address: | Network | Contract Address | | --- | --- | | BSC | 0xf0Cc35840394eD6274e058620FC6eb3aBA27Ba2d | #### 2.5 On-Chain Payment Shares Interaction Example This is an interactive demo demonstrating how to integrate the DeBox Shares protocol to implement shares functionality for on-chain native token (e.g., ETH) and ERC20 token payments. **Example Link:** [https://shares-test.vercel.app/bsc_new.html](https://shares-test.vercel.app/bsc_new.html) (Please open in the DeBox App) **Instructions:** 1. Open the link above in the DeBox App. 2. Click the buttons on the page to call the corresponding shares methods (native token payment shares, ERC20 token payment shares). 3. Observe the detailed call process and execution results in the "vConsole" at the bottom right of the page. 4. This demo is a standalone HTML file. You can press F12 in your browser to open the developer tools and view its source code to understand the specific integration method. --- ## DeBox Grant Program DeBox Grant Program supports high-quality ecosystem projects that integrate with DeBox capabilities and deliver measurable user value. ## Program Focus - Accelerate practical integrations on top of DeBox infrastructure. - Support developer teams building sustainable bot, DApp, or protocol products. - Improve end-user experience through useful and active ecosystem tools. ## Priority Project Types ### 1. Bot and Community Tools - Community operation bots - Customer support bots - Knowledge and AI assistant bots - Automation and workflow bots ### 2. DApp and Product Tools - Growth and retention tools - Trading and analytics tools - Utility products integrated with DeBox social graph ### 3. Protocol and Infra Integrations - Shares protocol integrations - Wallet and account infrastructure integrations - Web3 service integrations with clear adoption plans ## Basic Requirements - Product is already integrated with at least one DeBox capability (API/SDK/DApp/Bot). - Team provides a clear roadmap, delivery milestones, and operating plan. - Team can provide integration evidence (demo, docs, repo, or production usage). - Team agrees to coordinate launch and communication with DeBox ecosystem operations. ## What Selected Projects Receive - Potential token grant support based on complexity and impact. - Discovery and exposure opportunities inside DeBox ecosystem surfaces. - Technical and ecosystem collaboration with DeBox team. ## Application - Tools page listing application form: [submit form](https://forms.gle/jAxuHUo9bydB69iB8) - Grant proposal application form: [submit form](https://forms.gle/9M61P812j6pfN92p9) ## Review Process 1. Submit complete application materials. 2. DeBox team performs technical and product review. 3. Qualified projects enter ecosystem decision flow. 4. Approved projects receive onboarding and collaboration follow-up. --- ## DeBox Bot Development Overview This is the bot overview guide for external developers, covering the full path from finding `BotMother`, creating/managing bots, and choosing webhook or long polling development with SDKs. ## 1. Find BotMother first You can open BotMother in 3 ways: 1. Deep link: `https://m.debox.pro/user/chat?id=u7ooqdjt&start=` 2. Address search: `0xda521900ac9dfeff8a8e692bb627ff8cd80a7b28` 3. DeBox AI assistant entry Recommended sequence starts from AI assistant: ### 1.1 Find BotMother from AI assistant ![AI assistant entry](/imgBotmother/Ai助手查找-1.jpg) ### 1.2 Enter BotMother conversation entry ![BotMother entry](/imgBotmother/BotMother入口-2.jpg) ### 1.3 Check BotMother command menu ![BotMother commands](/imgBotmother/BotMother指令-3.jpg) ## 2. Create a bot with BotMother Follow the instruction flow shown by BotMother. Typical flow: 1. Trigger bot creation command. 2. Set bot profile (name, avatar, description). 3. Complete creation and enter bot management list. ## 3. Manage and update bot settings After creation, finish baseline settings first, then choose development mode. ### 3.1 Bot management home ![Bot management home](/imgBotmother/bot管理首页-4.jpg) On this page you can: - View all bots - Enter a specific bot management page - Add or remove bots ### 3.2 Single bot management page ![Single bot management](/imgBotmother/某个bot管理首页-5.jpg) On this page you can configure: - Bot profile (name, avatar, description) - Credentials (`API Key`, and `App Secret` when needed) - Webhook settings (`App Domain`, `Webhook URL`) ## 4. Choose one receiving mode (required) DeBox Bot supports two receive modes: - Webhook mode (platform pushes to your service) - Long polling mode (`getUpdates` pull) They are strictly mutually exclusive: - If webhook is configured, webhook is the active receive path. - Long polling will receive none or near-none updates in that state. - To switch back to long polling, clear webhook config first. ## 5. Webhook mode Minimal setup steps: 1. Configure `App Domain` in bot settings. 2. Configure `Webhook URL` (public HTTPS endpoint). 3. Implement callback API and validate `X-API-KEY == Webhook Key`. 4. Handle payload and send replies with OpenAPI. References: - [DeBox Bot Go SDK Webhook](/GO-SDK-Webhook) - [DeBox Developer OpenAPI](/ApiOnePage) ## 6. Long polling mode Minimal setup steps: 1. Ensure webhook is not configured. 2. Initialize bot with `API Key` + `API Secret` via SDK. 3. Enable listener and process updates from `GetUpdates/GetUpdatesChan`. 4. Send replies using SDK/OpenAPI. ## 7. SDK options (3 official SDKs) 1. Go SDK: - Doc: [DeBox Bot Go SDK](/GO-SDK) - Best for high-concurrency backend services. 2. Nodejs SDK: - Doc: [DeBox Bot Nodejs SDK](/NODE-SDK) - Best for JS/TS stacks and rapid iteration. 3. Python SDK: - Doc: [DeBox Bot Python SDK](/PYTHON-SDK) - Best for AI workflows, scripts, and data workflows. ## 8. API reference boundary SDK docs focus on usage patterns, while OpenAPI is the source of truth for field constraints and response contracts. Use together: - [DeBox Developer OpenAPI](/ApiOnePage) - [Developer FAQ / Troubleshooting](/APIQA) ## 9. Recommended implementation path 1. Create bot in BotMother and complete baseline settings. 2. Start with webhook for small-scale integration testing. 3. Select Go/Nodejs/Python SDK by team stack. 4. Validate all request/response details against OpenAPI. --- ## DeBox Developer OpenAPI ## Endpoint Index (Ordered) 1. [`POST /openapi/bot/sendMessage`](#api-bot-sendmessage) 2. [`POST /openapi/bot/sendMessageToFans`](#api-bot-sendmessagetofans) 3. [`POST /openapi/bot/editMessage`](#api-bot-editmessage) 4. [`POST /openapi/bot/getMe`](#api-bot-getme) 5. [`POST /openapi/bot/getUpdates`](#api-bot-getupdates) 6. [`GET /openapi/group/info`](#api-group-info) 7. [`GET /openapi/group/is_join`](#api-group-is-join) 8. [`POST /openapi/group/admin/dao_member`](#api-group-admin-dao-member) 9. [`POST /openapi/group/admin/kick_member`](#api-group-admin-kick-member) 10. [`POST /openapi/group/admin/message/recall`](#api-group-admin-message-recall) 11. [`GET /openapi/user/info`](#api-user-info) 12. [`GET /openapi/user/is_follow`](#api-user-is-follow) 13. [`GET /openapi/token/info`](#api-token-info) 14. [`GET /openapi/box/info`](#api-box-info) ## Base URL `https://open.debox.pro` ## Authentication All endpoints except `GET /openapi/box/info` require: ```http X-API-KEY: ``` ## Response Envelopes ### Standard envelope ```json { "code": 1, "success": true, "data": {} } ``` ### Bot envelope ```json { "ok": true, "success": true, "result": {} } ``` --- ## Global Parameter Ranges - `chat_type`: `group` | `private` - `chat_id`: - when `chat_type=group`: group `gid` - when `chat_type=private`: user `user_id` (invite code) - `content` is the primary field - max length for text-like modes (`text`/`richtext`/`Markdown`/`MarkdownV2`/`HTML`): 5000 chars - default `parse_mode`: `richtext` - `parse_mode` enum: - `richtext` (default) - `text` - `Markdown` - `MarkdownV2` - `HTML` - `image` - `video` - `file` ### How to fill `content` (critical) - `parse_mode=richtext`: normal text/rich text string (default). - `parse_mode=text`: plain text only (no Markdown/HTML parsing). - `parse_mode=Markdown`: Markdown content. - `parse_mode=MarkdownV2`: MarkdownV2 content (escape special chars as required). - `parse_mode=HTML`: HTML fragment (e.g. `Hello`). - `parse_mode=image`: set `content` to a public image URL (e.g. `https://cdn.example.com/a.png`). - `parse_mode=video`: set `content` to a public video URL (e.g. `https://cdn.example.com/a.mp4`). - `parse_mode=file`: set `content` to a public file URL (e.g. `https://cdn.example.com/a.pdf`). ### Minimal `reply_markup` / `user_action_markup` sample ```json { "inline_keyboard": [ [ { "text": "View detail", "url": "https://docs.debox.pro/ApiOnePage" }, { "text": "Callback button", "callback_data": "detail" } ] ] } ``` ### `mention_type` / `mention_ids` practical guidance - Recommended mainly when `parse_mode=text`. - For rich text modes (`richtext/Markdown/MarkdownV2/HTML`), prefer writing `@` directly in `content` and avoid `mention_*`. - If no mention behavior is needed, omit both fields. --- ## 1. POST `/openapi/bot/sendMessage` {#api-bot-sendmessage} ### Curl Example ```bash 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","parse_mode":"richtext"}' ``` ### Request params (Body, JSON) - `chat_id` string, required - `chat_type` string, required, enum: `group` | `private` - `content` string, required - `parse_mode` string, optional, default `richtext` - `message_id` string, optional - `mention_type` int, optional - `mention_ids` string[], optional - `reply_markup` object, optional - `user_action_markup` object, optional ### Success response example ```json { "ok": true, "success": true, "result": { "message_id": "01JYXXXX", "text": "Hello from DeBox", "parse_mode": "richtext" } } ``` ### Error response example ```json { "ok": false, "success": false, "message": "message can't be empty" } ``` --- ## 2. POST `/openapi/bot/sendMessageToFans` {#api-bot-sendmessagetofans} ### Curl Example ```bash curl -X POST "https://open.debox.pro/openapi/bot/sendMessageToFans" \ -H "Content-Type: application/json" \ -H "X-API-KEY: YOUR_APP_KEY" \ -d '{"chat_id":"cc0onr82","chat_type":"group","content":"broadcast","parse_mode":"richtext"}' ``` ### Request params (Body, JSON) - `chat_id` string, required - `chat_type` string, required, enum: `group` | `private` - `content` string, required - `parse_mode` string, optional, default `richtext` Constraint: `content` max 2000 bytes. ### Success response example ```json { "ok": true, "success": true, "result": true } ``` ### Error response example ```json { "ok": false, "success": false, "message": "message must be less than 2000 bytes" } ``` --- ## 3. POST `/openapi/bot/editMessage` {#api-bot-editmessage} ### Curl Example ```bash curl -X POST "https://open.debox.pro/openapi/bot/editMessage" \ -H "Content-Type: application/json" \ -H "X-API-KEY: YOUR_APP_KEY" \ -d '{"chat_id":"cc0onr82","chat_type":"group","message_id":"01JYXXXX","content":"edited","parse_mode":"richtext"}' ``` ### Request params (Body, JSON) - `chat_id` string, required - `chat_type` string, required, enum: `group` | `private` - `message_id` string, required - `content` string, required - `parse_mode` string, optional, default `richtext` ### Success response example ```json { "ok": true, "success": true, "result": true } ``` ### Error response example ```json { "ok": false, "success": false, "message": "EditMessageText param Group Id is error" } ``` --- ## 4. POST `/openapi/bot/getMe` {#api-bot-getme} ### Curl Example ```bash curl -X POST "https://open.debox.pro/openapi/bot/getMe" \ -H "X-API-KEY: YOUR_APP_KEY" ``` ### Request params None. ### Success response example ```json { "ok": true, "success": true, "result": { "name": "DeBox Bot", "address": "0x...", "pic": "https://...", "user_id": "u1", "level": 3, "level_icon": "https://.../icon/level/v3.png" } } ``` ### Error response example ```json { "ok": false, "success": false, "message": "invalid param" } ``` --- ## 5. POST `/openapi/bot/getUpdates` {#api-bot-getupdates} ### Curl Example ```bash curl -X POST "https://open.debox.pro/openapi/bot/getUpdates" \ -H "Content-Type: application/json" \ -H "X-API-KEY: YOUR_APP_KEY" \ -d '{"timeout":30}' ``` ### Request params (Body, JSON) - `timeout` int, optional, range `1~60`, default `30` Note: if webhook URL is configured in platform console, webhook becomes the only effective receive path. In that case this endpoint usually returns none or near-none updates. ### Success response example (with updates) ```json { "ok": true, "success": true, "result": [ { "id": 123, "message": { "message_id": "01JYXXXX", "from": { "user_id": "u1", "name": "Alice", "address": "0x..." }, "chat": { "id": "cc0onr82", "type": "group" }, "text": "Ping", "parse_mode": "richtext" } } ] } ``` ### Success response example (timeout, no updates) ```json { "ok": true, "success": true, "result": [] } ``` ### Error response example ```json { "ok": false, "success": false, "message": "Invalid timeout value" } ``` --- ## 6. GET `/openapi/group/info` {#api-group-info} ### Curl Example ```bash curl "https://open.debox.pro/openapi/group/info?gid=cc0onr82" \ -H "X-API-KEY: YOUR_APP_KEY" ``` ### Query params - `gid` string, required ### Success response example ```json { "code": 1, "success": true, "data": { "is_charge": false, "subchannel_number": 2, "group_name": "DeBox Dev", "gid": "cc0onr82", "group_number": 345, "group_pic": "https://...", "create_time": "2026-05-14 14:00:00", "maximum": "Unlimited", "mod": ["Alice", "Bob"], "mod_info": [ { "name": "Alice", "address": "0x...", "pic": "https://...", "user_id": "u1" } ] } } ``` ### Error response example ```json { "code": -3001, "success": false, "message": "No such group" } ``` --- ## 7. GET `/openapi/group/is_join` {#api-group-is-join} ### Curl Example ```bash curl "https://open.debox.pro/openapi/group/is_join?gid=cc0onr82&walletAddress=0x1234567890abcdef1234567890abcdef12345678" \ -H "X-API-KEY: YOUR_APP_KEY" ``` ### Query params - `gid` string, required - `walletAddress` string, required (EVM address) ### Success response example ```json { "code": 1, "data": true } ``` ### Error response example ```json { "error": "Bad Request", "code": 401, "message": "Param error" } ``` --- ## 8. POST `/openapi/group/admin/dao_member` {#api-group-admin-dao-member} ### Curl Example ```bash curl -X POST "https://open.debox.pro/openapi/group/admin/dao_member" \ -H "Content-Type: application/json" \ -H "X-API-KEY: YOUR_APP_KEY" \ -H "nonce: RANDOM_NONCE" \ -H "timestamp: 1715500000" \ -H "signature: SHA1(app_secret+nonce+timestamp)" \ -d '{"gid":"cc0onr82","page":1,"size":20}' ``` ### Extra headers (required) - `nonce` string - `timestamp` string - `signature` string Signature algorithm: `sha1(app_secret + nonce + timestamp)`. ### Request params (Body, JSON) - `gid` string, required, length `1~8` - `page` int, optional, if `<=0` then treated as `1` - `size` int, optional, default `50`, max `50` ### Success response example ```json { "code": 1, "success": true, "data": [ { "user_id": "u1", "name": "Alice", "pic": "https://...", "address": "0x...", "signature": "builder" } ] } ``` ### Error response example ```json { "code": -4017, "success": false, "message": "permission denied" } ``` --- ## 9. POST `/openapi/group/admin/kick_member` {#api-group-admin-kick-member} ### Purpose Remove one or more members from a DeBox group. The bot account bound to the current `X-API-KEY` must already be in the target group and must have moderator or builder permission in that group. ### Curl Example ```bash curl -X POST "https://open.debox.pro/openapi/group/admin/kick_member" \ -H "Content-Type: application/json" \ -H "X-API-KEY: YOUR_APP_KEY" \ -H "nonce: RANDOM_NONCE" \ -H "timestamp: 1715500000" \ -H "signature: SHA1(app_secret+nonce+timestamp)" \ -d '{ "gid":"cc0onr82", "user_ids":["u1","u2"] }' ``` ### Extra headers (required) - `nonce` string - `timestamp` string - `signature` string Signature algorithm: `sha1(app_secret + nonce + timestamp)`. ### Permission requirements - `X-API-KEY` must be valid. - The API key must be bound to an existing DeBox bot account. - The bound bot must be a moderator or builder of the target group. ### Request params (Body, JSON) - `gid` string, required, target group ID, length `1~8` - `user_ids` string array, required, list of DeBox `user_id` values to remove - `user_ids` maximum size: `20` per request ### Validation and execution rules - Empty `user_ids` is rejected. - Empty string items inside `user_ids` are rejected. - Duplicate `user_id` values are de-duplicated before execution. - If any provided `user_id` cannot be resolved to a valid user, the request fails. ### Success response example ```json { "code": 1, "success": true, "message": "success", "data": true } ``` ### Error response examples ```json { "code": -2004, "success": false, "message": "uid size must be less than or equal to 20", "data": null } ``` ```json { "code": -4017, "success": false, "message": "permission denied", "data": null } ``` --- ## 10. POST `/openapi/group/admin/message/recall` {#api-group-admin-message-recall} ### Purpose Recall a group message through an administrator action. After recall, the message will be displayed as the following group notification: `MOD {operator_name} 撤回了 {sender_name}的消息` ### Curl Example ```bash curl -X POST "https://open.debox.pro/openapi/group/admin/message/recall" \ -H "Content-Type: application/json" \ -H "X-API-KEY: YOUR_APP_KEY" \ -H "nonce: RANDOM_NONCE" \ -H "timestamp: 1715500000" \ -H "signature: SHA1(app_secret+nonce+timestamp)" \ -d '{ "gid":"cc0onr82", "user_id":"u1", "message_id":"01HXYZABCDEF1234567890" }' ``` ### Extra headers (required) - `nonce` string - `timestamp` string - `signature` string Signature algorithm: `sha1(app_secret + nonce + timestamp)`. ### Permission requirements - `X-API-KEY` must be valid. - The API key must be bound to an existing DeBox bot account. - The bound bot must be a moderator or builder of the target group. ### Request params (Body, JSON) - `gid` string, required, target group ID, length `1~8` - `user_id` string, required, DeBox `user_id` of the original sender - `message_id` string, required, message ID to recall ### Important notes - `user_id` must resolve to an existing DeBox user. - `message_id` must identify a message in the target group that can be modified by the platform. - The operator name in the recall notice prefers the bot display name and falls back to the bot `user_id`. - The original sender name follows the same fallback rule. ### Success response example ```json { "code": 1, "success": true, "message": "success", "data": true } ``` ### Error response examples ```json { "code": -2004, "success": false, "message": "message_id is required", "data": null } ``` ```json { "code": -2000, "success": false, "message": "recall message failed", "data": null } ``` --- ## 11. GET `/openapi/user/info` {#api-user-info} ### Curl Example ```bash curl "https://open.debox.pro/openapi/user/info?user_id=u1" \ -H "X-API-KEY: YOUR_APP_KEY" ``` ### Query params - `user_id` string, optional - `address` string, optional (EVM address) - at least one is required ### Success response example ```json { "code": 1, "success": true, "data": { "user_id": "u1", "name": "Alice", "address": "0x...", "pic": "https://...", "signature": "gm builder" } } ``` ### Error response example ```json { "code": -2004, "success": false, "message": "invalid param" } ``` --- ## 12. GET `/openapi/user/is_follow` {#api-user-is-follow} ### Curl Example ```bash curl "https://open.debox.pro/openapi/user/is_follow?walletAddress=0x1234567890abcdef1234567890abcdef12345678&followAddress=0xabcdefabcdefabcdefabcdefabcdefabcdefabcd" \ -H "X-API-KEY: YOUR_APP_KEY" ``` ### Query params - `walletAddress` string, required (EVM address) - `followAddress` string, required (EVM address) ### Success response example ```json { "code": 1, "data": true } ``` ### Error response example ```json { "error": "Bad Request", "code": 401, "message": "Please input the wallet address correctly" } ``` --- ## 13. GET `/openapi/token/info` {#api-token-info} ### Curl Example ```bash curl "https://open.debox.pro/openapi/token/info?contract_address=0x55d398326f99059fF775485246999027B3197955&chain_id=56" \ -H "X-API-KEY: YOUR_APP_KEY" ``` ### Query params - `contract_address` string, required - `chain_id` int, optional; missing/negative is treated as `0` ### Success response example ```json { "code": 1, "success": true, "data": { "chain_id": 56, "token": "0x55d398326f99059fF775485246999027B3197955", "decimal": 18, "name": "Tether USD", "symbol": "USDT", "logo_url": "https://..." } } ``` ### Error response example ```json { "code": -2004, "success": false, "message": "contract_address must be a valid contract address" } ``` --- ## 14. GET `/openapi/box/info` {#api-box-info} ### Curl Example ```bash curl "https://open.debox.pro/openapi/box/info" ``` Public endpoint, no API key required. ### Query params None. ### Success response example ```json { "code": 1, "success": true, "data": { "max_supply": "1000000000", "burned": "...", "supply": "...", "locked": "...", "address": "0x...", "symbol": "BOX", "chainId": 1, "icon": "https://...", "stake": "..." } } ``` --- ## DeBox Bot Go SDK # DeBox Bot Go SDK Guide Source repository: - [debox-pro/debox-chat-go-sdk](https://github.com/debox-pro/debox-chat-go-sdk) ## 1. SDK capabilities The SDK provides: - Bot init: `NewBotAPI(apiKey, apiSecret)` - Message sending: `bot.Send(...)` - Long polling updates: `GetUpdates` / `GetUpdatesChan` - Inline keyboard callbacks: `InlineKeyboardMarkup` + `CallbackQuery` - Message editing: `NewEditMessageText` + `bot.Send(...)` Webhook is split into a standalone guide: - [DeBox Bot Go SDK Webhook](/GO-SDK-Webhook) ## 2. Receiving mode notes This document focuses on Long Polling. If you already configured webhook in platform console, polling may receive little or no data. For webhook deployment, read: - [DeBox Bot Go SDK Webhook](/GO-SDK-Webhook) --- ## 3. Long polling usage (detailed SDK workflow) ### 3.1 Install ```bash go get github.com/debox-pro/debox-chat-go-sdk ``` ### 3.2 Credentials Get from DeBox Open Platform: - `API_KEY` (required) - `API_SECRET` (recommended) ### 3.3 Init + first message ```go package main import ( "log" boxbotapi "github.com/debox-pro/debox-chat-go-sdk/boxbotapi" ) func main() { bot, err := boxbotapi.NewBotAPI("YOUR_APP_KEY", "YOUR_API_SECRET") if err != nil { log.Fatalf("init bot failed: %v", err) } msg := boxbotapi.NewMessage("cc0onr82", "group", "Hello from Go SDK") msg.ParseMode = boxbotapi.ModeRichText sent, err := bot.Send(msg) if err != nil { log.Fatalf("send failed: %v", err) } log.Printf("sent message_id=%s", sent.MessageID) } ``` ### 3.4 Long polling via `GetUpdatesChan` (recommended) ```go package main import ( "context" "log" boxbotapi "github.com/debox-pro/debox-chat-go-sdk/boxbotapi" ) func main() { bot, err := boxbotapi.NewBotAPI("YOUR_APP_KEY", "YOUR_API_SECRET") if err != nil { log.Fatal(err) } boxbotapi.MessageListener = true cfg := boxbotapi.NewUpdate(0) cfg.Timeout = 30 ctx := context.Background() updates := bot.GetUpdatesChan(cfg) for { select { case <-ctx.Done(): bot.StopReceivingUpdates() return case upd := <-updates: if upd.Message != nil { log.Printf("from=%s chat=%s text=%s", upd.Message.From.UserId, upd.Message.Chat.ID, upd.Message.Text) } if upd.CallbackQuery != nil { log.Printf("callback=%s", upd.CallbackQuery.Data) } } } } ``` ### 3.5 Manual polling via `GetUpdates` ```go cfg := boxbotapi.NewUpdate(0) cfg.Timeout = 30 updates, err := bot.GetUpdates(cfg) if err != nil { log.Printf("get updates failed: %v", err) return } for _, upd := range updates { if upd.Message != nil { log.Println(upd.Message.Text) } } ``` ### 3.6 Send multiple message types ```go m1 := boxbotapi.NewMessage(chatID, chatType, "*bold* _italic_") m1.ParseMode = boxbotapi.ModeMarkdownV2 _, _ = bot.Send(m1) m2 := boxbotapi.NewMessage(chatID, chatType, "Hello docs") m2.ParseMode = boxbotapi.ModeHTML _, _ = bot.Send(m2) m3 := boxbotapi.NewMessage(chatID, chatType, "https://example.com/a.png") m3.ParseMode = boxbotapi.ModeImage _, _ = bot.Send(m3) ``` Available parse modes: - `boxbotapi.ModeRichText` - `boxbotapi.ModeText` - `boxbotapi.ModeMarkdown` - `boxbotapi.ModeMarkdownV2` - `boxbotapi.ModeHTML` - `boxbotapi.ModeImage` - `boxbotapi.ModeVideo` - `boxbotapi.ModeFile` `content` rules by `parse_mode`: - `richtext` (default): use normal text/rich text string, e.g. `Hello and welcome to DeBox Bot`. - `text`: use plain text only (no Markdown/HTML rendering), e.g. `plain text only`. - `Markdown`: use Markdown string, e.g. `**bold**`. - `MarkdownV2`: use MarkdownV2 string with required escaping, e.g. `\\*bold\\*`. - `HTML`: use HTML fragment string, e.g. `Hello`. - `image`: set `content` to a publicly reachable image URL, e.g. `https://cdn.example.com/a.png`. - `video`: set `content` to a publicly reachable video URL, e.g. `https://cdn.example.com/demo.mp4`. - `file`: set `content` to a publicly reachable file URL, e.g. `https://cdn.example.com/spec.pdf`. - Text modes (`richtext/text/Markdown/MarkdownV2/HTML`) support up to 5000 characters. ### 3.7 Inline keyboard + callback ```go markup := boxbotapi.NewInlineKeyboardMarkup( boxbotapi.NewInlineKeyboardRow( boxbotapi.NewInlineKeyboardButtonData("Details", "detail"), boxbotapi.NewInlineKeyboardButtonURL("Open site", "https://debox.pro"), ), ) msg := boxbotapi.NewMessage("cc0onr82", "group", "Pick one") msg.ParseMode = boxbotapi.ModeRichText msg.ReplyMarkup = markup _, _ = bot.Send(msg) ``` Callback handler: ```go if upd.CallbackQuery != nil { data := upd.CallbackQuery.Data _ = data } ``` ### 3.8 Edit message ```go edit := boxbotapi.NewEditMessageText("cc0onr82", "group", "MESSAGE_ID", "edited text") edit.ParseMode = boxbotapi.ModeRichText _, err := bot.Send(edit) if err != nil { log.Printf("edit failed: %v", err) } ``` --- ## DeBox Bot Nodejs SDK # DeBox Bot Nodejs SDK Guide Source repository: - [debox-pro/debox-chat-nodejs-sdk](https://github.com/debox-pro/debox-chat-nodejs-sdk) ## 1. SDK capabilities `debox-chat-nodejs-sdk` provides: - Bot initialization: `NewBotAPI(apiKey, apiSecret)` - Send message: `bot.Send(...)` - Long polling updates: `GetUpdates` / `GetUpdatesChan` - Inline keyboard and callback handling - Edit message: `NewEditMessageText(...)` / `NewEditMessageTextAndMarkup(...)` ## 2. Receiving mode notes This document focuses on Long Polling mode. Webhook and Long Polling are strictly mutually exclusive: - If webhook is configured in platform console, webhook becomes the active receiving path. - To receive updates via polling, clear webhook config first. Webhook usage is covered separately: - [DeBox Bot Go SDK Webhook](/GO-SDK-Webhook) ## 3. Install and init ### 3.1 Install ```bash npm install github:debox-pro/debox-chat-nodejs-sdk ``` Or clone and install locally: ```bash git clone https://github.com/debox-pro/debox-chat-nodejs-sdk.git cd debox-chat-nodejs-sdk npm install ``` ### 3.2 Credentials Get from DeBox Open Platform: - `API_KEY` (required) - `API_SECRET` (recommended) Set environment variables: ```bash export DEBOX_BOT_API_KEY="YOUR_APP_KEY" export DEBOX_BOT_API_SECRET="YOUR_API_SECRET" ``` ### 3.3 First message ```js const boxbotapi = require("./boxbotapi"); async function main() { const bot = await boxbotapi.NewBotAPI( process.env.DEBOX_BOT_API_KEY, process.env.DEBOX_BOT_API_SECRET || "", ); const msg = boxbotapi.NewMessage("cc0onr82", "group", "Hello from Nodejs SDK"); msg.ParseMode = boxbotapi.ModeRichText; const sent = await bot.Send(msg); console.log("sent message_id=", sent.MessageID); } main().catch(console.error); ``` ## 4. Receive messages with Long Polling ```js const boxbotapi = require("./boxbotapi"); async function run() { boxbotapi.Debug = false; boxbotapi.MessageListener = true; const bot = await boxbotapi.NewBotAPI( process.env.DEBOX_BOT_API_KEY, process.env.DEBOX_BOT_API_SECRET || "", ); const u = boxbotapi.NewUpdate(0); u.Timeout = 60; for await (const update of bot.GetUpdatesChan(u)) { if (update.Message) { const text = update.Message.Text || ""; console.log("message:", text); const reply = boxbotapi.NewMessage( update.Message.Chat.ID, update.Message.Chat.Type, `Received: ${text}`, ); reply.ParseMode = boxbotapi.ModeRichText; await bot.Send(reply); } if (update.CallbackQuery) { console.log("callback:", update.CallbackQuery.Data); } } } run().catch(console.error); ``` ## 5. Parse mode and content rules SDK constants: - `boxbotapi.ModeRichText` - `boxbotapi.ModeMarkdown` - `boxbotapi.ModeMarkdownV2` - `boxbotapi.ModeHTML` - `boxbotapi.ModeImage` - `boxbotapi.ModeVideo` - `boxbotapi.ModeFile` `content` rules: - `richtext` / `Markdown` / `MarkdownV2` / `HTML`: send text content. - `image` / `video` / `file`: `content` must be a publicly reachable URL. - Text content max length is 5000 characters. ## 6. Inline keyboard + callback ```js const markup = boxbotapi.NewInlineKeyboardMarkup( boxbotapi.NewInlineKeyboardRow( boxbotapi.NewInlineKeyboardButtonData("Details", "detail"), boxbotapi.NewInlineKeyboardButtonURL("Open docs", "https://docs.debox.pro"), ), ); const msg = boxbotapi.NewMessage("cc0onr82", "group", "Choose one"); msg.ParseMode = boxbotapi.ModeRichText; msg.ReplyMarkup = markup; await bot.Send(msg); ``` Handle callback: ```js if (update.CallbackQuery) { const data = update.CallbackQuery.Data; const chat = update.CallbackQuery.Message.Chat; const messageId = update.CallbackQuery.Message.MessageID; const edit = boxbotapi.NewEditMessageText(chat.ID, chat.Type, messageId, `clicked: ${data}`); edit.ParseMode = boxbotapi.ModeRichText; await bot.Send(edit); } ``` ## 7. Chat routing fields When sending/editing messages: - `chat_type=group` -> `chat_id` must be group `gid` - `chat_type=private` -> `chat_id` must be user `user_id` (invite code) ## 8. Common issues 1. No updates received: - Check webhook status first (mutually exclusive with polling). - Ensure `boxbotapi.MessageListener = true`. 2. Request failed with auth error: - Check `API_KEY/API_SECRET` and signature-related headers. 3. Media send failed: - Ensure URL is public and directly accessible. --- ## DeBox Bot Python SDK # DeBox Bot Python SDK Guide Source repository: - [debox-pro/debox-chat-python-sdk](https://github.com/debox-pro/debox-chat-python-sdk) ## 1. SDK capabilities `debox-chat-python-sdk` provides: - Bot initialization: `NewBotAPI(api_key, api_secret)` - Message sending: `bot.Send(...)` - Long polling updates: `GetUpdates` / `GetUpdatesChan` - Inline keyboard + callback handling - Message editing: `NewEditMessageText(...)` / `NewEditMessageTextAndMarkup(...)` ## 2. Receiving mode notes This document covers Long Polling mode. Webhook and Long Polling are strictly mutually exclusive: - If webhook is configured in platform console, messages are delivered to webhook. - To use polling, clear webhook configuration first. Webhook guide: - [DeBox Bot Go SDK Webhook](/GO-SDK-Webhook) ## 3. Install and init ### 3.1 Install ```bash pip install git+https://github.com/debox-pro/debox-chat-python-sdk.git ``` Or clone and install locally: ```bash git clone https://github.com/debox-pro/debox-chat-python-sdk.git cd debox-chat-python-sdk pip install -e . ``` ### 3.2 Credentials Get from DeBox Open Platform: - `API_KEY` (required) - `API_SECRET` (recommended) ```bash export DEBOX_BOT_API_KEY="YOUR_APP_KEY" export DEBOX_BOT_API_SECRET="YOUR_API_SECRET" ``` ### 3.3 First message ```python import os import boxbotapi bot = boxbotapi.NewBotAPI( os.getenv("DEBOX_BOT_API_KEY", ""), os.getenv("DEBOX_BOT_API_SECRET", ""), ) msg = boxbotapi.NewMessage("cc0onr82", "group", "Hello from Python SDK") msg.ParseMode = boxbotapi.ModeRichText sent = bot.Send(msg) print("sent message_id=", sent.MessageID) ``` ## 4. Receive messages with Long Polling ```python import os import boxbotapi from boxbotapi import configs as cfg cfg.Debug = False cfg.MessageListener = True bot = boxbotapi.NewBotAPI( os.getenv("DEBOX_BOT_API_KEY", ""), os.getenv("DEBOX_BOT_API_SECRET", ""), ) u = boxbotapi.NewUpdate(0) u.Timeout = 60 for update in bot.GetUpdatesChan(u): if update.Message is not None: text = update.Message.Text or "" print("message:", text) reply = boxbotapi.NewMessage( update.Message.Chat.ID, update.Message.Chat.Type, f"Received: {text}", ) reply.ParseMode = boxbotapi.ModeRichText bot.Send(reply) if update.CallbackQuery is not None: print("callback:", update.CallbackQuery.Data) ``` ## 5. Parse mode and content rules SDK constants: - `boxbotapi.ModeRichText` - `boxbotapi.ModeMarkdown` - `boxbotapi.ModeMarkdownV2` - `boxbotapi.ModeHTML` - `boxbotapi.ModeImage` - `boxbotapi.ModeVideo` - `boxbotapi.ModeFile` `content` rules: - `richtext` / `Markdown` / `MarkdownV2` / `HTML`: send text content. - `image` / `video` / `file`: `content` must be a publicly reachable URL. - Text content max length is 5000 characters. ## 6. Inline keyboard + callback ```python markup = boxbotapi.NewInlineKeyboardMarkup( boxbotapi.NewInlineKeyboardRow( boxbotapi.NewInlineKeyboardButtonData("Details", "detail"), boxbotapi.NewInlineKeyboardButtonURL("Open docs", "https://docs.debox.pro"), ) ) msg = boxbotapi.NewMessage("cc0onr82", "group", "Choose one") msg.ParseMode = boxbotapi.ModeRichText msg.ReplyMarkup = markup bot.Send(msg) ``` Handle callback and edit message: ```python if update.CallbackQuery is not None: data = update.CallbackQuery.Data chat = update.CallbackQuery.Message.Chat message_id = update.CallbackQuery.Message.MessageID edit = boxbotapi.NewEditMessageText(chat.ID, chat.Type, message_id, f"clicked: {data}") edit.ParseMode = boxbotapi.ModeRichText bot.Send(edit) ``` ## 7. Chat routing fields When sending/editing messages: - `chat_type=group` -> `chat_id` must be group `gid` - `chat_type=private` -> `chat_id` must be user `user_id` (invite code) ## 8. Common issues 1. No updates received: - Check webhook status first (mutually exclusive with polling). - Ensure `cfg.MessageListener = True`. 2. Auth error: - Verify `API_KEY/API_SECRET` and header signature path. 3. Media send failed: - Ensure URL is public and directly accessible. --- ## DeBox Bot Go SDK Webhook # DeBox Bot Go SDK Webhook Guide Source repository: - [debox-pro/debox-chat-go-sdk](https://github.com/debox-pro/debox-chat-go-sdk) This document covers DeBox bot Webhook integration for Go services. It is intended for backend developers who need a production-grade callback receiver, payload parser, and reply flow. ## 1. Webhook vs Long Polling (strictly mutually exclusive) There are two ways to receive bot updates: 1. Webhook: DeBox pushes updates to your server via `POST`. 2. Long Polling: your app pulls updates via `getUpdates`. Strict exclusivity rule: - Once a webhook URL is configured on the platform, updates are routed to Webhook as the only effective receive path. - In that state, `GetUpdates/GetUpdatesChan` is effectively disabled for message receiving. Conclusion: - If you choose Webhook, do not use Long Polling to receive messages. - If you want to switch back to Long Polling, clear the webhook configuration first. ## 2. When to use Webhook Use Webhook when: - Your service is publicly reachable over HTTP/HTTPS. - You need lower latency than polling. - You want a push-based event flow. - You need server-side handling for media messages or group join events. ## 3. Platform configuration Configure your webhook URL in the DeBox bot console, for example: - `https://your-domain.com/bot/webhook` Also ensure: - `App Domain` is configured correctly. - The webhook endpoint is stable and publicly reachable. - The webhook key is rotated after webhook URL changes. ## 4. Delivery contract ### 4.1 HTTP request DeBox sends: - Method: `POST` - Content-Type: `application/json` - Header: `X-API-KEY: ` Recommendations: - Reject requests with missing or invalid `X-API-KEY`. - Return `200 OK` only after your application has accepted the event. - Implement idempotency using your own event deduplication strategy if needed. ### 4.2 Top-level payload fields Webhook callbacks use a flattened JSON payload. The most important fields are: | Field | Type | Required | Description | | --- | --- | --- | --- | | `from_user_id` | `string` | Yes | DeBox invite code of the event sender exposed to the bot. In private chat, this is the other user. In group chat, this is the speaking user. For current join-group events, this is the joined member. | | `to_user_id` | `string` | Yes | Invite code of the target bot account. | | `name` | `string` | No | Display name of `from_user_id`. | | `pic` | `string` | No | Avatar URL of `from_user_id`. | | `address` | `string` | No | Wallet address of `from_user_id`. | | `language` | `string` | No | User language, if available. | | `group_id` | `string` | No | DeBox group ID or chatroom ID. Empty for private chat. | | `parse_mode` | `string` | Yes | Type of the current payload, such as `text`, `image`, `video`, `file`, `link`, `event:joinGroup`. | | `message` | `string` | Yes | Normalized message body. Meaning depends on `parse_mode`. | | `message_raw` | `string` | Yes | Original content after DeBox parsing. Meaning depends on `parse_mode`. | | `mention_users` | `array` | No | Mentioned users in group text messages. Present when the source message contains mentions. | `mention_users` item structure: | Field | Type | Description | | --- | --- | --- | | `user_id` | `string` | Invite code of the mentioned user | | `name` | `string` | Display name | | `pic` | `string` | Avatar URL | | `address` | `string` | Wallet address | ### 4.3 `parse_mode` values | `parse_mode` | Meaning | `message` / `message_raw` | | --- | --- | --- | | `text` | Plain text or command-like text | Message text. Mentions are removed from `message` and preserved in `message_raw`. | | `image` | Image message | Image URL | | `video` | Video message | Video URL | | `file` | File message | File URL | | `link` | Shared link / dapp share | Shared link URL | | `event:joinGroup` | Group join event | Current joined member invite code | Important behavior notes: - For `image`, `video`, and `file`, the bot receives a URL string, not the binary file body. - For `text`, `message` is normalized text, while `message_raw` preserves the original text. - For `event:joinGroup`, current payload semantics are event-oriented rather than conversational: - `group_id` is the target group. - `from_user_id` is the joined member exposed by the current callback implementation. - `message` is also the joined member invite code. ## 5. Payload examples by message type ### 5.1 Text message ```json { "from_user_id": "u_alice", "to_user_id": "u_bot", "name": "Alice", "pic": "https://cdn.example.com/alice.png", "address": "0x1234", "language": "en", "group_id": "cc0onr82", "parse_mode": "text", "message": "hello bot", "message_raw": "@MyBot hello bot", "mention_users": [ { "user_id": "u_bot", "name": "MyBot", "pic": "https://cdn.example.com/bot.png", "address": "" } ] } ``` ### 5.2 Image message ```json { "from_user_id": "u_alice", "to_user_id": "u_bot", "name": "Alice", "language": "en", "group_id": "cc0onr82", "parse_mode": "image", "message": "https://cdn.example.com/image.png", "message_raw": "https://cdn.example.com/image.png" } ``` ### 5.3 Video message ```json { "from_user_id": "u_alice", "to_user_id": "u_bot", "name": "Alice", "language": "en", "group_id": "cc0onr82", "parse_mode": "video", "message": "https://cdn.example.com/video.mp4", "message_raw": "https://cdn.example.com/video.mp4" } ``` ### 5.4 File message ```json { "from_user_id": "u_alice", "to_user_id": "u_bot", "name": "Alice", "language": "en", "group_id": "cc0onr82", "parse_mode": "file", "message": "https://cdn.example.com/report.pdf", "message_raw": "https://cdn.example.com/report.pdf" } ``` ### 5.5 Group join event ```json { "from_user_id": "u_new_member", "to_user_id": "u_bot", "name": "New Member", "pic": "https://cdn.example.com/new-member.png", "address": "0xabcd", "language": "en", "group_id": "cc0onr82", "parse_mode": "event:joinGroup", "message": "u_new_member", "message_raw": "u_new_member" } ``` Use this event when your bot needs to: - Send onboarding messages to new members. - Trigger group welcome workflows. - Record membership events in your own backend. ## 6. Go receiver design Recommended server flow: 1. Verify `X-API-KEY`. 2. Parse JSON into a typed struct. 3. Route logic by `parse_mode`. 4. Infer chat context from `group_id`. 5. Use Go SDK to send reply messages. ### 6.1 Suggested payload structs ```go type WebhookUser struct { UserID string `json:"user_id"` Name string `json:"name"` Pic string `json:"pic"` Address string `json:"address"` } type WebhookPayload struct { FromUserID string `json:"from_user_id"` ToUserID string `json:"to_user_id"` Name string `json:"name"` Pic string `json:"pic"` Address string `json:"address"` Language string `json:"language"` GroupID string `json:"group_id"` ParseMode string `json:"parse_mode"` Message string `json:"message"` MessageRaw string `json:"message_raw"` MentionUsers []WebhookUser `json:"mention_users"` } ``` ### 6.2 Full sample (Gin + Go SDK) ```go package main import ( "fmt" "net/http" "os" "github.com/gin-gonic/gin" boxbotapi "github.com/debox-pro/debox-chat-go-sdk/boxbotapi" ) type WebhookUser struct { UserID string `json:"user_id"` Name string `json:"name"` Pic string `json:"pic"` Address string `json:"address"` } type WebhookPayload struct { FromUserID string `json:"from_user_id"` ToUserID string `json:"to_user_id"` Name string `json:"name"` Pic string `json:"pic"` Address string `json:"address"` Language string `json:"language"` GroupID string `json:"group_id"` ParseMode string `json:"parse_mode"` Message string `json:"message"` MessageRaw string `json:"message_raw"` MentionUsers []WebhookUser `json:"mention_users"` } func main() { webhookKey := os.Getenv("DEBOX_WEBHOOK_KEY") apiKey := os.Getenv("DEBOX_BOT_API_KEY") apiSecret := os.Getenv("DEBOX_BOT_API_SECRET") if webhookKey == "" || apiKey == "" || apiSecret == "" { panic("missing required env: DEBOX_WEBHOOK_KEY / DEBOX_BOT_API_KEY / DEBOX_BOT_API_SECRET") } bot, err := boxbotapi.NewBotAPI(apiKey, apiSecret) if err != nil { panic(err) } r := gin.Default() r.POST("/bot/webhook", func(c *gin.Context) { if c.GetHeader("X-API-KEY") != webhookKey { c.JSON(http.StatusUnauthorized, gin.H{"error": "invalid webhook key"}) return } var payload WebhookPayload if err := c.ShouldBindJSON(&payload); err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } chatType := "private" chatID := payload.FromUserID if payload.GroupID != "" { chatType = "group" chatID = payload.GroupID } switch payload.ParseMode { case "text": reply := boxbotapi.NewMessage(chatID, chatType, "Received: "+payload.Message) reply.ParseMode = boxbotapi.ModeText _, err = bot.Send(reply) case "image": reply := boxbotapi.NewMessage(chatID, chatType, "Image received: "+payload.Message) reply.ParseMode = boxbotapi.ModeText _, err = bot.Send(reply) case "video": reply := boxbotapi.NewMessage(chatID, chatType, "Video received: "+payload.Message) reply.ParseMode = boxbotapi.ModeText _, err = bot.Send(reply) case "file": reply := boxbotapi.NewMessage(chatID, chatType, "File received: "+payload.Message) reply.ParseMode = boxbotapi.ModeText _, err = bot.Send(reply) case "event:joinGroup": welcome := fmt.Sprintf("Welcome %s to the group.", payload.FromUserID) reply := boxbotapi.NewMessage(chatID, chatType, welcome) reply.ParseMode = boxbotapi.ModeText _, err = bot.Send(reply) default: reply := boxbotapi.NewMessage(chatID, chatType, "Unsupported payload type: "+payload.ParseMode) reply.ParseMode = boxbotapi.ModeText _, err = bot.Send(reply) } if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } c.JSON(http.StatusOK, gin.H{"ok": true}) }) _ = r.Run(":8080") } ``` ## 7. Sending media replies with Go SDK When your bot replies with media, use the media URL as message content and set the matching `ParseMode`. ```go image := boxbotapi.NewMessage("cc0onr82", "group", "https://cdn.example.com/welcome.png") image.ParseMode = boxbotapi.ModeImage _, _ = bot.Send(image) video := boxbotapi.NewMessage("cc0onr82", "group", "https://cdn.example.com/intro.mp4") video.ParseMode = boxbotapi.ModeVideo _, _ = bot.Send(video) file := boxbotapi.NewMessage("cc0onr82", "group", "https://cdn.example.com/guide.pdf") file.ParseMode = boxbotapi.ModeFile _, _ = bot.Send(file) ``` Parse mode rules for send: - `boxbotapi.ModeText`: plain text - `boxbotapi.ModeImage`: content must be an image URL - `boxbotapi.ModeVideo`: content must be a video URL - `boxbotapi.ModeFile`: content must be a file URL ## 8. Production recommendations - Put webhook authentication and JSON parsing in middleware or a shared adapter. - Log `parse_mode`, `from_user_id`, `to_user_id`, and `group_id` for traceability. - Do not trust media URLs indefinitely; download or process them according to your retention policy. - For group bots, branch business logic by `group_id` instead of assuming one bot serves one group only. - Keep reply generation asynchronous if your downstream processing is slow. ## 9. Common pitfalls - Webhook configured but no updates received: - Check endpoint reachability, TLS, server logs, and `X-API-KEY` verification. - Webhook and Long Polling both enabled: - Only one receive mode is valid. With Webhook enabled, polling is not a valid receive path. - Treating media payloads as binary uploads: - Webhook delivers media URLs, not file streams. - Ignoring `parse_mode`: - Always branch on `parse_mode`, not only on the existence of `message`. - Local development without a public domain: - Use a tunnel to expose your local endpoint temporarily. ## 10. Related docs - Long Polling guide: [DeBox Bot Go SDK](/GO-SDK) --- ## DeBox Bot Blockchain Buttons # DeBox Bot Blockchain Buttons (button3) This page does only two things: 1. Describe button parameters in `button3` (`eth_getBalanceStr`, etc.) 2. Provide verbatim `main.go` so users can copy and run directly ## 1. button3 parameters (source-aligned) These payload strings are defined in `main.go` and bound to button `CallbackData` on `/start`: - `eth_getBalanceStr` - `personal_signStr` - `eth_signTypedData_v4Str` - `eth_sendTransactionStrNative` - `eth_sendTransactionStrToken` - `eth_sendTransactionApproveStr` - `sendTransactionStrTransferFrom` - `sendTransactionStrMint` - `sendTransactionStrSwap` - `sendTransactionStrDeploy` Replacement rules (exact source behavior): - `selfAddress` -> current user wallet address - `botAddress` -> bot wallet address (some calldata uses `botAddress[2:]`) - removes spaces/newlines/tabs via `escapeAllStr` ## 2. main.go (verbatim) ```go package main import ( "context" "log" "strings" "github.com/debox-pro/debox-chat-go-sdk/boxbotapi" ) var ( // Button texts homeInfoContent = "home content" eth_getBalance = "查账户余额" // eth_gasPrice = "查gas费" personal_sign = "personal_sign" eth_signTypedData_v4 = "eth_signTypedData_v4" eth_sendTransaction_native = "原生币转账" eth_sendTransaction_token_approve = "Approve授权支付" eth_sendTransaction_token_TransferFrom = "第三方授权转账TransferFrom" eth_sendTransaction_Mint = "Mint" eth_sendTransaction_token = "合约币转账" eth_sendTransaction_swap = "swap" eth_sendTransaction_deploy = "合约部署" walletRequest = "debox://wallet/request" bot *boxbotapi.BotAPI // Keyboard layout for the second menu. Two buttons, one per row homeMenuMarkup = boxbotapi.NewInlineKeyboardMarkup( boxbotapi.NewInlineKeyboardRow( boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_getBalance, walletRequest, eth_getBalance, "#21C161"), ), // boxbotapi.NewInlineKeyboardRow( // boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_gasPrice, walletRequest, eth_gasPrice, "#21C161"), // ), boxbotapi.NewInlineKeyboardRow( boxbotapi.NewInlineKeyboardButtonDataWithColor("", personal_sign, walletRequest, personal_sign, "#21C161"), ), boxbotapi.NewInlineKeyboardRow( boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_signTypedData_v4, walletRequest, eth_signTypedData_v4, "#21C161"), ), boxbotapi.NewInlineKeyboardRow( boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_sendTransaction_native, walletRequest, eth_sendTransaction_native, "#21C161"), ), boxbotapi.NewInlineKeyboardRow( boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_sendTransaction_token, walletRequest, eth_sendTransaction_token, "#21C161"), ), boxbotapi.NewInlineKeyboardRow( boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_sendTransaction_swap, walletRequest, eth_sendTransaction_swap, "#21C161"), ), boxbotapi.NewInlineKeyboardRow( boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_sendTransaction_token_approve, walletRequest, eth_sendTransaction_token_approve, "#21C161"), ), boxbotapi.NewInlineKeyboardRow( boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_sendTransaction_token_TransferFrom, walletRequest, eth_sendTransaction_token_TransferFrom, "#21C161"), ), boxbotapi.NewInlineKeyboardRow( boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_sendTransaction_Mint, walletRequest, eth_sendTransaction_Mint, "#21C161"), ), // boxbotapi.NewInlineKeyboardRow( // boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_sendTransaction_token, walletRequest, eth_sendTransaction_token, "#21C161"), // ), // boxbotapi.NewInlineKeyboardRow( // boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_sendTransaction_swap, walletRequest, eth_sendTransaction_swap, "#21C161"), // ), boxbotapi.NewInlineKeyboardRow( boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_sendTransaction_deploy, walletRequest, eth_sendTransaction_deploy, "#21C161"), ), ) ) func main() { var err error boxbotapi.MessageListener = true boxbotapi.Debug = true bot, err = boxbotapi.NewBotAPI("", "") if err != nil { // Abort if something is wrong log.Panic(err) } // Set this to true to log all interactions with debox servers u := boxbotapi.NewUpdate(0) u.Timeout = 30 // Create a new cancellable background context. Calling `cancel()` leads to the cancellation of the context ctx := context.Background() // ctx, cancel := context.WithCancel(ctx) // `updates` is a golang channel which receives debox updates updates := bot.GetUpdatesChan(u) // Pass cancellable context to goroutine go receiveUpdates(ctx, updates) // Tell the user the bot is online log.Println("Start listening for updates. Press enter to stop") //new stop select {} } func receiveUpdates(ctx context.Context, updates boxbotapi.UpdatesChannel) { // `for {` means the loop is infinite until we manually stop it for { select { // stop looping if ctx is cancelled case <-ctx.Done(): return // receive update from channel and then handle it case update := <-updates: handleUpdate(update) } } } func handleUpdate(update boxbotapi.Update) { switch { // Handle messages case update.Message != nil: handleMessage(update.Message) break // Handle button clicks case update.CallbackQuery != nil: handleButton(update.CallbackQuery) break } } func handleMessage(message *boxbotapi.Message) { user := message.From text := message.Text botAddress := bot.Self.Address if user == nil { return } // Print to console log.Printf("%s wrote %s", user.Name, text) var err error if len(text) > 0 { msg := boxbotapi.NewMessage(message.Chat.ID, message.Chat.Type, message.Text) msg.ParseMode = boxbotapi.ModeHTML if text == "/start" { msg.Text = homeInfoContent msg.ReplyMarkup = homeMenuMarkup var eth_getBalanceStr = `{ "jsonrpc": "2.0", "id": 101, "method": "eth_getBalance", "params": [ { "chainId": "0x38" }, "selfAddress", "latest" ] }` //hexString := hex.EncodeToString(byteData) var personal_signStr = `{ "jsonrpc": "2.0", "id": 102, "method": "personal_sign", "params": [ { "chainId": "0x38" }, "0x506c65617365207369676e2074686973206d65737361676520746f20636f6e6669726d20796f7572206964656e746974792e", "selfAddress" ] }` //typedata_v4 // 使用 any 类型代替 interface{} var eth_signTypedData_v4Str = `{ "jsonrpc": "2.0", "id": 103, "method": "eth_signTypedData_v4", "params": [ "selfAddress", { "types": { "EIP712Domain": [ { "name": "name", "type": "string" }, { "name": "version", "type": "string" }, { "name": "chainId", "type": "uint256" }, { "name": "verifyingContract", "type": "address" } ], "Person": [ { "name": "name", "type": "string" }, { "name": "wallet", "type": "address" } ], "Mail": [ { "name": "from", "type": "Person" }, { "name": "to", "type": "Person" }, { "name": "contents", "type": "string" } ] }, "primaryType": "Mail", "domain": { "name": "Ether Mail", "version": "1", "chainId": 1, "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC" }, "message": { "from": { "name": "Cow", "wallet": "selfAddress" }, "to": { "name": "Bob", "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB" }, "contents": "Hello, Bob!" } } ] }` var eth_sendTransactionStrNative = `{ "jsonrpc": "2.0", "id": 104, "method": "eth_sendTransaction", "params": [ { "chainId": "0x38", "to": "botAddress", "from": "selfAddress", "gas": "0x76c0", "value": "0x38D7EA4C68000", "data": "0x", "gasPrice": "0x4a817c800" } ] }` var eth_sendTransactionStrToken = `{ "jsonrpc": "2.0", "id": 105, "method": "eth_sendTransaction", "params": [ { "chainId": "0x38", "from": "selfAddress", "to": "0x6386Adc4BC9c21984E34fD916BB349dD861742af", "value": "0x0", "data": "0xa9059cbb000000000000000000000000botAddress0000000000000000000000000000000000000000000000000de0b6b3a7640000", "gas": "0x76c0", "gasPrice": "0x4a817c800" } ] }` var eth_sendTransactionApproveStr = `{ "jsonrpc": "2.0", "id": 106, "method": "eth_sendTransaction", "params": [ { "chainId": "0x38", "from": "selfAddress", "to": "0x6386Adc4BC9c21984E34fD916BB349dD861742af", "gas": "0xb89b", "gasPrice": "0x5d27a277", "value": "0x0", "data": "0x095ea7b3000000000000000000000000botAddress0000000000000000000000000000000000000000000000000de0b6b3a7640000" } ] }` var sendTransactionStrTransferFrom = `{ "jsonrpc": "2.0", "id": 106, "method": "eth_sendTransaction", "params": [ { "from": "selfAddress", "chainId":"0x38", "data": "0x23b872dd000000000000000000000000cba3fce9d49ce5d7870443f324a8dd56a5788bfc0000000000000000000000006c663ff4b23ba3452e5ad1ad0c567e54b5ceee2e0000000000000000000000000000000000000000000000000de0b6b3a7640000", "gas": "0xad12", "gasPrice": "0x596c5e37", "to": "0x6386Adc4BC9c21984E34fD916BB349dD861742af", "value": "0x0" } ] }` var sendTransactionStrMint = `{ "jsonrpc": "2.0", "id": 106, "method": "eth_sendTransaction", "params": [ { "chainId":"0xa", "from": "selfAddress", "data": "0x3b4b1381000000000000000000000000000000000000000000000000000000000000000a", "gas": "0x5135c", "gasPrice": "0x18df9", "to": "0x98c56f0903d1cb0c7eaedb91fb9d58409bbb1fbe", "value": "0x0" } ] }` var sendTransactionStrSwap = `{ "jsonrpc": "2.0", "id": 106, "method": "swap", "params": [ { "fromAddress": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", "toAddress": "0x6386Adc4BC9c21984E34fD916BB349dD861742af", "fromChainId": "0x38", "toChainId": "0x38" } ] }` var sendTransactionStrDeploy = `{ "id": 4218609415, "jsonrpc": "2.0", "method": "eth_sendTransaction", "params": [ { "chainId":"0x38", "from": "selfAddress", "data":"0x60806040523480156200001157600080fd5b506040518060400160405280600c81526020017f54657374446170704e46547300000000000000000000000000000000000000008152506040518060400160405280600381526020017f54444e000000000000000000000000000000000000000000000000000000000081525081600090816200008f919062000324565b508060019081620000a1919062000324565b5050506200040b565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806200012c57607f821691505b602082108103620001425762000141620000e4565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b600060088302620001ac7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826200016d565b620001b886836200016d565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b600062000205620001ff620001f984620001d0565b620001da565b620001d0565b9050919050565b6000819050919050565b6200022183620001e4565b6200023962000230826200020c565b8484546200017a565b825550505050565b600090565b6200025062000241565b6200025d81848462000216565b505050565b5b8181101562000285576200027960008262000246565b60018101905062000263565b5050565b601f821115620002d4576200029e8162000148565b620002a9846200015d565b81016020851015620002b9578190505b620002d1620002c8856200015d565b83018262000262565b50505b505050565b600082821c905092915050565b6000620002f960001984600802620002d9565b1980831691505092915050565b6000620003148383620002e6565b9150826002028217905092915050565b6200032f82620000aa565b67ffffffffffffffff8111156200034b576200034a620000b5565b5b62000357825462000113565b6200036482828562000289565b600060209050601f8311600181146200039c576000841562000387578287015190505b62000393858262000306565b86555062000403565b601f198416620003ac8662000148565b60005b82811015620003d657848901518255600182019150602085019450602081019050620003af565b86831015620003f65784890151620003f2601f891682620002e6565b8355505b6001600288020188555050505b505050505050565b612be6806200041b6000396000f3fe608060405234801561001057600080fd5b50600436106100f45760003560e01c806342842e0e11610097578063a22cb46511610066578063a22cb46514610283578063b88d4fde1461029f578063c87b56dd146102bb578063e985e9c5146102eb576100f4565b806342842e0e146101e95780636352211e1461020557806370a082311461023557806395d89b4114610265576100f4565b8063081812fc116100d3578063081812fc14610165578063095ea7b31461019557806323b872dd146101b15780633b4b1381146101cd576100f4565b80629a9b7b146100f957806301ffc9a71461011757806306fdde0314610147575b600080fd5b61010161031b565b60405161010e91906119ac565b60405180910390f35b610131600480360381019061012c9190611a33565b61032c565b60405161013e9190611a7b565b60405180910390f35b61014f61040e565b60405161015c9190611b26565b60405180910390f35b61017f600480360381019061017a9190611b74565b6104a0565b60405161018c9190611be2565b60405180910390f35b6101af60048036038101906101aa9190611c29565b6104e6565b005b6101cb60048036038101906101c69190611c69565b6105fd565b005b6101e760048036038101906101e29190611b74565b61065d565b005b61020360048036038101906101fe9190611c69565b6106ac565b005b61021f600480360381019061021a9190611b74565b6106cc565b60405161022c9190611be2565b60405180910390f35b61024f600480360381019061024a9190611cbc565b610752565b60405161025c91906119ac565b60405180910390f35b61026d610809565b60405161027a9190611b26565b60405180910390f35b61029d60048036038101906102989190611d15565b61089b565b005b6102b960048036038101906102b49190611e8a565b6108b1565b005b6102d560048036038101906102d09190611b74565b610913565b6040516102e29190611b26565b60405180910390f35b61030560048036038101906103009190611f0d565b6109ac565b6040516103129190611a7b565b60405180910390f35b60006103276006610a40565b905090565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806103f757507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610407575061040682610a4e565b5b9050919050565b60606000805461041d90611f7c565b80601f016020809104026020016040519081016040528092919081815260200182805461044990611f7c565b80156104965780601f1061046b57610100808354040283529160200191610496565b820191906000526020600020905b81548152906001019060200180831161047957829003601f168201915b5050505050905090565b60006104ab82610ab8565b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006104f1826106cc565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610561576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105589061201f565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610580610b03565b73ffffffffffffffffffffffffffffffffffffffff1614806105af57506105ae816105a9610b03565b6109ac565b5b6105ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105e5906120b1565b60405180910390fd5b6105f88383610b0b565b505050565b61060e610608610b03565b82610bc4565b61064d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161064490612143565b60405180910390fd5b610658838383610c59565b505050565b6000600190505b8181116106a8576106756006610f52565b60006106816006610a40565b905061069461068e610b03565b82610f68565b5080806106a090612192565b915050610664565b5050565b6106c7838383604051806020016040528060008152506108b1565b505050565b6000806106d883610f86565b9050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610749576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161074090612226565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036107c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107b9906122b8565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60606001805461081890611f7c565b80601f016020809104026020016040519081016040528092919081815260200182805461084490611f7c565b80156108915780601f1061086657610100808354040283529160200191610891565b820191906000526020600020905b81548152906001019060200180831161087457829003601f168201915b5050505050905090565b6108ad6108a6610b03565b8383610fc3565b5050565b6108c26108bc610b03565b83610bc4565b610901576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108f890612143565b60405180910390fd5b61090d8484848461112f565b50505050565b6060600060405180610160016040528061013c8152602001612a7561013c9139905060006109408461118b565b61094983611259565b6109528661118b565b604051602001610964939291906124b6565b6040516020818303038152906040529050600061098082611259565b604051602001610990919061255f565b6040516020818303038152906040529050809350505050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600081600001549050919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b610ac1816113d1565b610b00576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610af790612226565b60405180910390fd5b50565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16610b7e836106cc565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080610bd0836106cc565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480610c125750610c1181856109ac565b5b80610c5057508373ffffffffffffffffffffffffffffffffffffffff16610c38846104a0565b73ffffffffffffffffffffffffffffffffffffffff16145b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16610c79826106cc565b73ffffffffffffffffffffffffffffffffffffffff1614610ccf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cc6906125f3565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610d3e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3590612685565b60405180910390fd5b610d4b8383836001611412565b8273ffffffffffffffffffffffffffffffffffffffff16610d6b826106cc565b73ffffffffffffffffffffffffffffffffffffffff1614610dc1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610db8906125f3565b60405180910390fd5b6004600082815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4610f4d8383836001611418565b505050565b6001816000016000828254019250508190555050565b610f8282826040518060200160405280600081525061141e565b5050565b60006002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603611031576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611028906126f1565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516111229190611a7b565b60405180910390a3505050565b61113a848484610c59565b61114684848484611479565b611185576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161117c90612783565b60405180910390fd5b50505050565b60606000600161119a84611600565b01905060008167ffffffffffffffff8111156111b9576111b8611d5f565b5b6040519080825280601f01601f1916602001820160405280156111eb5781602001600182028036833780820191505090505b509050600082602001820190505b60011561124e578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a8581611242576112416127a3565b5b049450600085036111f9575b819350505050919050565b6060600082510361127b576040518060200160405280600081525090506113cc565b6000604051806060016040528060408152602001612a3560409139905060006003600285516112aa91906127d2565b6112b49190612806565b60046112c09190612837565b905060006020826112d191906127d2565b67ffffffffffffffff8111156112ea576112e9611d5f565b5b6040519080825280601f01601f19166020018201604052801561131c5781602001600182028036833780820191505090505b509050818152600183018586518101602084015b8183101561138b576003830192508251603f8160121c168501518253600182019150603f81600c1c168501518253600182019150603f8160061c168501518253600182019150603f8116850151825360018201915050611330565b6003895106600181146113a557600281146113b5576113c0565b613d3d60f01b60028303526113c0565b603d60f81b60018303525b50505050508093505050505b919050565b60008073ffffffffffffffffffffffffffffffffffffffff166113f383610f86565b73ffffffffffffffffffffffffffffffffffffffff1614159050919050565b50505050565b50505050565b6114288383611753565b6114356000848484611479565b611474576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161146b90612783565b60405180910390fd5b505050565b600061149a8473ffffffffffffffffffffffffffffffffffffffff16611970565b156115f3578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026114c3610b03565b8786866040518563ffffffff1660e01b81526004016114e594939291906128ce565b6020604051808303816000875af192505050801561152157506040513d601f19601f8201168201806040525081019061151e919061292f565b60015b6115a3573d8060008114611551576040519150601f19603f3d011682016040523d82523d6000602084013e611556565b606091505b50600081510361159b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161159290612783565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506115f8565b600190505b949350505050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000831061165e577a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008381611654576116536127a3565b5b0492506040810190505b6d04ee2d6d415b85acef8100000000831061169b576d04ee2d6d415b85acef81000000008381611691576116906127a3565b5b0492506020810190505b662386f26fc1000083106116ca57662386f26fc1000083816116c0576116bf6127a3565b5b0492506010810190505b6305f5e10083106116f3576305f5e10083816116e9576116e86127a3565b5b0492506008810190505b612710831061171857612710838161170e5761170d6127a3565b5b0492506004810190505b6064831061173b5760648381611731576117306127a3565b5b0492506002810190505b600a831061174a576001810190505b80915050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036117c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117b9906129a8565b60405180910390fd5b6117cb816113d1565b1561180b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161180290612a14565b60405180910390fd5b611819600083836001611412565b611822816113d1565b15611862576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161185990612a14565b60405180910390fd5b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a461196c600083836001611418565b5050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b6000819050919050565b6119a681611993565b82525050565b60006020820190506119c1600083018461199d565b92915050565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b611a10816119db565b8114611a1b57600080fd5b50565b600081359050611a2d81611a07565b92915050565b600060208284031215611a4957611a486119d1565b5b6000611a5784828501611a1e565b91505092915050565b60008115159050919050565b611a7581611a60565b82525050565b6000602082019050611a906000830184611a6c565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015611ad0578082015181840152602081019050611ab5565b60008484015250505050565b6000601f19601f8301169050919050565b6000611af882611a96565b611b028185611aa1565b9350611b12818560208601611ab2565b611b1b81611adc565b840191505092915050565b60006020820190508181036000830152611b408184611aed565b905092915050565b611b5181611993565b8114611b5c57600080fd5b50565b600081359050611b6e81611b48565b92915050565b600060208284031215611b8a57611b896119d1565b5b6000611b9884828501611b5f565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000611bcc82611ba1565b9050919050565b611bdc81611bc1565b82525050565b6000602082019050611bf76000830184611bd3565b92915050565b611c0681611bc1565b8114611c1157600080fd5b50565b600081359050611c2381611bfd565b92915050565b60008060408385031215611c4057611c3f6119d1565b5b6000611c4e85828601611c14565b9250506020611c5f85828601611b5f565b9150509250929050565b600080600060608486031215611c8257611c816119d1565b5b6000611c9086828701611c14565b9350506020611ca186828701611c14565b9250506040611cb286828701611b5f565b9150509250925092565b600060208284031215611cd257611cd16119d1565b5b6000611ce084828501611c14565b91505092915050565b611cf281611a60565b8114611cfd57600080fd5b50565b600081359050611d0f81611ce9565b92915050565b60008060408385031215611d2c57611d2b6119d1565b5b6000611d3a85828601611c14565b9250506020611d4b85828601611d00565b9150509250929050565b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b611d9782611adc565b810181811067ffffffffffffffff82111715611db657611db5611d5f565b5b80604052505050565b6000611dc96119c7565b9050611dd58282611d8e565b919050565b600067ffffffffffffffff821115611df557611df4611d5f565b5b611dfe82611adc565b9050602081019050919050565b82818337600083830152505050565b6000611e2d611e2884611dda565b611dbf565b905082815260208101848484011115611e4957611e48611d5a565b5b611e54848285611e0b565b509392505050565b600082601f830112611e7157611e70611d55565b5b8135611e81848260208601611e1a565b91505092915050565b60008060008060808587031215611ea457611ea36119d1565b5b6000611eb287828801611c14565b9450506020611ec387828801611c14565b9350506040611ed487828801611b5f565b925050606085013567ffffffffffffffff811115611ef557611ef46119d6565b5b611f0187828801611e5c565b91505092959194509250565b60008060408385031215611f2457611f236119d1565b5b6000611f3285828601611c14565b9250506020611f4385828601611c14565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680611f9457607f821691505b602082108103611fa757611fa6611f4d565b5b50919050565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b6000612009602183611aa1565b915061201482611fad565b604082019050919050565b6000602082019050818103600083015261203881611ffc565b9050919050565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60008201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c000000602082015250565b600061209b603d83611aa1565b91506120a68261203f565b604082019050919050565b600060208201905081810360008301526120ca8161208e565b9050919050565b7f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560008201527f72206f7220617070726f76656400000000000000000000000000000000000000602082015250565b600061212d602d83611aa1565b9150612138826120d1565b604082019050919050565b6000602082019050818103600083015261215c81612120565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061219d82611993565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036121cf576121ce612163565b5b600182019050919050565b7f4552433732313a20696e76616c696420746f6b656e2049440000000000000000600082015250565b6000612210601883611aa1565b915061221b826121da565b602082019050919050565b6000602082019050818103600083015261223f81612203565b9050919050565b7f4552433732313a2061646472657373207a65726f206973206e6f74206120766160008201527f6c6964206f776e65720000000000000000000000000000000000000000000000602082015250565b60006122a2602983611aa1565b91506122ad82612246565b604082019050919050565b600060208201905081810360008301526122d181612295565b9050919050565b600081905092915050565b7f7b226e616d65223a2022546573742044617070204e4654732023000000000000600082015250565b6000612319601a836122d8565b9150612324826122e3565b601a82019050919050565b600061233a82611a96565b61234481856122d8565b9350612354818560208601611ab2565b80840191505092915050565b7f222c20226465736372697074696f6e223a2022546573742044617070204e465460008201527f7320666f722074657374696e672e222c2022696d616765223a2022646174613a60208201527f696d6167652f7376672b786d6c3b6261736536342c0000000000000000000000604082015250565b60006123e26055836122d8565b91506123ed82612360565b605582019050919050565b7f222c202261747472696275746573223a205b7b2274726169745f74797065223a60008201527f2022546f6b656e204964222c202276616c7565223a2022000000000000000000602082015250565b60006124546037836122d8565b915061245f826123f8565b603782019050919050565b7f227d5d7d00000000000000000000000000000000000000000000000000000000600082015250565b60006124a06004836122d8565b91506124ab8261246a565b600482019050919050565b60006124c18261230c565b91506124cd828661232f565b91506124d8826123d5565b91506124e4828561232f565b91506124ef82612447565b91506124fb828461232f565b915061250682612493565b9150819050949350505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000600082015250565b6000612549601d836122d8565b915061255482612513565b601d82019050919050565b600061256a8261253c565b9150612576828461232f565b915081905092915050565b7f4552433732313a207472616e736665722066726f6d20696e636f72726563742060008201527f6f776e6572000000000000000000000000000000000000000000000000000000602082015250565b60006125dd602583611aa1565b91506125e882612581565b604082019050919050565b6000602082019050818103600083015261260c816125d0565b9050919050565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b600061266f602483611aa1565b915061267a82612613565b604082019050919050565b6000602082019050818103600083015261269e81612662565b9050919050565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b60006126db601983611aa1565b91506126e6826126a5565b602082019050919050565b6000602082019050818103600083015261270a816126ce565b9050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b600061276d603283611aa1565b915061277882612711565b604082019050919050565b6000602082019050818103600083015261279c81612760565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006127dd82611993565b91506127e883611993565b9250828201905080821115612800576127ff612163565b5b92915050565b600061281182611993565b915061281c83611993565b92508261282c5761282b6127a3565b5b828204905092915050565b600061284282611993565b915061284d83611993565b925082820261285b81611993565b9150828204841483151761287257612871612163565b5b5092915050565b600081519050919050565b600082825260208201905092915050565b60006128a082612879565b6128aa8185612884565b93506128ba818560208601611ab2565b6128c381611adc565b840191505092915050565b60006080820190506128e36000830187611bd3565b6128f06020830186611bd3565b6128fd604083018561199d565b818103606083015261290f8184612895565b905095945050505050565b60008151905061292981611a07565b92915050565b600060208284031215612945576129446119d1565b5b60006129538482850161291a565b91505092915050565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b6000612992602083611aa1565b915061299d8261295c565b602082019050919050565b600060208201905081810360008301526129c181612985565b9050919050565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b60006129fe601c83611aa1565b9150612a09826129c8565b602082019050919050565b60006020820190508181036000830152612a2d816129f1565b905091905056fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f3c737667206865696768743d22333530222077696474683d22333530222076696577426f783d2230203020313030203130302220786d6c6e733d22687474703a2f2f7777772e77332e6f72672f323030302f737667223e3c646566733e3c706174682069643d224d7950617468222066696c6c3d226e6f6e6522207374726f6b653d227265642220643d224d31302c3930205139302c39302039302c3435205139302c31302035302c3130205131302c31302031302c3430205131302c37302034352c3730205137302c37302037352c353022202f3e3c2f646566733e3c746578743e3c746578745061746820687265663d22234d7950617468223e517569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f672e3c2f74657874506174683e3c2f746578743e3c2f7376673ea2646970667358221220922487cf7bfec55ad9cf0c646397333bb79204b1a8ef63134f78b23d697570ef64736f6c63430008120033", "gas": "0x26e8af", "gasPrice": "0x18e17", "value": "0x0" } ] }` // balanceParamsStr, _ := json.Marshal(balanceParams) eth_getBalanceStr = escapeAllStr(eth_getBalanceStr, "selfAddress", user.Address) personal_signStr = escapeAllStr(personal_signStr, "selfAddress", user.Address) eth_signTypedData_v4Str = escapeAllStr(eth_signTypedData_v4Str, "selfAddress", user.Address) eth_sendTransactionStrNative = escapeAllStr(eth_sendTransactionStrNative, "selfAddress", user.Address) eth_sendTransactionStrNative = escapeAllStr(eth_sendTransactionStrNative, "botAddress", botAddress) eth_sendTransactionStrToken = escapeAllStr(eth_sendTransactionStrToken, "selfAddress", user.Address) eth_sendTransactionStrToken = escapeAllStr(eth_sendTransactionStrToken, "botAddress", botAddress[2:]) sendTransactionStrSwap = escapeAllStr(sendTransactionStrSwap, "selfAddress", user.Address) eth_sendTransactionApproveStr = escapeAllStr(eth_sendTransactionApproveStr, "selfAddress", user.Address) eth_sendTransactionApproveStr = escapeAllStr(eth_sendTransactionApproveStr, "botAddress", botAddress[2:]) sendTransactionStrTransferFrom = escapeAllStr(sendTransactionStrTransferFrom, "selfAddress", user.Address) sendTransactionStrMint = escapeAllStr(sendTransactionStrMint, "selfAddress", user.Address) sendTransactionStrDeploy = escapeAllStr(sendTransactionStrDeploy, "selfAddress", user.Address) homeMenuMarkup.InlineKeyboard[0][0].CallbackData = ð_getBalanceStr homeMenuMarkup.InlineKeyboard[1][0].CallbackData = &personal_signStr homeMenuMarkup.InlineKeyboard[2][0].CallbackData = ð_signTypedData_v4Str homeMenuMarkup.InlineKeyboard[3][0].CallbackData = ð_sendTransactionStrNative //合约币转账 homeMenuMarkup.InlineKeyboard[4][0].CallbackData = ð_sendTransactionStrToken homeMenuMarkup.InlineKeyboard[5][0].CallbackData = &sendTransactionStrSwap homeMenuMarkup.InlineKeyboard[6][0].CallbackData = ð_sendTransactionApproveStr homeMenuMarkup.InlineKeyboard[7][0].CallbackData = &sendTransactionStrTransferFrom homeMenuMarkup.InlineKeyboard[8][0].CallbackData = &sendTransactionStrMint homeMenuMarkup.InlineKeyboard[9][0].CallbackData = &sendTransactionStrDeploy _, err = bot.Send(msg) } } if err != nil { log.Printf("An error occured: %s", err.Error()) } } func escapeAllStr(text, old, new string) string { text = strings.ReplaceAll(text, "\n", "") text = strings.ReplaceAll(text, "\t", "") text = strings.ReplaceAll(text, " ", "") text = strings.ReplaceAll(text, old, new) return text } func handleButton(query *boxbotapi.CallbackQuery) { message := query.Message var text = query.Data markup := boxbotapi.NewInlineKeyboardMarkup() markup = homeMenuMarkup // Replace menu text and keyboard msg := boxbotapi.NewEditMessageTextAndMarkup(message.Chat.ID, message.Chat.Type, message.MessageID, text, markup) msg.ParseMode = boxbotapi.ModeHTML bot.Send(msg) } ``` --- ## Developer FAQ / Troubleshooting ## DeBox Developer FAQ / Troubleshooting This page covers high-frequency integration issues and practical diagnosis paths. Primary docs for new integrations: - [DeBox Developer OpenAPI](/ApiOnePage) - [DeBox Bot Go SDK](/GO-SDK) - [DeBox Bot Go SDK Webhook](/GO-SDK-Webhook) ## 1. Which document should I start with? Choose by integration path: - Field definitions, enums, success/error samples: OpenAPI. - Go SDK with long polling: GO-SDK. - Webhook mode: GO-SDK Webhook. ## 2. Why does `getUpdates` return no messages? Most likely webhook is already configured. In DeBox, webhook and long polling are strictly mutually exclusive: - With webhook configured, webhook is the effective receive path. - To use long polling, clear webhook config first. ## 3. How should I fill `chat_id` and `chat_type`? - `chat_type=group`: `chat_id` must be group `gid` (e.g. `cc0onr82`). - `chat_type=private`: `chat_id` must be user `user_id` (invite code). These two fields are the primary routing keys for `sendMessage` / `editMessage`. ## 4. For `parse_mode=image/video/file`, what should `content` be? `content` must be a public URL: - `image`: image URL - `video`: video URL - `file`: file URL For text modes (`richtext/text/Markdown/MarkdownV2/HTML`), max content length is 5000 chars. ## 5. How to secure webhook callbacks? Webhook callback includes header `X-API-KEY = Webhook Key`. Your backend must validate it before processing payload. Troubleshooting note: - Webhook Key rotates when webhook URL changes. - Sync the new key to your backend validator. ## 6. How to diagnose send failures? Recommended check order: 1. `X-API-KEY` header exists and is valid. 2. `chat_type/chat_id` mapping is correct. 3. `content` is not empty and within limits. 4. `parse_mode` matches content format. 5. For signed endpoints (such as `dao_member`), verify `nonce/timestamp/signature`. ## 7. Common errors and fixes - `message can't be empty`: missing `content`. - `message must be less than 5000 characters`: text-mode payload too long. - `message must be less than 2000 bytes`: fan-broadcast payload too large. - `permission denied`: caller has no required group admin permission. - `Param error`: missing/invalid parameters (often malformed addresses). ## 8. How to get `gid` (group ID)? Open the target group in app and copy its share link. The `id` query value is `gid`. ## 9. Support channels - Open Platform: [developer.debox.pro](https://developer.debox.pro) - Official support group (if available): [https://m.debox.pro/group?id=l3izdfzd](https://m.debox.pro/group?id=l3izdfzd) --- ## DeBox FAQs ## 1. Where can I get official support? - Official account: [DeBox Official](https://m.debox.pro/card?id=uu08en3w) - Official support group: [DeBox Support](https://m.debox.pro/group?id=l3izdfzd) ## 2. How do I report a product issue? In the official support group, click the `⊕` button and choose the ticket option to submit detailed issue information. ## 3. Where can I obtain Open Platform credentials? Get `App ID`, `API Key`, and `App Secret` from the DeBox developer portal: [developer.debox.pro](https://developer.debox.pro/) ## 4. Which chains are currently supported? Current chain list: | Chain ID | Chain Name | | --- | --- | | -200 | Solana | | 1 | Ethereum | | 10 | Optimism | | 56 | BNB | | 137 | Polygon | | 196 | X Layer | | 250 | Fantom | | 324 | ZkSync Era | | 4200 | Merlin | | 5000 | Mantle | | 8453 | Base | | 42161 | Arbitrum | | 43114 | Avalanche | | 59144 | Linea | | 81457 | Blast | | 200901 | Bitlayer | | 534352 | Scroll | ## 5. Where are developer integration docs? - OpenAPI: [DeBox Developer OpenAPI](/ApiOnePage) - Bot guide: [DeBox Bot Guide](/APIs/BotGuide) - Go SDK (long polling): [DeBox Bot Go SDK](/GO-SDK) - Go SDK (webhook): [DeBox Bot Go SDK Webhook](/GO-SDK-Webhook)