Static Public Member Functions | |
static | getMethodSignature ($input) |
static | phpKeccak256 ($string) |
static | sha3 ($string) |
static | isValidFunction ($input) |
static | getDefinition () |
static | isValidHexQuantity ($str) |
static | isValidHexData ($str) |
static | isValidAddress ($address, $throw=false) |
static | hasHexPrefix ($str) |
static | removeHexPrefix ($str) |
static | ensureHexPrefix ($str) |
static | convertCurrency (float $amount, string $from='wei', string $to='ether') |
Static helper functions for Ethereum JsonRPC API for PHP.
Definition at line 10 of file EthereumStatic.php.
|
static |
Convert from and to ether Ether
Defaults from wei to ether.
float | $amount | |
string | $from | |
string | $to |
Definition at line 291 of file EthereumStatic.php.
|
static |
Add Hex Prefix "0x".
string | $str | String without prefix. |
Definition at line 271 of file EthereumStatic.php.
Referenced by EthS\hexVal(), EthBlockParam\hexVal(), EthBytes\validate(), and EthD\validate().
|
static |
Retrieve the Ethereum JsonRPC API definition.
Normally the content of the file resources/ethjs-schema.json.
Definition at line 124 of file EthereumStatic.php.
Referenced by EthDataType\getAllTypeClasses().
|
static |
Get signature of a solidity method.
Returns hash of the Smart contract method - it's signature.
See: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI#function-selector
string | $input | Method signature. |
Definition at line 29 of file EthereumStatic.php.
|
static |
Test if a string is prefixed with "0x".
string | $str | String to test prefix. |
Definition at line 239 of file EthereumStatic.php.
Referenced by EthS\validate(), and EthQ\validate().
|
static |
Check for a valid Ethereum address.
Tests if the given string qualifies as a Ethereum address. (DATA, 20 Bytes - address)
string | $address | String to test for Address. |
bool | $throw | If TRUE we will throw en error. |
Definition at line 216 of file EthereumStatic.php.
References $address.
|
static |
Is valid function.
"The signature is defined as the canonical expression of the basic prototype, i.e. the function name with the parenthesised list of parameter types."
This function ignores Aliases. E.g: test(uint) test(uint256) should both result in 0x29e99f07. This is intentional. It is not recommended to use short names for function signatures.
string | $input | Function ABI as string. See: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI. |
Definition at line 105 of file EthereumStatic.php.
|
static |
Tests if the given string is a HEX UNFORMATED DATA value.
See: https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding.
string | $str | String to test for Hex. |
Definition at line 182 of file EthereumStatic.php.
|
static |
Decodes a HEX encoded number.
See: https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding.
This is now handled by Math_BigInteger https://pear.php.net/package/Math_BigInteger/docs/latest/Math_BigInteger/Math_BigInteger.html.
See class EthQ. Tests string for valid hex quantity.
See: https://github.com/ethereum/wiki/wiki/JSON-RPC#hex-value-encoding.
string | $str | String to test for Hex. |
Definition at line 154 of file EthereumStatic.php.
|
static |
Keccak hash function.
This is a a local version of web3_sha3() based on https://github.com/kornrunner/php-keccak
Ethereum JsonRPC provides web3.sha3(), but making a JsonRPC call for that seems costly.
Unlike web3's sha3 method suggests Ethereum is NOT using SHA3-256 standard implementation (the NIST SHA3-256 became a standard later), but Keccak256. Is is the pure Keccak[r=1088, c=512] implementation.
string | $string | String to hash. |
Definition at line 61 of file EthereumStatic.php.
|
static |
Remove Hex Prefix "0x".
string | $str | String with prefix. |
Definition at line 253 of file EthereumStatic.php.
Referenced by EthBytes\val(), and EthBytes\validate().
|
static |
Wrapper to phpKeccak256($string).
Ethereum sha3 is not the same as the standardized sha3.
As web3js provides a sha3() method we have this wrapper for convenience.
$string | String to hash. |
Definition at line 80 of file EthereumStatic.php.