This describes a technique for cheaper approve() transactions for dapps. There is a common pattern where, when approving, dapps approve 0xffffffff…ffffffff, the maximum integer, for a smart contract. However, approving slightly less than that, 0xff000000…00000000, is just as good, and uses less gas. However, you can save even more gas by truncating the calldata. The EVM will read zeroes where calldata does not exist, so it is unnecessary to provide the full parameter if the last parameter ends in zeroes.

Typical calldata:

0x095ea7b300000000000000000000000088df13889e20efa93ff9a0c08f101f431bd9ddd7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

Zero-replacement, saving 1984 gas:

0x095ea7b300000000000000000000000088df13889e20efa93ff9a0c08f101f431bd9ddd7ff00000000000000000000000000000000000000000000000000000000000000

Truncated, saving an additional 124 gas:

0x095ea7b300000000000000000000000088df13889e20efa93ff9a0c08f101f431bd9ddd7ff

Example transaction