Ethereum PHP
PHP interface to Ethereum JSON-RPC API.
EthDataType Class Reference
+ Inheritance diagram for EthDataType:
+ Collaboration diagram for EthDataType:

Public Member Functions

 getProperty (string $property='value', bool $returnHexVal=false)
 
 setValue ($val, array $params=[])
 
 getClassName ()
 
- Public Member Functions inherited from EthDataTypeInterface
 toArray ()
 

Static Public Member Functions

const static getClassByAbi (string $abiType)
 
static getDataLengthType ()
 
static isPrimitive ()
 
static getTypeClass (string $type, bool $typed_constructor=false)
 
static getAllTypeClasses ()
 
- Static Public Member Functions inherited from EthereumStatic
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')
 

Detailed Description

Base Class for all Data types.

Definition at line 44 of file EthDataType.php.

Member Function Documentation

◆ getAllTypeClasses()

static getAllTypeClasses ( )
static

Returns array of all existing data type class names.

Returns
array Array with names of all type classes.

Definition at line 311 of file EthDataType.php.

References $schema, EthereumStatic\getDefinition(), and EthD\getPrimitiveTypes().

+ Here is the call graph for this function:

◆ getClassByAbi()

const static getClassByAbi ( string  $abiType)
static

Get PHP-class by ABI.

Parameters
string$abiTypeEthereum ABI type. See https://solidity.readthedocs.io/en/develop/abi-spec.html#types
Returns
string Name spaced class, you may use to do things like: new $class($myVal)
Exceptions

Definition at line 131 of file EthDataType.php.

◆ getClassName()

getClassName ( )

Get type class name.

Returns
string ClassName without namespace.

Definition at line 252 of file EthDataType.php.

◆ getDataLengthType()

static getDataLengthType ( )
static

Every Data class is 'static' or 'dynamic'.

See also
: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI#types
Returns
string

Implements EthDataTypeInterface.

Definition at line 161 of file EthDataType.php.

◆ getProperty()

getProperty ( string  $property = 'value',
bool  $returnHexVal = false 
)

Get hexadecimal representation of $value.

Parameters
string$propertyName of the property.
bool$returnHexValSet to TRUE to get the hexadecimal value.
Exceptions

Implements EthDataTypeInterface.

Definition at line 197 of file EthDataType.php.

◆ getTypeClass()

static getTypeClass ( string  $type,
bool  $typed_constructor = false 
)
static

Determine type class name for primitive and complex data types.

Parameters
string$typeType containing Schema name. Might be "[D20]" to indicate an array
bool$typed_constructorIf true this function will return "array" for types of array($type), instead of $type.
Returns
string Class name of type.
Exceptions

Implements EthDataTypeInterface.

Definition at line 274 of file EthDataType.php.

References EthD\typeMap().

Referenced by Ethereum\__call(), and Ethereum\handleFilterChangeValues().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isPrimitive()

static isPrimitive ( )
static

Check if Type is a primitive type.

Primitive types are implemented manually, while the complex types are generated with php scripts/generate-complex-datatypes.php using resources/ethjs-schema.json['objects'] as a source.

Returns
bool True if data type is primitive.

Implements EthDataTypeInterface.

Definition at line 176 of file EthDataType.php.

◆ setValue()

setValue (   $val,
array  $params = [] 
)

Validation is implemented in subclasses.

Parameters
mixed$valValue to set.
array$paramsArray with optional keyed arguments.
Exceptions

Implements EthDataTypeInterface.

Definition at line 233 of file EthDataType.php.

Referenced by EthD\__construct().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: