\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{bgarces} \pdfinfo{ /Title (ethereum-opcodes.pdf) /Creator (Cheatography) /Author (bgarces) /Subject (Ethereum OPCODES Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{A3A3A3} \definecolor{LightBackground}{HTML}{F3F3F3} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Ethereum OPCODES Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{bgarces} via \textcolor{DarkBackground}{\uline{cheatography.com/45435/cs/13366/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}bgarces \\ \uline{cheatography.com/bgarces} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 1st November, 2017.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{4} \begin{tabularx}{3.833cm}{p{0.3033 cm} p{0.57627 cm} x{2.15343 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{3.833cm}}{\bf\textcolor{white}{0s: Stop and Arithmetic Operations}} \tn % Row 0 \SetRowColor{LightBackground} 0x00 & STOP & Halts execution \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} 0x01 & ADD & Addition operation \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} 0x02 & MUL & Multiplication operation \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} 0x03 & SUB & Subtraction operation \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} 0x04 & DIV & Integer division operation \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} 0x05 & SDIV & Signed integer division operation (truncated) \tn % Row Count 7 (+ 2) % Row 6 \SetRowColor{LightBackground} 0x06 & MOD & Modulo remainder operation \tn % Row Count 8 (+ 1) % Row 7 \SetRowColor{white} 0x07 & SMOD & Signed Modulo remainder operation \tn % Row Count 10 (+ 2) % Row 8 \SetRowColor{LightBackground} 0x08 & ADDMOD & Modulo addition operation \tn % Row Count 11 (+ 1) % Row 9 \SetRowColor{white} 0x09 & MULMOD & Modulo multiplication operation \tn % Row Count 13 (+ 2) % Row 10 \SetRowColor{LightBackground} 0x0a & EXP & Exponential operation \tn % Row Count 14 (+ 1) % Row 11 \SetRowColor{white} 0x0b & \seqsplit{SIGNEXTEND} & Extend length of two's complement signed integer \tn % Row Count 16 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3033 cm} p{0.45495 cm} x{2.27475 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{3.833cm}}{\bf\textcolor{white}{50s: Stack, Memory, Storage and Flow Operations}} \tn % Row 0 \SetRowColor{LightBackground} 0x50 & POP & Remove item from stack \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} 0x51 & MLOAD & Load word from memory \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} 0x52 & \seqsplit{MSTORE} & Save word to memory \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} 0x53 & \seqsplit{MSTORES} & Save byte to memory \tn % Row Count 5 (+ 2) % Row 4 \SetRowColor{LightBackground} 0x54 & SLOAD & Load word from storage \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} 0x55 & \seqsplit{SSTORE} & Save word to storage \tn % Row Count 7 (+ 1) % Row 6 \SetRowColor{LightBackground} 0x56 & JUMP & Alter the program counter \tn % Row Count 8 (+ 1) % Row 7 \SetRowColor{white} 0x57 & JUMPI & Conditionally alter the program counter \tn % Row Count 10 (+ 2) % Row 8 \SetRowColor{LightBackground} 0x58 & PC & Get the value of the program counter prior to the increment corresponding to this instruction \tn % Row Count 14 (+ 4) % Row 9 \SetRowColor{white} 0x59 & MSIZE & Get the size of active memory in bytes \tn % Row Count 16 (+ 2) % Row 10 \SetRowColor{LightBackground} 0x5a & GAS & Get the amount of available gas, including the corresponding reduction \tn % Row Count 19 (+ 3) % Row 11 \SetRowColor{white} 0x5b & \seqsplit{JUMPDEST} & Mark a valid destination for jumps \tn % Row Count 21 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3033 cm} p{0.45495 cm} x{2.27475 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{3.833cm}}{\bf\textcolor{white}{10s: Comparison \& Bitwise Logic Operations}} \tn % Row 0 \SetRowColor{LightBackground} 0x10 & LT & Less-than comparison \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} 0x11 & GT & Greater-than comparison \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} 0x12 & SLT & Signed less-than comparison \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} 0x13 & SGT & Signed greater-than comparison \tn % Row Count 5 (+ 2) % Row 4 \SetRowColor{LightBackground} 0x14 & EQ & Equality comparison \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} 0x15 & \seqsplit{ISZERO} & Simple not operator \tn % Row Count 7 (+ 1) % Row 6 \SetRowColor{LightBackground} 0x16 & AND & Bitwise AND operation \tn % Row Count 8 (+ 1) % Row 7 \SetRowColor{white} 0x17 & OR & Bitwise OR operation \tn % Row Count 9 (+ 1) % Row 8 \SetRowColor{LightBackground} 0x18 & XOR & Bitwise XOR operation \tn % Row Count 10 (+ 1) % Row 9 \SetRowColor{white} 0x19 & NOT & Bitwise NOT operation \tn % Row Count 11 (+ 1) % Row 10 \SetRowColor{LightBackground} 0x1a & BYTE & Retrieve single byte from word \tn % Row Count 12 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.39429 cm} p{0.39429 cm} x{2.24442 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{3.833cm}}{\bf\textcolor{white}{20s: SHA3}} \tn % Row 0 \SetRowColor{LightBackground} 0x20 & SHA3 & Compute Keccak-256 hash \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3033 cm} p{0.36396 cm} x{2.36574 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{3.833cm}}{\bf\textcolor{white}{60s \& 70s: Push Operations}} \tn % Row 0 \SetRowColor{LightBackground} 0x60 & PUSH1 & Place 1-byte item on stack \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} 0x61 & PUSH2 & Place 2-byte item on stack \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} 0x7f & \seqsplit{PUSH32} & Place 32-byte (full word) item on stack \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.36396 cm} p{0.45495 cm} x{2.21409 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{3.833cm}}{\bf\textcolor{white}{80s: Duplication Operations}} \tn % Row 0 \SetRowColor{LightBackground} 0x80 & DUP1 & Duplicate 1st stack item \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} 0x81 & DUP2 & Duplicate 2nd stack item \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} 0x8f & DUP16 & Duplicate 16th stack item \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3033 cm} p{0.42462 cm} x{2.30508 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{3.833cm}}{\bf\textcolor{white}{90s: Exchange Operations}} \tn % Row 0 \SetRowColor{LightBackground} 0x90 & SWAP1 & Exchange 1st and 2nd stack items \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} 0x91 & SWAP2 & Exchange 1st and 3rd stack items \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} 0x9f & \seqsplit{SWAP16} & Exchange 1st and 17th stack items \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3033 cm} p{0.63693 cm} x{2.09277 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{3.833cm}}{\bf\textcolor{white}{30s: Environmental Information}} \tn % Row 0 \SetRowColor{LightBackground} 0x30 & ADDRESS & Get address of currently executing account \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} 0x31 & BALANCE & Get balance of the given account \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} 0x32 & ORIGIN & Get execution origination address \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} 0x33 & CALLER & Get caller address \tn % Row Count 7 (+ 1) % Row 4 \SetRowColor{LightBackground} 0x34 & \seqsplit{CALLVALUE} & Get deposited value by the instruction/transaction responsible for this execution \tn % Row Count 10 (+ 3) % Row 5 \SetRowColor{white} 0x35 & \seqsplit{CALLDATALOAD} & Get input data of current environment \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} 0x36 & \seqsplit{CALLDATASIZE} & Get size of input data in current environment \tn % Row Count 14 (+ 2) % Row 7 \SetRowColor{white} 0x37 & \seqsplit{CALLDATACOPY} & Copy input data in current environment to memory \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} 0x38 & \seqsplit{CODESIZE} & Get size of code running in current environment \tn % Row Count 18 (+ 2) % Row 9 \SetRowColor{white} 0x39 & \seqsplit{CODECOPY} & Copy code running in current environment to memory \tn % Row Count 20 (+ 2) % Row 10 \SetRowColor{LightBackground} 0x3a & \seqsplit{GASPRICE} & Get price of gas in current environment \tn % Row Count 22 (+ 2) % Row 11 \SetRowColor{white} 0x3b & \seqsplit{EXTCODESIZE} & Get size of an account's code \tn % Row Count 24 (+ 2) % Row 12 \SetRowColor{LightBackground} 0x3c & \seqsplit{EXTCODECOPY} & Copy an account's code to memory \tn % Row Count 26 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3033 cm} p{0.3033 cm} x{2.4264 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{3.833cm}}{\bf\textcolor{white}{a0s: Logging Operations}} \tn % Row 0 \SetRowColor{LightBackground} 0xa0 & LOG0 & Append log record with no topics \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} 0xa1 & LOG1 & Append log record with one topic \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} 0xa2 & LOG2 & Append log record with two topics \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} 0xa3 & LOG3 & Append log record with three topics \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} 0xa4 & LOG4 & Append log record with four topics \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3033 cm} p{0.63693 cm} x{2.09277 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{3.833cm}}{\bf\textcolor{white}{f0s: System operations}} \tn % Row 0 \SetRowColor{LightBackground} 0xf0 & CREATE & Create a new account with associated code \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} 0xf1 & CALL & Message-call into an account \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} 0xf2 & \seqsplit{CALLCODE} & Message-call into this account with an alternative account's code \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} 0xf3 & RETURN & Halt execution returning output data \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} 0xf4 & \seqsplit{DELEGATECALL} & Message-call into this account with an alternative account's code, but persisting the current values for sender and value \tn % Row Count 14 (+ 5) % Row 5 \SetRowColor{white} 0xfe & INVALID & Designated invalid instruction \tn % Row Count 16 (+ 2) % Row 6 \SetRowColor{LightBackground} 0xff & \seqsplit{SELFDESTRUCT} & Halt execution and register account for later deletion \tn % Row Count 18 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3033 cm} p{0.57627 cm} x{2.15343 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{3.833cm}}{\bf\textcolor{white}{40s: Block Information}} \tn % Row 0 \SetRowColor{LightBackground} 0x40 & \seqsplit{BLOCKHASH} & Get the hash of one of the 256 most recent complete blocks \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} 0x41 & \seqsplit{COINBASE} & Get the block's beneficiary address \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} 0x42 & \seqsplit{TIMESTAMP} & Get the block's timestamp \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} 0x43 & NUMBER & Get the block's number \tn % Row Count 8 (+ 1) % Row 4 \SetRowColor{LightBackground} 0x44 & \seqsplit{DIFFICULTY} & Get the block's difficulty \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} 0x45 & \seqsplit{GASLIMIT} & Get the block's gas limit \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}