Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Smart Contract Security
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
POTHURI HARIKA
Smart Contract Security
Commits
a638da6e
Commit
a638da6e
authored
Jun 15, 2023
by
POTHURI HARIKA
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
3689e746
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tools/SmartCheck/Solidity/Rules/SOLIDITY_ERC20_INDEXED.md
+92
-0
92 additions, 0 deletions
Tools/SmartCheck/Solidity/Rules/SOLIDITY_ERC20_INDEXED.md
with
92 additions
and
0 deletions
Tools/SmartCheck/Solidity/Rules/SOLIDITY_ERC20_INDEXED.md
0 → 100644
+
92
−
0
View file @
a638da6e
# Analysis of Smart Contract Security Vulnerabilities and Tools 






<br/>
!
[](
https://img.shields.io/badge/BlockchainCourse-21CY712-green
)


<br/>

<br/>

## SOLIDITY_ERC20_INDEXED
### Rule Description
Address arguments of
<code>
Transfer
</code>
and
<code>
Approve
</code>
events of ERC-20 token standard must be indexed.
### Solidity-Rules


```
<!-- looks for Transfer and Aproval events -->
//eventDefinition[identifier[text()[1] = "Transfer" or text()[1] = "Approval"]]
<!-- with unindexed address parameter -->
[
indexedParameterList/indexedParameter
[typeName/elementaryTypeName[text()[1] = "address"]]
[not(text()[1] = "indexed")]
]
<!-- check that event has three parameters -->
[indexedParameterList[count(child::indexedParameter) = 3]
<!-- check that there are two address parameters in the event -->
[count(child::indexedParameter//elementaryTypeName[text()[1] = "address"]) = 2]
<!-- check that there is one uint256 parameter in the event -->
[count(child::indexedParameter//elementaryTypeName[text()[1] = "uint256"]) = 1]]
```
### Sample Code
```
pragma solidity 0.5.0;
contract TestToken1 is ERC20{
event Transfer(address indexed _from, address indexed _to, uint256 _value);
// <yes> <report> SOLIDITY_ERC20_INDEXED ac081b
event Approval(address _owner, address indexed _spender, uint256 _value);
event Check(address _owner, address indexed _spender, uint256 _value);
}
contract Test2 is ERC20Mintable{
// <yes> <report> SOLIDITY_ERC20_INDEXED ac081b
event Transfer(address _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
contract TestToken3 is ERC20Pausable{
event Transfer(address indexed _from, address indexed _to, uint256 _value);
// <yes> <report> SOLIDITY_ERC20_INDEXED ac081b
event Approval(address _owner, address _spender, uint256 _value);
}
contract Test4 is ERC20{
// <yes> <report> SOLIDITY_ERC20_INDEXED ac081b
event Transfer(address _from, address _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
contract Test5 is SafeERC20{
// <yes> <report> SOLIDITY_ERC20_INDEXED ac081b
event Transfer(address indexed _from, address _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
contract TestToken5 is ERC20Burnable{
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
contract SendSomething1 {
event Transfer(address indexed _from, uint256 _value);
}
contract SendSomething2 {
event Transfer(address indexed _from, address indexed _to);
}
contract SendSomething3 {
event Approval(address indexed _to);
}
```
### Abstract Syntax Tree
[
Click Here
](
https://astexplorer.net/#/gist/f2cd522a64f8c8eb19d141be205e610c/84d860b1ebf4d19786f3f0698c2b89ce28c69700
)
to view the AST for the above code. Code generated from AST Explorer using _solidity-parser-antlr-0.4.11_
### Code Result
```
SOLIDITY_ERC20_INDEXED.sol
jar:file:/C:/Users/Pothuri%20Harika/AppData/Roaming/npm/node_modules/@smartdec/smartcheck/jdeploy-bundle/smartcheck-2.0-jar-with-dependencies.jar!/solidity-rules.xml
```
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment