Linked Questions

1
vote
0answers
110 views

What are the differences between msg.sender, tx.origin, and ethereum accounts? [duplicate]

I am trying to solve the problem of contract access and I understand from the very informative documentation that owner should be assigned to msg.sender by a constructor when the contract is created. ...
1
vote
0answers
56 views

msg.sender and tx.origin - how to use them in practice? [duplicate]

I wrote a contract A that uses msg.sender for authentication: When A creates an item it stores msg.sender in itemsOwners mapping (itemOwners[itemId] = msg.sender;). Later A compares msg.sender to ...
1
vote
1answer
40 views

What does msg.sender == tx.origin actually do? Why? [duplicate]

A lot of contracts use require(msg.sender == tx.origin) What is the purpose of it? When should you add this code? What difference does it make if the msg.sender is not a tx.origin? And in which cases ...
26
votes
5answers
12k views

How does a contract find out if another address is a contract?

Is it possible, from within a contract written in Solidity, to check if a contract is placed on a specific address or if this address does not contain any code?
39
votes
1answer
5k views

How do I make my DAPP "Serenity-Proof?"

When Serenity comes around, the network will undergo many changes, some of which may have unexpected consequences on existing Smart Contracts. How can I plan so that I am best prepared to take ...
16
votes
2answers
4k views

isContract function using EVM assembly to get the address' code size

My problem is that I need to make sure my contract processes only the transactions coming from EOA (externally owned accounts). For this I need to determine the type of account I'm dealing with. In ...
8
votes
5answers
1k views

What are legitimate uses of tx.origin?

It is known that msg.sender must be used for authentication instead of tx.origin (the difference explained here). Some static analysis tools (e.g., in Remix) detect all usages of tx.origin as ...
10
votes
2answers
1k views

Is it possible to call another contract from a contract maintaining the msg.sender of the original caller?

Imagine that Alice calls a contract method C1 and that method calls another method in contract C2. Regularly msg.sender equals the Alice Account in the C1 method. And msg.sender equals the C1 ...
4
votes
1answer
1k views

Can a contract be the owner of another contract and kill it?

How can contract B (created and owned by contract A) verify that contract A invoked the kill method? (Is msg.sender the same for contract A and B or is msg.sender the address of contract A when A ...
0
votes
1answer
958 views

Correct way of sending Token via contract

[Sender] -> [My Contract] -> [ERC20 Contract] The sender invokes my Contract, and my contract in turns will invoke ERC20 contract to Transfer token on behalf of the senders (using his msg....
0
votes
1answer
2k views

DeclarationError: Undeclared identifier. But already declared

DeclarationError: Undeclared identifier.on line 8,12,14.
0
votes
4answers
2k views

How to pass the external account address to the contract function when calling another contract

If we deploy the contract B, and pass the contract B address to the contract A. When call the contract B function from the contract A, inside the contract B function, the msg.sender is the "address ...
2
votes
1answer
1k views

What is the format for sending erc20 token to multiple address?

Code contract ERC20 { function transfer(address _recipient, uint256 _value) public returns (bool success); } contract Airdrop { function drop(ERC20 token, address[] recipients, uint256[...
4
votes
1answer
248 views

tx.origin alternative

I couldn't find an appropriate, simple fix of the tx.origin vulnerability, without having to use any modifier, any help is very much appreciated, thanks, PS: msg.sender is not what I'm looking for (...
2
votes
2answers
374 views

Tx.origin and msg.sender when sending signed Raw transaction

A client with address A signs a raw transaction, and leaves it all ready to be sent, gives it to the server with address B, which later will send it with sendSignedTransaction(...). What will be the ...

15 30 50 per page