Skip to content

Conversation

@Gaubee
Copy link
Contributor

@Gaubee Gaubee commented Jan 9, 2026

Problem

硬编码的默认手续费 0.00001 BFM 是错误的。BioForest 链的手续费需要根据交易意图和上下文动态计算。

Solution

新增 SDK 函数 (bioforest-sdk/index.ts)

// 通用接口:根据意图计算手续费
getMinFee({ baseUrl, chainId, intent, fromAddress })

// 快捷函数:转账手续费
getTransferMinFee(baseUrl, chainId, fromAddress?, amount?, remark?)

手续费计算考虑因素

因素 说明
交易类型 transfer / setPayPassword 等
支付密码 若有 secondPublicKey,交易需二次签名,体积增大 5%
备注 (remark) 内容越多,交易体积越大
转账金额 影响序列化字节数

Changes

文件 修改
bioforest-sdk/index.ts 新增 getMinFee()getTransferMinFee() 函数
chain-service.ts 使用 SDK 动态计算,移除硬编码默认值
transaction-service.ts 传入 fromAddress 精确计算手续费
05-BioForest.md 更新手续费模型文档

Closes #192

- Add getMinFee() and getTransferMinFee() functions to bioforest-sdk
- Support fee calculation based on transaction intent (transfer, setPayPassword)
- Consider sender's pay password status (secondPublicKey) for accurate fee
- Remove hardcoded 0.00001 BFM default fee from chain-service.ts
- Remove hardcoded fallback from transaction-service.ts
- Update whitebook: fee model from 'fixed' to 'dynamic calculation'
- Document factors affecting fee: tx type, pay password, remark, amount

Closes #192
@Gaubee Gaubee force-pushed the fix/bioforest-dynamic-fee branch from ba4438d to 825eecd Compare January 9, 2026 03:04
@Gaubee Gaubee merged commit 685d4db into main Jan 10, 2026
5 checks passed
@Gaubee Gaubee deleted the fix/bioforest-dynamic-fee branch January 10, 2026 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix BioForest dynamic fee calculation

2 participants