MyCrypto/common/libs/values.js
William O'Beirne 7541d6f486 Estimate gas (WIP) (#102)
* relayout rpc code, start contract helper

* Dont ask for estimate if theres no value

* Split out conversion of ether to wei hex into lib function.

* big.js -> bignumber.js
2017-08-07 22:45:08 -05:00

17 lines
481 B
JavaScript

// @flow
import Big from 'bignumber.js';
import { toWei } from 'libs/units';
export function stripHex(address: string): string {
return address.replace('0x', '').toLowerCase();
}
export function valueToHex(n: Big | number | string): string {
// Convert it to a Big to handle any and all values.
const big = new Big(n);
// Values are in ether, so convert to wei for RPC calls
const wei = toWei(big, 'ether');
// Finally, hex it up!
return `0x${wei.toString(16)}`;
}