Skip to content

Commit 3958e7c

Browse files
committed
initial commit
0 parents  commit 3958e7c

File tree

13 files changed

+800
-0
lines changed

13 files changed

+800
-0
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.idea
2+
.php_cs
3+
.php-cs-fixer.cache
4+
.phpunit.result.cache
5+
build
6+
composer.lock
7+
coverage
8+
docs
9+
psalm.xml
10+
vendor

.styleci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
preset: laravel

CHANGELOG.md

Whitespace-only changes.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2022 slvler <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# slvler - Etherscan Service
2+
3+
[![Latest Stable Version](http://poser.pugx.org/qwerty/tmdb/v)](https://packagist.org/packages/qwerty/tmdb)
4+
[![Latest Unstable Version](http://poser.pugx.org/qwerty/tmdb/v/unstable)](https://packagist.org/packages/qwerty/tmdb)
5+
[![License](http://poser.pugx.org/qwerty/tmdb/license)](https://packagist.org/packages/qwerty/tmdb)
6+
7+
8+
9+
An api service for etherscan.io
10+
11+
12+
## Installation
13+
14+
To install this package tou can use composer:
15+
16+
```bash
17+
composer require qwerty/tmdb
18+
```
19+
20+
## Usage
21+
22+
- First, you should extract the config/etherscan.php file to the config folder.
23+
24+
```php
25+
php artisan vendor:publish --tag=ether
26+
```
27+
28+
- API key to be obtained from etherscan.io address should be declared.
29+
30+
```php
31+
'ether' => [
32+
'etherscan_url' => 'https://api.etherscan.io/',
33+
'etherscan_key' => 'XXXXXXXXXXXXXXXXXXXXXXXX'
34+
]
35+
```
36+
37+
- This is how you can connect to the etherscan api service.
38+
- Returns the Ether balance of a given address.
39+
40+
```php
41+
$ether = new EtherScanService();
42+
$ether->balance('0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae');
43+
```
44+
45+
- Returns the balance of the accounts from a list of addresses.
46+
47+
```php
48+
$data = [
49+
'0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a',
50+
'0x63a9975ba31b0b9626b34300f7f627147df1f526',
51+
'0x198ef1ec325a96cc354c7266a038be8b5c558f67'
52+
];
53+
54+
$ether = new EtherScanService();
55+
$ether->balance_multiple($data);
56+
```
57+
58+
59+
- Returns the list of transactions performed by an address, with optional pagination.
60+
61+
```php
62+
$ether = new EtherScanService();
63+
$ether->transactions_normal('0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae');
64+
```
65+
66+
67+
- Returns the list of internal transactions performed by an address, with optional pagination.
68+
69+
```php
70+
$ether = new EtherScanService();
71+
$ether->transactions_internal('0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae');
72+
```
73+
74+
- Returns the list of internal transactions performed within a transaction.
75+
76+
```php
77+
$ether = new EtherScanService();
78+
$ether->transactions_internal_hash('0x40eb908387324f2b575b4879cd9d7188f69c8fc9d87c901b9e2daaea4b442170');
79+
```
80+
81+
- Returns the list of internal transactions performed within a block range, with optional pagination.
82+
83+
```php
84+
$ether = new EtherScanService();
85+
$ether->transactions_internal_block_range();
86+
```
87+
88+
89+
- Returns the list of ERC-20 tokens transferred by an address, with optional filtering by token contract.
90+
91+
```php
92+
$ether = new EtherScanService();
93+
$ether->token_transfer_events_erc20();
94+
```
95+
96+
97+
- Returns the list of ERC-721 ( NFT ) tokens transferred by an address, with optional filtering by token contract.
98+
99+
```php
100+
$ether = new EtherScanService();
101+
$ether->token_transfer_events_erc721();
102+
```
103+
104+
- Returns the list of ERC-1155 ( Multi Token Standard ) tokens transferred by an address, with optional filtering by token contract.
105+
106+
```php
107+
$ether = new EtherScanService();
108+
$ether->token_transfer_events_erc1155();
109+
```
110+
111+
112+
- Returns the list of blocks mined by an address.
113+
114+
```php
115+
$ether = new EtherScanService();
116+
$ether->address_blocks_mined();
117+
```
118+
119+
- Returns the balance of an address at a certain block height. - PRO
120+
121+
```php
122+
$ether = new EtherScanService();
123+
$ether->balance_single_adress();
124+
```
125+
126+
127+
### Testing
128+
129+
```bash
130+
composer test
131+
```
132+
133+
## Credits
134+
135+
- [slvler](https://github.com/slvler)
136+
137+
138+
## License
139+
140+
The MIT License (MIT). Please see [License File](https://github.com/hs-qwerty/TMDB/blob/main/LICENSE.md) for more information.

composer.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "slvler/ether",
3+
"description": "etherscan api",
4+
"type": "package",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "slvler",
9+
"email": "[email protected]"
10+
}
11+
],
12+
"autoload": {
13+
"psr-4": {
14+
"Slvler\\Ether\\": "src/"
15+
}
16+
},
17+
"autoload-dev": {
18+
"psr-4": {
19+
"Slvler\\Ether\\Tests\\": "tests/"
20+
}
21+
},
22+
"require": {},
23+
"require-dev": {
24+
"orchestra/testbench": "^6.18.0",
25+
"phpunit/phpunit": "^9.5",
26+
"guzzlehttp/guzzle": "^7.0.1"
27+
},
28+
"scripts": {
29+
"test": "vendor/bin/phpunit tests"
30+
},
31+
"extra": {
32+
"laravel": {
33+
"providers": [
34+
"Slvler\\Ether\\EtherServiceProvider"
35+
]
36+
}
37+
},
38+
"minimum-stability": "dev",
39+
"prefer-stable": true
40+
}

config/etherscan.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
4+
return [
5+
6+
'ether' => [
7+
'etherscan_url' => 'https://api.etherscan.io/',
8+
9+
'etherscan_key' => 'WI48Q1V6RFNY7E1U773E2J5EAB8A1ZG8UM'
10+
]
11+
12+
];

phpunit.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
>
7+
<testsuites>
8+
<testsuite name="Unit">
9+
<directory suffix="Test.php">./tests/Unit</directory>
10+
</testsuite>
11+
<testsuite name="Feature">
12+
<directory suffix="Test.php">./tests/Feature</directory>
13+
</testsuite>
14+
</testsuites>
15+
<coverage processUncoveredFiles="true">
16+
<include>
17+
<directory suffix=".php">./src</directory>
18+
</include>
19+
</coverage>
20+
</phpunit>

src/EtherServiceProvider.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
4+
namespace Slvler\Ether;
5+
6+
use Illuminate\Support\ServiceProvider;
7+
8+
class EtherServiceProvider extends ServiceProvider{
9+
10+
11+
public function boot()
12+
{
13+
if ($this->app->runningInConsole()) {
14+
$this->publishResources();
15+
}
16+
17+
}
18+
19+
protected function publishResources()
20+
{
21+
$this->publishes([
22+
__DIR__ . '/../config/etherscan.php' => config_path('etherscan.php'),
23+
], 'ether');
24+
}
25+
26+
}

src/Resources/Balance.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
4+
namespace Slvler\Ether\Resources;
5+
6+
use Illuminate\Http\Resources\Json\JsonResource;
7+
8+
class Balance extends JsonResource
9+
{
10+
11+
/**
12+
* Transform the resource collection into an array.
13+
*
14+
* @param \Illuminate\Http\Request $request
15+
* @return array
16+
*/
17+
public function toArray($request)
18+
{
19+
20+
return [
21+
'status' => $this->status,
22+
'message' => $this->message,
23+
'result' => $this->result
24+
];
25+
26+
}
27+
}

0 commit comments

Comments
 (0)