Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
11 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
1answer
14 views

How to add actual Ether to custom token

I built a token by creating a smart contract for it, and have successfully connected to it, which is on a Ethereum test-net. Using web3.js I have been able to send token from one account to another ...
1
vote
1answer
20 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 ...
0
votes
1answer
36 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 ...
0
votes
0answers
26 views

Require msg.sender.balance not work correct in payable function

I create payable method in my contract. All works good, but when I add condition about balance of sender I catch error: "VM Exception while processing transaction: revert": Method buy is below: ...
5
votes
2answers
215 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 ...
1
vote
1answer
60 views

Unable to return address array in solidity

I have the following code for a simple gambling game. The code works fine except for getPlayers function pragma solidity >=0.4.22 <0.6.0; contract Lottery { address payable public manager; ...
8
votes
1answer
478 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, ...
1
vote
1answer
29 views

32/5000 Update on balance in contract

How do I update my balance on a contract? I created a function that receives an address as a parameter, I can visualize the balance: address.balance. But I want to transfer the balance to an ...
2
votes
1answer
26 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 ...
5
votes
3answers
309 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
-1
votes
0answers
26 views

Requesting help to sell a struct

I am a coding noob learning solidity. In order to better learn solidity, I am building a game called DinoFighter. In Dino Fighter, I want to add a feature where you can directly sell a struct with a ...
2
votes
0answers
41 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 { ....
0
votes
1answer
25 views

Sending real ETH to contract on Rinkeby

I have a contract deployed to the Rinkeby testnet. It includes the following function: function deposit(uint amount) payable public { require(msg.value == amount); } If I try to send ETH to this ...
1
vote
1answer
99 views

Calling and funding a payable function from existing contract balance [duplicate]

If smart contract A has a balance of 1 ETH, can I call a payable function on Contract B, from a function in Contract A, with a msg.value that would be effectively withdrawn from the balance of smart ...
0
votes
1answer
35 views

Intializing ERC20 token using payable constructor from another function of different contract

I have an ERC20 contract which is deployed from another contract as following: function createDao(string _tokenName) public payable returns (address tokenAddress) { tokenNumberIndex = safeAdd(...
1
vote
1answer
31 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 ...
0
votes
2answers
251 views

How to set msg.value in solidity function call [duplicate]

If I have a function: contract one { function buyTokens(address _beneficiary) public payable { require(msg.value == 1 ether); // do something... } } How do I call that ...
0
votes
2answers
47 views

what is the difference between payable and view in a smart contract in solidity?

I don't quite understand the concept of payable in a function in the smart contract and the difference between payable ,view and pure.
4
votes
1answer
82 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 ...
1
vote
0answers
19 views

How best to handle variable pricing during auction/sale

I'm building a contract for running multiple auctions, each selling individual ERC721 tokens from an array of token IDs, and the price increases with each one sold (the properties of the sale is ...
1
vote
0answers
48 views

the constructor should be payable if you send

I have been testing the code and for some reason I am having a block. The error is described as "the constructor should be payable if you send value". The debugger points to " uint256 weiAmount = ...
2
votes
1answer
63 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)...
1
vote
1answer
29 views

Audit request due to paranoia [closed]

I'm paranoid about whether the following contract will work, and the only comments are about where I am paranoid; so, that's where the questions/paranoia really are. This is essentially my one and ...
2
votes
1answer
230 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 ...
1
vote
1answer
184 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;...
1
vote
0answers
30 views

Add payable to 0FUCKS [closed]

I've been working on building a contract that essentially creates a distributed mortgage as a means of fundraising to pull my parents small business out of probate. I had started with modifying the ...
0
votes
2answers
30 views

How transaction with gas used ok 28k succeed for payable?

I'm trying to understand what I can do in fallback payable (I have read the docs and I know what I can't do for sure). Here is my contract: pragma solidity ^0.4.22; contract SmartMsgData { // ...
2
votes
1answer
32 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); ...
1
vote
0answers
20 views

How to call super in fallback payable function? [duplicate]

My contract is derived from another contract. And I wish to call the fallback payable function in the super class. May I know how can I do that? For example: function () public payable { // Do ...
0
votes
1answer
45 views

Solidity - Calling parent payable not possible?

I'm trying to inherit and override a parent's payable function (and adding some modifier and logic) but so far seem unable to do so. My first intuitive try was something like this: contract foo { ...
1
vote
2answers
35 views

Code Exception (VM error: revert): The constructor should be payable if you send value

I am creating a contract where to store a sort of ADN for a game, here is the code: pragma solidity ^0.4.22; contract Player{ struct ADN{ string[] html; //direccion donde estará la ...
1
vote
1answer
198 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
2answers
139 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 ...
0
votes
1answer
168 views

Deploying a contract with a “payable” constructor and including input parameters?

There is a useful Solidity contract HERE. However, there are two things at time of its deployment: (1) The first thing is the contract balance since its constructor is payable. (2) And the second ...
1
vote
1answer
333 views

Calling a payable contract function from truffle console [duplicate]

Let's say I have this function is a contract, that should enable users to deposit ETH into the contract, and have the contract manage their deposits function deposit() payable public { balances[...
0
votes
1answer
135 views

Help using msg.value and transfer()

Im trying to make a transfer ownership example by transferring ownership by sending ether. I've been trying to use msg.value and transfer() to send ether from owner B to owner A so owner B can take ...
0
votes
2answers
16 views

using “payable” even when we do not send ETH?

When we want to send some ETH, we need to use the "payable" keyword. However, even when we want to send some tokens (i.e. uint256 token), we need to use again the "payable" keyword in our function as ...
0
votes
1answer
45 views

Can a smart contract be set up so that a function to forward funds sends a set percentage of the Ether received to 2 or more contracts?

For example the the openzeppelin crowdsale contract has a function that sends ether to a wallet address. Could this method include logic to send 60% of the funds received to Alice's wallet and 40% to ...
0
votes
1answer
44 views

When we have to annotate that function is payable in smart contract? [duplicate]

I have used solidity smart contracts since 3 months ago, but I never used the decorator "payable". Is it sometimes necessary to use a payable function?
0
votes
1answer
155 views

Web app to call a payable function with parameter

Let suppose we have a contract with a payable function like this: function join(address sender) payable {}; So I have an user to join, invited by a presenter which address is address. I want to ...
0
votes
1answer
19 views

Why does ethereum.org suggest different prototypes for 'buy' and 'sell' functions?

Scrolling https://www.ethereum.org/token approximately half way down, I read this: The next step is making the buy and sell functions: function buy() payable returns (uint amount){ amount = ...
0
votes
1answer
39 views

Set a number in Remix payable source

There's buyprice on function buy and sellprice on function sell. I would like to set up 1 ETH = 10000(SYMBOL) 0.1 ETH = 1000 (SYMBOL) 0.01 ETH = 100 (SYMBOL) 0.001 ETH = 10 (SYMBOL) HOW can I set a ...
0
votes
0answers
55 views

Unable to call payable function from node console

I am trying to execute following function function createSurvey() external payable notTheOwner returns(uint surveyId, address newSurveyAddress) { require(msg.value > surveyCreationFees); ...
0
votes
1answer
689 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
337 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/...
0
votes
0answers
47 views

web3 solidity meteor payable in the Dapp

web3 solidity meteor payable in the Dapp hi I am currently building a Dapp by meteor, i wish user can pay the 1 ether to my contract, this function in the browser-solidity is work, but i don't know ...
0
votes
1answer
550 views

The constructor should be payable if you send value

I have written a contract as follows: pragma solidity ^0.4.0; /* Simple contract that mediates disputes using a trusted arbiter */ contract Taxi { enum State {IDLE, FINDING_DRIVER, ...
1
vote
0answers
869 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')...
0
votes
1answer
42 views

solidity how can payable?

hihi this is my code pragma solidity ^0.4.18; contract ValueIO { uint myidaaaa; uint price = 100000000 wei; function Input(uint feion) public payable { require(msg.value > price); ...