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
30
votes
2answers
14k 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 ...
12
votes
2answers
7k 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 ...
0
votes
2answers
372 views

Why transfer funds breaks contract?

My deployed contract called successfully only by "function invocation" through web3 or Remix. But it always failed when I sending funds to the contract. I thought that only requirement that contract ...
12
votes
1answer
2k 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, ...
2
votes
2answers
1k 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 ...
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 ...
1
vote
1answer
379 views

How to create payable contract solidity

contract Test { constructor() public payable { } } contract MyContract { constructor() public payable { Test test = new Test(); } } How do I pay the Test contract's ...
0
votes
1answer
1k views

Call a smart contract payable function sending erc20 token

We can send a er20 token to a smart contract. To track it we can use a function ( msg.value is always wei ) But how do i verify if the erc20 token is actually sent ? For example i want to set map ...
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 ...
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 =...
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')...
4
votes
1answer
3k views

Compiler solc expected a state variable declaration

I try example from book Mastering Ethereum: contract Faucet { function withdraw(uint withdraw_amount) public { require(withdraw_amount<=10000000000000000); msg.sender.transfer(...
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
1answer
66 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?
1
vote
1answer
4k views

How do you send Ether as a function to a contract using Remix?

New to Solidity... When deploying a contract on a private blockchain using Remix, I am unable to execute payable functions. When executing these functions, the following error message displays: gas ...
0
votes
1answer
168 views

How can a Smart Contract pull an amount of Ether equal to its own balance from an External Account?

I'm writing a 2 Player Game. Rules: Player 1 must place a bet (and send some ether to the contract). Then, Player 2 must match the bet placed by Player 1, and send the same exact amount of ether to ...
0
votes
1answer
788 views

How to call “payable function” via interface in solidity [duplicate]

I have a function marked as payable in contract A and I want to call it from contract B so that msg.value in contract A can have its desired value and contract A must have balance of sent amount , how ...