我可以散列mongodb,在本例中,该Id由demoId表示?如果可以的话,解决办法是什么?谢谢
我尝试了以下方法(注意mongodb是12字节),但得到错误
当我在bytes12中将类型设置为soliditySha3时,我会得到0x的错误无效bytes12 .
当我在bytes16中将类型设置为soliditySha3时,我会得到0x的错误无效bytes16。
const demoIdHex = web3 && web3.utils.utf8ToHex(demoId!);
console.log("demoIdHex", demoIdHex);
const orderHash =
web3 &&
web3.utils.soliditySha3(
{ type: "bytes16", value: demoIdHex },
{ type: "address", value: account.data }
); // THIS FUNCTION FAILED
console.log("orderHash", orderHash);发布于 2021-12-17 08:47:54
我得到了一些帮助
不需要使用utf8ToHex
只需为mongoId做下面的操作
const orderHash =
web3 &&
web3.utils.soliditySha3(
{ type: "bytes12", value: demoId! },
{ type: "address", value: account.data }
);https://stackoverflow.com/questions/70344973
复制相似问题