【解决方案1】:
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

当我使用 starknet.js 运行 encodeShortString('SN_MAIN')? 时,我得到:

0x534e5f4d41494e

为什么?

回答: hex(23448594291968334) = 0x534e5f4d41494e

【讨论】: