core icon indicating copy to clipboard operation
core copied to clipboard

Use hexadecimal strings for chain ID

Open Gudahtt opened this issue 3 years ago • 0 comments

We currently store the chain ID in different formats throughout MetaMask products and libraries. It can be a number, a decimal string,a 0x-prefixed hexadecimal string, or a non-prefixed hexadecimal string.

We should converge on one standard way of representing a chain ID internally. The best of these three formats is the 0x-prefixed hexadecimal string, because it's the only string format that is not ambiguous. The number format is inappropriate because some networks use chain IDs that exceed the maximum safe integer in JavaScript.

We could also consider using BigInteger, but that would require additional serialization that we are probably better off avoiding.

Gudahtt avatar May 26 '22 15:05 Gudahtt