debank
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseScript Usage
脚本使用方法
Script-mode skill — read this file, then invoke from a block:
bashbash
python3 - <<'EOF'
import sys, json
sys.path.insert(0, "/data/workspace/skills/debank")
from exports import db_chain_list, db_user_total_balance, db_user_all_token_list
print(db_chain_list()[:3])
print(db_user_total_balance(user_addr="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"))
EOFRead for the full list of functions and exact
signatures. Common ones: , , ,
, ,
, ,
, , , .
exports.pydb_*db_chain_listdb_chaindb_tokendb_user_total_balancedb_user_all_token_listdb_user_all_simple_protocol_listdb_user_all_complex_protocol_listdb_user_history_listdb_protocoldb_pre_exec_txdb_explain_tx脚本模式技能——阅读本文件后,在代码块中调用:
bashbash
python3 - <<'EOF'
import sys, json
sys.path.insert(0, "/data/workspace/skills/debank")
from exports import db_chain_list, db_user_total_balance, db_user_all_token_list
print(db_chain_list()[:3])
print(db_user_total_balance(user_addr="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"))
EOF查看获取完整的函数列表及精确签名。常用函数包括:、、、、、、、、、、。
exports.pydb_*db_chain_listdb_chaindb_tokendb_user_total_balancedb_user_all_token_listdb_user_all_simple_protocol_listdb_user_all_complex_protocol_listdb_user_history_listdb_protocoldb_pre_exec_txdb_explain_txDeBank
DeBank
DeBank provides comprehensive blockchain data including wallet portfolios, token balances, transaction history, DeFi protocol positions, NFTs, and transaction simulation.
DeBank提供全面的区块链数据服务,涵盖钱包资产组合、代币余额、交易历史、DeFi协议持仓、NFT以及交易模拟功能。
Function Reference (signatures)
函数参考(签名)
All functions are in . uses DeBank's lowercase
codes: , , , , , , , , ,
, , , , etc. — use to enumerate.
is the wallet address (lowercase). from
.
exports.pychain_idethbscarbopbasematicavaxsolerascrllineamntblastdb_chain_list()user_addrprotocol_iddb_protocol_list()所有函数都在中。使用DeBank的小写编码:、、、、、、、、、、、、等——可调用获取完整列表。为钱包地址(小写)。可从获取。
exports.pychain_idethbscarbopbasematicavaxsolerascrllineamntblastdb_chain_list()user_addrprotocol_iddb_protocol_list()Chain & Token reference
链与代币参考
| Function | Description |
|---|---|
| List all supported chains. |
| One chain's metadata. |
| Gas prices for a chain. |
| Token detail. |
| Batch token lookup. |
| Historical prices (unix timestamps). |
| Top holders. |
| 函数 | 描述 |
|---|---|
| 列出所有支持的链。 |
| 获取单条链的元数据。 |
| 获取某条链的Gas价格。 |
| 获取代币详情。 |
| 批量查询代币信息。 |
| 获取代币历史价格(时间戳格式)。 |
| 获取代币持仓大户。 |
User portfolio (single-chain)
用户资产组合(单链)
| Function | Description |
|---|---|
| USD value on one chain. |
| Tokens on one chain. |
| One token balance. |
| DeFi positions (light) on one chain. |
| DeFi positions (detailed) on one chain. |
| NFTs on one chain. |
| Tx history on one chain. |
| Net worth curve on one chain. |
| Token approvals (security audit). |
| NFT approvals. |
| 函数 | 描述 |
|---|---|
| 获取用户在某条链上的资产USD估值。 |
| 获取用户在某条链上的代币列表。 |
| 获取用户某条链上的单个代币余额。 |
| 获取用户在某条链上的DeFi轻量持仓信息。 |
| 获取用户在某条链上的DeFi详细持仓信息。 |
| 获取用户在某条链上的NFT列表。 |
| 获取用户在某条链上的交易历史。 |
| 获取用户在某条链上的净值曲线。 |
| 获取用户在某条链上的代币授权情况(安全审计)。 |
| 获取用户在某条链上的NFT授权情况。 |
User portfolio (all-chain — heavier calls)
用户资产组合(全链——调用成本较高)
| Function | Description |
|---|---|
| Total USD across all chains + breakdown. |
| Net worth curve across all chains. |
| Which chains the address has used. |
| All tokens across all chains. |
| All DeFi positions (light). |
| All DeFi positions (detailed). |
| All NFTs. |
| All tx history. |
| All app-level positions (more granular). |
| 函数 | 描述 |
|---|---|
| 获取用户全链资产总USD估值及明细。 |
| 获取用户全链资产净值曲线。 |
| 获取用户已使用的链列表。 |
| 获取用户全链代币列表。 |
| 获取用户全链DeFi轻量持仓信息。 |
| 获取用户全链DeFi详细持仓信息。 |
| 获取用户全链NFT列表。 |
| 获取用户全链交易历史。 |
| 获取用户全链应用级持仓信息(更细粒度)。 |
Protocol reference
协议参考
| Function | Description |
|---|---|
| Protocol detail. |
| Protocols on one chain. |
| All protocols across chains. |
| App-level protocols (groups). |
| User's position in one protocol. |
| One pool's detail. |
| 函数 | 描述 |
|---|---|
| 获取协议详情。 |
| 获取某条链上的协议列表。 |
| 获取全链协议列表。 |
| 获取应用级协议分组列表。 |
| 获取用户在某一协议中的持仓情况。 |
| 获取某一资金池的详情。 |
Tx simulation
交易模拟
| Function | Description |
|---|---|
| Simulate tx before sending. |
| Human-readable explanation of a tx. |
DeBank uses snake_case (, , ).
USD values are floats. Token amounts are floats (already adjusted for
decimals — no need to divide by ).
total_usd_valuechain_idusd_value10**decimals| 函数 | 描述 |
|---|---|
| 发送前模拟交易。 |
| 生成交易的人类可读解析说明。 |
DeBank使用蛇形命名法(、、)。USD值为浮点数,代币数量为已调整小数位的浮点数(无需再除以)。
total_usd_valuechain_idusd_value10**decimalsWhen to Use DeBank
DeBank适用场景
Use DeBank for:
- User Portfolio - Total balance, token holdings, NFTs across all chains
- Transaction History - Historical transactions on single or all chains
- DeFi Positions - Protocol balances and complex portfolio positions
- Token Data - Token details, prices, and top holders
- Transaction Simulation - Pre-execute and explain transactions before submission
- Authorization Tracking - View token and NFT approvals
- Analytics - 24-hour net worth curves and portfolio tracking
DeBank适用于以下场景:
- 用户资产组合 - 全链总余额、代币持仓、NFT管理
- 交易历史 - 单链或全链的历史交易记录查询
- DeFi持仓 - 协议余额及复杂资产组合持仓管理
- 代币数据 - 代币详情、价格及持仓大户查询
- 交易模拟 - 提交前预执行并解析交易
- 授权追踪 - 查看代币及NFT授权情况
- 数据分析 - 24小时净值曲线及资产组合追踪
Common Workflows
常见工作流程
Get User Portfolio
获取用户资产组合
db_user_total_balance(user_addr="0x...") # Total balance across all chains
db_user_all_token_list(user_addr="0x...") # All token holdings
db_user_all_nft_list(user_addr="0x...") # All NFT collectionsdb_user_total_balance(user_addr="0x...") # 全链总余额
db_user_all_token_list(user_addr="0x...") # 所有代币持仓
db_user_all_nft_list(user_addr="0x...") # 所有NFT藏品Check Token Balances on Specific Chain
查询特定链上的代币余额
db_user_token_list(user_addr="0x...", chain_id="eth") # Ethereum tokens
db_user_token_list(user_addr="0x...", chain_id="bsc") # BSC tokensdb_user_token_list(user_addr="0x...", chain_id="eth") # 以太坊代币
db_user_token_list(user_addr="0x...", chain_id="bsc") # BSC代币Get Transaction History
获取交易历史
db_user_history_list(user_addr="0x...", chain_id="eth") # Eth transactions
db_user_all_history_list(user_addr="0x...") # All chain transactionsdb_user_history_list(user_addr="0x...", chain_id="eth") # 以太坊交易记录
db_user_all_history_list(user_addr="0x...") # 全链交易记录Check DeFi Protocol Positions
查询DeFi协议持仓
db_user_simple_protocol_list(user_addr="0x...", chain_id="eth") # Simple balances
db_user_complex_protocol_list(user_addr="0x...", chain_id="eth") # Detailed positions
db_user_all_complex_protocol_list(user_addr="0x...") # All chainsdb_user_simple_protocol_list(user_addr="0x...", chain_id="eth") # 轻量持仓余额
db_user_complex_protocol_list(user_addr="0x...", chain_id="eth") # 详细持仓信息
db_user_all_complex_protocol_list(user_addr="0x...") # 全链详细持仓Token Information
代币信息查询
db_token(chain_id="eth", token_id="0x...") # Token details
db_token_history_price(chain_id="eth", token_id="0x...", start_time=1234567890, end_time=1234567990)
db_token_top_holders(chain_id="eth", token_id="0x...") # Top 100 holdersdb_token(chain_id="eth", token_id="0x...") # 代币详情
db_token_history_price(chain_id="eth", token_id="0x...", start_time=1234567890, end_time=1234567990) # 代币历史价格
db_token_top_holders(chain_id="eth", token_id="0x...") # 前100持仓大户Transaction Simulation
交易模拟
db_pre_exec_tx(user_addr="0x...", chain_id="eth", tx={...}) # Enhanced pre-execution
db_explain_tx(user_addr="0x...", chain_id="eth", tx={...}) # Explain transactiondb_pre_exec_tx(user_addr="0x...", chain_id="eth", tx={...}) # 增强版预执行
db_explain_tx(user_addr="0x...", chain_id="eth", tx={...}) # 解析交易内容Protocol Data
协议数据查询
db_protocol(protocol_id="uniswap") # Protocol details
db_protocol_list(chain_id="eth") # All protocols on chain
db_protocol_all_list() # All protocols across chainsdb_protocol(protocol_id="uniswap") # 协议详情
db_protocol_list(chain_id="eth") # 链上所有协议
db_protocol_all_list() # 全链所有协议Chain Information
链信息查询
db_chain_list() # All supported chains
db_chain(chain_id="eth") # Specific chain details
db_gas_market(chain_id="eth") # Gas pricesdb_chain_list() # 所有支持的链
db_chain(chain_id="eth") # 指定链的详情
db_gas_market(chain_id="eth") # Gas价格Important Notes
重要说明
- API Key: Requires DEBANK_API_KEY environment variable (DeBank Cloud API)
- User Address: Most endpoints require a valid blockchain address (0x... format)
- Chain IDs: Use DeBank chain identifiers (eth, bsc, polygon, arbitrum, optimism, etc.)
- Rate Limits: Be mindful of API rate limits and unit costs
- Unit Costs: Different endpoints have different unit costs (see API documentation)
- API密钥:需要设置DEBANK_API_KEY环境变量(DeBank云API)
- 用户地址:大多数接口需要有效的区块链地址(0x...格式)
- 链ID:使用DeBank的链标识符(eth、bsc、polygon、arbitrum、optimism等)
- 速率限制:注意API速率限制及单位成本
- 单位成本:不同接口的单位成本不同(详见API文档)
Chain ID Reference
链ID参考
Common chain identifiers:
- eth → Ethereum Mainnet
- bsc → BNB Smart Chain
- polygon → Polygon
- arbitrum → Arbitrum One
- optimism → Optimism
- avax → Avalanche C-Chain
- ftm → Fantom
- op → Optimism
- base → Base
Important: Use to get the complete list of supported chains and their identifiers.
db_chain_list()常用链标识符:
- eth → 以太坊主网
- bsc → BNB智能链
- polygon → Polygon链
- arbitrum → Arbitrum One
- optimism → Optimism
- avax → Avalanche C链
- ftm → Fantom
- op → Optimism
- base → Base链
重要提示:调用获取支持的完整链列表及标识符。
db_chain_list()Address Format
地址格式
All user addresses should be in Ethereum format (0x followed by 40 hexadecimal characters):
- Valid: 0x1234567890abcdef1234567890abcdef12345678
- Invalid: 1234567890abcdef1234567890abcdef12345678 (missing 0x prefix)
所有用户地址需采用以太坊格式(0x开头,后跟40个十六进制字符):
- 有效格式:0x1234567890abcdef1234567890abcdef12345678
- 无效格式:1234567890abcdef1234567890abcdef12345678(缺少0x前缀)