type
status
date
slug
summary
category
tags
icon
password
 
When checking an Ethereum token approval, we encountered this string of numbers:
115792089237316195423570985008687907853269984665640564039457584007913129639935
 
Q: What is this seemingly random large number?
A: This is the "unlimited approval" value in Ethereum smart contracts, used to grant maximum token usage rights to third-party contracts.
 
Q: Why was this number chosen to represent "unlimited"?
A: When converted to hexadecimal, it shows a special pattern: 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff This is the maximum value that uint256 can represent, which is 2^256-1.
 
Q: Why is it 2^256-1 and not 2^256? A: This involves basic computer principles: using 4-bit binary as an example, from 0000 to 1111, the range is 0 to 15 (2^4-1). Similarly, the range for 256-bit binary is 0 to 2^256-1.
 
Q: What if we absolutely need to represent 2^256? A: 2^256 in hexadecimal would be 0x1 followed by 64 zeros, but this requires 257 bits, exceeding the range of uint256. This is the technical reason why smart contracts choose 2^256-1 as "unlimited".
 
This example demonstrates how blockchain elegantly implements the concept of "unlimited" within finite data types.
“I Know” and “It’s Fine”: Two Toxic Communication HabitsHow to write Git commit messages?
Loading...
Zhenye Dong
Zhenye Dong
Product Manager | New Dad | New Blogger
Latest posts
Fixing Terminal Exit Code 1 in Cursor IDE on Windows
2025-3-19
Cross-Platform Line Ending Issues When Syncing Git Repositories with OneDrive
2025-3-10
The Crying Test: A Guide for Setting Rules
2025-2-6
Parenting Note: Learning to Say Goodbye
2025-2-6
Parenting Note: Why laughter Can’t neutralize Tears?
2025-2-6
How to display [[roam/js]] results inline in Roam Research?
2025-1-5