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
22 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
18 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
9 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
23 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
25 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
16 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
30 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
10 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
34 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
0answers
22 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
36 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
99 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
56 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
45 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 &...
2
votes
1answer
1k 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
26 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, ...
1
vote
1answer
154 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
46 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
104 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
110 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
89 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
0answers
16 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
366 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
49 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
387 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
40 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 ...
0
votes
0answers
50 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
78 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
194 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
13 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
155 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
65 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
130 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 ...
0
votes
2answers
174 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
48 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 ...
2
votes
2answers
139 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
1answer
131 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
28 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
1answer
40 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
2answers
55 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 ...
2
votes
1answer
197 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; ...
1
vote
1answer
105 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 ...
0
votes
1answer
610 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 { ...
0
votes
1answer
49 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
58 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
82 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
28 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 ...
0
votes
1answer
52 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
1answer
174 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 ...