{"id":15065226,"url":"https://github.com/idouble/ethereum-solidity-inline-assembly","last_synced_at":"2025-04-10T13:23:04.710Z","repository":{"id":53270795,"uuid":"216110416","full_name":"IDouble/Ethereum-Solidity-inline-Assembly","owner":"IDouble","description":"🌐 A Collection of Notes \u0026 Knowledge about Solidity inline Assembly 🔧","archived":false,"fork":false,"pushed_at":"2024-02-29T16:46:40.000Z","size":696,"stargazers_count":37,"open_issues_count":1,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T10:44:27.729Z","etag":null,"topics":["blockchain","blockchain-technology","eth","ethereum","ethereum-assembly","ethereum-blockchain","ethereum-contract","ethereum-inline-assembly","smart-contract","smart-contract-template","smart-contracts","solidity","solidity-assembly","solidity-inline-assembly","solidity-language"],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IDouble.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-10-18T21:36:58.000Z","updated_at":"2025-03-30T00:46:08.000Z","dependencies_parsed_at":"2024-04-08T23:12:41.285Z","dependency_job_id":null,"html_url":"https://github.com/IDouble/Ethereum-Solidity-inline-Assembly","commit_stats":null,"previous_names":["idouble/ethereum-solidity-inline-assembly"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IDouble%2FEthereum-Solidity-inline-Assembly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IDouble%2FEthereum-Solidity-inline-Assembly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IDouble%2FEthereum-Solidity-inline-Assembly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IDouble%2FEthereum-Solidity-inline-Assembly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IDouble","download_url":"https://codeload.github.com/IDouble/Ethereum-Solidity-inline-Assembly/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248225664,"owners_count":21068078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","blockchain-technology","eth","ethereum","ethereum-assembly","ethereum-blockchain","ethereum-contract","ethereum-inline-assembly","smart-contract","smart-contract-template","smart-contracts","solidity","solidity-assembly","solidity-inline-assembly","solidity-language"],"created_at":"2024-09-25T00:35:25.540Z","updated_at":"2025-04-10T13:23:04.684Z","avatar_url":"https://github.com/IDouble.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🌐 Ethereum Solidity inline Assembly 🔧\n🌐 A Collection of Notes \u0026 Knowledge about Solidity inline Assembly 🔧\n\n##  What is Solidity inline Assembly ❓\nSolidity defines an assembly language that you can use without Solidity and also as “**inline assembly**” **inside Solidity source code**. \n\nYou can interleave Solidity statements with inline assembly in a language close to the one of the **Ethereum Virtual Machine (EVM)**.\n\nAs the **Ethereum Virtual Machine (EVM) is a stack machine**, it is often hard to address the correct stack slot and provide arguments to opcodes at the correct point on the stack. Solidity’s inline assembly helps you do this, and with other issues that arise when writing manual assembly.\n## GetCode 🔍\n```\npragma solidity ^0.4.0;\n\nlibrary GetCode {\n    function at(address _addr) public view returns (bytes o_code) {\n        assembly {\n            // retrieve the size of the code, this needs assembly\n            let size := extcodesize(_addr)\n            // allocate output byte array - this could also be done without assembly\n            // by using o_code = new bytes(size)\n            o_code := mload(0x40)\n            // new \"memory end\" including padding\n            mstore(0x40, add(o_code, and(add(add(size, 0x20), 0x1f), not(0x1f))))\n            // store length in memory\n            mstore(o_code, size)\n            // actually retrieve the code, this needs assembly\n            extcodecopy(_addr, add(o_code, 0x20), 0, size)\n        }\n    }\n}\n```\n## sumPureAsm 🔧\n```\npragma solidity ^0.4.16;\n\nlibrary VectorSum {\n    function sumPureAsm(uint[] _data) public view returns (uint o_sum) {\n        assembly {\n           // Load the length (first 32 bytes)\n           let len := mload(_data)\n\n           // Skip over the length field.\n           // Keep temporary variable so it can be incremented in place.\n           // NOTE: incrementing _data would result in an unusable\n           //       _data variable after this assembly block\n           let data := add(_data, 0x20)\n\n           // Iterate until the bound is not met.\n           for\n               { let end := add(data, len) }\n               lt(data, end)\n               { data := add(data, 0x20) }\n           {\n               o_sum := add(o_sum, mload(data))\n           }\n        }\n    }\n}\n```\n\n![Binance Ready to give crypto a try ? buy bitcoin and other cryptocurrencies on binance](Images/binance.jpg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidouble%2Fethereum-solidity-inline-assembly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidouble%2Fethereum-solidity-inline-assembly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidouble%2Fethereum-solidity-inline-assembly/lists"}