Questions tagged [msg.sender]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
23 views

How does ERC-4337 play with the Bundler and msg.sender?

We typically know thay msg.sender stands for the address who invoked the current method of a contract. Let's say that I have address A (which is a Smart Contract abstract account) and I want to send ...
Luis Masuelli's user avatar
0 votes
1 answer
14 views

How to build a 3 contract structure with delegatecall

I'm looking for help to build an intermediate contract using delegatecall. My challenge would be with 3 contracts. I need contract A to be the owner of Contract B, and contract B to have a ...
Leandro Loures's user avatar
0 votes
0 answers
10 views

Who is the msg.sender in the context when calling the "super.{....}" contract method on the inherited parent contract?

The child contract's method is: (1) function redeem( uint256 shares, address receiver, address owner ) public override andSync returns (uint256 assets) { return ...
Mila A's user avatar
  • 264
1 vote
1 answer
25 views

How can I execute a call from a contract using another contract?

I own a contract (contract A), which in turn, when deployed, created a secondary contract (Contract B). I have funds trapped in contract B, contract B, has a function that allows its owner to withdraw ...
Leandro Loures's user avatar
1 vote
1 answer
28 views

is this how delegatecall works? what other ways are there keep msg.sender the same when a contract is interacting with a different contract? [duplicate]

I recently started development on a personal project, and one of the suggested methods to achieve what i want was using delegatecall. Essentially I have a main contract that the user interacts with ...
pierre96's user avatar
0 votes
1 answer
26 views

delegateCall to a function of an upgradeable contract (TransparentUpgradeable)

I have the following TransparentUgradeable contract on ArbitrumOne: https://arbiscan.io/address/0x4582f67698843Dfb6A9F195C0dDee05B0A8C973F I want to call the function depositTokenViaUsdc() from a ...
user66732's user avatar
  • 435
0 votes
0 answers
25 views

Set the correct spender when calling gasless transferFrom from another contract with GSN

Actually I'm trying to figure out the best way to implement gasless call to transferFrom of a ERC-20 token. I'm not very familiar with GSN so maybe it could be a best way to achieve this. I wrote a ...
viac92's user avatar
  • 33
0 votes
1 answer
148 views

Who will be msg.sender in Multicall?

Good day to all, I know that msg.sender is eoa if multicall delegate some function to (this), but what if we will pass in callData selector of Multicall with params of other function? So eoa->...
dingo's user avatar
  • 57
2 votes
2 answers
171 views

How is this solidity function calling another solidity function without referencing it?

I wanted to create an NFT that chooses between an enum of 3 different NFT types. Also I wanted this choice to be decided at random so the minter doesn't know what type of NFT they'll get. I followed ...
ChristianOConnor's user avatar
0 votes
1 answer
113 views

How can I set amount value in address(this).balance

Like i want to Insert the value that how much ethers are transfer from my smart contract. I tried this second day but it's not working so i'm looking for solution any help is highly appriciated here ...
MindCoder's user avatar
0 votes
0 answers
35 views

How to compare two values of structs of the same msg.sender from different mappings

I'm having a Smart Contract contest among friends about who loses the most weight. Each competitor is expected to enter its weight at the beginning of the week and at the end of the week. The ...
Jean Paul Laclau's user avatar
1 vote
2 answers
579 views

How does `msg.sender == address(this)` work in compound protocol?

I was going through compound's Timelock.sol contract and found this function. function setDelay(uint delay_) public { require( msg.sender == address(this), "...
Shubham Sharma's user avatar
0 votes
1 answer
126 views

How to pass msg.sender to another function?

function sell(address useraddress, string memory propertyId) payable public { request storage sellingRequest = sellingRequests[propertyId]; require(!sellingRequest.users[useraddress], &...
Shubhankar Kumar's user avatar
0 votes
1 answer
26 views

Is it not necessary to use deployed contract for using interface?

I've been practicing Ethernaut Elevator problem. In this code, it just passing msg.sender to Building interface. But, I think that it should be passing deployed contract address of Building to use ...
Shift_that's user avatar
1 vote
2 answers
70 views

msg.sender not recognized

I am getting the following error for the code // SPDX-License-Identifier: MIT pragma solidity ^0.8.7 ; contract Variables { //Global variables uint public pubInt = 25; bool public truth = ...
drao's user avatar
  • 311
2 votes
2 answers
290 views

What is standard practice to cast msg.sender to "payable"?

Introduction I am working on a bounty contract. Here is the function for somebody answering the bounty. I am trying to figure out when it is better to cast to payable, it seems intuitively that always ...
Victor Forissier's user avatar
1 vote
0 answers
50 views

This is the source code for adding the token to the wallet, but the token is not added to the wallet [closed]

ERC20 Token smart contract: // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ERC20.sol"; contract Shinobi is ERC20 { constructor (...
Ali Hoosseini's user avatar
0 votes
1 answer
191 views

`msg.sender` instead of `tx.origin`

I am new to solidity but I have read at many times that tx.origin should be avoided & msg.sender should be used . There is a given demo on this in solidity page. It says like :- Never use tx....
Brijesh's user avatar
  • 43
1 vote
2 answers
157 views

why msg.sender always gives me 0x0000000000000000000?

I want to call a contract method like this: pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/...
Siwei's user avatar
  • 292
0 votes
1 answer
521 views

How is transferring to payable(msg.sender) costing less gas than transferring to an address?

Consider the contract: // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; contract Test { address payable public owner; constructor() { owner = payable(msg.sender); } ...
Shubham Sharma's user avatar
2 votes
2 answers
189 views

OpenZeppelin Context.sol, when to use & why?

When, and why is it better to use functions _msgSender() & _msgData() introduced by the Context.sol by OpenZeppelin, instead of msg.sender & msg.data?
David's user avatar
  • 153
0 votes
1 answer
214 views

transaction fail after calling transfer to the contract itself

I have this line in some function in an ERC721 contract: IERC20 instance = IERC20(token_address); instance.transfer(address(this),1); And when deploying the contract I make sure the caller of the ...
DavOriel's user avatar
0 votes
1 answer
163 views

Need to specify the amount with payable(msg.sender)?

I am working through Mastering Ethereum and have been building their first example Faucet Contract. I recognize that a lot of their syntax is out of date, and written in ^0.4.19. I've been writing it ...
jud21's user avatar
  • 1
0 votes
1 answer
44 views

I accidentally sent my KINDER (BNB token) to the KINDER token contract address. Can I get them back? (I believe I have the source code too)

I was trying to send some of my KINDER tokens to another wallet I own and somehow I sent it to the KINDER token contract address. I have since reached out to an admin in the KINDER telegram group. He ...
kadence1's user avatar
1 vote
1 answer
111 views

How to send ether from smart contract to a particular address

I initially transferred some ether into the smart contract when deployed and in one of the function I should be transferring ether to the address of the msg.sender. Help me out if you can!
qwak's user avatar
  • 11
0 votes
1 answer
228 views

What are the input parameters for keccak256?

I'm trying to interact with a smart contract in python. With Metamask i can see, that there is a signature trasferred to verify my wallet. Now the point is how to calculate this signature to use a ...
EthNoob's user avatar
1 vote
2 answers
7k views

Error: Returned error: unknown account - Web3 be the msg.sender of a functioncall to a Contract

i trying to call the function getRewards() from this contract: https://polygonscan.com/address/0x4AB071C42C28c4858C4BAc171F06b13586b20F30#code This function use msg.sender to give me the rewards to my ...
CErdtmann's user avatar
1 vote
1 answer
742 views

how to use the value of msg.value and msg.sender of a contract, when a function calls a different contract

I'm studing Solidity and tring to understand how it works. Starting from Safe Remote Purchase in the "Solidity section by example" the doc (https://docs.soliditylang.org/en/v0.8.12/solidity-...
juole's user avatar
  • 13
1 vote
1 answer
342 views

When does msg.sender change?

If a function inside a contract calls another function in the same contract, is the msg.sender now the contract or still the original address that sent the initial transaction? I know if contract A ...
degendeveloper's user avatar
1 vote
2 answers
512 views

What kinds of functions are executed on-chain vs. off-chain?

I was building a withdrawal function for a contract that was using msg.sender.call{value: balance}, after checking that the given msg.sender was registered in the contract and had the given balance; ...
user avatar
2 votes
2 answers
4k views

How to send ether from msg.sender to another address from within the contract

I'm new to solidity and I'm currently experimenting with smart contracts. As shown in the code below (only a part), I want to write a contract that lets you borrow money by paying a fee. I implemented ...
fastRatt's user avatar
0 votes
1 answer
315 views

How to input a value into a function without parameter on Remix?

I read this where it has a function deposit() as below, without any parameter. We are supposed to send a value to msg.value but how do you do that in Remix as I can't find one text field for deposit ...
vagef53574's user avatar
2 votes
0 answers
117 views

How to connect wallet / set caller for Read Contract buttons on Etherscan?

When I use the "Read Contract" tab on Etherscan, it works even if I didn't "connect" by Web3 wallet. It seems to be reading the blockchain passively. The thing is, one of the ...
Gregory Magarshak's user avatar
0 votes
1 answer
167 views

How to create a "hasBalance" modifier in solidity for any token address?

I've been researching if it's possible to create a modifier that checks if msg.sender has any given amount of a token address. Use Case: limit certain functions to owners of a given token or NFT. I've ...
matlemad's user avatar
1 vote
1 answer
194 views

If a contract call fails at require is the ethereum value returned to msg sender?

According to this and this answer any remaining gas after a require statements assert condition fails is returned/refunded back to msg.sender but what about any ETHER sent in that transaction call i.e....
MShakeG's user avatar
  • 1,418
0 votes
1 answer
284 views

Solidity 0.4, send ether through smart contract

I am struggling to find how to send ether value through a smart contract on the version of solidity 0.4. I know by experience that we can use: contract.deposit{value: 1 ether}(); from the version 0.6 ...
oktapodia's user avatar
  • 467
2 votes
1 answer
6k 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
  • 125
2 votes
1 answer
4k views

payable(msg.sender)

pragma solidity ^0.8.4; contract Contract { address payable public owner; constructor() public { owner=payable(msg.sender); } } msg.sender is of type address by default? so I ...
Engin YILMAZ's user avatar
2 votes
1 answer
1k views

Who is msg.sender when function calls a function within the same contract?

So yeah, who is the msg.sender if a function calls another function within the same contract? contract A { function doSomething() { do2(); //msg.sender == the user } ...
smenir443's user avatar
  • 125
0 votes
1 answer
348 views

How to Calculate Jager using msg.value on Binance Smart Chain?

Very quick and likely easy question here. I am trying to code a crowdsale contract that accepts BNB and returns a number of tokens to the sender. My transactions keep failing because it says the BNB ...
Austin's user avatar
  • 21
2 votes
1 answer
3k views

Using different accounts for executing a function in solidity unit testing

I have written a smart contract and within which I have declared a payable function where everyone could send their funds to the contract. Once they have transferred their funds, they would have the ...
Sina Rahimi's user avatar
0 votes
0 answers
780 views

msg.sender and msg.value - do they work only for sent Etherum or do they work for ERC20 tokens sent to the contract too?

I'm starting to learn Vyper and I wanted to ask a question regarding msg.sender and msg.value If I created a simple contract that simply returns msg.sender and msg.value I understand that if I sent ...
Christian Papathanasiou's user avatar
1 vote
1 answer
1k views

Can someone sign a transaction and have someone else broadcast it and pay the transaction fees?

Can someone sign a transaction, maybe for sending funds or for smart contract interaction, and have someone else broadcast it and pay the transaction fees? Or is it that the signer of the transaction ...
YulePale's user avatar
  • 1,823
3 votes
1 answer
335 views

What is value of msg.sender when reading contract on etherscan or bscscan?

When I look at a contract on etherscan or bscscan, it is possible to read the contract, which basically just calls a public function of the contract. But what value is used for msg.sender when I read ...
Marc's user avatar
  • 257
4 votes
3 answers
712 views

How to prevent front-running the salt when using CREATE2?

I was looking at Optionality's clone-factory, which is based off EIP-1167, and wondering whether it can be ported to use CREATE2. One concern is that a third-party could, in theory, "front-run&...
Paul Razvan Berg's user avatar
0 votes
1 answer
86 views

Sending tokens to and from a contract address

I have a contract that's responsible for distributing an ERC20 token to a list of addresses. In the contract there's a function that simplifies to something like: function sendTokenToAddresses(uint ...
Rolan's user avatar
  • 135
0 votes
1 answer
782 views

TypeError: Member "isContract" not found or not visible after argument-dependent lookup in address

pragma solidity ^0.8.4; This modifier: modifier onlyNotContract() { require(!msg.sender.isContract(), "Contracts are prohibited"); _; } Is generating this error: ...
alpo's user avatar
  • 164
0 votes
1 answer
191 views

Get the sender address in ContractB when called from ContractA

I have 2 contracts A & B. A calls one of the methods from B. How do I get the caller address in that method of B? Usually msg.sender in A will give the address of caller but we cannot do the same ...
NinjaMAN's user avatar
  • 409
0 votes
2 answers
127 views

Would an EOA's balance change within the same transaction?

I'm trying to understand various aspects of the micro-process of a transaction such as how msg.sender's balance is changed prior to and after a transaction is mined. Is the balance updated after the ...
Maxareo's user avatar
  • 633
4 votes
3 answers
4k views

How can msg.sender == address(this)?

I know that msg.sender will be the address that connects to the contract. Address(this) is the current contract address Then == means it connects to itself. When using this condition in require, the ...
Jem's user avatar
  • 99