Dataset Viewer
Auto-converted to Parquet Duplicate
text
stringlengths
203
50k
source
stringclasses
28 values
address
stringlengths
0
42
name
stringlengths
1
76
compiler
stringclasses
25 values
license
stringclasses
14 values
path
stringlengths
0
98
n_chars
int64
203
50k
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.24; import {IUniswapV2Pair} from '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol'; import {UniswapV2Library} from './UniswapV2Library.sol'; import {UniswapImmutables} from '../UniswapImmutables.sol'; import {Permit2Payments} from '../../Permit...
github/uniswap-universal-router
V2SwapRouter
contracts/modules/uniswap/v2/V2SwapRouter.sol
6,063
// SPDX-License-Identifier: LZBL-1.2 pragma solidity ^0.8.20; import { BytesLib } from "solidity-bytes-utils/contracts/BytesLib.sol"; import { BitMap256 } from "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/BitMaps.sol"; import { CalldataBytesLib } from "@layerzerolabs/lz-evm-protocol-v2/contracts/libs...
github/layerzero-v2
DVNOptions
packages/layerzero-v2/evm/messagelib/contracts/uln/libs/DVNOptions.sol
7,321
// SPDX-License-Identifier: LZBL-1.2 pragma solidity ^0.8.20; import "@layerzerolabs/lz-evm-protocol-v2/contracts/libs/CalldataBytesLib.sol"; library ExecutorOptions { using CalldataBytesLib for bytes; uint8 internal constant WORKER_ID = 1; uint8 internal constant OPTION_TYPE_LZRECEIVE = 1; uint8 i...
github/layerzero-v2
ExecutorOptions
packages/layerzero-v2/evm/messagelib/contracts/libs/ExecutorOptions.sol
4,329
// SPDX-License-Identifier: LZBL-1.2 pragma solidity ^0.8.20; import { CalldataBytesLib } from "../../libs/CalldataBytesLib.sol"; library ExecutorOptions { using CalldataBytesLib for bytes; uint8 internal constant WORKER_ID = 1; uint8 internal constant OPTION_TYPE_LZRECEIVE = 1; uint8 internal cons...
github/layerzero-v2
ExecutorOptions
packages/layerzero-v2/evm/protocol/contracts/messagelib/libs/ExecutorOptions.sol
3,561
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/utils/ERC1363Utils.sol) pragma solidity ^0.8.20; import {IERC1363Receiver} from "../../../interfaces/IERC1363Receiver.sol"; import {IERC1363Spender} from "../../../interfaces/IERC1363Spender.sol"; /** * @dev Library that pr...
github/openzeppelin
ERC1363Utils
contracts/token/ERC20/utils/ERC1363Utils.sol
3,297
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.6.0) (token/ERC20/extensions/ERC20FlashMint.sol) pragma solidity ^0.8.20; import {IERC3156FlashBorrower} from "../../../interfaces/IERC3156FlashBorrower.sol"; import {IERC3156FlashLender} from "../../../interfaces/IERC3156FlashLender.sol"; imp...
github/openzeppelin
ERC20FlashMint
contracts/token/ERC20/extensions/ERC20FlashMint.sol
5,542
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/extensions/ERC1363.sol) pragma solidity ^0.8.20; import {ERC20} from "../ERC20.sol"; import {IERC165, ERC165} from "../../../utils/introspection/ERC165.sol"; import {IERC1363} from "../../../interfaces/IERC1363.sol"; import {...
github/openzeppelin
ERC1363
contracts/token/ERC20/extensions/ERC1363.sol
5,631
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.6.0) (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.24; import {ERC721} from "../ERC721.sol"; import {IERC721Enumerable} from "./IERC721Enumerable.sol"; import {IERC165} from "../../../utils/introspection/ERC165.sol"; /**...
github/openzeppelin
ERC721Enumerable
contracts/token/ERC721/extensions/ERC721Enumerable.sol
7,273
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.6.0) (token/ERC20/extensions/ERC20FlashMint.sol) pragma solidity ^0.8.20; import {IERC3156FlashBorrower} from "@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol"; import {IERC3156FlashLender} from "@openzeppelin/contracts/interfaces...
github/openzeppelin-upgradeable
ERC20FlashMintUpgradeable
contracts/token/ERC20/extensions/ERC20FlashMintUpgradeable.sol
5,869
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/extensions/ERC1363.sol) pragma solidity ^0.8.20; import {ERC20Upgradeable} from "../ERC20Upgradeable.sol"; import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import {ERC165Upgradeable} from "../....
github/openzeppelin-upgradeable
ERC1363Upgradeable
contracts/token/ERC20/extensions/ERC1363Upgradeable.sol
6,078
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.24; import {Constants} from '../libraries/Constants.sol'; import {ActionConstants} from '@uniswap/v4-periphery/src/libraries/ActionConstants.sol'; import {BipsLibrary} from '@uniswap/v4-periphery/src/libraries/BipsLibrary.sol'; import {PaymentsImmutable...
github/uniswap-universal-router
Payments
contracts/modules/Payments.sol
5,197
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; import "@openzeppelin/contracts/utils/math/Math.sol"; import "@openzeppelin-upgrades/contracts/utils/math/SafeCastUpgradeable.sol"; /// @dev All scaling factors have `1e18` as an initial/default value. This value is represented /// by the constant `WAD`, w...
github/eigenlayer
SlashingLib
src/contracts/libraries/SlashingLib.sol
7,446
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; import {OperatorSet} from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; import {IAllocationManager} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {IStrategy} from "eigenlayer-contracts/src/contr...
github/eigenlayer-middleware
BN254WeightedTableCalculator
src/middlewareV2/tableCalculator/unaudited/BN254WeightedTableCalculator.sol
7,673
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; import "@openzeppelin-upgrades/contracts/utils/cryptography/SignatureCheckerUpgradeable.sol"; /** * @title SignatureCheckerLib * @dev This library wraps the EIP1271SignatureUtils library to provide an external function for signature validation. * This a...
github/eigenlayer-middleware
SignatureCheckerLib
src/libraries/SignatureCheckerLib.sol
1,067
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; import { ISlashingRegistryCoordinator, ISlashingRegistryCoordinatorTypes } from "../interfaces/ISlashingRegistryCoordinator.sol"; /// @title QuorumBitmapHistoryLib /// @notice This library operates on the _operatorBitmapHistory in the RegistryCoord...
github/eigenlayer-middleware
QuorumBitmapHistoryLib
src/libraries/QuorumBitmapHistoryLib.sol
6,829
// SPDX-License-Identifier: MIT pragma solidity ^0.8.27; import {ISignatureUtilsMixinTypes} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtilsMixin.sol"; import {ECDSAStakeRegistry} from "../ECDSAStakeRegistry.sol"; import {IDelegationManager} from "eigenlayer-contracts/src/contracts/interface...
github/eigenlayer-middleware
ECDSAStakeRegistryPermissioned
src/unaudited/examples/ECDSAStakeRegistryPermissioned.sol
4,420
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; interface IIndexRegistryErrors { /// @notice Thrown when a function is called by an address that is not the RegistryCoordinator. error OnlyRegistryCoordinator(); /// @notice Thrown when attempting to query a quorum that has no history. error...
github/eigenlayer-middleware
IIndexRegistry
src/interfaces/IIndexRegistry.sol
7,633
// SPDX-License-Identifier: MIT pragma solidity ^0.8.27; import {ISlashingRegistryCoordinator} from "./ISlashingRegistryCoordinator.sol"; import {IStakeRegistry} from "./IStakeRegistry.sol"; interface IEjectionManagerErrors { /// @notice Thrown when the caller is not the owner or ejector. error OnlyOwnerOrEje...
github/eigenlayer-middleware
IEjectionManager
src/interfaces/IEjectionManager.sol
6,036
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; import {IAllocationManager} from "eigenlayer-contracts/src/contracts/interfaces/IAllocationManager.sol"; import {ISlasher} from "./ISlasher.sol"; interface IVetoableSlasherErrors { /// @notice Thrown when a caller without veto committee privileges ...
github/eigenlayer-middleware
IVetoableSlasher
src/interfaces/IVetoableSlasher.sol
3,709
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; import {IAVSRegistrar} from "eigenlayer-contracts/src/contracts/interfaces/IAVSRegistrar.sol"; import {IAVSRegistrarInternal} from "./IAVSRegistrarInternal.sol"; import {ISocketRegistryV2} from "./ISocketRegistryV2.sol"; import {IAllowlist} from "./IAllowli...
github/eigenlayer-middleware
ITaskAVSRegistrarBase
src/interfaces/ITaskAVSRegistrarBase.sol
2,775
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.27; import {ISlashingRegistryCoordinator} from "./ISlashingRegistryCoordinator.sol"; import {IBLSApkRegistry} from "./IBLSApkRegistry.sol"; import {IStakeRegistry, IDelegationManager} from "./IStakeRegistry.sol"; import {BN254} from "../libraries/BN254.sol"; ...
github/eigenlayer-middleware
IBLSSignatureChecker
src/interfaces/IBLSSignatureChecker.sol
7,683
// SPDX-License-Identifier: LZBL-1.2 pragma solidity ^0.8.20; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { EndpointV2 } from "./EndpointV2.sol"; import { Errors } from "./libs/Errors.sol"; /// @notice this is the endpoint contract for layerzero v2 deployed on chains using ERC20 ...
github/layerzero-v2
EndpointV2Alt
packages/layerzero-v2/evm/protocol/contracts/EndpointV2Alt.sol
1,888
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; // @dev Import the Origin so it's exposed to OAppPreCrimeSimulator implementers. // solhint-disable-next-line no-unused-import import { InboundPacket, Origin } from "../libs/Packet.sol"; /** * @title IOAppPreCrimeSimulator Interface * @dev Interface for the ...
github/layerzero-v2
IOAppPreCrimeSimulator
packages/layerzero-v2/evm/oapp/contracts/precrime/interfaces/IOAppPreCrimeSimulator.sol
1,920
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { IOAppReceiver, Origin } from "./interfaces/IOAppReceiver.sol"; import { OAppCore } from "./OAppCore.sol"; /** * @title OAppReceiver * @dev Abstract contract implementing the ILayerZeroReceiver interface and extending OAppCore for OApp receivers. */...
github/layerzero-v2
OAppReceiver
packages/layerzero-v2/evm/oapp/contracts/oapp/OAppReceiver.sol
5,410
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { SafeERC20, IERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { MessagingParams, MessagingFee, MessagingReceipt } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol"; import { OAppCore } f...
github/layerzero-v2
OAppSender
packages/layerzero-v2/evm/oapp/contracts/oapp/OAppSender.sol
5,631
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; /** * @dev Struct representing enforced option parameters. */ struct EnforcedOptionParam { uint32 eid; // Endpoint ID uint16 msgType; // Message Type bytes options; // Additional options } /** * @title IOAppOptionsType3 * @dev Interface for the...
github/layerzero-v2
IOAppOptionsType3
packages/layerzero-v2/evm/oapp/contracts/oapp/interfaces/IOAppOptionsType3.sol
1,442
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { ILayerZeroEndpointV2 } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol"; /** * @title IOAppCore */ interface IOAppCore { // Custom error messages error OnlyPeer(uint32 eid, bytes32 sender); error NoP...
github/layerzero-v2
IOAppCore
packages/layerzero-v2/evm/oapp/contracts/oapp/interfaces/IOAppCore.sol
1,864
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; /** * @title IOAppMsgInspector * @dev Interface for the OApp Message Inspector, allowing examination of message and options contents. */ interface IOAppMsgInspector { // Custom error message for inspection failure error InspectionFailed(bytes message...
github/layerzero-v2
IOAppMsgInspector
packages/layerzero-v2/evm/oapp/contracts/oapp/interfaces/IOAppMsgInspector.sol
909
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { MessagingReceipt, MessagingFee } from "../../oapp/OAppSender.sol"; /** * @dev Struct representing token parameters for the OFT send() operation. */ struct SendParam { uint32 dstEid; // Destination endpoint ID. bytes32 to; // Recipient addres...
github/layerzero-v2
IOFT
packages/layerzero-v2/evm/oapp/contracts/oft/interfaces/IOFT.sol
6,161
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; /// @title TransientContext /// @notice Library for transient storage. library TransientContext { /// @notice Slot for call depth. /// Equal to bytes32(uint256(keccak256("transient.calldepth")) - 1). bytes32 internal constant CALL_DEPTH_SLOT ...
github/optimism-bedrock
TransientContext
packages/contracts-bedrock/src/libraries/TransientContext.sol
4,168
// SPDX-License-Identifier: MIT pragma solidity 0.8.25; // Libraries import { PredeployAddresses } from "interop-lib/src/libraries/PredeployAddresses.sol"; // Interfaces import { IERC7802, IERC165 } from "interop-lib/src/interfaces/IERC7802.sol"; import { IL2ToL2CrossDomainMessenger } from "interop-lib/src/interfaces...
github/optimism-bedrock
CustomBridge
docs/public-docs/public/tutorials/CustomBridge.sol
4,360
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.5.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC1363} from "../../../interfaces/IERC1363.sol"; import {IERC20Metadata} from "../../../interfaces/IERC20Metadata.sol"; /** * @ti...
github/openzeppelin
SafeERC20
contracts/token/ERC20/utils/SafeERC20.sol
13,963
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol) pragma solidity ^0.8.20; /** * @dev Provides tracking nonces for addresses. Nonces will only increment. */ abstract contract Nonces { /** * @dev The nonce used for an `account` is not the expected current nonc...
github/openzeppelin
Nonces
contracts/utils/Nonces.sol
1,490
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.6.0) (utils/introspection/ERC165Checker.sol) pragma solidity ^0.8.20; import {IERC165} from "./IERC165.sol"; /** * @dev Library used to query support of an interface declared via {IERC165}. * * Note that these functions return the actual r...
github/openzeppelin
ERC165Checker
contracts/utils/introspection/ERC165Checker.sol
5,829
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.6.0) (account/utils/draft-ERC7579Utils.sol) pragma solidity ^0.8.20; import {Execution} from "../../interfaces/draft-IERC7579.sol"; import {Packing} from "../../utils/Packing.sol"; import {Address} from "../../utils/Address.sol"; type Mode is...
github/openzeppelin
draft-ERC7579Utils
contracts/account/utils/draft-ERC7579Utils.sol
11,326
End of preview. Expand in Data Studio

Solidity CPT Top-10% Quality-Filtered Corpus

A curated, deduplicated corpus of 23,471 modern Solidity source files (~86M tokens) intended for continued-pretraining (CPT) of code LLMs on smart-contract code.

It's the top 10% slice (by composite quality score) of a larger raw corpus that combined:

  • ASSERT-KTH/DISL — 514 k unique deployed Solidity files, deduped at file level
  • 30 hand-picked GitHub blue-chip protocols (OpenZeppelin, Uniswap v2/v3/v4, Aave v3, Compound, Morpho, EigenLayer, Pendle, Solady, Seaport, LayerZero, ENS, Optimism, Arbitrum, Polygon L1, etc.)

After scoring all 234 877 raw rows on a 0–115 quality scale (see Quality filter below) and keeping the top 10 %, the result is 23 487 source files. After cross-source SHA-256 deduplication of whitespace-normalised text, 23 471 unique files remain. This is what's published here.

At a glance

Rows 23,471
Total characters 342,858,470
Approx. tokens (Qwen3.6 tokenizer, ~4 chars/tok) ~86M
Average chars per row 14,607
Source: disl (Etherscan-verified) 20,975 (89 %)
Source: github/<protocol> (audited blue-chips) 2,496 (11 %)
File format parquet (snappy) + jsonl

Schema

Each row is one Solidity source file:

Field Type Description
text string Raw Solidity source code
source string disl (Etherscan-verified contract) or github/<repo-slug>
address string Ethereum mainnet address (DISL only)
name string Contract name
compiler string Solc version e.g. v0.8.20+commit.a1b2c3d4 (DISL only)
license string License from Etherscan (often empty)
path string Path inside the GitHub repo (GitHub rows only)
n_chars int Length of text in characters

Quality filter (composite 0–115 score)

Every raw row was scored independently on each signal; rows scoring ≥ 55 (top-10% threshold) were kept.

Signal Points
Pragma 0.8.20+ (modern compiler) +30
Pragma 0.8.13–19 +20
Pragma 0.8.x (any) +10
Has SPDX license header +10
Has @notice / @dev NatSpec +10
Has @param / @return NatSpec +10
Comment density 5–30 % +10
Uses custom errors (error X();) +5
Uses unchecked { ... } blocks +5
No SafeMath import (avoids old patterns) +5
Size 500–8000 chars +10
Source: GitHub blue-chip +20

Pre-scoring filters (applied to all sources before scoring):

  • Pragma must be 0.8.x (0.4–0.7 dropped — incompatible with forge-std/Test.sol >=0.8.13)
  • Not flagged as proxy=True in DISL (drops EIP-1167/1967 minimal proxies)
  • Has at least one contract X declaration (drops interface-only / library-only files)
  • 200 ≤ length ≤ 50000 chars (drops stubs and mega-flatteners)
  • For GitHub: vendored lib/openzeppelin-contracts, lib/forge-std, out/, cache/, typechain-types/ stripped

Post-quality dedup: SHA-256 of the whitespace-collapsed text. Caught 16 cross-source duplicates.

Score distribution of the top-10% slice

The 23 471 surviving rows have scores in [55, 115]. The mode falls in the 55–69 band (typical "modern, idiomatic, audited" Solidity). The long tail (90+) skews heavily toward GitHub blue-chips and DISL contracts that cite their license + use NatSpec extensively.

Suggested use

This corpus is sized for adapter-based CPT (LoRA / DoRA) on a 7B–30B+ code LM. Per Biderman et al. 2024 ("LoRA Learns Less and Forgets Less"), useful adapter-CPT plateaus around 200M–1B tokens — this 86M corpus is on the lower end of that range and works well as a fast first-iteration validation slice.

For larger adapter-CPT runs, the same pipeline produces:

  • top30 tier (~70 k rows, ~229M tokens)
  • top60 tier (~141 k rows, ~458M tokens)

(Not yet published. Open an issue if you'd like them released.)

Loading

datasets library (recommended)

from datasets import load_dataset

ds = load_dataset("samscrack/solidity-cpt-top10-quality", split="train")
print(ds)               # ~23 471 rows
print(ds[0]["text"][:500])

Direct parquet

import pyarrow.parquet as pq
table = pq.read_table("top10.parquet")
df = table.to_pandas()
print(df.head())

Streaming (for low-RAM environments)

ds = load_dataset(
    "samscrack/solidity-cpt-top10-quality",
    split="train",
    streaming=True,
)
for row in ds.take(3):
    print(row["source"], row["name"], row["compiler"])

Suggested CPT recipe (Qwen3.6-27B reference)

This corpus was built for the Qwopus3.6-27B-solidity-cpt-stageA pipeline. The recipe used:

  • LoRA r=64, α=64, target modules: q_proj k_proj v_proj o_proj gate_proj up_proj down_proj out_proj
  • Megatron-style packing into 8192-token sequences with EOS separators
  • LR 5e-5 (cosine), bf16 + 4-bit base (QLoRA), 1 epoch
  • Tokenized with the Qwen3.6 tokenizer (vocab 152 k)

A Stage-A CPT over a 1500-sequence (~12M token) subset of this corpus showed loss drop from a warmup peak of 0.67 to a stable 0.36–0.41 plateau in ~40 steps — clear evidence the data is high-signal for adapter-CPT.

License & legal notes

This dataset is released under CC BY 4.0, inheriting the most-restrictive upstream license (DISL is CC BY 4.0).

Per-row provenance varies:

  • DISL rows: derived from Etherscan public-verified contracts. The dataset (and DISL itself) are CC BY 4.0; the underlying contract source has whatever license the deployer chose — often empty / "unspecified" / all-rights-reserved by default. Suitable for research and adapter-style CPT, not necessarily safe for redistribution-as-source.
  • GitHub blue-chip rows: each repo has its own SPDX header. Most are MIT or Apache-2.0; some Uniswap pieces are BUSL/GPL. Inspect the path field and the upstream repo if license matters for your use case.

If you need stronger commercial-use guarantees, restrict to rows where:

  • source starts with github/, AND
  • text contains an explicit MIT or Apache-2.0 SPDX line near the top.

Citation

@misc{solidity_cpt_top10_2026,
  title  = {Solidity CPT Top-10\% Quality-Filtered Corpus},
  author = {samscrack},
  year   = {2026},
  url    = {https://huggingface.co/datasets/samscrack/solidity-cpt-top10-quality}
}

If you use this data, please also cite the upstream sources:

@misc{disl_2024,
  title  = {DISL: Fueling Research with A Large Dataset of Solidity Smart Contracts},
  author = {Storhaug, Andreas et al.},
  year   = {2024},
  url    = {https://arxiv.org/abs/2403.16861}
}

Acknowledgements

  • ASSERT-KTH for releasing DISL
  • The OpenZeppelin, Uniswap, Aave, Compound, Morpho, EigenLayer, Pendle, Solady, Seaport, LayerZero, ENS, Optimism, Arbitrum, and Polygon teams for keeping their protocol code public and auditable
  • The Foundry team for forge-std (used as the >=0.8.13 floor for pragma filtering)

Changelog

  • 2026-05-03 — initial release; 23 471 rows, ~86M tokens, top 10% by composite quality score
Downloads last month
11

Papers for samscrack/solidity-cpt-top10-quality