caliper-benchmarks icon indicating copy to clipboard operation
caliper-benchmarks copied to clipboard

Caliper Benchmark Ethereum: Payable functions

Open canarseven opened this issue 4 years ago • 5 comments

One of my Ethereum smart contract functions is of type payable. Thus, I need to send a certain amount of ether to the function so it executes its logic. I could not find such a field provided by your Blockchain call function blockchain.invokeSmartContract(), I also looked at caliper/packages/caliper-ethereum/lib/ethereum.js trying to find a field or function to specify but still have no clue.

Appreciate any hint or idea on what I could do to test my payable function through Caliper.

canarseven avatar Jun 04 '20 17:06 canarseven

@benjamincburns Can you help with this question/request?

aklenik avatar Jun 05 '20 10:06 aklenik

Just to reiterate over my question, because maybe it was too ambiguous:

For example: I have a function of this format in my smart contract: function sendMeEther() payable public { contractValue += msg.value }

And would like to send ether by setting the value field in my transaction call to this function. Otherwise, my function will not compute correctly. With web3js I would do it like this e.g:

web3.eth.sendTransaction({ from: '0x.....', to: '0x....', value: myValue.asHex() })

Thus, how can I access this through the Caliper Blockchain class inside my benchmark js? Suggestions on how to access it not through the Blockchain class but through other ways, is also appreciated! :)

canarseven avatar Jun 08 '20 11:06 canarseven

Any answer to this question yet?

fbalwy avatar Oct 15 '20 00:10 fbalwy

Following the question.

nachikettapas avatar Dec 24 '20 09:12 nachikettapas

Following the question.

If anyone is still looking for the solution, I created a PR #1122 and #1124 for this. For usage, check caliper documentation for version vNext. Also, you can have a look at integration tests about how to use value parameter.

https://github.com/hyperledger/caliper/blob/master/packages/caliper-tests-integration/ethereum_tests/open.js

nachikettapas avatar Jan 22 '21 10:01 nachikettapas