journal article·2025-08-13Open access

Yul2Vec: Yul Code Embeddings

Krzysztof Fonał

Applied Sciences· Volume 15· Issue 16

Abstract

In this paper, I propose Yul2Vec, a novel method for representing Yul programs as distributed embeddings in continuous space. Yul serves as an intermediate language between Solidity and Ethereum Virtual Machine (EVM) bytecode, designed to enable more efficient optimization of smart contract execution compared to direct Solidity-to-bytecode compilation. The vectorization of a program is achieved by aggregating the embeddings of its constituent code elements from the bottom to the top of the program structure. The representation of the smallest construction units, known as opcodes (operation codes), along with their types and arguments, is generated using knowledge graph relationships to construct a seed vocabulary, which forms the foundation for this approach. This research is important for enabling future enhancements to the Solidity compiler, paving the way for advanced optimizations of Yul and, consequently, EVM code. Optimizing the EVM bytecode is essential not only for improving performance but also for minimizing the operational costs of smart contracts—a key concern for decentralized applications. By introducing Yul2Vec, this paper aims to provide a foundation for further research into compiler optimization techniques and cost-efficient smart contract execution on Ethereum. The proposed method is not only fast in learning embeddings but also efficient in calculating the final vector representation of Yul code, making it feasible to integrate this step into the future compilation process of Solidity-based smart contracts.
Source: crossref · Quality: baseline

Research context

OpenAlex topics: Ferroelectric and Negative Capacitance Devices · Software Engineering Research · Advanced Memory and Neural Computing

SciVX discovery tags are terminology-based. OpenAlex topics are source-provided classifications.

Affiliations

Faculty of Electronics, Photonics and Microsystems, Wrocław University of Science and Technology, Janiszewskiego 11/17, 50-372 Wrocław, Poland

References (29)

Show source-provided references
1. Buterin, V. (2025, April 15). A Next-Generation Smart Contract and Decentralized Application Platform. White Paper 2014. Available online: https://ethereum.org/en/whitepaper.
2. Foundation, E. (2025, January 12). YUL Documentation. Available online: https://docs.soliditylang.org/en/latest/yul.html.
3. Muchnick, S.S. (1998). Advanced Compiler Design and Implementation, Morgan Kaufmann Publishers Inc.
4. Finding effective compilation sequences10.1145/998300.997196 ↗
5. Cooper, K.D., Schielke, P.J., and Subramanian, D. (1999, January 5). Optimizing for reduced code space using genetic algorithms. Proceedings of the ACM SIGPLAN 1999 Workshop on Languages, Compilers, and Tools for Embedded Systems, Atlanga, Georgia.10.1145/314403.314414 ↗
6. Adaptive optimizing compilers for the 21st century10.1023/A:1015729001611 ↗
7. Finding effective optimization phase sequences10.1145/780731.780735 ↗
8. Mitigating the compiler optimization phase-ordering problem using machine learning10.1145/2398857.2384628 ↗
9. Jain, S., Andaluri, Y., VenkataKeerthy, S., and Upadrasta, R. (2022, January 22–24). POSET-RL: Phase ordering for Optimizing Size and Execution Time using Reinforcement Learning. Proceedings of the 2022 IEEE International Symposium on Performance Analysis of Systems and Software (ISPASS), Singapore.10.1109/ISPASS55109.2022.00012 ↗
10. Huang, Q., Haj-Ali, A., Moses, W., Xiang, J., Stoica, I., Asanovic, K., and Wawrzynek, J. (May, January 28). AutoPhase: Compiler Phase-Ordering for HLS with Deep Reinforcement Learning. Proceedings of the 2019 IEEE 27th Annual International Symposium on Field-Programmable Custom Computing Machines (FCCM), San Diego, CA, USA.10.1109/FCCM.2019.00049 ↗
11. code2vec: Learning distributed representations of code10.1145/3290353 ↗
12. IR2VEC: LLVM IR Based Scalable Program Embeddings10.1145/3418463 ↗
13. Fonal, K. (2025). Dataset of Yul Contracts to Support Solidity Compiler Research. arXiv.
14. Allamanis, M., Barr, E.T., Bird, C., and Sutton, C. (September, January 30). Suggesting accurate method and class names. Proceedings of the 2015 10th Joint Meeting on Foundations of Software Engineering, New York, NY, USA.10.1145/2786805.2786849 ↗
15. Allamanis, M., Brockschmidt, M., and Khademi, M. (May, January 30). Learning to Represent Programs with Graphs. Proceedings of the International Conference on Learning Representations, Vancouver, BC, Canada.
16. A general path-based representation for predicting program properties10.1145/3296979.3192412 ↗
17. Brauckmann, A., Goens, A., Ertel, S., and Castrillon, J. (2020, January 22–23). Compiler-based graph representations for deep learning models of code. Proceedings of the 29th International Conference on Compiler Construction, San Diego, CA, USA.10.1145/3377555.3377894 ↗
18. Mikolov, T., Chen, K., Corrado, G., and Dean, J. (2013). Efficient Estimation of Word Representations in Vector Space. arXiv.
19. Moschitti, A., Pang, B., and Daelemans, W. (2014, January 25–29). GloVe: Global Vectors for Word Representation. Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP), Doha, Qatar.
20. Alon, U., Brody, S., Levy, O., and Yahav, E. (2019, January 6–9). code2seq: Generating Sequences from Structured Representations of Code. Proceedings of the International Conference on Learning Representations, New Orleans, LA, USA.
21. Kanade, A., Maniatis, P., Balakrishnan, G., and Shi, K. (2020). Learning and Evaluating Contextual Embedding of Source Code. arXiv.
22. Mou, L., Li, G., Zhang, L., Wang, T., and Jin, Z. (2016, January 12–17). Convolutional neural networks over tree structures for programming language processing. Proceedings of the Thirtieth AAAI Conference on Artificial Intelligence, Phoenix, AZ, USA.10.1609/aaai.v30i1.10139 ↗
23. Gupta, R., Pal, S., Kanade, A., and Shevade, S. (2017, January 4–9). DeepFix: Fixing common C language errors by deep learning. Proceedings of the Thirty-First AAAI Conference on Artificial Intelligence, San Francisco, CA, USA.10.1609/aaai.v31i1.10742 ↗
24. Lin, Y., Liu, Z., Sun, M., Liu, Y., and Zhu, X. (2015, January 25–30). Learning entity and relation embeddings for knowledge graph completion. Proceedings of the Twenty-Ninth AAAI Conference on Artificial Intelligence, Austin, TX, USA.10.1609/aaai.v29i1.9491 ↗
25. Zong, C., and Strube, M. (2015, January 26–31). Knowledge Graph Embedding via Dynamic Mapping Matrix. Proceedings of the 53rd Annual Meeting of the Association for Computational Linguistics and the 7th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), Beijing, China.
26. Foundation, E. (2025, February 10). Solidity Documentation. Available online: https://docs.soliditylang.org/en/v0.8.30/.
27. Foundation, E. (2025, January 10). YUL Gramma Specification. Available online: https://docs.soliditylang.org/en/latest/yul.html#restrictions-on-the-grammar.
28. Burges, C., Bottou, L., Welling, M., Ghahramani, Z., and Weinberger, K. (2013, January 5–10). Translating Embeddings for Modeling Multi-relational Data. Proceedings of the Advances in Neural Information Processing Systems, Lake Tahoe, Nevada.
29. Blanco, E., and Lu, W. (November, January 31). OpenKE: An Open Toolkit for Knowledge Embedding. Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, Brussels, Belgium.