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
21
votes
2answers
7k views

What's the difference between 'address' and 'address payable'?

I saw a Solidity smart contract where some variables were declared with the type address and some were declared with the type address payable. What are the differences between the two? Do they store ...
14
votes
1answer
1k views

Bad Jump Destination error

I wrote what I thought was a dead simple contract - a saving jar... you add value ("save") into the jar and when the balance of the contract reaches a certain amount ("target"), then I am able to ...
9
votes
2answers
2k views

How to cast address to address payable in solidity 0.5.0

Got address from 3rd-party library: address wallet = rlp[5].toAddress(); And wanna transfer some funds to it: wallet.transfer(amount); Got error: TypeError: Member "transfer" not found or not ...
9
votes
1answer
1k views

Can a contract with no payable function have ether?

The question in the title says it all. To the best of my understanding, the only way to deposit ether into a contract is by calling a payable function, and set msg.value larger than 0 (and of course, ...
9
votes
3answers
999 views

Why is there more than one payable function in a solidity contract?

When someone transfers ether to a contract address the payable callback (without name) function is called automatically. What I don't understand is why are there many examples with multiple payable ...
5
votes
3answers
3k views

Transfer from contract address

I created a contract with a payable function but the ether is stored in the contract I am looking for a way to transfer the ether to another address
5
votes
1answer
341 views

What are 'payable' state variables?

https://solidity.readthedocs.io/en/latest/solidity-by-example.html#simple-open-auction pragma solidity ^0.4.22; contract SimpleAuction { address payable public beneficiary; What exactly does ...
4
votes
2answers
3k views

How can a smart contract run when receiving ether directly, not through a function?

I have a smart contract with a payable bet() function. When someone sends 1 ether to the bet function, the contract is executed. I'd like the contract to run the same code when someone sends ether to ...
4
votes
1answer
519 views

Will payable modifier throw if no ether is sent to it?

Should I add a check to make sure Ether was sent along with the transaction or is that redundant?
4
votes
1answer
662 views

Why are the transfer and approve functions payable in the ERC-721 spec?

In the ERC-721 spec interface, the functions safeTransferFrom, transferFrom and approve all have the payable modifier. What is the reason for this? As far as I can tell, none of these functions ...
3
votes
2answers
1k views

What is the significance of making constructor payable?

Aren`t constructors used to initialize variable at the time of contract creation? In common patterns section in solidity documentation, payable constructor is used for withdrawal pattern example. ...
3
votes
1answer
2k views

What denomination should I issue my ERC20 token by?

Following the "Create a cryptocurrency" tutorial on ethereum.org, I ended up with the following function (stripped down): function () payable { if (msg.value == 0) { return; } uint256 tokens =...
3
votes
1answer
5k views

How to pass argument/parameter to a payable function of a contract that has been already deployed, via web3 / javascript / truffle?

I'm wondering how to pass argument to a payable function of a contract that has already been deployed, via web3 / javascript / truffle. For instance, I see the following piece of code at: http://...
3
votes
1answer
200 views

Transaction fee restrictions with solidity

Can I restrict transaction fee (gas price) for the payable method of the crowdsale contract. And if I can, how? And one more question, if I restrict fee and call revert() - this transaction will be ...
3
votes
1answer
994 views

Make function payable for a specific ERC20 token?

a method can be payable and then it's possible to send ether to the contract while calling it, and the function can check the ammount sent through msg.value. How can I make a function receive ...
3
votes
2answers
522 views

Can a miner “cheat” my lottery smart contract?

I developed a smart contract that you: 1) Send 1 ether to an address, the contract saves your address 2) After 5 people have sent one ether, the contract chooses one address at random and sends the ...
3
votes
1answer
920 views

Send ether to a payable function from nethereum

I have created a payable function in a smart contract and deployed it in a private blockchain network. Now I am using Nethereum to make rpc calls to the geth node on which the network is running. But ...
3
votes
0answers
1k views

Hi i am getting error msg.value non-payable [duplicate]

I had this function function enter() { if (msg.value >10 finney) { uint amount=msg.value; uint payout; but i am getting error: ballot.sol:56:9: Warning: "msg.value" used in non-...
2
votes
2answers
2k views

Payable: Sent - Hold amount - Sent_back mechanism (Refund)

[Q] When following transaction get called: Bank.pay({"from": eth.accounts[0], "value": 1});, who retrieves the money, does the owner of the contract? (Sorry I get lost who actually gains the money). ...
2
votes
1answer
112 views

How to transfer wei from a contract to a specific address?

I was making an auction system and I wanted to make sure that when someone bid higher the contract would return the money to the address of the previous bid. pragma solidity >=0.4.22 <0.6.0; ...
2
votes
3answers
291 views

why don't popular tokens have payable fallback

I'm referring to the source of of the most popular tokens on etherscan. It looks like they don't have any payable functions. How do they accept ether and transfer the tokens automatically when ...
2
votes
2answers
2k views

Gas limit dangerously high

When I tried to send ether to my contract, I get this error. Even if try to change the value of Gas Limit and Gas Price the transaction still fails. What could be the possible reason? What I ...
2
votes
1answer
63 views

Are the functions in this code missing the payable modifier?

These functions are transferring ether between balances, so why aren't they modified with payable?
2
votes
2answers
115 views

Instantiating a contract with ether

I have a factory contract that I need to be able to deploy with some ETH. I'm getting an error TypeError: Member "transfer" not found or not visible after argument-dependent lookup in address. I ...
2
votes
1answer
1k views

Testing Payable Functions From Truffle

I'm trying to test a payable function from Truffle my function looks like so: function recordOrder(bytes32 orderNumber) payable returns(bool success) { if(msg.value==0) { return false;...
2
votes
2answers
956 views

How to accept bitcoin and transfer tokens from smart contract to sender ethereum address

I have created sample tokens Smart Contract with the payable feature/constructor, if someone pay from their Ethereum address to Smart Contract will get instant token into their Ethereum address. But ...
2
votes
3answers
401 views

Why is Fallback function not being executed?

I have a fallback function for receive ether on my contract and I have a function for send ether to my contract, also in my contract, I have withdrawal function. Why is the fallback function not ...
2
votes
1answer
1k views

Is it possible to call payable functions of smart contract using web3j’s smart contract wrappers?

How do we call payable functions of smart contract using web3j? UPDATE: I'm going to change generated smart contract wrapper class manually. Now I have: public Future<TransactionReceipt&...
2
votes
1answer
168 views

If a function is called with a certain gas amount, will msg.value == amount of gas sent?

My function needs gas to fulfill a transaction, but I don't want people accidentally sending Ether to it.
2
votes
1answer
43 views

How to add more logic to a payable function?

How can I add to a payable function the possibility for the buyer (a company, in my case) to add some details about itself at the moment of performing the payment (e.g. registered number and company ...
2
votes
1answer
66 views

How to extract int128 from msg.data as first argument?

Let's say we have Ethereum smart contract with fallback function: event onDeposit(int128 indexed key, address from, uint amount); ... function () payable public { require(msg.value > 0); ...
2
votes
0answers
107 views

Can I call a library function from a payable function?

I seem to get a revert each time I try this. I'm unable to get any useful revert message from truffle, so any assistance there might also help solve this. I have a library: library LibInterface { ....
2
votes
1answer
81 views

How to process Smart Contracts payable functions in batch?

I am aware that metamask will enable effective security for processing via the web browser a payable function action to a smart contract. What happens in batch? I have an API service which then ...
2
votes
1answer
199 views

Contract working on Javascript VM and not Web3 Provider, why?

Here is the code: Calling contract: pragma solidity ^0.4.24; contract Caller { address public called_address; constructor() public payable { } function set_address(address _addy)...
2
votes
0answers
2k views

Web3 - how to send transaction with some data and include Ether at the same time?

Using web3 0.20.3 I want to call function and send some Etherium at the same time. JavaScript Contract = web3.eth.contract(ABI); Instance = Contract.at('0x162b74ea16da6ae9d7f7b349eaeab2fcadf4e835')...
2
votes
0answers
30 views

Why not possible limiting gas but forwarding ether in creating this contract from Solidity documentation

In the Solidity docs Creating contracts via new there is an example: contract D { uint x; function D(uint a) public payable { x = a; } } and it states in the accompanying text: ...
1
vote
1answer
2k views

Invalid type for argument in function call. Invalid implicit conversion from address to address payable requested

function endSuply() public { require(msg.sender == admin,"only admin can end the token sale"); require(tokenContract.transfer(admin, tokenContract.balanceOf(address(this))),"balance not ...
1
vote
1answer
1k views

Solidity 0.5.x - make address array payable

I'm trying to write a contract that uses an address[] array which should contain payable addresses. But apparently creating a payable address array doesn't work in solidity 0.5.x. All I'm trying to ...
1
vote
2answers
175 views

UPDATED : How to determine “payer address” in “address.transfer(amount)”?

Consider we a function as follows : address public recipient; function settlement(uint256 amount) public { recipient = msg.sender; recipient.transfer(amount); } Then the ...
1
vote
1answer
33 views

Someone Please Explain this “The concept of payable and non-payable addresses only exists at compile time not after the contract is compiled” [duplicate]

Actually I was reading this Answer https://ethereum.stackexchange.com/a/64109/55286 . And this person says The concept of payable and non-payable addresses only exists in the Solidity type system at ...
1
vote
1answer
410 views

Testing payable functions with truffle console - where do you input msg.value?

Trying to test my token contract using truffle console + ganache, lets say I have a payable function someFunc(string _string, uint256 _int), how would I call it with arguments "hello", 100 and msg....
1
vote
1answer
563 views

Cannot send ether to a payable function in truffle unit test

I am debugging a bug happened on my truffle solidity test. I can narrow down the problem to an exception happened in the payable modifier. my contract code: import "zeppelin-solidity/contracts/token/...
1
vote
1answer
37 views

Paying contract can't inherit?

I have two contracts. One inherits a function that gets the value to be paid by the second one. If I remove the 'is Reference' and replace the values from the external function, the code pays, ...
1
vote
1answer
80 views

Fallback function fails when ethers sent from metamask

This is my code snippet for fallback function, If I use it by explicity using "fallback" function on Remix, then equivalent no of tokens do come in my wallet but if I send ethers via metamask directly ...
1
vote
1answer
37 views

What does mutability guarantees mean in erc721

Some functions from ERC-721 interface contain payable modifiers. function transferFrom(address _from, address _to, uint256 _tokenId) external payable; I was wondering why it is payable and found ...
1
vote
1answer
66 views

Possible replay attack when paying to smart contract

I am afraid of a possible replay attack when paying to a smart contract. Given these 3 assumptions An action gas cost may change according to the state of the blockchain (even if its the same action)....
1
vote
1answer
94 views

Is it possible to call a payable function within __callback of Oraclize?

I want to run an Oracle query periodically and my idea was to call getUTCTimestamp(0) for the first query where getUTCTimestamp is: function getUTCTimestamp(uint256 delay) payable { oraclize_query(...
1
vote
1answer
92 views

How to get require() to accept decimal value of ether in payable functions in Solidity?

On using, require(msg.value == registerFeeMap[msg.sender] /_currentRate) (fractional ETH value calculated) require(msg.value == registerFeeMap[msg.sender]*10**18/ _currentRate) (ETH converted to ...
1
vote
2answers
86 views

How to use function arguments of payable function for require statement?

function createCampaign(uint deposit, address ll) public payable{ dpst = deposit; require(msg.value > (40*dpst)/100 wei); address newCampaign = address((new Campaign).value(msg.value)(...
1
vote
1answer
439 views

ParserError: Expected identifier but got 'payable'

function getWinners() public onlyOwner { require (now > endQuiztime, 'Quiz did not end '); require (isReveal, "You didnt reveal Questions"); // calculate winner for each ques based on ...