Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [opcode]

operation codes specify the instructions to be performed in machine languages

Filter by
Sorted by
Tagged with
0 votes
1 answer
8 views

What happens to opcodes during fork tests in foundry?

When you fork a chain in foundry, does it also copy the chain opcodes and the associated gas?
smol-ninja's user avatar
1 vote
1 answer
21 views

What's the difference between zkSync `system contracts` and EVM precompiles?

According to the zkSync docs While most of the primitive EVM opcodes can be supported out of the box (i.e. zero-value calls, addition/multiplication/memory/storage management, etc), some of the ...
Patrick Collins's user avatar
0 votes
1 answer
17 views

can we send value as well as call smart contract function using CALL

CALL opcode consumes value of the stack (which is transferred to the account). It can also additionally consume stack items to pass input to the smart contract account function. Can both happen ...
Sudeep Kumar's user avatar
1 vote
2 answers
28 views

what's the point of CODECOPY opcode

CODECOPY is used to copy the executing program's opcode onto the memory. I wonder what's the use of this though. Is there a deployed example where CODECOPY is useful?
Sudeep Kumar's user avatar
0 votes
1 answer
82 views

Received `NotActivated` error when debugging my foundry test

I have hand-written a smart contract in opcodes. The first few opcodes are as such: PUSH1 0x20 CALLDATALOAD CALLER PUSH0 SLOAD ADD However, all my tests for this contract keep breaking at PUSH0. When ...
Patrick Collins's user avatar
0 votes
0 answers
10 views

Why remaining gas increase after some opcodes

I use debug api of go ethereum to get traces of transactions. The api document shows that field gas represents the amount of gas remaining in the transaction at the current step of execution and field ...
Zoey's user avatar
  • 1
3 votes
2 answers
125 views

Why does mload(0x40) result in 0x20?

I ran the code below and had a question. function mloadTest1() public pure returns(bytes memory) { bytes memory a; assembly { a :=mload(0x40) } return a; } mload(x) is a Yul ...
imelon2's user avatar
  • 548
0 votes
0 answers
13 views

Could someone please dumb down how the sign extend opcode works? [duplicate]

I was trying to understand how the sign extend opcode works via the playground of evm.codes, but I can't seem to wrap my head around it. Somebody please help me and explain how it works?
davidastro's user avatar
1 vote
1 answer
50 views

How does opcode JUMP work in the EVM?

Could someone kindly explain how the program counter in the EVM knows where to jump to when the JUMP opcode is executed? I understand that a counter is supplied using PUSH (something) before the JUMP ...
davidastro's user avatar
0 votes
1 answer
24 views

How does the stack multiply a 32 byte number with a 1 byte number?

I was looking at an example of the multiply opcode(MUL) on the website www.evm.codes and noticed it multiplied: 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF x 2 resulting in ...
davidastro's user avatar
0 votes
1 answer
28 views

Solidity - Function Selector Loading onto the stack: why DIV instead of SHR?

I'm currently learning about how the function selector is loaded from calldata. The algorithm is like so: PUSH4 ffffffff PUSH29 0100000000000000000000000000000000000000000000000000000000000000 PUSH1 ...
riordant's user avatar
0 votes
1 answer
24 views

Reliably disassamble bytecode to opcodes across various evm versions

Is there a reliable way of disassembling bytecode into opcodes across different EVM versions, to make it agnostic to the EVM version used during compilation? As the second best option - is there a ...
Stas Buzuluk's user avatar
1 vote
1 answer
85 views

Run optimizer on opcodes

According to documentation, one of the steps of solidity compilation is the optimization on opcodes level, with the following set of rules. How can I apply optimization directly on opcodes? Details ...
Stas Buzuluk's user avatar
3 votes
1 answer
86 views

How do old smart contracts that contain certain opcodes behave when those opcodes get deprecated/removed in hard fork upgrades?

For example say a contract with a compiler version of 0.7.5 (pragma solidity 0.7.5) contained selfdestruct(payable(address)) what happens to the contract when the self destruct opcode gets deprecated ...
davidastro's user avatar
2 votes
1 answer
46 views

Is there a way to stop wallet homomorph attacks without ditching the create2 opcode?

Losses from create2 wallets that look similar to recently active wallets has surpassed $60m: https://gbhackers.com/create2-bypass-wallet-security-alerts/ Even today I made a transaction, and noticed ...
rook's user avatar
  • 141
0 votes
1 answer
176 views

Invalid OpCode while deploying "HelloWorld"

I'm receiving the following error message trying to deploy a very simple contract to Ganache. How can I resolve this? Contract: pragma solidity ^0.8.21; // ^0.4.24; contract HelloWorld { string ...
Mark P's user avatar
  • 1
2 votes
1 answer
360 views

Beacon contract contructor seems to call address 0x02?

The Beacon (Eth 2.0 deposit) contract was once deployed using a certain (constructor) script, like every other contract on the EVM blockchain. While analyzing that constructor script, it seems that it ...
Albert Hendriks's user avatar
2 votes
2 answers
336 views

What does FE stand for in "InvalidFEOpcode"?

I've seen the name InvalidFEOpcode used in client implementations, e.g. in REVM: https://github.com/bluealloy/revm/blob/8206193e65ad199a1dde1e79e38bf9ffe38118c9/crates/interpreter/src/...
Paul Razvan Berg's user avatar
0 votes
1 answer
226 views

Can I edit in the msg.sender value for the called contract?

let's assume following solidity contracts: contract EntryPointContract { address one = '0x...'; address two = '0x...'; address delegateContract; constructor(address ...
Jaroslaw Piatek's user avatar
0 votes
1 answer
81 views

Determining if a smart contract is using delegatecall

Let's say that I have the bytecode of a smart contract deployed on ethereum (which I got with a call to eth_getCode). How can I programmatically determine if this smart contract uses delegatecall ...
galpo's user avatar
  • 145
1 vote
2 answers
29 views

Where is the return data from an external call stored?

In ethervm.io, RETURNDATASIZE is described as follows. RETURNDATASIZE : Byzantium hardfork, EIP-211: the size of the returned data from the last external call, in bytes The smart contract has 3 ...
imelon2's user avatar
  • 548
2 votes
1 answer
36 views

Should all method hashes be found in a smart contract's opcodes?

I have a compiled/deployed solidity smart contract for which I have encoded all the functions signatures. (4-byte hashes) With the deployed bytecode, I have parsed the pushdata into an array for all '...
jjordan's user avatar
  • 31
0 votes
1 answer
32 views

what does it mean "JUMPDEST occupies position 43"

I'm looking at the minimal proxy posted by OpenZeppelin(link). I don't know what the text below means. The entire set of instructions for this EVM runtime code is made up of 45 bytes, and JUMPDEST ...
imelon2's user avatar
  • 548
0 votes
1 answer
25 views

EVM opcodes for Boolean AND operations

What opcodes does the EVM use in performing boolean AND (&&) operations
Emmanuel Anah's user avatar
0 votes
1 answer
173 views

Inline Assembly: RETURN opcode can't not work. Failed to decode output

I know that: return(p, s): end execution, return data mem[p…(p+s)). I want to return something in memory but not a multiple of bytes32. For example, I want to return 1 byte: pragma solidity 0.8.20; ...
LEVI_104's user avatar
0 votes
0 answers
37 views

Is there a way to calculate all the gas used in a transaction from within a smart contract?

If I use gasleft() and the beginning and end of the function then I only capture the amount of gas used between those two points. Is there a way to capture all of the gas used then to multiply that ...
Nat's user avatar
  • 279
1 vote
1 answer
837 views

How does opcode PUSH0 work in EVM?

PUSH0 is a new opcode that appeared in solidity 0.8.20 to replace PUSH1 00. Q1) Do PUSH0~32 need numbers(data) to be pushed next to it unconditionally? example : PUSH1 00 || PUSH2 05 Q2) PUSH0 ...
imelon2's user avatar
  • 548
7 votes
5 answers
12k views

invalid opcode: opcode 0x5f not defined

I'm new to Solidity and it's my first try to write a smart contract using Openzeppelin, Pancakeswap and BEP20 libraries basically to make a BEP-20 token. When i try to deploy the smart contract, i get ...
Mohammed's user avatar
1 vote
1 answer
227 views

When did each opcode get added to the EVM?

After the original set defined in the Ethereum yellow paper, many new opcodes have been added. I'm after a list of when each one was added (by fork).
bguiz's user avatar
  • 225
1 vote
1 answer
152 views

How do the LT and GT opcodes differ from SLT and SGT respectively?

When reading the Opcodes for the EVM article, I saw that the LT and SLT opcodes are evaluated to the same expression (a < b), as well as the GT and SGT opcodes (a > b). How do LT and GT differ ...
Iaroslav's user avatar
  • 365
3 votes
2 answers
155 views

Remix Assembly vs. Solidity Compiler Assembly

I am just diving into EVM assembly and am a little confused about the following. I have the following simple contract: pragma solidity >=0.8.1; contract MyTest {} When I compile it using Remix, I ...
Sebastian Dine's user avatar
2 votes
1 answer
98 views

Question about a function implementation in Ethereum Account Abstraction

function numberMarker() internal view { assembly {mstore(0, number())} } I'm studying about Account Abstraction, and exploring through the implementation code of EntryPoint.sol by Infinitism. ...
sm-stack's user avatar
1 vote
2 answers
60 views

Why don't specify add/sub/div/mul in the bytecode opcodes?

// SPDX-License-Identifier: MIT pragma solidity ^0.8.10; contract Test { uint num = 2 * 2 + 10; } For example, when compiling the above code in Remix, PUSH1 80 PUSH1 40 MSTORE PUSH1 0e PUSH1 00 ...
imelon2's user avatar
  • 548
2 votes
1 answer
129 views

Is the deploying of the contract anonymous?

Is the deploying of the contract anonymous? is it possible to find the owner who posted the contract? Is the only mention of it a link to the wallet from which the smart contract was first replenished ...
newbeee's user avatar
  • 21
1 vote
0 answers
32 views

Hardhat: setPrevRandao does not work

I'm trying to simulate prevrandao but it does not work out. To check it, I've written a contract and a test. contracts/AnotherContract.sol // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.9;...
unegare's user avatar
  • 21
1 vote
0 answers
82 views

Which contract's storage does SLOAD/SSTORE use?

A given SSTORE and SLOAD instruction uses storage from a certain smart contract. How can we know which contract that is, and do we need any additional data than the raw struct/opcode traces to find ...
Vegard Stikbakke's user avatar
1 vote
1 answer
49 views

How do RETURN and MLOAD work for high offsets?

When trying to load the 32 bytes of memory that follow a high offset (say 0x12345678), the RETURN and MLOAD opcodes give an out of gas error. Why is that ? Example PUSH1 0x20 PUSH4 0x12345678 RETURN ...
Sileo's user avatar
  • 139
1 vote
1 answer
245 views

EOA transfer and OPCODEs

I'm doing some research on how the transactions are made in Ethereum. I got reading the code of Geth and the Yellow Paper that a Smart Contract method call with a value on the payload will transfer ...
dbp's user avatar
  • 11
0 votes
1 answer
121 views

How does the PUSH instruction get its input?

I'm trying to understand state storage, and by doing so (for the first time) looking at raw geth traces. I've hit a blocker, though, which is understanding where the arguments to PUSH instructions ...
Vegard Stikbakke's user avatar
3 votes
3 answers
706 views

OPCODES WHY DOES free memory pointer(0X40) use 0x80 as starting value?

The following opcodes 0x40 is "offset in the memory in bytes" My question is why evm uses 0x80 as a "32-byte value to write in the memory." PUSH1 0x80 PUSH1 0x40 MSTORE Sincerely
Engin YILMAZ's user avatar
0 votes
1 answer
425 views

OPCODES How is work "CODECOPY"?

Somebody could explain how CODECOPY works in practice ? There is only one sample in evm.playground but I dont understand above-mentioned sample. Could you give me another concrete sample (with ...
Engin YILMAZ's user avatar
1 vote
2 answers
528 views

Does the EVM revert if a call is attempted to an address that doesn't have code?

The following code would revert in high-level Solidity if the provided addr is an EOA or a contract that does not implement MyInterface: interface MyInterface { function myFunction() external; } ...
Paul Razvan Berg's user avatar
1 vote
1 answer
2k views

OPCODES How is work "CALLDATACOPY"?

I try to understand how CALLDATACOPY works. destOffset: byte offset in the memory where the result will be copied. offset: byte offset in the calldata to copy. size: byte size to copy. I try to ...
Engin YILMAZ's user avatar
1 vote
1 answer
616 views

selfBalance() and address(this).balance gas cost

Yesterday I found out about the existence of selfbalance() and that it's cheaper than address(this).balance. I checked the EVM opcodes: opcode 31 BALANCE - The static cost is 0. If the accessed ...
Viktor Cortez's user avatar
0 votes
1 answer
28 views

Invalid opcode when storing value in array part of a mapped struct

I have a public function that accepts some data from users and i basically want to store this data into a struct that is mapped to an address. This is the definition of the Struct : struct ...
Moustafa Mowaffak El Damer's user avatar
1 vote
1 answer
81 views

How to make submod in evm assembly?

I've been playing with huff language (assembly for EVM) and tried creating a macro for subtraction modulo n. At first, I thought it would be easy since addmod(a,n-b,n) would do the job, but this isn't ...
Dragan Pilipovic's user avatar
0 votes
0 answers
17 views

Invalid Opcode Error SHR [duplicate]

call to UniswapV2Factory.INIT_CODE_HASH call to UniswapV2Factory.INIT_CODE_HASH errored: Internal JSON-RPC error. "code": -32000, "message": "invalid opcode: SHR" I'...
Gask's user avatar
  • 1
1 vote
2 answers
272 views

Why do I not see CREATE or CREATE2 opcodes in traces of contract creating transactions?

I am trying to see smart contract creations from opcodes in transaction traces with debug_traceTransaction. But traces of transactions that created contracts do not seem to include the CREATE opcode. ...
ruben's user avatar
  • 13
5 votes
1 answer
423 views

What are the first 128 bytes in solidity memory reserved for?

In most solidity contracts, the first few opcodes generate the free memory pointer PUSH1 0x80 PUSH1 0x40 MSTORE This places the 0x80 value (128) at location 0x40 in memory. So, why don't we start ...
Patrick Collins's user avatar
1 vote
1 answer
95 views

Vyper - Why is my first memory variable placed with an offset of 0x40 (64 bytes) instead of 0x20 (32 bytes) or even 0x00 (no offset)?

I have a vyper contract, as such: @external def add_two(my_number: uint256) -> uint256: two: uint256 = 123456 return my_number + two When you compile this (with 0.3.6), a piece of the ...
Patrick Collins's user avatar