hi, is there anyone could redirect me to the explanation of "how can I set msg.value in web3js " or simply tell? I can interact to the contract totally but i don't know how to get/set value at msg.value in the dapp

Mar 26, 2021, 7:04 PM
That's the amount of Ethers you send in the transaction (not to be confused with gas things). You can't set it explicitly. If you don't send any Ethers, the value is 0
Mar 26, 2021, 7:05 PM
thanks. the problem is i can't find how to reach to that value via web3js.
Mar 26, 2021, 7:07 PM
to send Ethers in a transaction you can do something like contr.someFunc(someParam, {value: amountInWeis} )
Mar 26, 2021, 7:07 PM
I've got a deposit function uses msg.value. should I write a transaction function to run deposit function, you suggest?
Mar 26, 2021, 7:08 PM
no, just call the deposit function from your web3 code
Mar 26, 2021, 7:08 PM
web3.eth.sendTransaction({from: someAddress, to: someAddress, value: web3.utils.toWei(“1”, “ether”)})
Mar 26, 2021, 7:31 PM
I'm testing this, thanks... @sleepstntnc
thank you, too @Lauri_P
Mar 26, 2021, 7:33 PM
I m sorry
Corrected to the newer version
If u want to send on the contract
Use @Lauri_P example
Mar 26, 2021, 7:38 PM
well the things is i just need to pass a value that I got from input element to the network as msg.value, I'm building a dapp on someone else's contract, their deposit function doesn't have a getter value parameter, it uses msg.value only. i think it's best to send transaction to the contract manually to realize the deposit.
Mar 26, 2021, 7:40 PM

© 2024 Draquery.com All rights reserved.