Web3.swift icon indicating copy to clipboard operation
Web3.swift copied to clipboard

Using decimal precision with EthereumQuantity

Open mrdavey opened this issue 7 years ago • 3 comments

'EthereumQuantity' only accepts BigUInt, however this becomes a problem if I want to do this: EthereumQuantity(quantity: BigUInt(1.5).eth)

Is there a way to create an 'EthereumQuantity' using a Double?

mrdavey avatar Aug 01 '18 18:08 mrdavey

Why would you want to create an EthereumQuantity with a Double? Everything in this library (and in the Ethereum ecosystem) is calculated with wei. There are no fragments of wei as this is the smallest unit in Ethereum.

koraykoska avatar Aug 04 '18 10:08 koraykoska

If you need it as an input parameter for a Contract which uses fixed or ufixed types, you will have to wait until the next minor version jump where we will add those types and corresponding BigDecimal and BigUDecimal types. You can track the progress in branch feature/decimal.

koraykoska avatar Aug 04 '18 10:08 koraykoska

@koraykoska I need BigDecimals in my project - whats the state of the decimal branch? It seems to be ready, why was it never merged in?

daihovey avatar Mar 08 '21 13:03 daihovey