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
45 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
21 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 ...
0
votes
0answers
20 views

Smart Contract payouts [closed]

What is max number that can be generated from receive() and did transactions use gas(fee)??I mad this and i can't send 0.009eth to my contract.Can anyone explain me why? pragma solidity ^0.6.4; ...
0
votes
1answer
29 views

payable function not working

function() payable external { eth_balance[msg.sender] += msg.value; } This is not working. The execution is reverted and uses about 21,000 gas. No matter if I set the gas crazy high like 800,...
2
votes
1answer
61 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
20 views

What does a payable parameter mean in constructor?

constructor( uint _biddingTime, address payable _beneficiary ) public { beneficiary = _beneficiary; auctionEndTime = now + _biddingTime; } This code is from the contract SimpleAuction ...
1
vote
1answer
74 views

How to add an amount of ether to function calling?

I have a function in my contract, suppose function foo(uint _param1) payable { require(msg.value == 1000); someArray.push(x); } Then I have my Javascript code: contract = web3.eth....
2
votes
1answer
178 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)...
0
votes
2answers
112 views

Trying to reference function from parent contract - Member “xxx” not found or not visible after argument-dependent lookup in address

I am trying to make a parent contract which deploys a child-contract for each unique caller (which does not inherit from parent contract, but calls one of the parent's functions). I have looked up ...
0
votes
0answers
42 views

Why the function needs payable in Solidity?

In my Solidity code, I'm not using any global variables 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 ...
1
vote
2answers
511 views

function () public payable modifier can trigger actions when sending tokens or only works when sending ether?

Modifier payable triggers an action when an address sends ether to a contract. For example: function () public payable { require(msg.data.length == 0); DoSomething(); } Is this ...
1
vote
2answers
128 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 ...
0
votes
1answer
42 views

Trigger a payable function to send ipfsHash back to sender

I want to make a testnetwork, a supply chain, with 10 manufacturers/addresses. For that I want to make a function that sends the saved ipfsHash, which is the information about the product that will be ...
0
votes
1answer
34 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, ...
1
vote
2answers
36 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
2answers
190 views

A function declared payable is throwing a VMerror:revert in Remix

I was trying to fund a campaign created with a funding goal 10000000000000000000 and funding cap 10000000000000000000 by calling the payable method contributeMsgValue with parameter["...
1
vote
2answers
823 views

transferFrom function doesn't work

I have made a simple ERC20 token smart contract, but my transferFrom function does not work. I keep getting "Note: The constructor should be payable if you send value." even if I declared it as ...
16
votes
2answers
5k 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 ...
0
votes
1answer
73 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. ...
2
votes
2answers
108 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 ...
0
votes
2answers
98 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 ...
2
votes
2answers
814 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. ...
0
votes
1answer
54 views

How to use web3js to call a function with “payable” and transfer some ether to contract?

My code is like this : gameInstance.initGame.sendTransaction({from: webInstance.eth.coinbase, to: contractAddress, value: webInstance.toWei(person_num, "ether")}); Of course, it doesn't work very ...
0
votes
1answer
51 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); ...
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 ...
0
votes
1answer
38 views

Can someone send their stable coin ERC-20 tokens to my smart contract?

Here is a business case. Two people own an asset, and they estimate the annual maintenance on that asset is $1000 over the next year. So they each want to put $500 and lock it up in my smart ...
0
votes
1answer
17 views

how to handle gas run out in a payable function

function payMe() payable{ // doing some stuff with `msg.value` users[msg.sender].balance += modifiedMsgValue ; } In the above code what if gas runs out on the second line? so there will be ...
0
votes
2answers
37 views

How bad is it to change a function inside ERC721 interface?

I'm creating a NFT and I want the transferFrom function to be payable. In order to do so I need to edit the ERC721 interface and make that function payable also there. If I do so everything compiles ...
0
votes
0answers
17 views

Avoid upfront cost for calling own faucet?

To onboard users to a project quickly, I want to build my own little Rinkeby-faucet where users with new accounts (0 ETH) can get a bit of ETH by clicking a button. However, just calling the ...
1
vote
1answer
57 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 ...
2
votes
1answer
65 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; ...
0
votes
1answer
65 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 { ...
1
vote
1answer
28 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
38 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
23 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 ...
1
vote
1answer
972 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
1answer
86 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 ...
0
votes
1answer
96 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 ...
1
vote
1answer
76 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
0answers
50 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
64 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
2answers
887 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; ...
5
votes
1answer
281 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
2answers
69 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
230 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; ...
7
votes
1answer
1k 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
127 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
44 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 ...
0
votes
1answer
69 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
314 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 ...