solidity
James McComish pfp

@jamco.eth

TIL* Polygon POS (and their testnet attempted here) only support up to paris evm version... so still no PUSH0 or compatibility with solidity >= 0.8.20 any good place to get a breakdown of chains and their latest version? L2 Beat didn't show this * or at least re-learned, was more aware of this before but haven't run into it in a long time
1 reply
0 recast
2 reactions

Josh | The Blockchain Socialist pfp

@tbsocialist

Introducing Gas Killer: Super Scaling Ethereum Computation Reach out through the form in the article if you'd like to try testing it out!
1 reply
2 recasts
10 reactions

Rosario Borgesi pfp

@rosarioborgesi

⚡ abi.encode vs abi.encodePacked in Solidity Both encode data, but there’s a key difference: 🔹abi.encode → adds padding (less gas efficient) 🔹abi.encodePacked → no padding (more compact, cheaper in gas) ⚡ For gas efficiency → prefer abi.encodePacked 🔎 For strict decoding → use abi.encode Example 👇
0 reply
0 recast
3 reactions

Rosario Borgesi pfp

@rosarioborgesi

❌ In Solidity, you cannot use == to compare two strings. Strings are complex types (dynamic byte arrays), so == won’t work like it does with primitives. ✅ The correct way is to compare their hashes 👇
1 reply
1 recast
5 reactions

Rosario Borgesi pfp

@rosarioborgesi

🚀 Using Foundry’s cast send to call smart contracts right from the CLI For the @CyfrinUpdraft Foundry Fundamentals Section 1 NFTs I had to call: function solveChallenge(string yourFavoriteIceCream, string yourTwitterHandle) on contract 0x6c4791c3a9E9Bc5449045872Bd1b602d6385E3E1 (Sepolia). Here’s the cast send command I used 👇
0 reply
0 recast
3 reactions

Rosario Borgesi pfp

@rosarioborgesi

Day 24 of Foundry Fundamentals 🚀 with @cyfrin Updraft ✅ Deploy the Lottery on the Testnet pt.1 💡 Pro tip: Always test locally on Anvil before testing on a testnet
0 reply
0 recast
1 reaction

kompreni 🚂 pfp

@kompreni

Uniswap LP math strikes again ☠️ I've been writing some LP-creation libraries for farstore. In the end, the only working solution I've come to is to *binary search* the tick ranges onchain with a bunch of fake/test pairs. The saving grace is cheap gas. This never would have worked as a "solution" on ETH mainnet.
2 replies
1 recast
20 reactions

arseniy pfp

@arseniy.eth

Perplexity on encoding deck of cards in uint256: To encode a **full permutation** (the exact order) of a 52-card deck in Solidity using a `uint256`, you can use the **factorial number system** (also called Lehmer code). This system allows you to map any permutation of 52 elements to a unique integer between 0 and $$52! - 1$$, and vice versa[8][14]. ### Key Points - **Bits required:** $$ \log_2(52!) \approx 225.58 $$ bits, so a `uint256` (256 bits) is sufficient. - **Encoding:** Convert the permutation to its Lehmer code, then to a single integer. - **Decoding:** Convert the integer back to a Lehmer code, then reconstruct the permutation[14]. ### How It Works 1. **Lehmer code:** For each position in the permutation, count how many remaining elements are less than the current element. This produces a sequence of 52 numbers, each less than or equal to its positional factorial base. 2. **Integer representation:** Each digit of the Lehmer code is multiplied by its factorial base and summed, resulting in a unique integer for each permutation[14]. ### Solidity Implementation Outline While the search results do not provide Solidity code for permutation encoding/decoding, the factorial number system is well-documented and can be implemented as follows: #### Encoding a permutation to an integer (Lehmer code): ```solidity function permutationToIndex(uint8[] memory perm) public pure returns (uint256 index) { uint8[52] memory temp; for (uint8 i = 0; i < 52; i++) temp[i] = i; for (uint8 i = 0; i < 52; i++) { uint8 v = perm[i]; uint8 less = 0; for (uint8 j = 0; j < 52 - i; j++) { if (temp[j] == v) { index = index * (52 - i) + less; // Remove used element for (uint8 k = j; k < 51 - i; k++) temp[k] = temp[k+1]; break; } less++; } } } ``` #### Decoding an integer to a permutation: ```solidity function indexToPermutation(uint256 index) public pure returns (uint8[] memory perm) { perm = new uint8[](52); uint8[52] memory temp; for (uint8 i = 0; i < 52; i++) temp[i] = i; for (uint8 i = 0; i < 52; i++) { uint256 f = factorial(52 - 1 - i); uint8 pos = uint8(index / f); perm[i] = temp[pos]; // Remove used element for (uint8 k = pos; k < 51 - i; k++) temp[k] = temp[k+1]; index %= f; } } ``` (The `factorial` function must be implemented efficiently; precompute values if needed.) ### Summary Table | Deck Representation | Bits Needed | Fits in uint256? | Encoding Method | |---------------------------|-------------|------------------|------------------------| | Full permutation (order) | ~226 | Yes | Factorial number system| **References:** - Factorial number system and permutation encoding[8][14]. This is the **most efficient way** to encode a full permutation of 52 cards in Solidity. Sources [1] Mathematical Operations in Solidity - GeeksforGeeks https://www.geeksforgeeks.org/solidity/mathematical-operations-in-solidity/ [2] Factorial contract errors in version 0.5.1 - Ethereum Stack Exchange https://ethereum.stackexchange.com/questions/72169/factorial-contract-errors-in-version-0-5-1 [3] EthIR/examples/factorial.sol at master - GitHub https://github.com/costa-group/EthIR/blob/master/examples/factorial.sol [4] Calculate factorial | DApp World https://dapp-world.com/problem/math-calculate-factorial-tvfh/problem [5] bc factorial - Posts - OneCompiler https://onecompiler.com/posts/3zz8q623f/bc-factorial [6] Contracts — Solidity 0.8.31 documentation https://docs.soliditylang.org/en/latest/contracts.html [7] Solidity Contract for demoing how to use libraries. The ... - GitHub Gist https://gist.github.com/ashwinYardi/029cfddd5b7eceb677d4b750cf064e68 [8] Factorial number system and enumerating permutations - Reddit https://www.reddit.com/r/math/comments/kz5sc/factorial_number_system_and_enumerating/ [9] Solidity by Example — Solidity 0.8.31 documentation https://docs.soliditylang.org/en/latest/solidity-by-example.html [10] Solidity and Rust Syntax, Data Types, and Basic Constructs https://developers.stellar.org/docs/learn/migrate/evm/solidity-and-rust-basics [11] Implementation of a nonlinear transformation of a substitution in the form of elements of a numbering system of a number of factorial sets https://bit.mephi.ru/index.php/bit/article/view/1365 [12] Design and implementation of NFT-based system https://drpress.org/ojs/index.php/HSET/article/view/4929 [13] IID-Based QPP-RNG: A Random Number Generator Utilizing Random Permutation Sorting Driven by System Jitter https://arxiv.org/abs/2502.18609 [14] Factorial Numbers and Their Practical Applications https://www.mdpi.com/2076-3417/14/19/8588 [15] A Universal Classification System of Skin Substitutes Inspired by Factorial Design. https://www.liebertpub.com/doi/10.1089/ten.teb.2017.0477 [16] Engagement is a necessary condition to test audit and feedback design features: results of a pragmatic, factorial, cluster-randomized trial with an embedded process evaluation https://implementationscience.biomedcentral.com/articles/10.1186/s13012-023-01271-6 [17] Improving medication adherence among persons with cardiovascular disease through m-health and community health worker-led interventions in Kerala; protocol for a type II effectiveness-implementation research-(SHRADDHA-ENDIRA) https://trialsjournal.biomedcentral.com/articles/10.1186/s13063-024-08244-0 [18] Implementation Intention and Reminder Effects on Behavior Change in a Mobile Health System: A Predictive Cognitive Model http://www.jmir.org/2017/11/e397/ [19] IMPACT OF DEMOGRAPHIC FACTORS GENDER AND NUMBER OF YEARS OF ERP POST IMPLEMENTATION OPERATIONS ON USER PRODUCTIVITY: AN EMPIRICAL STUDY IN HIGHER EDUCATION SETTINGS, IN INDIAN CONTEXT https://www.granthaalayahpublication.org/journals/index.php/granthaalayah/article/view/10_IJRG19_A11_2887 [20] PERFORMANCE COMPARISON OF THE LANGUAGE PROGRAMMING LUA AND C++ ON IMPLEMENTATION PROGRAM FIBONACCI AND FACTORIAL. https://www.semanticscholar.org/paper/e9e80120862824bc1d2de862f3ce35bfbed5cb77
1 reply
0 recast
3 reactions

Hoot 🎩 pfp

@owl

Important rule from solhint ☝️
0 reply
0 recast
3 reactions

apoorv.eth pfp

@apoorvlathey

Solady contracts are 7702 ready 👀 If you decide to change the delegation address for EOA, the storage state isn't cleared So if you are not careful, then there'll be slot conflicts!
1 reply
0 recast
3 reactions

nicholas 🧨 pfp

@nicholas

Contract for Project 2 v0.0.4 revised and deployed to testnet last night. Time to lock in and revise @crowdfund (Project 1) contract. v0.1.0 deploying very soon.
1 reply
0 recast
1 reaction

Kazani pfp

@kazani

OpenZeppelin Solidity Contracts v5.3 is here 🧑‍💻 This release introduces new token standards and governance improvements, along with new smart account and crosschain capabilities through the Community Contracts Library. Here's what's new 👇 📝 Core Contracts Highlights ERC-6909 – New multi-token standard with: • Minimal implementation • Metadata support • Supply tracking • Content URI extension Governor Improvements: • New Proposal Guardian role • Added Sequential Proposal IDs • New Super Quorum mechanism ❤️‍🩹 5.3 also packs quality-of-life upgrades such as:  • trySafeTransfer() for ERC20s (no more surprise reverts) • clear() for EnumerableSet and EnumerableMap • MerkleTree.update() for dynamic leaf management • 512-bit and saturating math operations (add512, mul512, etc)
1 reply
0 recast
5 reactions

James McComish pfp

@jamco.eth

anyone using a solidity extension in cursor? i can't get any (juan blanco, nomic, or solidity extended) to highlight errors. i've had this happen before, but restarting the extension would fix it for a while until it happened again. now it's just not working at all.
0 reply
0 recast
0 reaction

⟠ ichristwin〔▸‿◂〕 pfp

@ichristwin.eth

😂 what in the footgun is that! ...why would the compiler allow this?? 🙂
2 replies
0 recast
2 reactions

Devin Conley pfp

@dcon.eth

wbtc has entered the chat
0 reply
0 recast
4 reactions