Questions tagged [opcode]

operation codes specify the instructions to be performed in machine languages

Filter by
Sorted by
Tagged with
2
votes
0answers
21 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
62 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
23 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
26 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
14 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; ...
0
votes
0answers
20 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 ...
2
votes
0answers
99 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
51 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 ...
1
vote
1answer
51 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
17 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 ...
0
votes
0answers
35 views

Does the EVM have an opcode to check private key signatures?

I have plain and simple desire. I want my dapp users to be able to generate some data payload, sign it with their private key, and send it using any external channel (eg JSON between apps) to a ...
4
votes
1answer
41 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
47 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, ...
2
votes
1answer
90 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
112 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
881 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 ...
0
votes
1answer
155 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
16 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
85 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
20 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
332 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
42 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
123 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, ...
3
votes
1answer
782 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
85 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
95 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
27 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
51 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.
2
votes
1answer
358 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 ...
3
votes
2answers
366 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 ...
2
votes
1answer
398 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
75 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 (...
0
votes
1answer
264 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
474 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
758 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 ...
2
votes
0answers
40 views

What do last few opcodes of a smart contract do? [duplicate]

I built a sample smart contract, then I looked at the opcodes, and always found similar opcodes at the end - for all samples I tried - like below. a1 log1 65 62 7a 7a 72 30 58 push6 627a7a723058 20 ...
2
votes
1answer
81 views

how are negative numbers stored within the EVM stack?

for example, I have these opcodes: PUSH60 PUSH40 SUB for sub operations, I believe that the second stack item is subtracted from the first stack item (60 - 40) which would equal to -20 being the new ...
1
vote
0answers
34 views

Code scope in evm

Short question, how is code scope defined/determined by the compiler when looking at EVM opcodes (or rather bitcode)? Is it simply by looking out for jump calls or return statements? Or does it define ...
2
votes
2answers
268 views

CALL instruction push GAS to stack?

According to https://ethervm.io, when CALL instruction is executed, the stack layout like this: [address, value, argOffset, argLen, retOffset, retLen] So CALL would pop 6 words from stack bottom to ...
4
votes
2answers
394 views

Ethereum opcode: meaning of first few instructions?

Looking at the opcode level, the first few instructions of any smart contracts start with this: push1 80 push1 40 mstore I understand that this saves 0x80 to address 0x40, but what is this all for? ...
4
votes
2answers
775 views

How to separate functions in evm bytecode?

I want to build the control-flow-graph (CFG) from the bytecode of a smart-contract (assuming it is obtained by compiling a Solidity source file). This CFG should also distinguish the different methods ...
1
vote
1answer
77 views

Pushing bytes to EVM stack

I am sorry if this question seems to be somewhat bad, but I am trying to work out the stack representation of the following opcodes: PUSH1 60 PUSH2 40 would the stack representation of this be: [...
3
votes
2answers
388 views

How can we implement a new opcode in the Ethereum Virtual Machine.

How can we implement a new opcode in the Ethereum Virtual Machine. For eg : I want to implement an opcode logic such that the opcode number of this operation is 0x21. The EVM-implementation I am using ...
0
votes
1answer
155 views

What’s the purpose of the delegatecall second target parameter?

Simple question, but I couldn’t figure the answer. Are there plans/EIP to use the second parameter of DELEGATECALL ? Or am I wrong (in which case the parameter isn’t ignored) ? In c++ Ethereum evm ...
1
vote
1answer
375 views

What’s the opcode chain for sending ethereum from a smart contract?

Simple question, but I couldn’t find the answer anywhere. I know CALL is used and sometimes CALLER, but I don’t have any idea on how msg.sender.call.value(100) would be performed.
1
vote
1answer
225 views

What happens in CALL when gas is set to 0?

Reading the documentation on the CALL opcode : "call contract at address a with input mem[in..(in+insize)) providing g gas and v wei and output area mem[out..(out+outsize)) returning 0 on error (eg. ...
4
votes
1answer
196 views

How are storage pointers implemented in the EVM layer?

I'm trying to understand how storage pointers work. From looking at the ethereumjs-vm implementation it seems that the actual value is returned from SLOAD. Does the compiler handle the 'pointer' ...
0
votes
1answer
312 views

How does message call send gas?

contract Sample{ event Data(uint test) ; function test2() { Data(msg.gas) ; } } contract Sample2{ function try(address addr){ Sample(addr).test2() ; addr.call(...
2
votes
3answers
882 views

Updated list of EVM Opcodes

Is there an updated Opcode Specifications available for the EVM to date? Specifically, is there a continuously updated list of Opcode Specifications similar to that found in the ethereum yellow paper?...
2
votes
1answer
707 views

EVM opcodes-prices

1) Why are opcodes in Ethereum priced the way they are priced and why is the EVM so expensive? 2) Right upfront, I do not say that it is too expensive to perform a tx on Ethereum, I just say that ...