Questions tagged [opcode]

operation codes specify the instructions to be performed in machine languages

Filter by
Sorted by
Tagged with
3
votes
0answers
32 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 ...
4
votes
3answers
386 views

convert bytes to uint8[8] using mstore()

I know how to convert bytes to uint8[8] using mload but mstore seemed like it could be more gas efficient. Is something like this possible? function bytesToUintArray(bytes input) returns (uint8[8])) ...
1
vote
1answer
18 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
1answer
132 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=...
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) { ...
8
votes
1answer
773 views

Is the cost of updating storage different than the cost of adding to storage?

Do these have a separate cost? sstore(1, 10) # first time adding a value to storage with this key sstore(1, 20) # changing the value in storage. I looked for a list of gas costs / opcodes, and the ...
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; ...
34
votes
2answers
13k views

Is there a table of EVM instructions and their gas costs?

The EVM instructions are in the yellow paper, or they are summed up in this answer. But their gas costs are not there. Where can I find a list of all instructions with their associated gas costs?
0
votes
0answers
15 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 ...
1
vote
2answers
40 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 ...
2
votes
0answers
56 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
50 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
2answers
132 views

Why return to String need so many operations when develop a smart contract?

I found a smart contract. The address is '0x2fabe69843e9a74a35b89145cb52e5568986c7a1'. I am really confused about is that why it need over 3000 lines Opcode to when Created this smart contract? Like ...
1
vote
1answer
31 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
16 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 ...
1
vote
1answer
208 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. ...
2
votes
1answer
366 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?
0
votes
0answers
24 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
35 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 ...
4
votes
3answers
1k views

Understanding solidity inline assembly code

Here is a code from solidity documentation: function sumAsm(uint[] _data) public returns (uint o_sum) { for (uint i = 0; i < _data.length; ++i) { assembly { ...
0
votes
1answer
34 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
74 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
105 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
775 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
290 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
106 views

How to code ADDRESS using opcodes in a solidity function?

Reference - http://solidity.readthedocs.io/en/develop/assembly.html Objective - example of a function returning the contract address. Code - pragma solidity ^0.4.18; contract d4{ function ...
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
79 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....
2
votes
1answer
676 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 ...
57
votes
5answers
16k views

How can you decompile a smart contract?

On the blockchain I can inspect the code of a contract, and see the EVM opcodes. Is there a way to decompile this and convert it back to (Solidity) source code?
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 ...
5
votes
1answer
476 views

What are the reasons behind jumpdest?

I know, the practical reasons behind it is just to add additional security layer. But why does EVM even need it? Asm doesn't have it and works great.
0
votes
1answer
112 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
719 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
81 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
89 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.
1
vote
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
336 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
349 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 ...
1
vote
1answer
74 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 (...
60
votes
2answers
22k views

What OPCODES are available for the Ethereum EVM?

The Ethereum virtual machine has a large number of operation codes and base level instruction sets. Is a complete listing available?
2
votes
1answer
751 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 ...
4
votes
2answers
733 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 ...
0
votes
1answer
244 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 ...
2
votes
1answer
450 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?
3
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
78 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
255 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 ...