Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [opcode]

operation codes specify the instructions to be performed in machine languages

1
vote
1answer
32 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
0answers
27 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
35 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 ...
0
votes
1answer
44 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?
1
vote
0answers
29 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
22 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
32 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
24 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
47 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 ...
3
votes
2answers
51 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? ...
3
votes
2answers
131 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
24 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: [...
1
vote
2answers
123 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
46 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
53 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
0answers
47 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. ...
3
votes
1answer
74 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
93 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
194 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?...
1
vote
1answer
174 views

EVM opcodes-prices

1) Why are opcodes in Ethereum priced the way they are priced and why is die 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 ...
2
votes
1answer
47 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 ...
0
votes
1answer
48 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
173 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])) ...
0
votes
1answer
456 views

Transaction Error. Exception thrown in contract code. REVERT opcode when sending ETH to crowdsale

I wanted to follow the tutorial - https://blog.zeppelin.solutions/how-to-create-token-and-initial-coin-offering-contracts-using-truffle-openzeppelin-1b7a5dae99b6 - but there was a new release - https:/...
0
votes
1answer
104 views

Why is a state-modifying function working from Truffle console, but not when calling from web3?

I have a contract which offers two functions: 1) A state modifying function which takes two parameters 2) A constant function I have a web frontend in React calling these functions. When I call the ...
2
votes
1answer
715 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 { ...
3
votes
1answer
149 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
2answers
177 views

Why is using `<address>.callcode()` discouraged in Solidity?

The Solidity document says Note The use of callcode is discouraged and will be removed in the future. But in what reason is using <address>.callcode() discouraged? Is using CALLCODE ...
2
votes
0answers
92 views

Is it possible to get compiler version from the bytecode and smart contract code?

The problem is that I have deployed some contract on the etherscan.io some time ago. Now I want to verify it, so I need to specify: Smart contract code Compiler version ABI encoded constructor ...
0
votes
2answers
203 views

Why does an Oraclize contract deployed with Remix JavaScript VM gives an “invalid opcode error” and not on main/testnet?

Why does an Oraclize contract deployed with Remix JavaScript VM gives an "invalid opcode error" and not on main/testnet? I have thought why the Remix JavaScript VM reports the error: Exception ...
2
votes
1answer
271 views

Why does PUSH1 0x60 PUSH1 x40 MSTORE store 0x60 at memory location 0x50 (and not 0x40)?

According to browser solidity, after executing 000 PUSH1 60 002 PUSH1 40 004 MSTORE Memory is: 0x00: 00000000000000000000000000000000 ???????????????? 0x10: 00000000000000000000000000000000 ?????...
2
votes
1answer
113 views

Are makeLog instruction functions opcodes or not?

The following code snippet is a constituent piece of the instructions.go file, where our lieblings opCodes all live. // make log instruction function func makeLog(size int) executionFunc { ...
3
votes
1answer
618 views

why is the EVM stack limited to 1024?

Here you can see that if the EVM stack gets larger than 1024, it results in an error: Why is there this hard limit on the stack size? What is the justification for this not being parametrizable? ...
3
votes
1answer
342 views

does the command `evm --debug --code OPCODES` still work?

I've been trying to run this command evm --debug --code 600580600b6000396000f36005600401, and some associated permutations of it, such as: evm --debug --code ...
1
vote
1answer
92 views

Why does the EVM program counter not increase by one but by two in PUSH1 opcode?

In the tutorial here, the program counter increases by 2 for a PUSH1 opcode. Then it increases by 1 for other opcodes. Why is this? Does it have to do with the opcodes size in memory? Aren't they all ...
1
vote
2answers
127 views

filter to restrict output of opcode data only to contracts/functions called by local node

Having modified the instructions.go file in geth I'm able to see the execution time of individual opcodes, it looks like this: My interpretation of that output is that it represents the execution of ...
0
votes
0answers
245 views

log output of modified function to geth console

To analyze the execution time of different opcodes I've created the following modifications to the go-ethereum file instructions.go: func opAdd(pc *uint64, evm *EVM, contract *Contract, memory *...
5
votes
1answer
148 views

Are new Opcodes approved in EIP's implemented in Solidity before they are introduced in a hardfork?

REVERT, STATICCALL, RETURNDATASIZE and RETURNDATACOPY are all approved and pending the next Ethereum hardfork as specified here However, the Solidity changelogs shows all 4 of these opcodes entering ...
3
votes
1answer
218 views

evaluation of execution speeds for various opcodes in EVM

Using traceTransaction we can get the following data: debug.traceTransaction("0x0cec118d22fbd572bf25c7e4143919e608989bec7da08512f2a6f3171df3b3b8") { gas: 104030, returnValue: "...
2
votes
1answer
147 views

geth console flag/option to output all opcodes executed in call to contract or function invocation

What I'd like to do is analyze all the opcodes that are executed when I call a contract, or call a function from a contract. According to my understanding, this computation would happen on my own ...
2
votes
0answers
181 views

analysis of the opcodes used in smart contract execution on ropsten, geth

I've deployed the following verified smart-contract to ropsten: contract Incrementer { uint iteration; function Incrementer() { iteration = 0; } function increment(uint ...
3
votes
1answer
426 views

Why doesn't bytecode match the opcodes on Etherscan?

I'm just going through the first few opcodes on this contract: https://etherscan.io/address/0xab7c74abc0c4d48d1bdad5dcb26153fc8780f83e#code. Which are (according to the opcodes view): PUSH1 0x60 ...
4
votes
1answer
126 views

Why does the init code of a contract change for Solidity > 0.4.5?

I have a simple empty contract: contract test { } That I compile on Remix using different versions. I notice that the compiled output is getting more and more complex with later compiler versions: ...
1
vote
1answer
1k views

Where are the opcode 0xfe and 0xfd documented?

The Solidity documentation has the following: Internally, Solidity performs a revert operation (instruction 0xfd) for a require-style exception and executes an invalid operation (instruction ...
5
votes
3answers
295 views

Can a transaction have a negative fee?

I know there are some opcodes that have negative gas costs (see this). So if I send a transaction that calls one (or multiple) instance(s) of these opcodes, will the gas used be negative? i.e. will my ...
2
votes
1answer
452 views

Internal message call CALL opcode

I am trying to make sense of a contacts internal messaging. The contract is sending 6.6 ether to the address that invoked the contract. From what I understand, the CALL opcode carries out a ...
4
votes
2answers
354 views

Can the CALL opcode be used to create a contract?

The Yellow Paper Appendix H defines the CREATE and CALL opcodes. For CALL: the operand order is: gas, to, value, in offset, in size, out offset, out size. By setting the second operand (the "to"...
20
votes
1answer
7k 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?
5
votes
1answer
346 views

Can a contract fetch the global block gas limit?

The OPCODE GASLIMIT gets the block's gas limit. Could in-line assembly, uint gasLimit; assembly { gasLimit := gaslimit } fetch the gas limit ? contract B { function ...
11
votes
3answers
2k views

what is block.timestamp

In a function, does block.timestamp record the time the transaction was processed, or the time the block.timestamp computational step was processed? Is block.timestamp the time the transaction is ...