Hi guys, I'm new to the world of blockchain and after a bit of general study, I've been practising with Solidity.
Now I'm building a small Dapp but I have a problem: I can't figure out how to change the actual balance of the contract (understood as "address(this).balance"). In Solidity it is possible to do this automatically via the msg.value passing to a "Deposit" event, in my case, however, as the interface is linked to metamask, I realised that it is not possible to do this. So I was wondering if the only way is to declare a balance variable and modify it accordingly through a method that takes as variable a "uint amount" taken from inputval entered through the front end interface
The strange thing though is that this doesn't actually work with ether, so I don't know if I'm doing something wrong or not.
Thanks for the help

Jun 24, 2022, 8:34 PM
Do u use tokens or eth for balance
Just make a function that returns address this balance
Jun 24, 2022, 8:52 PM
I'd like to work with ethers so I can automatically use the various send, call and transfer methods but I can't throw an event to deposit ether from an account to that contract I'm working on.
Only way is msg.value but I don't know if you can convert it somehow in the front end
Jun 24, 2022, 8:56 PM
ok so you can't modify the contract
but i mean address.balance should return the contract balance
Jun 24, 2022, 8:59 PM
Ahh okk
I understand... Thanks
Jun 24, 2022, 9:01 PM

© 2024 Draquery.com All rights reserved.