Is there any way in solidity to refer to the one calling the present function
Aug 24, 2021, 2:58 AM
Not the origin (tx.origin) and not the finisher (msg.sender), but the one calling the individual function
Aug 24, 2021, 2:58 AM
address(this)
Aug 24, 2021, 3:19 AM
This refers to the current contract
Not the function caller
Aug 24, 2021, 3:41 AM
msg.sender then
If it's another contract it will be this
Aug 24, 2021, 3:41 AM
Thats not working if the contract of the function calls another contract
But then it will be the contract
Aug 24, 2021, 3:42 AM
Yes, which is the caller
If my contract calls transfer() on your token, then msg.sender is identified in transfer() as my contract
Aug 24, 2021, 3:43 AM
Yes but what if i want the one that gets his tokens transferred to be a person and not the contract
The one deciding to call the initial function
That in the 2nd step calls transfer
Aug 24, 2021, 3:45 AM
require(msg.sender==tx.origin)
Aug 24, 2021, 3:45 AM
Thought about that too
Then use tx.origin
But sounds unclean
To me
Aug 24, 2021, 3:45 AM
you can find it in PCS auto-compounding cake pool
Aug 24, 2021, 3:46 AM
Require(tx.origin == msg.sender)?
Aug 24, 2021, 3:46 AM
Yes
Aug 24, 2021, 3:47 AM
Ok thanks
Aug 24, 2021, 3:47 AM
You can also use isContract
https://github.com/OpenZeppelin/openzeppelin-contracts/issues/1212
The guys at OZ prefer it - well it uses their libs too haha
Aug 24, 2021, 3:48 AM
Do you think this would work
what if i did
IBEP token = some address
function fancytransfer() {
require(amount >= 0);
require(msg. sender == tx.origin);
token.transferFrom(tx.origin, recipient, amount);
}
IBEP token = some address
function fancytransfer() {
require(amount >= 0);
require(msg. sender == tx.origin);
token.transferFrom(tx.origin, recipient, amount);
}
Aug 24, 2021, 3:48 AM
Yes that would work, or require(!isContract(msg.sender))
Aug 24, 2021, 3:49 AM
Ok thanks will look into that github tomorrow then
Aug 24, 2021, 3:50 AM
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol
Here
Aug 24, 2021, 3:50 AM
Thanks will look into it๐
Aug 24, 2021, 3:51 AM
Pleasure, if you need deeper help, I do custom development, or internal auditing, too.
Aug 24, 2021, 4:02 AM
whats your price for auditing
just curious
Aug 24, 2021, 12:04 PM