Problem I face: How to work with Money in PHP if currencies are Bitoins, Litecoins, Etherum and others alt-coins?
This problem in case of fiat money is solved mostly by representing money as int
in the smallest unit (cents, etc...).
- Implementation for example looks like: https://github.com/moneyphp/money
But as crypto-coins are represented mostly as number like 0.0235678
and the smallest unit is not so clear.
Yes, for Bitcoins there are Satoshi, Etherum has Tether and other crypto coins are similar mechanics. But as those currencies are designed to be deflationary, there is theoretical chance that the smaller units will be needed in the future.
I would like to solve this too.
Exact numbers are very often represented as string
. And therefore using of http://php.net/manual/en/book.bc.php came up to my mind.
- Does anyone have any other alternative?
- Or there is some implemention of
Money
object in PHP (I didn't find any).
Now, I see only option to implement my own Money
object internally using bcmath
.
Thanks for suggestions.