Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 47b1389

Browse filesBrowse files
committed
Merge branch 'release/token'
2 parents 79f8bf8 + 427c284 commit 47b1389
Copy full SHA for 47b1389

File tree

Expand file treeCollapse file tree

2 files changed

+102
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+102
-1
lines changed

‎CHANGELOG.md

Copy file name to clipboardExpand all lines: CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
8+
## [1.3.3] - 2021-11-03
9+
### Added
10+
- token actions
11+
712
## [1.3.2] - 2021-10-14
813
### Changed
914
- update documentation links

‎lib/Etherscan/Api/Token.php

Copy file name to clipboardExpand all lines: lib/Etherscan/Api/Token.php
+97-1Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,101 @@
99
*/
1010
class Token extends AbstractApi
1111
{
12+
/**
13+
* Get ERC20-Token TotalSupply by ContractAddress
14+
* Returns the current amount of an ERC-20 token in circulation.
15+
*
16+
* @param string $contractAddress the contract address of the ERC-20 token
17+
*
18+
* @return array
19+
* @throws \Etherscan\Exception\ErrorException
20+
*/
21+
public function getTokenSupply($contractAddress)
22+
{
23+
return $this->request->exec([
24+
'module' => "stats",
25+
'action' => "tokensupply",
26+
'contractaddress' => $contractAddress
27+
]);
28+
}
1229

13-
}
30+
/**
31+
* Get ERC20-Token Account Balance for TokenContractAddress
32+
* Returns the current balance of an ERC-20 token of an address.
33+
*
34+
* @param string $contractAddress the contract address of the ERC-20 token
35+
* @param string $address the string representing the address to check for token balance
36+
*
37+
* @return array
38+
* @throws \Etherscan\Exception\ErrorException
39+
*/
40+
public function getTokenBalance($contractAddress, $address)
41+
{
42+
return $this->request->exec([
43+
'module' => "account",
44+
'action' => "tokenbalance",
45+
'contractaddress' => $contractAddress,
46+
'address' => $address
47+
]);
48+
}
49+
50+
/**
51+
* Get Historical ERC20-Token TotalSupply by ContractAddress & BlockNo
52+
* Returns the amount of an ERC-20 token in circulation at a certain block height.
53+
*
54+
* @param string $contractAddress the contract address of the ERC-20 token
55+
* @param string $blockNumber the integer block number to check total supply for eg. 12697906
56+
*
57+
* @return array
58+
* @throws \Etherscan\Exception\ErrorException
59+
*/
60+
public function getTokenSupplyHistory($contractAddress, $blockNumber)
61+
{
62+
return $this->request->exec([
63+
'module' => "stats",
64+
'action' => "tokensupplyhistory",
65+
'contractaddress' => $contractAddress,
66+
'blockno' => $blockNumber
67+
]);
68+
}
69+
70+
/**
71+
* Get Historical ERC20-Token Account Balance for TokenContractAddress by BlockNo
72+
* Returns the balance of an ERC-20 token of an address at a certain block height.
73+
*
74+
* @param string $contractAddress the contract address of the ERC-20 token
75+
* @param string $address the string representing the address to check for balance
76+
* @param string $blockNumber the integer block number to check total supply for eg. 12697906
77+
*
78+
* @return array
79+
* @throws \Etherscan\Exception\ErrorException
80+
*/
81+
public function getTokenBalanceHistory($contractAddress, $address, $blockNumber)
82+
{
83+
return $this->request->exec([
84+
'module' => "account",
85+
'action' => "tokenbalancehistory",
86+
'contractaddress' => $contractAddress,
87+
'address' => $address,
88+
'blockno' => $blockNumber
89+
]);
90+
}
91+
92+
/**
93+
* Get Token Info by ContractAddress
94+
* Returns project information and social media links of an ERC-20/ERC-721 token.
95+
*
96+
* @param string $contractAddress the contract address of the ERC-20/ERC-721 token to retrieve token info
97+
*
98+
* @return array
99+
* @throws \Etherscan\Exception\ErrorException
100+
*/
101+
public function getTokenInfo($contractAddress)
102+
{
103+
return $this->request->exec([
104+
'module' => "token",
105+
'action' => "tokeninfo",
106+
'contractaddress' => $contractAddress
107+
]);
108+
}
109+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.