Questions tagged [payable]
The payable modifier in Solidity can be used to make smart contract functions able to receive either, or to make Ether transfers to address variables possible.
260 questions
2
votes
1
answer
21
views
Does delegate calling to a non-payable function result into a revert?
I have a payable function that takes an array of call datas as input, to which it delegate calls one-by-one:
function batch(bytes[] calldata calls) external payable override {
uint256 count = ...
0
votes
1
answer
33
views
EvmError: Revert, Foundry when call Payable transfer from testContract with a proxy
I am getting a EvmError: Revert when I am trying to withdraw native token from the first contract to the second contract.
I do not know if this is an Foundry issue because we add in a 3rd contract (...
0
votes
1
answer
36
views
Why is the function throwing an error when called from another contract but not when called independently?
I have 3 solidity contracts, main.sol, provider.sol and allowance.sol
Now from main.sol, I am calling a function "Transact", which calls another function "Transact" in provider.sol ...
1
vote
1
answer
240
views
Payable multi-delegatecall
I have a code of multi-delegatecall like this:
function multicall(bytes[] calldata _data) external payable returns(bytes[] memory _results) {
_results = new bytes[](data.length);
for (uint256 ...
0
votes
1
answer
33
views
i am compiling this lottery contract but the picWinner and getPlayers are not working
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0;
contract lottery{
address public manager;
address payable[] public players;
constructor(){
manager = msg.sender;
}
...
0
votes
1
answer
45
views
contract keeps reverting but gets depoyed when i don't send a value and does not deploy when i send a value
Here is a screenshot of remix and my smart contract also the gas limit and amount of ether I am sending in the value field, but it still reverts only deployes when i don't send a value. And ever after ...
0
votes
3
answers
557
views
How to call external payable function in one contract from another in solidity
I get an EVM exception, when trying to call the external method of a payable function.
This is the called function
contract ContractA {
receive() external payable {}
function bookTicket() external ...
1
vote
1
answer
14
views
I am trying to build a p2p energy transaction
I am trying to build the p2p energy transaction blockchain network.
TypeError: "send" and "transfer" are only available for objects of type "address payable", not &...
1
vote
1
answer
32
views
remix.ethereum.org - you cannot test payable methods
I am using: https://remix.ethereum.org
contract:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Receiver {
receive() external payable {}
function getMoney() public payable ...
0
votes
1
answer
990
views
.call{}() in solidity
This is a Smart Contract written in solidity, compiled and deployed in remix
// SPDX-License-Identifier: MIT OR Apache 2.0
pragma solidity ^0.8.8;
contract Payable{
// payable address can send ...
0
votes
0
answers
37
views
I used payable function for fund transfer but getting revert transaction error
Function which I try to executre
function executeSale(
uint256 tokenId,
address _account
) public payable {
uint price = idToListedToken[tokenId].price;
address seller = ...
2
votes
1
answer
146
views
Can `msg.value` be trusted to remain the same after an external call?
Can msg.value be trusted to remain the same after the weth.deposit call in the foo function?
pragma solidity >=0.8.19;
interface WETHLike {
function balanceOf(address account) external view ...
0
votes
1
answer
32
views
Payable function issue
I am playing around with smart contracts and decided to build a simple contract for an eCommerce store. The contract allows the owner to add items to the contract with price in USD, it allows the ...
0
votes
1
answer
19
views
Any alternatives to reducing msg.value without resorting to refunds?
In my contract, users are required to deposit a specific amount of Wei. I want to prevent users from overpaying and need to decrease the value of msg.value.
Currently, I'm refunding the difference, ...
0
votes
1
answer
20
views
Do I have to mark addresses that I want to send ETH to in vyper as payable?
In solidity, if I want to send ETH to an address, I have to mark it as payable.
Do I need to do this in vyper?
Solidity example:
payable(msg.sender)
2
votes
2
answers
175
views
Contract with a struct argument can't receive ETH?
I have this minimal contract
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
struct Order {
address trader;
uint256 amount;
}
contract Test {
event Received(address, uint256);
...
2
votes
2
answers
2k
views
I can't deploy a contract with payable function
I am a total beginner and I just started the Patrick Collins's course on youtube.
I apologize for my stupid question but I didn't find similar topic and I have been struggling with this issue for 2 ...
1
vote
2
answers
182
views
2 transactions in 1 block. Anty drainer erc20
I have 2 wallets: on the first - eth, on the second - erc20 tokens.
I need to put 2 transactions in one block:
sending eth for gas from wallet 1 to wallet 2.
sending erc20 tokens to another wallet.
...
1
vote
1
answer
389
views
Can I make a payable function with zero ether value?
I have a payable function in solidity with the price to pay that can be dynamic, in particular, sometimes it can be 0. I can correctly call the payable function when the price is higher than zero, but ...
1
vote
2
answers
87
views
I have an "address payable", not "address" error [duplicate]
I have an error "TypeError: "send" and "transfer" are only available for objects of type "address payable", not "address"" on
function withdraw() ...
1
vote
1
answer
181
views
"Converting Address to Address Payable - Need Assistance"
below is my code :
function withdraw() external isOwner() {
address payable owner = address(uint160(getOwner()));
owner.transfer(address(this).balance);
}
what is wrong in the ...
1
vote
3
answers
3k
views
Can the smart contract automatically send the amount received to the owner's address or any fixed address defined in the contract?
Can we have a smart contract that when an amount is deposited into it, it will automatically transfer it to the owner's wallet address? I mean, as soon as the amount is received, the smart contract ...
2
votes
1
answer
632
views
How can msg.sender call a payable function with set price from another contract?
hello everyone and happy '23.
I'm having issues sorting out the following system.
Contract TipWallet: receives tips with a takeTip() and updates the tip +1 every time it receives one.
Contract Tipper: ...
0
votes
2
answers
252
views
Execution Reverted : Burn token and redeem ethers
I'm developing two contracts:
Tokens :
ERC20Burnable Transparent Upgradeable Proxy - contract minting a token 1:1 for each ethers sent.
Machine :
Transparent Upgradeable Proxy - contract accepting ...
1
vote
1
answer
44
views
Function reverts every time I call it
I am trying to write a Prediction Markets smart contract in Solidity. Whenever I call the following function in Remix, the function is reverted, even though all the parameters and require statements ...
0
votes
2
answers
668
views
Why do I get the "Error: non-payable method cannot override value" when both the function and constructor are payable?
I have ran into a strange problem. I get an 'Error: non-payable method cannot override value' when I try to send some ethereum to the smart contract via the transfer function. Here is the smart ...
1
vote
1
answer
1k
views
How to accept stabel coins such as USDT/USDC in a contract? [duplicate]
I am trying to create a contract in solidity that can accept ERC20 tokens more specifically stable coins like USDT/USDC. I am not sure how to make a minimum token amount to be paid. I have a basic ...
-1
votes
1
answer
145
views
sending eth to a specific address
i want to develop a contract where. when the function Optimizer is called it will send a specific amount of eth to a specific wallet address, problem is the wallet address is not receiving the amount ...
1
vote
1
answer
57
views
Payable function won't get executed (gas estimation fails)
Hey guys I am trying to create a function that would send Ether to a contract based on how many "USD" I put into an argument. But it keeps failing to estimate the gas and thus the ...
0
votes
1
answer
748
views
how to send wei unit in call [duplicate]
In a contract i was trying to send ether in wei units using the call method.
or is there any way to send fractions of ether like 0.048 ,
i wanna send 0.048to my contract from an account which ...
1
vote
1
answer
78
views
I tried to make a function that does the same operation both in ERC20, ETH. But I don't know how to do modularize it considering payable
I wanted to do commit both on ERC20 Token and ETH. _addCommitment function is about update local commit value. It will be better if two functions that work the same function can be combined into one, ...
0
votes
1
answer
28
views
Can EIP-1155 be implemented so that all the functions bring a set amount of money to a specified wallet?
So I want to make a penalty on all the transfers (with a const value). Can this be implemented, or if not what does prevent it?
1
vote
1
answer
24
views
Method calling with {} before the ()... what's the name of this calling, what is this {}'s terminology
function setXTransferETH(address otherContract, uint256 x) payable external{
OtherContract(otherContract).setX{value: msg.value}(x);
}
As above method, the calling with {} before the ()......
0
votes
1
answer
183
views
Unable to deposit ether inside contract using receive function
Code is :
contract sendEther{
//to send ether, we need to deposit some ether first in this contract
//We can do it by declaring constructor as payable which enables us to deposit some ether ...
1
vote
2
answers
626
views
Payable Function Modifier
I am currently running through a tutorial and am wondering if someone can explain when I need a payable modifier? For example, I have the below code and am unsure as to exactly why I would need to ...
1
vote
1
answer
154
views
how can i check hashcode and th amount
I'm new in Solidity, therefore if I have a wrong concept of anything kindly do explain.
I'm working for a personal escrow smart contract that should include these functions:
1- function deposit from ...
3
votes
3
answers
223
views
Is is possible to withdraw ETH without payable?
I'm practicing How to Build a Staking Dapp example in Alchemy.
In Staker.sol, there's a withdraw function which hasn't a payable keyword. But it does work. Isn't it necessary to use 'payable' when ...
3
votes
2
answers
442
views
Difference between address payable and payable(address)
What is actually the difference between address payable and payable(_address)
1
vote
1
answer
29
views
why contract is saving the ether in contract rather than sending it directly to senders wallet
Why the below code is saving the ether to the contract address rather than just directly sending it to sender ?
In remix**
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.12;
contract payablee {...
2
votes
2
answers
395
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 ...
0
votes
1
answer
541
views
When to use a payable function vs. a receive function
This SO answer explains the differences between using a function marked with payable versus the contract implementing a receive function and then sending ETH directly to the contract: why contract ...
2
votes
0
answers
28
views
payable extension required?
I am writing a simple contract to replicate a voting session led by a president. The contract compiles correctly, however, I can't deploy it because of the following error: "Note: The called ...
0
votes
1
answer
28
views
Connect Recipient Wallet - 'receive' function not defined
sorry to bother, trying to get an acknowledgment that my sender(msg.sender) address is sending to the receive() external payable. compiles fine, doesn't deploy correctly to show +1ETH in recipient ...
1
vote
1
answer
483
views
How is this scam code transferring tokens to the unspecified wallet within?
Below is the exact solidity code that the scammer were manipulating people to run by themselves. I checked that there is no wallet address specified within the code but this code will transfer the ...
0
votes
1
answer
36
views
Is the method call along with the book-keeping to send funds to a smart contract and the transaction to actually transfer funds separate?
I am new to ethereum or any blockchain for that matter. I have conceptual questions after looking at the "Fundme" example from freecodecamp.
The simplified fund() method does simple book-...
0
votes
2
answers
896
views
function depositTokens doesnt work in remix ethereum , please help
error in remix:
Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? Internal JSON-RPC error. { "code": 3, ...
0
votes
1
answer
51
views
Why is my mint function adding an extra gwei to mints?
I have been testing out my NFT smart contract on Rinkeby to test out interaction on the front end. I have done many testnet mints with this same function, but the last two times that I have tried the ...
0
votes
1
answer
998
views
Unable to transfer eth into contract in hardhat
I am working on some ERC20 tokens in which user have to send it to get tokens,
i am getting some error while running it!!
i am stuck at the
const txHash = await addr1.sendTransaction({
to: ...
0
votes
1
answer
184
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 ...
0
votes
1
answer
368
views
How do I test extra parameters in Remix?
I tried to use Remix to test a Smart Contract:
/********************************************************************
* Make bids with ETH or an ERC20 Token specified by the NFT seller.*
* Additionally,...