public function exec(array $req = []) {
        usleep(250000);

        // API settings
        $req['apikey'] = $this->apiKeyToken;

        // generate the POST data string
        $postData = http_build_query($req, '', '&');

        // curl handle (initialize if required)
        if (is_null(self::$ch)) {
            self::$ch = curl_init();
            curl_setopt(self::$ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt(
                self::$ch,
                CURLOPT_USERAGENT,
                'Mozilla/4.0 (compatible; Etherscan PHP API; ' . php_uname('a') . '; PHP/' . phpversion() . ')'
            );
        }
        curl_setopt(self::$ch, CURLOPT_URL, \etherscan\api\EtherscanAPIConf::getAPIUrl($this->net));
        curl_setopt(self::$ch, CURLOPT_POSTFIELDS, $postData);
        curl_setopt(self::$ch, CURLOPT_SSL_VERIFYPEER, false);

        // run the query
        $res = curl_exec(self::$ch);
        if ($res === false) {
            throw new \Exception("Curl error: " . curl_error(self::$ch));
        }

        $json = json_decode($res, true);

        // Check for the Etherscan API error
        if (isset($json['error'])) {
            throw new \Exception("Etherscan API error: {$json['error']}");
        }

        return $json;
    }
public function exec(array $req = []) {
        usleep(250000);

        // API settings
        $req['apikey'] = $this->apiKeyToken;

        // generate the POST data string
        $postData = http_build_query($req, '', '&');

        // curl handle (initialize if required)
        if (is_null(self::$ch)) {
            self::$ch = curl_init();
            curl_setopt(self::$ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt(
                self::$ch,
                CURLOPT_USERAGENT,
                'Mozilla/4.0 (compatible; Etherscan PHP API; ' . php_uname('a') . '; PHP/' . phpversion() . ')'
            );
        }
        curl_setopt(self::$ch, CURLOPT_URL, \etherscan\api\EtherscanAPIConf::getAPIUrl($this->net));
        curl_setopt(self::$ch, CURLOPT_POSTFIELDS, $postData);
        curl_setopt(self::$ch, CURLOPT_SSL_VERIFYPEER, false);

        // run the query
        $res = curl_exec(self::$ch);
        if ($res === false) {
            throw new \Exception("Curl error: " . curl_error(self::$ch));
        }

        $json = json_decode($res, true);

        // Check for the Etherscan API error
        if (isset($json['error'])) {
            throw new \Exception("Etherscan API error: {$json['error']}");
        }

        return $json;
    }
public function exec ( array $ req = [ ] ) { usleep ( 250000 ) ; // API settings $ req [ 'apikey' ] = $ this -> apiKeyToken ; // generate the POST data string $ postData = http_build_query ( $ req , '' , '&' ) ; // curl handle (initialize if required) if ( is_null ( self :: $ ch ) ) { self :: $ ch = curl_init ( ) ; curl_setopt ( self :: $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( self :: $ ch , CURLOPT_USERAGENT , 'Mozilla/4.0 (compatible; Etherscan PHP API; ' . php_uname ( 'a' ) . '; PHP/' . phpversion ( ) . ')' ) ; } curl_setopt ( self :: $ ch , CURLOPT_URL , \ etherscan \ api \ EtherscanAPIConf :: getAPIUrl ( $ this -> net ) ) ; curl_setopt ( self :: $ ch , CURLOPT_POSTFIELDS , $ postData ) ; curl_setopt ( self :: $ ch , CURLOPT_SSL_VERIFYPEER , false ) ; // run the query $ res = curl_exec ( self :: $ ch ) ; if ( $ res === false ) { throw new \ Exception ( "Curl error: " . curl_error ( self :: $ ch ) ) ; } $ json = json_decode ( $ res , true ) ; // Check for the Etherscan API error if ( isset ( $ json [ 'error' ] ) ) { throw new \ Exception ( "Etherscan API error: {$json['error']}" ) ; } return $ json ; }
Executes curl request to the Etherscan API.

@param array $req Request parameters list.

@return array JSON data.
@throws \Exception If Curl error or Etherscan API error occurred.
Executes curl request to the Etherscan API .