-
For The Graph TypeScript Library (graph-ts), why all functions related are in little-endian, instead of Ethereum's default big-endian? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
I was trying to ask the question in the discord. But the technical support engineer told me to open an issue. |
Beta Was this translation helpful? Give feedback.
-
A typical processor uses little-endian representation for integers because casts are a no-op.. Everything should be in little-endian because otherwise the system needs to convert to big-endian and back (which is extra work for no benefit). The real question is why is Ethereum using big-endian? |
Beta Was this translation helpful? Give feedback.
-
Thank you for your reply. So in the development of Subgraph using graph-ts, do we need to pay special attention to Ethereum's big-endian? For example, when using fromSignedBytes (https://github.com/graphprotocol/graph-tooling/blob/dcc246333397952506a9db6a6c556fc57b8017c2/packages/ts/ common/numbers.ts#L87), do I still need to call .reverse(), then pass in the input? |
Beta Was this translation helpful? Give feedback.
Yes, that's correct as the function documentation states. If you have suggestions for helpers we could introduce or possibly new names for these APIs that would reduce confusion, those are welcome.