question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

calling a payable function with parameters

See original GitHub issue

i’m struggling to find an example to use a payable function with parameters.

let’s say i’ve an function in my Smart Contract:

    function doSomething(address[] _adresses, address[] _groups, uint[] _percentages)
        public
        payable
        returns(address) {

How do i call this SC and send ethers to it & pass parameters and get the return value?

Thanks.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
shamatarcommented, Aug 23, 2018

Hello @ungaro

First of all you should understand that if the function is mutating (like one above) you are not guaranteed that a return value will in fact be the same when you check for it and when transaction executes.

  1. how to get a return value:
  • encode the parameters into the “TransactionIntermediate”. Please check the various examples in tests
  • use the “call” method on this intermediate and supply required options (Web3Options struct) into the call. One of the field in options is “value” - it’s an amount of Wei (1 ETH = 10^18 wei) attached to the transaction
  • upon execution you will get returned parameters
  1. to send a transaction
  • make an intermediate
  • use the “send” method and supply the options

I recommend you to go through the tests of web3swift to check the examples.

Sincerely, Alex

0reactions
BaldyAshcommented, Oct 25, 2018

It seems that the issue is resolved, so its closed

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to call a payable function with multiple parameters using ...
This is how you can call payable contract method along with some ether and sender. c.deposit(420, { value: 10000000000000000000, ...
Read more >
Call a Payable Solidity Function Using Ethers - vsupalov.com
A simple way to call a payable Solidity function, either from your tests or your dApp code. ... The ALL, OTHER, PARAMETERS part...
Read more >
Solidity calling payable function with arguments with hardhat ...
ethers.utils.parseEther returns object with BigNumber in it.. you have to convert it into string before using it in the test.. Eg:
Read more >
Calling payable contract method with arguments #563 - GitHub
I'm trying to execute trades on uniswap but I can't find how to call a payable method with arguments. I'm finding the documentation...
Read more >
Contracts — Solidity 0.8.17 documentation
A contract can have multiple functions of the same name but with different parameter types. This process is called “overloading” and also applies...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found