let batch = new this.web3.BatchRequest();
const arr = [
{name: "test1", att: 100, def: 100},
{name: "test2", att: 100, def: 100},
{name: "test3", att: 100, def: 100},
{name: "test4", att: 100, def: 100},
]
arr.forEach((d) => {
batch.add(this.contract.methods.createCountry(d.name, d.att, d.def, 10, this.account).send.request(this.contractObject, (err, res) => {
if (err) {
throw err;
} else {
console.log(res);
}
}));
});
console.log(batch);
batch.execute();
我知道问题不是智能合约,因为我在 Remix 中对它进行了彻底的测试,并在不同的国家/地区进行了推送。我使用 web3 和 Metamask。
合约中的所有值都设置为“test4”