Skip to content

Commit

Permalink
caluculate ether value in wei unit by powering 10 by 18
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzushioh committed Jun 16, 2018
1 parent ec3365b commit 48bac7e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion EthereumKit/Helper/Converter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ public typealias Ether = Decimal
public typealias Wei = BInt

public final class Converter {
private static let etherInWei = Decimal(1000000000000000000)

// NOTE: calculate wei by 10^18
private static let etherInWei = pow(Decimal(10), 18)

/// Convert Wei(BInt) unit to Ether(Decimal) unit
public static func toEther(wei: Wei) throws -> Ether {
Expand Down

0 comments on commit 48bac7e

Please sign in to comment.