-6

1 Ether = 1000000000000000000. //The ether price in wei

I know this price in wei.It is may be in other smallest unit of gas like Kwei, Ada, Femtoether or Finney, Milliether,Milli.So, solidity code how verify the price is in which unit??

So I define my price in solidity code like this:- 1 Ether = 1000000000000000000 wei. So, solidity code easily identify.Please tell me it is correct or not??

  • 1
    Please elaborate. It's not clear at all what you are asking. – mafrasi2 Apr 27 '18 at 14:19
0

Your token price should always be in Wei. Everything in solidity referring to units of Ether should do it in Wei.

0

I'm not sure I understand your question.
But take a look at this in the official documentation. There are ether units defined, which you can use in your code. wei, finney, szabo or ether. When you are not using any of these, it will be viewd as wei.

Please elaborate further if this doesn't answer your question

0

I believe the names like ether wei etc are hardcoded into solidity.

A literal number can take a suffix of wei, finney, szabo or ether to convert between the subdenominations of Ether, where Ether currency numbers without a postfix are assumed to be Wei, e.g. 2 ether == 2000 finney evaluates to true.

http://solidity.readthedocs.io/en/v0.4.21/units-and-global-variables.html

Regarding the other tokens, they belong to another contract,i think that if you want to define a value between tokens you'll have to call the contract that originated them. Hope it helps.

0

There are other ether units available for use. Finney, Szabo or Ether. For example:

require(withdraw_amount <= 1000000000000000000);

could also be written as:

require(withdraw_amount <= 1 ether);

The default unit of notation is wei.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.