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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
29 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 ...
saksham khandelwal's user avatar
0 votes
3 answers
69 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 ...
Sudheendran's user avatar
1 vote
1 answer
10 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 &...
Prithwi Chowdhury's user avatar
1 vote
1 answer
22 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 ...
Harry's user avatar
  • 11
0 votes
1 answer
213 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 ...
Nitesh Modi's user avatar
0 votes
0 answers
25 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 = ...
Faisal Hussain's user avatar
2 votes
1 answer
82 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 ...
Paul Razvan Berg's user avatar
0 votes
1 answer
30 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 ...
Brexela's user avatar
  • 11
0 votes
1 answer
12 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, ...
Damir Olejar's user avatar
0 votes
1 answer
16 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)
Patrick Collins's user avatar
2 votes
2 answers
166 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); ...
Wukong's user avatar
  • 21
2 votes
2 answers
615 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 ...
aymericf99's user avatar
1 vote
2 answers
127 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. ...
Azamat Valeev's user avatar
1 vote
1 answer
239 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 ...
Agilulfo's user avatar
1 vote
2 answers
69 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() ...
DJ Quimoso's user avatar
1 vote
1 answer
89 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 ...
Baby's user avatar
  • 29
1 vote
3 answers
2k 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 ...
softweng's user avatar
  • 129
1 vote
1 answer
395 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: ...
matlemad's user avatar
0 votes
2 answers
170 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 ...
Saucy's user avatar
  • 23
1 vote
1 answer
41 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 ...
Anon.eth's user avatar
0 votes
2 answers
544 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 ...
sunsakis's user avatar
1 vote
1 answer
809 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 ...
code-wolf-byte's user avatar
-1 votes
1 answer
104 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 ...
stofu's user avatar
  • 93
1 vote
1 answer
49 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 ...
f22daniel's user avatar
  • 333
0 votes
1 answer
604 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 ...
Vignesh s's user avatar
1 vote
1 answer
72 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, ...
Pia's user avatar
  • 11
0 votes
1 answer
22 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?
Blender's user avatar
  • 73
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 ()......
Nick's user avatar
  • 55
0 votes
1 answer
152 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 ...
shikamaru's user avatar
1 vote
2 answers
431 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 ...
Wattlebird's user avatar
1 vote
1 answer
111 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 ...
Yazan Arafat's user avatar
3 votes
3 answers
191 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 ...
Shift_that's user avatar
3 votes
2 answers
335 views

Difference between address payable and payable(address)

What is actually the difference between address payable and payable(_address)
Zartaj Afser's user avatar
  • 3,229
1 vote
1 answer
27 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 {...
MFaiqKhan's user avatar
2 votes
2 answers
327 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
0 votes
1 answer
295 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 ...
almel's user avatar
  • 786
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 ...
Federico Gambassi's user avatar
0 votes
1 answer
25 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 ...
alastair wright's user avatar
1 vote
1 answer
432 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 ...
ariel's user avatar
  • 11
0 votes
1 answer
32 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-...
Naveen Saxena's user avatar
0 votes
2 answers
852 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, ...
levlups's user avatar
0 votes
1 answer
48 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 ...
Gray Blanchard's user avatar
0 votes
1 answer
852 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: ...
DereK's user avatar
  • 294
0 votes
1 answer
172 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
328 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,...
NineCattoRules's user avatar
0 votes
1 answer
413 views

How to Call a payable function I am getting error={"code":-32603,"message":"Internal JSON-RPC error.","data":{"code":3,"message":"execution reverted"}

I am trying to call buy function which is a payable function using metamask signer method. I am getting error for sending incorrect ether value. Here I have set the price as 1 which is 0x01 in hex ...
crypto S.'s user avatar
  • 345
2 votes
2 answers
1k views

Send msg.value to another address immediately

Is it possible to implement a payable function and transfer msg.value to another address immediately? function purchase() payable public { //transfer msg.value } I'm thinking this wouldn't work ...
developer's user avatar
0 votes
1 answer
167 views

Payable function transaction failing

Please see the following code: // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.1; contract Crowdfund { uint fundLimit = 3 ether; bool contractOpen = true; function donate() ...
Rushank Savant's user avatar
0 votes
1 answer
221 views

Why are we using payable modifiers in both the ERC20 transferFrom and approve functions?

Why are we using payable modifiers in the ERC20 functions below? function transferFrom(address _from, address _to, uint256 _tokenId) external **payable** { require (zombieToOwner[_tokenId] == msg....
user avatar
0 votes
2 answers
39 views

why I am not getting balance of contract?

when I call the getbal() of contract "Account" it shows 0 balance but when I call createacc() of contract "accountfactory" with value=30, accountfactory's balance becomes 9.but ...
Hitesh's user avatar
  • 21

1
2 3 4 5 6