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
1answer
24 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 ...
0
votes
1answer
27 views

address payable type error

Just upgraded truffle to version 5 and having a problem with this new address payable type. contract Test { ERC721Full public tokenAddress; constructor(address _address) public { ...
0
votes
1answer
12 views

Address Payable and New Contracts

The following compiles in 0.4.26, but not 0.5.0. The error is "Type contract CustList is not implicitly convertible to expected type address." I figure it's something with address payable, but I have ...
1
vote
1answer
22 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 ...
0
votes
1answer
28 views

The constructor should be payable if you send value. The transaction has been reverted to the initial state

I'm following a LinkedIn course on Solidity and creating a simple contract. Code below: I'm new to solidity so I'm not sure exactly where I'm going wrong but I get the following error: Transact to ...
0
votes
1answer
17 views

Why the function needs payable() in solidity?

In my solidity code, I am not using the global variable msg.* but still I get the error message in the function. Please explain why this function needs to be a Payable function The below snippet is ...
0
votes
1answer
22 views

Smart contracts: is every public function payable?

I am aware of the payable annotation on the public methods. But just want to make things more clear: is every public function payable? Even without the payable annotation? what would happen if a ...
0
votes
1answer
17 views

Sending the bool to ```function() payable``` in another contract

I am trying to create a pair of contracts, let's say C1 and C2. I want to add an if...else in payable function function() public payable{} of C2, which works on the bool value returned by contract C1, ...
0
votes
1answer
45 views

Erc20 token smart contract fallback function is disabled, how can I enable it? [closed]

There is a payable fallback function available now on my smart contract, but I want to function it like if someone send 0.01 / 0.05 / 0.10 / 0.50 / 1 ETH and the contract will automatically send the ...
1
vote
2answers
88 views

How can I check if a specific contract's address inherits from a interface or contract?

I have a special contract with few extra functions. In the transfer wei function I want to send it to the special method or if receiver doesn't have it (because is a wallet or doesn't inherit from my ...
1
vote
2answers
27 views

Why is solidity throwing “Note: The constructor should be payable if you send value. ”, when clearly the issue is elsewhere?

I'm writing a contract on Remix that is able to deploy and track child contracts. Here are the 2 contracts: pragma solidity ^0.5.0; Contract Factory contract ContractFactory{ ChildContract[] ...
0
votes
1answer
38 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)....
0
votes
1answer
60 views

receiver.payable

Truffle v5.0.5 (core: 5.0.5) Solidity v0.5.0 (solc-js) Node v10.15.1 pragma solidity v0.5.0; contract ApprovalContracts { address public sender; address public receiver; address public ...
0
votes
0answers
30 views

How to Modify App.js Function to Send Ether

Struggling with how to adjust the following function in my app.js file send ether. I've made the target function in my solidity code payable and it tested out successfully in Remix. But, I'm ...
0
votes
0answers
35 views

Setting Fees/Prices for Items

I have a question on setting prices for the cards in the card game I'm working on. Right now, I have 2 cards available but there will be more (maybe a couple dozen). I store each card as a struct ...
1
vote
1answer
43 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
64 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 ...
0
votes
1answer
41 views

Getting error on sending ether/wei in payable function

error: transact to CampaignFactory.createCampaign errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The constructor should be payable if you send value. ...
1
vote
2answers
49 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)(...
0
votes
1answer
118 views

Is it possible to send Ether using delegatecall?

I tested this in Remix and it seems that the ether remains in the delegator contract and doesn't get forwarded. Using the code below to test: contract SomeContract { address public sender; ...
1
vote
1answer
791 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 ...
0
votes
1answer
84 views

“The constructor should be payable if you send value” although my address and constructor are already payable

I tried to write a simple contract (deployed on Virtual VM java script on Remix) that send a certain amount of money from an account to the other. I construct my receiver and sender address, and my ...
0
votes
0answers
38 views

Working with 0.4.4 version of solidity, still got error, “Member 'transfer' not found or not visible after argument-dependent lookup in address.”

According to some resources, this well known error occur because of versions 0.4.X to 0.5.X change. Previously I compiled contract with ^0.5.1, to solve this error currently I'm using 0.4.4. But ...
4
votes
1answer
687 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
41 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
199 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 ...
1
vote
1answer
598 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 ...
9
votes
2answers
3k 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
2answers
506 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
769 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
38 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
32 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
1k 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
2
votes
0answers
93 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
37 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
225 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
76 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
55 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
1k 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
151 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
204 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
22 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
88 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
153 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
36 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
542 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
547 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
41 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
33 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
48 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); ...