Questions tagged [opcode]

operation codes specify the instructions to be performed in machine languages

Filter by
Sorted by
Tagged with
0 votes
0 answers
15 views

Contract initialization opcodes

Every contract I compile starts with the following opcodes: Is this just a design choice by Solidity, or a "rule" in Ethereum? Otherwise it seems like every time the EVM starts up, it would ...
user avatar
0 votes
1 answer
26 views

Why dedicated ADDMOD opcode?

Is the ADDMOD that commonly used that we needed to create a specific opcode for it? Why couldn't we simply use the ADD opcode + the MOD opcode together? The same question is also valid for the MULMOD ...
user avatar
0 votes
0 answers
9 views

Completely disregarding all storage costs, is compute time a sufficient metric to determine the computational cost of an opcode operation?

Completely disregarding all storage costs, is compute time a sufficient metric to determine the computational cost of an opcode operation? Or are/is there some other factor(s) that need to be ...
user avatar
3 votes
0 answers
21 views

Why does a STORAGEADD op (SSTORE) add 80 bytes to state rather than 32?

According to this spreadsheet that Vitalik has referenced before, stating that it's what they used to determine gas fees for each opcode, a STORAGEADD opcode (presumably renamed to SSTORE) is ...
user avatar
1 vote
1 answer
30 views

Opcode LOG3 Data Value Problem

I am trying to get the Event data from LOG3 but the data sometimes on stack5 and sometimes on stack6, can anyone help? for example, transfer amount = 1 of both two transfer functions, take a look at ...
user avatar
  • 13
1 vote
0 answers
18 views

Jump within verbatim block with label

I want to inject verbatim block to my yul contract. My verbatim block is a function, I need to implement if block, to be able to implement it, I need to have ability to use labels, I need to point to ...
user avatar
  • 11
0 votes
0 answers
35 views

I am getting "invalid opcode: INVALID" as error when i try to return an array of structures

I am getting error as ValueError: invalid opcode: INVALID. Is it because of use of memory and storage keyword in the function or is it because i can't return an array. My Solidity Code:- struct ...
user avatar
1 vote
0 answers
46 views

What settings should a private PoA blockchain have to be free to use? ( No ether in use )

I am a total noob in creating blockchains, and I am trying to make one using geth with PoA. I want to make a PoA private blockchain where transactions and smart contracts ( usage and deployments ) are ...
user avatar
1 vote
0 answers
34 views

Is there a way to call a function via a selector from within a contract?

In the case of calling a function with signature foo(uint256) from contract A, I could use this construction in solidity: address(A).call(abi.encodeWithSignature("foo(uint256)", 100)); // or ...
user avatar
  • 167
0 votes
1 answer
114 views

How to get opcode trace of failed transaction without solidity source?

tldr: want to run simulated transactions against deployed bytecode on rinkeby that has no verified solidity source, and step through opcodes and view stack/memory leading up to revert. To clairfy: in ...
user avatar
0 votes
0 answers
12 views

Create and Create2 opcode in EVM [duplicate]

What is the difference between CREATE and CREATE2 opcode present in Ethereum Virtual Machine(EVM)? and How do they work?
user avatar
1 vote
0 answers
28 views

How are blocks processed while syncing Ethereum blockchain full sync mode?

I am syncing a Geth client in full sync mode and also have made some changes in the client to log the execution time , time stamp and block number of all the opcodes executed in the Ethereum virtual ...
user avatar
  • 55
0 votes
1 answer
43 views

Using assembly to store more values per word

I need to store 1250 numbers 16 bits elements in an array. Storing unit256 cost 20.000 gas units each (SSTORE opcode), which at 200gwei gas price, will cost around 4.5 ETH. My understanding is that I ...
user avatar
  • 101
0 votes
1 answer
69 views

Why does changing a storage slot's value from zero to non-zero cost more than non-zero to non-zero in the sstore opcode?

Why does changing a storage slot's value from zero to non-zero cost more than changing from non-zero to non-zero, zero to zero, or non-zero to zero?
user avatar
1 vote
1 answer
124 views

Why do Etherscan's opcode view and opcode disassembler show different opcodes for the USDT contract?

We have USDT smart contract, which is located at 0xdac17f958d2ee523a2206206994597c13d831ec7. I am trying to decompile the smart contract (at least view it as at opcodes). What I see is that it begins ...
user avatar
  • 123
0 votes
1 answer
254 views

Is the source code of any Ethereum smart necessarily contract open?

I thought that any smart contract had open code. However, from time to time I'll encounter smart contracts that have no publicly available Solidiy code, on etherscan. How can this be? Doesn't that ...
user avatar
1 vote
1 answer
182 views

Is there a size limitation on create2 bytecode field?

I have the following method in my Solidity contract. function deploy(bytes memory bytecode, uint _salt) public payable returns (address){ address addr; assembly { addr := create2( ...
user avatar
  • 13
0 votes
0 answers
77 views

invalid opcode: opcode 0xfe not defined) on erc20 transfer using walletconnect sdk on Android

I'm trying to send an erc20 token in an Android Kotlin App using the walletConnect Kotlin SDK v1 and testing it with Metamask. Sending the native token ETH works, but sending an erc20 token does not. ...
user avatar
  • 101
1 vote
1 answer
505 views

Solidity shr opcode

What does this code mean? sender := shr(96, calldataload(sub(calldatasize(), 20))) Btw sender is an address variable.
user avatar
0 votes
1 answer
122 views

SLOAD opcode working in ethereum virtual machine

How SLOAD opcode works in ethereum virtual machine and why it is one of the most computationally expensive and time consuming process. vm stats for different opcodes of evm
user avatar
  • 55
1 vote
0 answers
41 views

Understanding the relationship between opcodes and the number of semicolons in source maps

Contract Take the following contract: // SPDX-License-Identifier: Unlicense pragma solidity >=0.8.4; contract Adder { function add(uint256 x, uint256 y) external pure returns (uint256 z) { ...
user avatar
0 votes
1 answer
167 views

How to read the current program counter (PC) in Solidity or Yul?

I was reading about the EVM dialect in the docs, and saw this: Instruction Explanation pc() Current position in code I went to Remix to try it out: function read_pc() external view returns (uint256 ...
user avatar
3 votes
2 answers
1k views

does using external over public in a library reduce any gas costs?

I have a library utils.sol library Utils { struct UtilType { unit var1; bool var2; } function addExtra(UtilType storage state, uint extra) public { state.var1 += extra; } } ...
user avatar
0 votes
2 answers
262 views

Where do I find the solidity provisions of Ethereum OPCODEs?

There is Solidity Cheat Sheet: https://github.com/manojpramesh/solidity-cheatsheet There is OPCODEs list: https://github.com/crytic/evm-opcodes But is there any list that show opcode's solidity code ...
user avatar
0 votes
0 answers
33 views

Should the BYTE opcode return a byte shifted 248 bits to the left?

I'm working on a sort of EVM simulation and I have questions about the BYTE (0x1a) operation. Here's its specification according to the yellow-paper: The new value on top of the stack has its first 8 ...
user avatar
  • 101
3 votes
0 answers
222 views

Solidity sourceMap and opcodes. No map entries for every code?

After compiling a simple contract, the output are these values: "opcodes": "PUSH1 0x80 PUSH1 0x40 MSTORE CALLVALUE DUP1 ISZERO PUSH1 0xF JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST POP ...
user avatar
1 vote
1 answer
38 views

Is optimization in Remix worth the risk of bugs?

Is the future gas savings for users worth the risk of bugs? In other words, is optimization worth it when launching a token using Remix? Tether has had 112 million transfers...https://etherscan.io/...
user avatar
0 votes
1 answer
179 views

How to clone(fork) a smart contract with only bytecodes deployed on etherscan.io (without abi and source code)? [duplicate]

How to clone(fork) a smart contract with only bytecodes deployed on etherscan.io (without abi and source code)? First, I try to submit the same bytecodes from etherscan.io using web3, but it failed. ...
user avatar
2 votes
1 answer
112 views

BSC Op Code Costs

Where can I find the current cost of gas for each OP Code on the Binance Smart Chain? Is the gas per opcode always going to be the same as Ethereum? I'm specfically trying to figure out how much gas ...
user avatar
  • 131
2 votes
0 answers
38 views

How does addition look like at the opcode level in Solidity v0.8 and above?

In Solidity v0.7 and below, addition was a simple opcode: ADD Which cost 3 gas units and didn't handle overflows, silently returning the overflown value. But Solidity v0.8 made addition overflow-safe....
user avatar
3 votes
1 answer
372 views

Adding new custom opcode to solidity

I have a problem with adding new opcode to solidity. I'm using solc (on C++) and geth(ethereum on Go). I want to add new opcode, that takes address payable, uint256, uint256, bytes memory and returns ...
user avatar
1 vote
1 answer
140 views

another "invalid opcode" error

I am stuck on this little problem in my chat app smart contract(this is only the faulty piece of code) contract ChatApp { struct user{ bool acceptReq; uint nreq; ...
user avatar
  • 51
0 votes
0 answers
78 views

invalid opcode error

I would like to set array contents using data present in another one. I'm tring to use the function below but got opcode error. Can anyone explain me why? function getfreecars() public returns(uint) { ...
user avatar
1 vote
0 answers
223 views

Remix (or any other tool): Solidity program to EVM opcode

I am interested in obtaining sequence of opcodes for a Solidity program: One example is given in the following program obtained from Link of paper I have attached the image also I need a link to a ...
user avatar
  • 1,215
8 votes
2 answers
2k views

What is the difference between the STATICCALL and CALL EVM opcodes?

Besides the regular and very common CALL, the Ethereum Virtual Machine has the STATICCALL opcode. In which ways does it differ from the regular CALL? Edit: This is not a duplicate because this ...
user avatar
  • 9,037
3 votes
0 answers
82 views

Why Yul doesn't have the else block?

The yul documentation states: No “else” block can be defined. It seems really weird. Yul has much more complex control flow schemes like loops and switches. Also other EVM languages like Solidity ...
user avatar
2 votes
1 answer
393 views

How to implement the CREATE2 in Python

I'd like to know either how to implement the skinny CREATE2 in Python or a package that provides it. This is the function I'm trying to port from TypeScript to Python. It calls generateAddress2 with ...
user avatar
0 votes
1 answer
33 views

Do different clients use different amounts of gas?

I'm trying to understand clients/nodes a bit can someone help clarify the below for me. My understanding is that each client implements the EVM in their own way. Smart contracts are written in ...
user avatar
  • 145
5 votes
1 answer
363 views

Copy and deploy a smart contract from opcodes without source code

I extracted opcodes from an already existing and deployed smart contract and I would like to know if it is possible to deploy an exact copy of this contract from its opcodes? My extracted opcodes ...
user avatar
  • 51
0 votes
1 answer
249 views

How to determine the return address when we use CALL opcode?

I'm try to understand each opcode defined in Ethereum Virtual Machine. As for the opcode 'CALL' I find that it needs 7 arguments from the stack: gas, addr, value, argument addr, argument offset, ...
user avatar
4 votes
1 answer
511 views

Parameters on evm opcode create

Why the usual way to create a contract with evm opcodes use add and mload, for example: bytes memory bytecode = hex"600580600c6000396000b800602a600052b8"; ... assembly { _address := ...
user avatar
2 votes
1 answer
165 views

Efficient, safe pow using EXP opcode

I recently stumbled across ds-math's rpow() being a O(lg n) safe implementation of exponentiation. Such a function is ultimately created because the EVM EXP opcode is unsafe wrt. overflows. The ...
user avatar
  • 123
3 votes
2 answers
2k views

Solidity 0.6.0 address(this).balance throws error invalid opcode

Whenever I try to execute a function that uses address(this).balance I get an invalid opcode error. It compiles fine using 0.6.0. Using truffle debug I get the following error: Transaction halted ...
user avatar
  • 1,092
1 vote
1 answer
406 views

gasCost of opcode "STATICCALL" in Geth VM Trace

{ "pc": 4765, "op": "STATICCALL", "gas": 222711, "gasCost": 219243, "depth": 1, ... } As above, Geth VM Trace (https://etherscan.io/vmtrace?txhash=...
user avatar
1 vote
1 answer
38 views

How do I send funds from a contract to an account using bytecode?

The instruction CREATE will send funds to a new account. Is there another instruction for sending funds to an account that already exists? Or I just have to use CREATE as if the account doesn't exist?
user avatar
2 votes
1 answer
98 views

Missing create2 opcode in ethereum yellow paper

In eip 1014 Vitalik added Create2 at opcode 0xf5 Adds a new opcode at 0xf5 But in ethereum yellow paper opcode i don't see opcode 0xf5 or any create2 opcode, it doesn't appear in https://www....
user avatar
  • 1,024
0 votes
0 answers
26 views

What is the OP_CODE for getting another account (storage and/or code)?

I'm debugging solidity opcode by opcode. How do I tell when the compiler is referencing another smart contract through OpCode? I know that you can do this in Browser Solidity. However I would just ...
user avatar
0 votes
1 answer
621 views

CREATE / CREATE2 Verification

Where do I verify whether a contract has been created with CREATE or CREATE2, would I have to disassemble the contract and look for a CREATE2 opcode in the contract creation code?
user avatar
  • 1,145
0 votes
2 answers
54 views

Are current ethereum opcodes prices in pyethereum updated?

I am not an expert in opcodes for Ethereum, but I am wondering if their prices here [https://github.com/ethereum/pyethereum/blob/develop/ethereum/opcodes.py] are updated as the latest version used by ...
user avatar
  • 363
0 votes
1 answer
255 views

What is after RETURN opcode?

I compiled a simple smart contract with --bin option (vs --bin-runtime), and looked at the assembly code. I can see that at first, the "setup" code copy all the run-time code with CODECOPY to memory, ...
user avatar