Ethereum PHP
PHP interface to Ethereum JSON-RPC API.
SmartContract Class Reference

Public Member Functions

 __construct (array $abi, string $contractAddress, Ethereum $eth)
 
 __call (string $method, array $args)
 
 processLog (FilterChange $filterChange)
 
 getAddress ()
 

Static Public Member Functions

static createFromTruffleBuildDirectory ($path, $web3=null, $networkId=null)
 
static createMetaFromTruffle ($filePath)
 

Protected Attributes

 $events
 

Detailed Description

Ethereum SmartContract API for PHP.

Definition at line 16 of file SmartContract.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( array  $abi,
string  $contractAddress,
Ethereum  $eth 
)

SmartContract constructor.

Parameters
$abiarray Smart contract ABI.
string$contractAddressAddress of the contract at the network given in $eth.
\Ethereum\Ethereum$ethInstance of Ethereum connected to a Ethereum client.
Exceptions

Definition at line 56 of file SmartContract.php.

Member Function Documentation

◆ __call()

__call ( string  $method,
array  $args 
)

Calling contract functions.

Parameters
string$methodName of the Smart contract method you wish to call.
$argsArguments provided.
Exceptions
Todo:
Maybe we need a smarter default block param handling here.

Definition at line 79 of file SmartContract.php.

◆ createFromTruffleBuildDirectory()

static createFromTruffleBuildDirectory (   $path,
  $web3 = null,
  $networkId = null 
)
static

Create a array of Contracts from Truffle compiled solidity code.

These JSON files are generated, when you run truffle compile && truffle migrate.

If web3 and networkId are given the array will have initialized contracts.

Parameters
$pathPath to the compiled truffle Json files.
\Ethereum\Ethereum$web3Instance of a connected web3 client.
string$networkIdNetwork Id as defined in truffle.js
See also
https://github.com/digitaldonkey/ethereum-php/blob/dev/tests/TestEthClient/test_contracts/truffle.js
Exceptions

Definition at line 155 of file SmartContract.php.

References $address.

◆ createMetaFromTruffle()

static createMetaFromTruffle (   $filePath)
static
Parameters
$filePath
Returns
mixed

Definition at line 189 of file SmartContract.php.

◆ getAddress()

getAddress ( )
Returns
string

Definition at line 129 of file SmartContract.php.

◆ processLog()

processLog ( FilterChange  $filterChange)
Parameters
\Ethereum\DataType\FilterChange$filterChange
Exceptions

Definition at line 104 of file SmartContract.php.

Member Data Documentation

◆ $events

$events
protected

Contract Events array in the form $events[<topic hex>="">]= .

Definition at line 38 of file SmartContract.php.


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