task_categories:text-generation task_ids:language-modeling multilinguality:monolingual size_categories:100K<n<1M source_datasets:original language:en arxiv:2309.09826 doi:10.57967/hf/1182 region:us
Smart Contracts Dataset.
This is a dataset of verified (Etherscan.io) Smart Contracts that are deployed to the Ethereum blockchain. A set of about 100,000 to 200,000  contracts are provided, containing both Solidity and Vyper code.
@misc{storhaug2022smartcontracts,
    title = {Smart Contracts Dataset},
    author={André Storhaug},
    year={2022}
}
---
annotations_creators: []
language_creators: []
language:
- en
multilinguality:
- monolingual
pretty_name: Smart Contracts
size_categories:
- 100K<n<1M
source_datasets:
- original
task_categories:
- text-generation
task_ids:
- language-modeling
paperswithcode_id: verified-smart-contracts
---

# Dataset Card for Smart Contracts

## Table of Contents
- [Table of Contents](#table-of-contents)
- [Dataset Description](#dataset-description)
  - [Dataset Summary](#dataset-summary)
  - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
  - [Languages](#languages)
- [Dataset Structure](#dataset-structure)
  - [Data Instances](#data-instances)
    - [flattened](#flattened)
    - [flattened_plain_text](#flattened_plain_text)
    - [inflated](#inflated)
    - [inflated_plain_text](#inflated_plain_text)
    - [parsed](#parsed)
  - [Data Fields](#data-fields)
    - [flattened](#flattened-1)
    - [flattened_plain_text](#flattened_plain_text-1)
    - [inflated](#inflated-1)
    - [inflated_plain_text](#inflated_plain_text-1)
    - [parsed](#parsed-1)
  - [Data Splits](#data-splits)
- [Dataset Creation](#dataset-creation)
  - [Curation Rationale](#curation-rationale)
  - [Source Data](#source-data)
    - [Initial Data Collection and Normalization](#initial-data-collection-and-normalization)
    - [Who are the source language producers?](#who-are-the-source-language-producers)
  - [Annotations](#annotations)
    - [Annotation process](#annotation-process)
    - [Who are the annotators?](#who-are-the-annotators)
  - [Personal and Sensitive Information](#personal-and-sensitive-information)
- [Considerations for Using the Data](#considerations-for-using-the-data)
  - [Social Impact of Dataset](#social-impact-of-dataset)
  - [Discussion of Biases](#discussion-of-biases)
  - [Other Known Limitations](#other-known-limitations)
- [Additional Information](#additional-information)
  - [Dataset Curators](#dataset-curators)
  - [Licensing Information](#licensing-information)
  - [Citation Information](#citation-information)
  - [Contributions](#contributions)

## Dataset Description

- **Homepage:** https://andstor.github.io/smart-contracts
- **Repository:** https://github.com/andstor/verified-smart-contracts
- **Paper:** 
- **Leaderboard:**
- **Point of Contact:** [André Storhaug](mailto:andr3.storhaug@gmail.com)

### Dataset Summary

This is a dataset of verified Smart Contracts from Etherscan.io that are deployed to the Ethereum blockchain. A set of about 100,000 to 200,000 contracts are provided, containing both Solidity and Vyper code.

### Supported Tasks and Leaderboards

[More Information Needed]

### Languages

[More Information Needed]

## Dataset Structure

### Data Instances

#### flattened
```
{
  'contract_name': 'MiaKhalifaDAO',
  'contract_address': '0xb3862ca215d5ed2de22734ed001d701adf0a30b4',
  'language': 'Solidity',
  'source_code': '// File: @openzeppelin/contracts/utils/Strings.sol\r\n\r\n\r\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev String operations.\r\n */\r\nlibrary Strings {\r\n...',
  'abi': '[{"inputs":[{"internalType":"uint256","name":"maxBatchSize_","type":"uint256"}...]',
  'compiler_version': 'v0.8.7+commit.e28d00a7',
  'optimization_used': False,
  'runs': 200,
  'constructor_arguments': '000000000000000000000000000000000000000000000000000000000000000a000...',
  'evm_version': 'Default',
  'library': '',
  'license_type': 'MIT',
  'proxy': False,
  'implementation': '',
  'swarm_source': 'ipfs://e490df69bd9ca50e1831a1ac82177e826fee459b0b085a00bd7a727c80d74089'
}
```

#### flattened_extended

Same fields as `flattened` but with the following additional fields:
```
{
  ...
  'tx_count': 1074,
  'balance': 38
}
```

#### flattened_plain_text
```
{
  'language': 'Solidity',
  'text': '// File: SafeMath.sol\r\npragma solidity =0.5.16;\r\n\r\n// a library for performing overflow-safe math...'
}
```

#### inflated
```
{
  'contract_name': 'PinkLemonade',
  'file_path': 'PinkLemonade.sol',
  'contract_address': '0x9a5be3cc368f01a0566a613aad7183783cff7eec',
  'language': 'Solidity',
  'source_code': '/**\r\n\r\nt.me/pinklemonadecoin\r\n*/\r\n\r\n// SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.0;\r\n\r\n\r\n/*\r\n * @dev Provides information about the current execution context, including the\r\n * sender of the transaction and its data. While these are generally available...',
  'abi': '[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"}...]',
  'compiler_version': 'v0.8.4+commit.c7e474f2',
  'optimization_used': False,
  'runs': 200,
  'constructor_arguments': '',
  'evm_version': 'Default',
  'library': '',
  'license_type': 'MIT',
  'proxy': False,
  'implementation': '',
  'swarm_source': 'ipfs://eb0ac9491a04e7a196280fd27ce355a85d79b34c7b0a83ab606d27972a06050c'
}
```

#### inflated_plain_text
```
{
  'language': 'Solidity',
  'text': '\\npragma solidity ^0.4.11;\\n\\ncontract ERC721 {\\n    // Required methods\\n    function totalSupply() public view returns (uint256 total);...'
}
```

#### parsed
```
{
  'contract_name': 'BondedECDSAKeep',
  'file_path': '@keep-network/keep-core/contracts/StakeDelegatable.sol',
  'contract_address': '0x61935dc4ffc5c5f1d141ac060c0eef04a792d8ee',
  'language': 'Solidity',
  'class_name': 'StakeDelegatable',
  'class_code': 'contract StakeDelegatable {\n    using OperatorParams for uint256;\n\n    mapping(address => Operator) internal operators;\n\n    struct Operator {\n        uint256 packedParams;\n        address owner;\n        address payable beneficiary;\n        address authorizer;\n    }\n\n...',
  'class_documentation': '/// @title Stake Delegatable\n/// @notice A base contract to allow stake delegation for staking contracts.',
  'class_documentation_type': 'NatSpecSingleLine',
  'func_name': 'balanceOf',
  'func_code': 'function balanceOf(address _address) public view returns (uint256 balance) {\n        return operators[_address].packedParams.getAmount();\n    }',
  'func_documentation': '/// @notice Gets the stake balance of the specified address.\n/// @param _address The address to query the balance of.\n/// @return An uint256 representing the amount staked by the passed address.',
  'func_documentation_type': 'NatSpecSingleLine',
  'compiler_version': 'v0.5.17+commit.d19bba13',
  'license_type': 'MIT',
  'swarm_source': 'bzzr://63a152bdeccda501f3e5b77f97918c5500bb7ae07637beba7fae76dbe818bda4'
}
```

### Data Fields
#### flattened

- `contract_name` (`string`): containing the smart contract name.
- `contract_address` (`string`): containing the Ethereum address for the smart contract.
- `language` (`string`): containing the language of the smart contract.
- `source_code ` (`string`): containing the source code of the smart contract. This contains all code needed for compilation of the contract, including libraries.
- `abi` (`string`): containing the Application Binary Interface (ABI) of the smart contract.
- `compiler_version` (`string`): containing the compiler version used to compile the smart contract.
- `optimization_used` (`boolean`): indicating if the smart contract used optimization.
- `runs` (`number`): containing the number of optimization steps used.
- `constructor_arguments` (`string`): containing the constructor arguments of the smart contract.
- `evm_version` (`string`): containing the EVM version used to compile the smart contract.
- `library` (`string`): containing the `name:address` of libraries used separated by `;`.
- `license_type` (`string`): containing the license type of the smart contract.
- `proxy` (`boolean`): indicating if the smart contract is a proxy.
- `implementation` (`string`): containing the implementation of the smart contract if it is a proxy.
- `swarm_source` (`string`): containing the swarm source of the smart contract.

#### flattened_extended

Same fields as `flattened` but with the following additional fields:
- `tx_count` (`number`): containing the number of transactions made to the smart contract.
- `balance` (`string`): containing the ether balancce of the smart contract.

#### flattened_plain_text

- `text` (`string`): containing the source code of the smart contract. This contains all code needed for compilation of the contract, including libraries.
- `language` (`string`): containing the language of the smart contract.

#### inflated

Same fields as `flattened` but with the following additional fields:
- `file_path` (`string`): containing the original path to the file.

#### inflated_plain_text

- `text` (`string`): containing the source code of the smart contract. This contains all code needed for compilation of the contract, including libraries.
- `language` (`string`): containing the language of the smart contract.

#### parsed

- `contract_name` (`string`): containing the smart contract name.
- `file_path` (`string`): containing the original path to the file.
- `contract_address` (`string`): containing the Ethereum address for the smart contract.
- `language` (`string`): containing the language of the smart contract.
- `class_name` (`string`): containing the name of the "class" (contract).
- `class_code` (`string`): containing the source code of the "class" (contract).
- `class_documentation` (`string`): containing the documentation (code comment) of the "class" (contract).
- `class_documentation_type` (`string`): containing the documentation type of the "class" (contract). Can be one of: `NatSpecMultiLine`, `NatSpecSingleLine`, `LineComment` or `Comment`.
- `func_name` (`string`): containing the name of the function definition.
- `func_code` (`string`): containing the source code of the function.
- `func_documentation` (`string`): containing the documentation (code comment) of the contract definition (or "class").
- `func_documentation_type` (`string`): containing the documentation type of the function. Can be one of: `NatSpecMultiLine`, `NatSpecSingleLine`, `LineComment` or `Comment`.
- `compiler_version` (`string`): containing the compiler version used to compile the smart contract.
- `license_type` (`string`): containing the license type of the smart contract.
- `swarm_source` (`string`): containing the swarm source of the smart contract.

### Data Splits

[More Information Needed]

## Dataset Creation

### Curation Rationale

[More Information Needed]

### Source Data

#### Initial Data Collection and Normalization

[More Information Needed]

#### Who are the source language producers?

[More Information Needed]

### Annotations

#### Annotation process

[More Information Needed]

#### Who are the annotators?

[More Information Needed]

### Personal and Sensitive Information

[More Information Needed]

## Considerations for Using the Data

### Social Impact of Dataset

[More Information Needed]

### Discussion of Biases

[More Information Needed]

### Other Known Limitations

[More Information Needed]

## Additional Information

### Dataset Curators

[More Information Needed]

### Licensing Information

[More Information Needed]

### Citation Information

```bibtex
    @misc{storhaug2023efficient,
        title={Efficient Avoidance of Vulnerabilities in Auto-completed Smart Contract Code Using Vulnerability-constrained Decoding}, 
        author={André Storhaug and Jingyue Li and Tianyuan Hu},
        year={2023},
        eprint={2309.09826},
        archivePrefix={arXiv},
        primaryClass={cs.CR}
    }
```

### Contributions

Thanks to [@andstor](https://github.com/andstor) for adding this dataset.