Questions tagged [opcode]

operation codes specify the instructions to be performed in machine languages

Filter by
Sorted by
Tagged with
0
votes
1answer
13 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?
1
vote
1answer
23 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 ...
0
votes
1answer
29 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 ...
1
vote
1answer
63 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( ...
0
votes
0answers
38 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. ...
0
votes
1answer
180 views

Solidity shr opcode

What does this code mean? sender := shr(96, calldataload(sub(calldatasize(), 20))) Btw sender is an address variable.
0
votes
1answer
33 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
1
vote
0answers
19 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) { ...
0
votes
1answer
87 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 ...
3
votes
2answers
474 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; } } ...
0
votes
1answer
147 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 ...
0
votes
0answers
24 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 ...
2
votes
0answers
85 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 ...
1
vote
1answer
25 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/...
0
votes
1answer
92 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. ...
1
vote
1answer
66 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 ...
2
votes
0answers
36 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....
3
votes
1answer
235 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 ...
1
vote
1answer
92 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; ...
0
votes
0answers
39 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) { ...
0
votes
0answers
25 views

What is the purpose of EVM tags, their haphazard arrangement and their relationship to functions?

I want to understand the purpose of tags in EVM assembly and their relationship with Solidity function. pragma solidity ^0.5.1; import './Mod.sol'; contract MOFTest{ ModifiedBank mb; ...
1
vote
0answers
108 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 ...
5
votes
2answers
1k 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 ...
2
votes
0answers
64 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 ...
2
votes
1answer
259 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 ...
0
votes
1answer
30 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 ...
5
votes
1answer
245 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 ...
0
votes
1answer
170 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, ...
3
votes
1answer
249 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 := ...
2
votes
1answer
131 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 ...
3
votes
2answers
1k 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 ...
1
vote
1answer
306 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=...
1
vote
1answer
25 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?
2
votes
1answer
95 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....
0
votes
0answers
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 ...
0
votes
1answer
523 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?
0
votes
2answers
48 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 ...
0
votes
1answer
216 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, ...
4
votes
1answer
1k views

CREATE opcode: what does it really do?

I am looking at the docs, but cannot really understand what CREATE opcode does. I can tell that CREATE does create a new smart contract from a memory chunk, pass the gas value to this new contract, ...
0
votes
1answer
132 views

Which `EVM` bytecode is actually used to "deposit" the transferred Ether?

A quick question. Which EVM opcode is actually used to "deposit" the transferred Ether into the contract? From the EVM opcode list, there are only two opcodes related to the fund transfer: balance and ...
1
vote
1answer
166 views

why use up all the gasLimit when use assembly and revert together?

try to call erc20 token's transferFrom() using assembly(to save some gas), code like this: pragma solidity ^0.4.24; contract TestAssemblyAndRevert { function test(address from, address to, ...
1
vote
0answers
34 views

Why JUMP opcode costs more than the rest

Looking here, most of the basic opcodes are 3 while JUMP is 8. Wondering why this is, why the 3x multiplier on this instruction.
0
votes
1answer
59 views

Gas displayed on "Remix"

Is Gas displayed on "Remix" at function execution the same as when executed on the main net? I'm using the Javascript VM as the environment.
3
votes
1answer
522 views

Where can I learn to read a flow of opcodes and learn how to debug transactions?

There are many tools and visualizers to use to read through a transaction, but where can I go to learn how to understand this? Fore example, that first link has a series of opcodes (and their ...
4
votes
2answers
523 views

EVM SIGNEXTEND Opcode explanation

I am trying to develop my own small EVM. That is a good way for me to learn more about the bytelevel. I hadn't had any problems with most of the instructions, but there are a few, which I just don't ...
3
votes
1answer
660 views

How to deploy contract with bytecode from etherscan?

For example, I want to deploy a contract to my local testnet. But I only have its opcode from etherscan. How to deploy the contract with just those runtime bytecode?
1
vote
1answer
85 views

Are OPCODEs for ETH and ETC different?

I deployed an exactly same contract to both ETH and ETC. And I could see the contract doesn't work correctly only on ETC. contract ContractA { ContractB public BB; // Common constructor (...
1
vote
1answer
506 views

Opcodes PUSH, DUP and SWAP?

I studied EVM implementations and the bytecode sequences used by them. I wondered that there are three opcodes which are recognized by the EVM but actually are invalid opcodes. B0 PUSH B1 DUP B2 ...
1
vote
1answer
682 views

callvalue opcode, for what?

someone know what the opcode CALLVALUE is for? I would like to understand it well. Have you an example on which I can easily understand it?
2
votes
1answer
822 views

how are conditional JUMPI opcodes valid?

I've been reading this example from https://github.com/comaeio/porosity/wiki/Ethereum-Internals And I am wondering how some of these JUMPI operations are valid: loc_00000000: 0x00000000 60 60 ...