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.

44 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
1answer
433 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 ...
2
votes
0answers
125 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 { ....
2
votes
2answers
156 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 ...
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')...
2
votes
0answers
30 views

Why not possible limiting gas but forwarding ether in creating this contract from Solidity documentation

In the Solidity docs Creating contracts via new there is an example: contract D { uint x; function D(uint a) public payable { x = a; } } and it states in the accompanying text: ...
2
votes
2answers
755 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
28 views

How to send Ethereum to smart contract address without using keyword “payable”?

I have tried to send Ethereum from my wallet to the smart contract address by using the below code: pragma solidity >=0.6.10; contract NoUsePayable { function getBalance() public view returns (...
1
vote
0answers
16 views

Getting INVALID_ARGUMENT error when passing zero to a view function with a parameter of type address?

I recently upgraded to solidity 0.8.1 from 0.4.21. I have a view function in my contract with an address parameter. In the past I could pass 0 for this argument and that would be written to the ...
1
vote
2answers
57 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[] ...
1
vote
0answers
26 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
118 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 = ...
1
vote
2answers
1k 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 ...
1
vote
0answers
111 views

How to distribute credits between workers?

I have just started mining. I have a miner composed by 3 workers. Each worker belongs to a different person. When I'll finalise a block I will receive a payout. I would like to know how to distribite ...
0
votes
0answers
6 views

TypeError: address payable best practice v0.8.6

I'm getting TypeError: "send" and "transfer" are only available for objects of type "address payable", not "address" for items[_upc].consumerId.transfer(...
0
votes
0answers
13 views

Gas estimation fail only when sending eth to contract?

I have a payable function that works fine when calling without any eth, but if I try to call it with eth it gives me a gas estimation fail. I have another function that is payable and works fine when ...
0
votes
0answers
16 views

The called function should be payable if you send value and the value you send should be less than your balance

This is one of my parent contract (child factory contract) functions that creates a child contract. The function should be provided with 3 arguments function breed(uint _number, uint _amount, ...
0
votes
1answer
14 views

What would happen if I remove + from the line number 6?

pragma solidity ^0.8.1; contract SendMoneyExample{ uint public balanceRecived; function recivedMoney()public payable{ balanceRecived+=msg.value; } function getBalance()public ...
0
votes
1answer
47 views

Require a specific amount of Ether inside the payable function

I have a payble function that has some logic. I want that logic to be triggered only if the received amount is equal to the amount specified when the contract was created. Solidity v0.7.6 receive() ...
0
votes
0answers
15 views

How to send ethers to specific address based on solidity contract but not web3py?

I have written a solidity code, running it on Remix and I use ganache and web3py library to interact with it. My code is something like this: contract simplePayment{ function sendPayment(...
0
votes
1answer
66 views

Could A Solidity Developer with Binance Chain Familiarity Explain This?

I am a large holder of a certain token. We recently notice that one wallet where liquidity was being sent regarding 8% of transactions was unwrapping and selling those tokens. We confronted the ...
0
votes
1answer
22 views

Sending ether to a contract without data throws an error

I'm trying to deploy a smart contract that allows users to buy tokens that can be used to pay fees on its platform. In case someone is going to send ETH directly to the contract address without ...
0
votes
0answers
15 views

Oracle Price Feed Event-Based mechanism

As you know chainlink oracles work like callback functions. I have only one function is that payable one and I need to know the correct eth value in token parity. I cannot request data when the ...
0
votes
0answers
25 views

How Can I handle the amount of token to send to the contract by the user according the amount of ticket the user buy?

I want to know how can i set up a "require" for a payable function in order that when an user try to buy a ticket have to send exactly the correct amount of his purchase...for example if the ...
0
votes
0answers
119 views

How to implement crypto refunds in a smart contract?

I am quite new to cryptocurrencies and after some investigation I thought this might be the right place to ask. Problem: I have a small business and I would like to offer to my customers the option to ...
0
votes
0answers
62 views

Are there non-fungible tokens that can generate a pay-per-view revenue for the owner?

A non-fungible token (NFT) by definition represents (ownership of) a unique asset, which we will assume is a digital multimedia file in .avi format. The video's length in minutes, file size, content ...
0
votes
1answer
30 views

Sending Ethereum to the contract owner on purchase

I have a smart contract that allows one to purchase a set number of NFTs for 0.2 ether each. I have set the owner of the smart contract to the one who deploys it and whenever someone purchases an item ...
0
votes
1answer
40 views

Contract address payable issue

If i remove payable from: then i get this error with my receive function. Not sure how to fix this. I have an erc20 token contract that has a receive function and this contract inherits from it, that'...
0
votes
0answers
56 views

Error : Called function should be payable

I am trying to create a token contract and the token sale contract. Token Contract : ERC20 token is ready and it is flawless TokenSale Contract : I have passed the "Token"" contract to &...
0
votes
0answers
28 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
0answers
63 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
1answer
172 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
172 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
2answers
288 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 ...
0
votes
1answer
50 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
60 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
1answer
78 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
0answers
51 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 ...
0
votes
1answer
138 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
0answers
56 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
2answers
185 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
0answers
153 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
2answers
295 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["...
0
votes
1answer
65 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
0answers
128 views

can't get transfer to execute

I am trying to run the following solidity function: function test() payable { msg.sender.transfer((balances[msg.sender]/1000)*this.balance); } Where this.balance is 0.1 Ether and balances[msg.sender]...