wallet tron transactions
This commit is contained in:
@ -6,6 +6,8 @@ class Math
|
||||
const SCALE = 8;
|
||||
const SCALE_4 = 4;
|
||||
const SCALE_6= 6;
|
||||
const SCALE_8= 8;
|
||||
const DECIMAL_6= 6;
|
||||
static function bcMul($a1,$a2,$scale = self::SCALE): string
|
||||
{
|
||||
return bcmul($a1,$a2,$scale);
|
||||
@ -26,6 +28,17 @@ class Math
|
||||
return bccomp($a1,$a2,$scale);
|
||||
}
|
||||
|
||||
static function valueToAmount($amount,$decimal = self::DECIMAL_6,$scale = self::SCALE_8): string
|
||||
{
|
||||
return (float) bcdiv((string)$amount, '1e'.$decimal, $scale);
|
||||
}
|
||||
|
||||
static function amountToValue($amount,$decimal = self::DECIMAL_6): string
|
||||
{
|
||||
return (float) bcmul((string)$amount, '1e'.$decimal,0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tools;
|
||||
use App\Const\Prefix;
|
||||
use Godruoyi\Snowflake\Snowflake;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@ -53,9 +54,9 @@ class Tools
|
||||
return rand(100000,999999);
|
||||
}
|
||||
|
||||
static function genUuid(): string
|
||||
static function genUuid($prefix = Prefix::ORDER_SN_PREFIX): string
|
||||
{
|
||||
return Str::orderedUuid();
|
||||
return $prefix.Str::orderedUuid();
|
||||
}
|
||||
|
||||
static function JonsEncode(array $aData): string
|
||||
|
||||
20
app/Tools/TronTools.php
Normal file
20
app/Tools/TronTools.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tools;
|
||||
|
||||
use IEXBase\TronAPI\TronAwareTrait;
|
||||
|
||||
class TronTools
|
||||
{
|
||||
use TronAwareTrait;
|
||||
|
||||
static function hexToBase58(string $hex): string
|
||||
{
|
||||
return (new TronTools)->address2HexString($hex);
|
||||
}
|
||||
|
||||
static function base58ToHex(string $base58): string
|
||||
{
|
||||
return (new TronTools)->hexString2Address($base58);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user