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.

31 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
1answer
347 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
107 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
1answer
83 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
1answer
200 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)...
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: ...
1
vote
2answers
192 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
44 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
23 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
105 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
932 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
2answers
575 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
0answers
94 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
23 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
26 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
41 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
46 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
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
0answers
28 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<...
0
votes
2answers
45 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
32 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
29 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
46 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
87 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
48 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
118 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
119 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
213 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
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
0answers
126 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]...