Skip to content

chore[docs]: fix module/contract/interface terminology#4878

Open
lufa23 wants to merge 4 commits intovyperlang:masterfrom
lufa23:fixes
Open

chore[docs]: fix module/contract/interface terminology#4878
lufa23 wants to merge 4 commits intovyperlang:masterfrom
lufa23:fixes

Conversation

@lufa23
Copy link
Copy Markdown
Contributor

@lufa23 lufa23 commented Mar 9, 2026

What I did

Fixed inconsistent use of "module", "contract", and "interface" throughout the docs, based on feedback from @Sporarum. Changes are consistent with the direction of #4877.

How I did it

Replaced incorrect uses of "contract" with "module" where the text referred to source files. Fixed the inversion pattern that described "any contract is a valid module" — the correct relationship is that the entry-point module becomes a contract upon deployment.

How to verify it

Read the changed files and check terminology is consistent with the module/contract/interface distinctions.

Commit message

chore[docs]: fix module/contract/interface terminology
update docs to consistently distinguish between modules (source files),
contracts (deployed artifacts), and interfaces. fixes incorrect
inversion pattern which described any contract as a valid module. the
correct relationship is that the entry-point module becomes a contract
upon deployment.

@charles-cooper
Copy link
Copy Markdown
Member

hm yea technically contract refers to a deployed artifact but it can also informally refer to a toplevel module (compilation target)

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.06%. Comparing base (2856eaa) to head (d7184ae).
⚠️ Report is 19 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4878      +/-   ##
==========================================
+ Coverage   91.56%   92.06%   +0.49%     
==========================================
  Files         185      187       +2     
  Lines       26971    27132     +161     
  Branches     4739     4758      +19     
==========================================
+ Hits        24696    24978     +282     
+ Misses       1548     1437     -111     
+ Partials      727      717      -10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@pcaversaccio pcaversaccio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmmmmm, I'm not sure replacing "contract" with "module" everywhere improves the clarity of the docs tbh (reading the docs confused me here since what is a module really?; is it compileable? what about non-fully-to-bytecode-compileable module contracts? etc). While the terminology might be technically correct (up for debate), most devs still reason about deployed contracts rather than compilation modules. It's just a fact. Introducing "module" throughout the docs also raises the question of how it differs from a contract, and I don't see that concept clearly defined before it's used. This could make the docs harder to follow for users coming from Solidity or the broader Ethereum ecosystem tbh where "contract" is the standard term. It might be better to either keep "contract" in user-facing explanations or introduce a clear explanation of the module vs contract distinction before adopting the new terminology throughout the docs.

Copy link
Copy Markdown
Collaborator

@Sporarum Sporarum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple comments on the changes

Note: I used "root module" in my comments to mean "the module we point the compiler at, which will become the contract"
I see you have used the concept of "entry point module", which also works for me

#######################

Vyper contracts are contained within files. Each file contains exactly one contract.
Each Vyper source file contains exactly one module.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing explanation of what a contract is

The one from using-modules.rst is very good, I think its fine to reuse it
(might or might not require being adapted)

Comment thread docs/compiler-exceptions.rst Outdated
.. _exceptions-common:

Vyper raises one or more of the following exceptions when an issue is encountered while compiling a contract.
Vyper raises one or more of the following exceptions when an issue is encountered while compiling a module.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all these still make more sense with contract

There's not really a meaning to compiling a single module
(other than it becoming the contract)

Copy link
Copy Markdown
Contributor Author

@lufa23 lufa23 Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, reverted with d7184ae

Comment thread docs/interfaces.rst


This imports the defined interface from the vyper file at ``an_interface.vyi`` (or ``an_interface.json`` if using ABI json interface type) and ensures your current contract implements all the necessary external functions. If any interface functions are not included in the contract, it will fail to compile. This is especially useful when developing contracts around well-defined standards such as ERC20.
This imports the defined interface from the vyper file at ``an_interface.vyi`` (or ``an_interface.json`` if using ABI json interface type) and ensures your current module implements all the necessary external functions. If any interface functions are not included in the module, it will fail to compile. This is especially useful when developing contracts around well-defined standards such as ERC20.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make it clear that implements is only ever useful when used from a root-module, since other modules can chose whether to exports external methods

-----------------

The optimization mode can be one of ``"none"``, ``"codesize"``, or ``"gas"`` (default). For example, adding the following line to a contract will cause it to try to optimize for codesize:
The optimization mode can be one of ``"none"``, ``"codesize"``, or ``"gas"`` (default). For example, adding the following line to a module will cause it to try to optimize for codesize:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when pragmas are used in non-root modules ?

-----------------------------

When looking for a file to import, Vyper will first search relative to the same folder as the contract being compiled. It then checks for the file in the provided search paths, in the precedence provided. Vyper checks for the file name with a ``.vy`` suffix first, then ``.vyi``, then ``.json``.
When looking for a file to import, Vyper will first search relative to the same folder as the module being compiled. It then checks for the file in the provided search paths, in the precedence provided. Vyper checks for the file name with a ``.vy`` suffix first, then ``.vyi``, then ``.json``.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the wording should be clearer, are paths relative to the root-module, or the current module ?

(I'm pretty sure it's the current module, but it should be clear from this paragraph)

Comment thread docs/using-modules.rst
===========================

The simplest way to define a module is to write a contract. In Vyper, any contract is a valid module! For example, the following contract is also a valid module.
Any ``.vy`` file is a module. When a module is the entry point of compilation, it becomes a contract upon deployment. For example, the following module can be both deployed directly and imported by other modules.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect explanation !

@Sporarum
Copy link
Copy Markdown
Collaborator

Sporarum commented Mar 9, 2026

hm yea technically contract refers to a deployed artifact but it can also informally refer to a toplevel module (compilation target)

Yes I think we should be more explicit on this, since "contract" can mean either the root module only, or multiple modules (the deployed artifact) depending on the context

Even more so since with #4730 we might have modules which are not valid contracts (toplevel modules)

@Sporarum
Copy link
Copy Markdown
Collaborator

Sporarum commented Mar 9, 2026

most devs still reason about deployed contracts rather than compilation modules.

how it differs from a contract, and I don't see that concept clearly defined before it's used.

I agree, we should expand more on the distinction between modules and contracts, but I would the docs where already confusing in this regard before !
Since it was never clear what it meant to be a module (semantically)

I would however like to see some of the structure a bit more modified than just renaming things. In particular I think a (potentially shalow) definition of modules and contracts should come fairly early.

This could make the docs harder to follow for users coming from Solidity

I disagree, Solidity already has a concept of contract which can use source from other files, so the structure is actually very similar
To my understanding the main difference is that they have keywords like contract which distinguish contracts/modules, whereas we use where the compiler is pointed at

@Sporarum Sporarum closed this Mar 9, 2026
@Sporarum Sporarum reopened this Mar 9, 2026
@Sporarum
Copy link
Copy Markdown
Collaborator

Sporarum commented Mar 9, 2026

I clicked "close with comment" instead of deleting a message I was writing ...

Copy link
Copy Markdown
Contributor

@fubuloubu fubuloubu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor suggestions

Comment thread docs/interfaces.rst
=========================

You can define an interface for your contract with the ``implements`` statement:
You can define an interface for your module with the ``implements`` statement:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can define an interface for your module with the ``implements`` statement:
You can define an interface that your module must satisfy with the ``implements`` statement:

Comment thread docs/interfaces.rst
=====================

Vyper has a built-in format option to allow you to easily export a Vyper interface from a pre-existing contract.
Vyper has a built-in format option to allow you to easily export a Vyper interface from a pre-existing module.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be "top-level" module, artifact, etc. (Stay "contract"?)



In the above examples, the contract will only compile with Vyper versions ``0.4.x``.
In the above examples, the module will only compile with Vyper versions ``0.4.x``.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if file would actually be clearer here (or module file)

* state (variables), which may be tightly coupled with that functionality

Modules can be added to contracts by importing them from a ``.vy`` file. Any ``.vy`` file is a valid module which can be imported into another contract! This is a very powerful feature which allows you to assemble contracts via other contracts as building blocks.
Modules can be imported from any ``.vy`` file. Any ``.vy`` file is a valid module which can be imported into another module. When the entry-point module is compiled and deployed, it becomes a contract.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems very important, maybe consider listing higher?

Also I haven't see "entry-point module" defined yet, I see it below I'm "Using Modules"

Copy link
Copy Markdown
Contributor

@rafael-abuawad rafael-abuawad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting approach, but I don't think it is going to be useful, especially because the word 'contract' is engraved so deeply in EVM development. Maybe adding a new section on modules would be better

Comment thread docs/interfaces.rst
==============================

Interfaces can be added to contracts either through inline definition, or by importing them from a separate file.
Interfaces can be added to a module either through inline definition, or by importing them from a separate file.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modules would be better

Suggested change
Interfaces can be added to a module either through inline definition, or by importing them from a separate file.
Interfaces can be added to modules either through inline definition, or by importing them from a separate file.

#######################

Vyper contracts are contained within files. Each file contains exactly one contract.
Each Vyper source file contains exactly one module.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think since this is really early in the docs, we should start using the word modules as a synonym, keeping the original and adding the word module

Suggested change
Each Vyper source file contains exactly one module.
Vyper contracts (or modules) are contained within files. Each file contains exactly one contract.

Something in that line

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal of this PR is specifically to make the two concepts more distinct !

And in particular "Each file contains exactly one contract." is incorrect.
That is especially true with the upcoming abstract modules, which are not valid contracts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants