Hi,
Please tell me how to send the mount in Ether through the Solidity function. I have got the following contract with transferTo(…) method.
pragma solidity ^0.4.18;
contract A {address owner;
function constructor() { owner = msg.sender;}
function transferTo(address to, uint amount) public {
to.call.value(amount)();}
function() payable public {}
}
I am accessing transferTo(…) function through Truffle console. I want to send the amount in Ether through ‘transferTo(…)’ method but I think it is accepting the amount in Wei and printing the value in decimal point instead of whole number. Please guide me how to send the value through Truffle console so that it should be in whole number.
I invoke the function like:
Do you know what web3.utils.fromWei(recev, "ether") does?
If you do, what is the reverse function of fromWei?
Is it possible to call the reverse function of fromWei and then use it in the transferTo function as a parameter?
If you can discover the answers to these questions, I believe you'd be able to solve all your questions.
Value is specified in uint. Sorry still I can't understand why I am not getting the Ether value as sent through 'transferTo(..) ' method. Why its dividing by 10^18? Please guide me, I am stuck.
Zulfi.
Maybe a few more questions for you.
If it’s dividing by 10^18, what should you do to get it back? Maybe reverse it?
What is toWei and fromWei again? Describe its operation mathematically. What does it do? Divide or multiply or both? And by how much again?
Hi,
I have already answered your questions in post#4 and post#6, please provide me the solution now. Otherwise, I would think that you don’t know the answer.
What exactly do you think toWei and fromWei is doing if it's not multiply by 10^18 and dividing by 10^18, when you specify 'ether' in the second parameter?
When I asked you what transferTo takes as a value, and what it's specified in, it was to let you think about it, and the answer is that the value is specified in Wei.
In your code, and in your line of thinking, you only used fromWei, without using the reverse, toWei. That's why you couldn't get the answer.
Asking somebody what the answer is, is rather easy.
Thinking about how to derive the answer is more challenging.