BDB Chain 为 EVM 兼容 公链,可使用标准 Ethereum JSON-RPC、Web3.js / Ethers.js 及 EIP-1193 钱包 Provider 进行转账、合约调用与签名。本文档供 DApp、交易所、区块浏览器与第三方钱包对接使用。
| 项 | 值 |
|---|---|
| 链名称 | BDB Chain |
| Chain ID(十进制) | 20240606 |
| Chain ID(十六进制) | 0x134d8de |
| 原生代币 | BDB(Gas 费) |
| 精度 | 18 |
| RPC URL(主) | https://chain.bdbweb3.us |
| 区块浏览器 | https://scan.bdbweb3.us |
| 交易详情页 | https://scan.bdbweb3.us/tx/{txHash} |
| 地址详情页 | https://scan.bdbweb3.us/address/{address} |
| DApp 首页 | http://www.bdbweb3.site/ |
| DEX 前端 | https://dex.bdbweb3.site |
{
"chainId": "0x134d8de",
"chainName": "BDB Chain",
"nativeCurrency": {
"name": "BDB",
"symbol": "BDB",
"decimals": 18
},
"rpcUrls": ["https://chain.bdbweb3.us"],
"blockExplorerUrls": ["https://scan.bdbweb3.us"]
}
POST
https://chain.bdbweb3.us
· Content-Type: application/json
| 方法 | 说明 |
|---|---|
eth_chainId | 返回 0x134d8de |
eth_blockNumber | 最新区块高度 |
eth_getBalance | 查询 BDB 余额(参数:address, block) |
eth_getTransactionCount | 查询 nonce |
eth_gasPrice | 建议 Gas Price(legacy) |
eth_estimateGas | 估算 Gas Limit |
eth_call | 只读合约调用 |
eth_sendRawTransaction | 广播已签名交易 |
eth_getTransactionReceipt | 查询交易回执 |
eth_getLogs | 查询事件日志 |
curl -X POST https://chain.bdbweb3.us \
-H "Content-Type: application/json" \
-d '{
"jsonrpc":"2.0",
"method":"eth_getBalance",
"params":["0xYourAddress", "latest"],
"id":1
}'
chainId(EIP-155 防重放),签名后通过 eth_sendRawTransaction 上链。
在 BDBKEY App 内置浏览器(Discover / DApp)中打开页面时,会注入 window.ethereum 与 window.web3,
兼容 MetaMask 类 DApp 的常见调用方式。
| 方法 | 说明 |
|---|---|
eth_requestAccounts / requestAccounts | 获取当前钱包地址 |
eth_accounts | 已连接账户列表 |
eth_chainId | 当前链 ID |
eth_sendTransaction | 发起转账 / 合约交易(App 内弹窗确认) |
personal_sign | 个人消息签名(EIP-191) |
eth_sign | 原始消息签名 |
eth_signTypedData_v4 | 结构化数据签名(EIP-712) |
eth_call | 通过钱包代理的只读调用 |
wallet_addEthereumChain | 添加自定义链(若链已内置则匹配切换) |
wallet_switchEthereumChain | 切换链 |
wallet_requestPermissions | 兼容映射到 eth_accounts |
const provider = new ethers.BrowserProvider(window.ethereum);
await provider.send("eth_requestAccounts", []);
const signer = await provider.getSigner();
const address = await signer.getAddress();
const network = await provider.getNetwork();
console.log("address:", address, "chainId:", network.chainId);
try {
await window.ethereum.request({
method: "wallet_switchEthereumChain",
params: [{ chainId: "0x134d8de" }]
});
} catch (e) {
if (e.code === 4902) {
await window.ethereum.request({
method: "wallet_addEthereumChain",
params: [{
chainId: "0x134d8de",
chainName: "BDB Chain",
nativeCurrency: { name: "BDB", symbol: "BDB", decimals: 18 },
rpcUrls: ["https://chain.bdbweb3.us"],
blockExplorerUrls: ["https://scan.bdbweb3.us"]
}]
});
}
}
bdbweb3.site / dex.bdbweb3.site 等站点时通常无需手动切链。
const tx = await signer.sendTransaction({
to: "0xRecipientAddress",
value: ethers.parseEther("1.0") // 1 BDB
});
await tx.wait();
// 1. 获取 nonce、gasPrice、estimateGas
// 2. 构造 legacy 交易(type 0)或 EIP-1559(若链支持)
// 3. signTransaction + eth_sendRawTransaction
const rawTx = await wallet.signTransaction({
to: recipient,
value: amountWei,
gasLimit,
gasPrice,
nonce,
chainId: 20240606
});
// eth_sendRawTransaction(rawTx)
BDB Chain 上常用代币为标准 ERC20(18 位小数,USDT 同为 18 位)。
const erc20Abi = [
"function balanceOf(address) view returns (uint256)",
"function decimals() view returns (uint8)",
"function symbol() view returns (string)"
];
const token = new ethers.Contract(tokenAddress, erc20Abi, provider);
const bal = await token.balanceOf(userAddress);
const erc20Abi = [
"function transfer(address to, uint256 amount) returns (bool)"
];
const token = new ethers.Contract(tokenAddress, erc20Abi, signer);
const tx = await token.transfer(recipient, ethers.parseUnits("100", 18));
await tx.wait();
const erc20Abi = [
"function approve(address spender, uint256 amount) returns (bool)",
"function allowance(address owner, address spender) view returns (uint256)"
];
const token = new ethers.Contract(tokenAddress, erc20Abi, signer);
await token.approve(spenderAddress, ethers.MaxUint256);
// personal_sign
const sig = await signer.signMessage("Hello BDB");
// EIP-712 typed data
const sig712 = await signer.signTypedData(domain, types, value);
BDB Chain 内置 AMM 合约为 BCT ↔ USDT 交易对。
方法名中 BNB 为历史命名,实际对应池内 BCT 储备,并非原生 BDB。
| 合约 | 地址 |
|---|---|
| Swap / Pool | 0x1F60aaF98D89e0d59d87ACDD15498FAA27099eD2 |
| Token Factory | 0xf98032d0ABC50EE27C9eEc63a530fcdb9DF14918 |
| 方法 | 说明 |
|---|---|
reserveBNB() | BCT 储备量(uint256,18 decimals) |
reserveUSDT() | USDT 储备量 |
getAmountOut(amountIn, reserveIn, reserveOut) | 按恒定乘积公式计算输出量 |
swapBNBForUSDT(bnbAmountIn, minUSDTOut) | 卖 BCT 换 USDT(需先 approve BCT) |
swapUSDTForBNB(usdtAmountIn, minBNBOut) | 卖 USDT 换 BCT(需先 approve USDT) |
getAmountOut 或读取 reserveBNB / reserveUSDT 计算预期输出approve(SWAP, amount)swap*,minOut 建议留 0.5%~2% 滑点const SWAP = "0x1F60aaF98D89e0d59d87ACDD15498FAA27099eD2";
const BCT = "0x9A98A76D616d3dE697265374b49282683f0486C0";
const USDT = "0xC9Fd65481a41e1fA82Bdb8BFA7b43776c7033Fa0";
// 示例:USDT → BCT
const amountIn = ethers.parseUnits("10", 18);
await usdt.approve(SWAP, amountIn);
const swap = new ethers.Contract(SWAP, [
"function swapUSDTForBNB(uint256 usdtAmountIn, uint256 minBNBOut)"
], signer);
await swap.swapUSDTForBNB(amountIn, minBctOut);
| 符号 | 名称 | 地址 | 精度 | 链 |
|---|---|---|---|---|
| BDB | 原生 Gas 代币 | —(无合约) | 18 | BDB |
| BCT | BDB Chain Token | 0x9A98A76D616d3dE697265374b49282683f0486C0 | 18 | BDB |
| USDT | BDB USDT | 0xC9Fd65481a41e1fA82Bdb8BFA7b43776c7033Fa0 | 18 | BDB |
| STC | STC Token | 0x8f94c7356aa03390e8bdcfd308c3287e1f7175f9 | 18 | BDB |
| STD | STD Token | 0x3ffa1a33756ad3ef3baeb6bdd8e058e13d350897 | 18 | BDB |
| BTZB | BTZB Token | 0xba8a6202ba93dd30dbcd80269b778cc9137bafb6 | 18 | BDB |
GET
https://scan.bdbweb3.us/api?
查询参数与 Etherscan API 类似,例如:
| 模块 | 示例 |
|---|---|
| 账户交易列表 | ?module=account&action=txlist&address=0x...&startblock=0&endblock=99999999&sort=desc |
| ERC20 转账 | ?module=account&action=tokentx&address=0x...&contractaddress=0x... |
| 余额 | ?module=account&action=balance&address=0x...&tag=latest |
https://chain.bdbweb3.us,Chain ID = 20240606eth_requestAccounts 连接钱包eth_chainId 为 0x134d8de,否则提示用户切链sendTransaction;ERC20 走合约 transferapprove,再调用 Swap 合约eth_getTransactionReceipt 或浏览器链接personal_sign 或 EIP-712,后端用 ecrecover 验签const web3 = new Web3(window.ethereum);
await window.ethereum.request({ method: "eth_requestAccounts" });
const accounts = await web3.eth.getAccounts();
const chainId = await web3.eth.getChainId();
console.log(accounts[0], chainId); // chainId 应为 20240606n
BDB 是链原生 Gas 代币;BCT 是链上 ERC20,并在 DEX 中与 USDT 组成交易对。 两者地址、用途、价格来源不同,对接时请区分。
可以。使用任意 EVM 库本地签名后,调用 eth_sendRawTransaction 广播即可,无需经过钱包 App。
任何支持自定义 EVM 链的钱包(MetaMask、WalletConnect 等)均可添加 BDB 网络参数。
WalletConnect 项目需配置 Chain ID eip155:20240606。
BCT/USDT 现货可读取 Swap 合约储备计算;STC/STD/BTZB 等可通过运营方 K 线服务
(如 kapi.bdbweb3.site)获取,与链上 RPC 相互独立。