web3js - Web3 批量请求返回未定义
问题描述
我正在尝试通过 BatchRequest 调用 BNT 和另一个 ERC20 的批准函数。
第一个请求效果很好,但第二个返回未定义,如果我交换订单也一样。
此外,如果我取消第一笔交易,第二笔交易也很好。
wrapperApprove = async () => {
// GET DATA
const web3 = this.props.MobXStorage.web3
let batch = new web3.BatchRequest()
const amount = await this.calculateConnectorBySmartTokenAmount()
const tokenInfo = this.getInfoBySymbol()
const converterAddress = tokenInfo[1]
const connectorAddress = tokenInfo[2]
const bnt = this.props.MobXStorage.web3.eth.Contract(ABISmartToken,
BNTToken)
const connector =
this.props.MobXStorage.web3.eth.Contract(ABISmartToken,
connectorAddress)
// MAKE BATCH REQUEST
batch.add(connector.methods.approve(
converterAddress,
this.props.MobXStorage.web3.utils.toWei(String(amount[1]))
).send.request({from: this.props.MobXStorage.accounts[0]}))
batch.add(bnt.methods.approve(
converterAddress,
this.props.MobXStorage.web3.utils.toWei(String(amount[0]))
).send.request({from: this.props.MobXStorage.accounts[0]}))
batch.execute()
}
解决方案
推荐阅读
- node.js - 使用 NodeJS 自动向 MongoDB 插入数据
- python - 根据不同列的 if 条件创建新列
- python - 如何将文本文件中的行复制到python中的剪贴板上
- reactjs - 通过 React Navigation 离开当前屏幕时传递参数并重置它
- python - 在while循环中计算用户的平均值(通过提示输入数据),直到Python中的某个条件
- reactjs - React Redux 错误:默认参数应该是最后一个 default-param-last
- python - 模块“spacy.util”在 Jupyter Notebook 中没有属性“filter_spans”
- javascript - JavaScript + MariaDB:SQL 查询返回 json 对象数组并从响应中删除 `\` 正斜杠
- node.js - 如何在 Cloud Firestore 中使用批处理写入 500 多个文档?
- c++ - 使用指针时未定义的引用