请参阅https://docs.starknet.io/docs/Blocks/transactions/#chain-id
这个例子是用python编写的。如何在javascript中完成等效的操作?
发布于 2022-07-08 09:36:18
import { encodeShortString, decodeShortString } from "starknet/dist/utils/shortString";
const SN_LOCALHOST = encodeShortString("SN_LOCALHOST");
const SN_GOERLI = encodeShortString("SN_GOERLI");
const SN_MAIN = encodeShortString("SN_MAIN");后续
当我使用python运行int.from_bytes(b'SN_MAIN', byteorder="big", signed=False)时,我得到:
23448594291968334
当我使用encodeShortString('SN_MAIN')?运行starknet.js时,我得到:
0x534e5f4d41494e
为什么?
答案: hex(23448594291968334) = 0x534e5f4d41494e
https://stackoverflow.com/questions/72909464
复制相似问题