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
2
votes
1answer
203 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
1answer
55 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(...
0
votes
0answers
24 views

Public function when called from another contract throws error “The called function should be payable if you send value”?

This is the contract I am calling from: contract MultiTransfer { function multiTransfer(Marcelo token, address _addresses, uint256 amount) public { token.transfer(_addresses, ...
0
votes
1answer
46 views

Take a percentage of msg.value on ERC721 transfer

I want to transfer part of the value paid to an address whenever an NFT is traded. If the value is 0, then nothing is transferred. My original idea was to override the transfer function in ...
0
votes
1answer
17 views

TypeError: push is not detected as a function for address payable dynamic array

I'm trying to add the manager address to the playes array. I get the following error: TypeError: Member "push" not found or not visible after argument-dependent lookup in address payable[] ...
0
votes
2answers
56 views

Transfer eth to accounts in Remix javasctipt VM solidity V 0.6.0+

I am simple man, but learning Eth Dev. I am testing a contract in Remix however I can't transfer Eth between the accounts in the javascript VM (using solidity V0.6.0 +). I have researched for a while ...
1
vote
2answers
590 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
208 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 ...
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, ...
0
votes
1answer
48 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
49 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
0answers
27 views

Failing to send() 1 wei from one contract to another

The following code is supposed to send 1 wei from the current contract to a newly created contract. The recipient contract gets created successfully and the sending contract has a positive balance, ...
0
votes
2answers
217 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
952 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 ...
0
votes
1answer
90 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. ...
0
votes
2answers
121 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 ...
0
votes
1answer
54 views

ParserError: Expected ',' but got 'payable' admin.transfer(address payable(this).balance); ^-----^

I have write a small smart contract. however there is problem. please see below full code pragma solidity ^0.5.16; import "./x.sol"; contract xSale { address admin; x public tokenContract; ...
0
votes
1answer
62 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
30 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
68 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
33 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,...
0
votes
1answer
23 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 ...
2
votes
1answer
84 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
0answers
12 views

Exucution of a payable function does not transfer any value between accounts when executing event on Ganache

I have created an smart contract that sends value from one account to another when calling the following function: function buyEnergy(uint _sellOrderId, address _sellerAddress ) public payable /*...
0
votes
1answer
93 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 ...
0
votes
2answers
39 views

Can I give multiple address parameters to a payable function?

Newbie here, making my very 1st Smart Contract (a rock/paper/scissors game). I'm using 0.5.11 because that's what the tutorial I'm learning from is taught in. I'd like to call my payable placeBet ...
0
votes
1answer
97 views

ParserError: Expected primary expression - address payable - payable()

I'm trying to get myself familiarized with ethereum. So I was going through a repo, and tried to rum the code : function transferFundOnResolve(uint cid) private { // Could also be used: ...
0
votes
0answers
29 views

web3j version 4.5.16 is not generating payable function properly

I am using web3j 4.5.16 version to generate my wrapper. For a payable function it is generating the following. // With out input argument to enter weiValue public RemoteFunctionCall<...
1
vote
1answer
35 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
37 views

What's the difference between payable function and non-payable function in bytecode for solidity?

Suppose I have two solidity functions: function funcA()public{} And function funcB()public payable{} What's the difference between their bytecode? if I call the funcA with some ether in the ...
0
votes
1answer
65 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
10 views

Calling payable function from contract with parameters

How do I call this function from my contract and send ether to it? abstract contract MainAcceptedOffers { function accept(uint _acceptance, address payable _casher) public payable virtual; } ...
9
votes
2answers
3k 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
43 views

Eventhough function is declared payable , getting this error:The called function should be payable if you send value

I am new to Solidity and can't understand why I am getting the above error even though the function purchaseProduct() is declared as payable. I tried this code on Remix IDE and got this error. VM ...
0
votes
2answers
58 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
91 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....
0
votes
2answers
158 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
1answer
46 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 ...
21
votes
2answers
8k 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 ...
2
votes
2answers
120 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 ...
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. ...
0
votes
1answer
55 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); ...
2
votes
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
81 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
21 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
46 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 ...
1
vote
1answer
84 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
125 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
152 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
40 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 ...