Skip to main content

Questions tagged [opcode]

operation codes specify the instructions to be performed in machine languages

Filter by
Sorted by
Tagged with
1 vote
0 answers
15 views

Can evm make an EOA transaction during another transaction?

I want to deploy a smart contract that would do something like this: transfer eth from the contract to account A make a transaction to another smart contract from account A(given the nonce and the ...
Andrew Slock's user avatar
1 vote
1 answer
23 views

Can init code of a contract not return the deployed code?

As I understand, when deploying a new smart contract, the transaction has only the init code, which includes the code that will be actually deployed (the deployed code). The init code is executed and ...
Andrew Slock's user avatar
0 votes
1 answer
28 views

why opcode create always returns zero address?

my 2 functions: function func1(bytes memory code) public { address addr; assembly { addr := create(callvalue(), add(code, 0x20), mload(code)) } emit ...
xia bohedsky's user avatar
1 vote
1 answer
42 views

How OPCODES fees were defined?

When a function from a contract is executed the total cost, in weis, is calculated based on the OPCODES executed. For example, this question shows how to calculate the gas cost for keccak, that is 30 ...
Rafael's user avatar
  • 429
0 votes
0 answers
31 views

Can't supply assets to Compound via call Solidity

I have Smart Contract I make two functions supplyLiquidity with call opcode and supplyLiquidity1 where using interface instead // SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {IERC20} ...
Victor's user avatar
  • 55
0 votes
1 answer
13 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
62 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
28 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
56 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
378 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
173 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
  • 570
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
74 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
28 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
36 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
29 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
103 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
99 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
54 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
225 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
380 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
482 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
381 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
104 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
36 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
  • 570
2 votes
1 answer
47 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
37 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
  • 570
0 votes
1 answer
30 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
221 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
1 vote
1 answer
986 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
  • 570
8 votes
5 answers
14k 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
2 votes
1 answer
251 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
  • 245
1 vote
1 answer
200 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
  • 410
3 votes
2 answers
189 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
103 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
64 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
  • 570
2 votes
1 answer
135 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
36 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
92 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
50 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
310 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
165 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
794 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
525 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
642 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
2 votes
1 answer
741 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
36 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
90 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