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
15 views

Ethers js deploy contract with balance, payable constructor

I have a smart contract with a payable constructor. I'm trying to figure out the syntax with ethers js how I can deploy the smart contract and send an initial balance with the deployment. const ...
0
votes
1answer
10 views

Transferring to contract from another contract - payable error when transferring

I have a contract (the factory) that deploys other contracts. These contracts behave like bonds where users can set an amount in the factory, deploy the bond and then others can subscribe to the bonds....
0
votes
0answers
11 views

ParserError: Expected primary expression. when using payable

I have the following code: function payout() public payable { uint ordersLength = orders.length; uint totalRaised = 0; for (uint i = 0; i < ordersLength; i++)...
0
votes
0answers
7 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
1answer
30 views

Where to pass the value at while using msg.value?

I had been using remix IDE for a long time but recently switched to using Truffle. Everything else was fine until I had to build a function for payment. In remix IDE, there is a box provided, labelled ...
0
votes
1answer
42 views

error type address is not implicitly convertible to expected type address payable

I get the following error type address is not implicitly convertible to expected type address payable on the withdraw function. pragma solidity ^0.8.1; contract sendMoneyExamples{ uint public ...
0
votes
1answer
78 views

how are we sending funds on polygon through contract

I know it sounds like a basic question (it should be), despite that I could not find any clear reference to that in polygon's (Matic) docs on how does payable(address).call works pragma solidity ^0.7....
0
votes
1answer
16 views

How does Solidity handle multiple payables in one function?

While I was experimenting with Solidity, this question popped in my head and I've been struggling to figure it out ever since. To test things, I wrote this simple contract: contract test{ uint256 ...
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
1answer
21 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
11 views

Does anyone know how to fix this address not payable error on my //Perform Sell section?

pragma solidity >=0.5.0; import "./Token.sol"; contract EthSwap { string public name = "CutiSwap Instant Exchange"; Token public token; uint public rate = 100; event ...
0
votes
1answer
55 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
1answer
29 views

How to make a smart contract which pays out only if a service is performed?

Hello I am new to the world of solidity. I am trying to create a smart contract with the following conditions: a customer wants to buy a service/product from a retailer (me). the price of my service (...
0
votes
0answers
17 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
33 views

How can I use the payable function to transfer fixed ether in a transaction?

contract MyContract { address payable[] recipients; function sendEther(address payable recipient) external payable { recipient.transfer(1 ether); } } Error- transact to ...
1
vote
1answer
27 views

Paying the gas cost with the ether stored in the SC

Let's suppose that an entity deploys an SC and wants to perform an allocation (which computationally speaking has a high gas cost). The participants of this delivery (registered persons) must be the ...
0
votes
1answer
68 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
23 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
1answer
52 views

How can i get the Payable function to send the right amount to the owner address?

function () public payable { uint tokens; /// this math isnt safe tokens = msg.value * 10; /// this didnt give us the address we needed address tokenOwner; ...
0
votes
1answer
31 views

Safe way to make a payable function that accepts a ERC20 Token in a contract that didn't create that Token

I have two contracts, contract A represents Token A, contract B is its own contract. I users to call a contract B function by paying Token A to contract B, as if they were using a payable function, ...
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 ...
1
vote
2answers
30 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 (...
0
votes
1answer
61 views

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

I want to create simple auction contract (see code below). But newBid() function is not working. To run this contract, you must first create an item newItem(name, price, time) and then run newBid(...
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 ...
1
vote
1answer
18 views

How can I ensure a player matches another player's bet?

First, I want someone to send a bet (money) to the contract. Then I want someone to match the original bet. (There are many more safety checks in the contract. I just removed them to keep this as ...
0
votes
0answers
129 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 ...
1
vote
0answers
17 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 ...
0
votes
0answers
65 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
31 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
1answer
367 views

How to transfer any ERC20 token trough a function with Metamask?

I'm developing a function that accepts any kind of ERC20 token, and transfer it to the provided address. The idea is to execute the function connecting Metamask address, and transferring the desired ...
1
vote
2answers
181 views

Best way to check balance? msg.sender.balance vs balances[msg.sender]

If I want to check if the payer has enough funds, should I use... msg.sender.balance or balances[msg.sender] ? I also see that people usually check balance in the following way: require((balances[...
0
votes
0answers
57 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 &...
4
votes
1answer
3k 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
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, ...
2
votes
1answer
326 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
0answers
64 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
180 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
176 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
175 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 ...
0
votes
1answer
835 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
80 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 ...
1
vote
1answer
1k 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: ...
1
vote
1answer
46 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
147 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 ...
1
vote
1answer
388 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
17 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; } ...
0
votes
2answers
304 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
100 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 ...