73

DELEGATECALL basically says that I'm a contract and I'm allowing (delegating) you to do whatever you want to my storage. DELEGATECALL is a security risk for the sending contract which needs to trust that the receiving contract will treat the storage well. DELEGATECALL was a new opcode that was a bug fix for CALLCODE which did not preserve msg.sender and ...


3

So basically the gas is specified as how much gas the sender willing to pay to send the money to the "msg.sender" This claim is not correct. To understand what's going on, you need to have a basic understanding of how a low-level call is executed (the yellow paper or this paper) are good starting points. Essentially, when a call is performed (implicitly, ...


3

So there is some unexpected behavior in the solidity compiler: https://github.com/ethereum/solidity/issues/2999 Works on pragma experimental "v0.5.0"; with compiler 0.4.18.


3

The general answer is that it follows the conventions of the ABI. You can work it out based on those rules. In this particular case, the encoding of data will start at position 36. The first four bytes will be the message signature, and the next 32 will be a pointer to the location of data's representation. Note that the first 32 bytes of data will give ...


2

You can use the manually-maintained directory at https://www.4byte.directory to search for the method given the signature. Here is the lookup for your example 0x3ccfd60b. There are further plans for the use of this directory like moving the lookup table into a smart contract - see https://github.com/ethereum/mist/issues/955.


2

No, means that if you use delegate call in your contract and the code at the target address contains a line with selfdestruct(someaddress), this code will be executed in your contract context, effectively destroying your contract. This means you should be careful when using delegatecall and only use it in contracts that you wrote or that you know well. ...


1

While you have knowledge about the code of Contract1 you can call the function directly. You can declare the return arguments (arg1, arg2) with the call. pragma solidity ^0.5.1; contract Contract1 { function func(uint256 x, uint8 y) public returns (uint32, uint32) { return (uint32(x), uint32(y)); } } contract ...


1

Simple way uint private constant MAGIC = ...; // Your birthday here uint private magic = MAGIC; function isDelegated () internal view return (bool) { return magic != MAGIC; } The idea is that MAGIC is compile-time constant, so it will be embedded into the byte code by Solidity, but magic is state variable. When contract is called normally, magic == ...


1

Unfortunately a contract can't handle raw transactions. We would face all sorts of new issues if it was possible (such as who pays for the gas). Nothing prevents you from creating your own contract which transfers tokens and triggers another contract. But this way the contract would have to own the tokens itself so they'd need to be transferred to the ...


1

Transactions are included in a block in a specific order. In your example, even if both transactions are in the same block, one will come before the other. In this case, the first tx in the block's tx list will become the super hero, and the price will increase to 2 ETH. When the second tx is executed, it is executed in a version of the smart contract ...


1

I think I found what was the problem: lack of double quotes. When instantiating the Smart Contract using the literal ABI from https://ethereum.github.io/browser-solidity/ everything works! > var greeter = eth.contract([{"constant":false,"inputs":[],"name":"kill","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"greet","...


1

I don't think so. As I understand it, Solidity takes the first few bytes of the sha3 hash of the contract's signature to identify methods. It can't be done in reverse unless you already had the source code.


1

The problem has to do with how variables arranged in the storage. The storage of the called and the calling contract should match. The answer to this question can be found here https://github.com/ethereum/solidity/issues/944


1

Showing the difference between the call, callcode and the delegatecall we can consider the example of the following code : Contracts can interact in three ways Call : By directly calling from a contract through a function which will not set the caller's value but sets the callee's value. And sender in this will be the caller only CallCode : When called ...


Only top voted, non community-wiki answers of a minimum length are eligible