Ethereum PHP
PHP interface to Ethereum JSON-RPC API.
TestEthContract.php
Go to the documentation of this file.
1 <?php
9 namespace Ethereum;
10 
12 use Exception;
13 
66 abstract class TestEthContract extends TestEthClient {
67 
68  protected $data;
69  protected $contract;
70 
77  protected function setUp()
78  {
87  $contractName = (new \ReflectionClass($this))->getShortName();
88  $fileName = getcwd() . '/tests/TestEthClient/test_contracts/build/contracts/' . $contractName . '.json';
89 
90  if (!file_exists($fileName)) {
91  throw new Exception(
92  'You need to compile and deploy the smartcontracts located in TestEthClient/test_contracts/contracts using truffle.'
93  . ' (npm -i -g truffle && truffle compile && truffle migrate)'
94  );
95  }
96 
97  $this->data = json_decode(file_get_contents($fileName));
98  $this->contract = new SmartContract(
99  $this->data->abi,
100  $this->data->networks->{NETWORK_ID}->address,
101  new Ethereum(SERVER_URL)
102  );
103  }
104 }
Definition: Abi.php:3