Linked Questions

2 votes
1 answer
7k 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 ...
smenir443's user avatar
  • 135
1 vote
0 answers
121 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. ...
Trevor Lee Oakley's user avatar
2 votes
0 answers
73 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 ...
porton's user avatar
  • 1,854
42 votes
7 answers
29k 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?
Thorkil Værge's user avatar
48 votes
1 answer
8k 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 ...
Tjaden Hess's user avatar
  • 37.3k
20 votes
2 answers
8k 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 ...
manidos's user avatar
  • 4,308
11 votes
5 answers
2k 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 ...
Sergei Tikhomirov's user avatar
11 votes
2 answers
3k 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 ...
jbaylina's user avatar
  • 775
5 votes
1 answer
640 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 (...
Arsalen's user avatar
  • 65
4 votes
1 answer
2k 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 ...
stefreak's user avatar
  • 155
3 votes
2 answers
736 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 ...
ranchalp's user avatar
  • 540
2 votes
4 answers
3k 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 ...
R.Grove's user avatar
  • 21
0 votes
1 answer
1k 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....
s k's user avatar
  • 886
0 votes
1 answer
2k views

DeclarationError: Undeclared identifier. But already declared

DeclarationError: Undeclared identifier.on line 8,12,14.
胡镡文's user avatar
0 votes
1 answer
1k views

deletegateCall to change contract's ownership

I am currently going deep into some Solidity functionalities and I would like to be able to change a contract's A ownership from a contract B, knowing that the caller of contract B is the owner of ...
Dario Anongba Varela's user avatar

15 30 50 per page