Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retroactive: Noir contract scope #1135

Closed
1 task done
kevaundray opened this issue Apr 11, 2023 · 1 comment
Closed
1 task done

Retroactive: Noir contract scope #1135

kevaundray opened this issue Apr 11, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@kevaundray
Copy link
Contributor

Problem

This is a retroactive issue for the contract scope.

We want Noir to be used as a private smart contract language. At the moment, we are only able to create private programs (libraries/binaries). We want a way to distinguish between a private program and a private contract because there is syntax and semantics that are allowed in contracts that are not allowed in programs.

For example, a private contract has the notion of a storage slot however, private programs do not inherently have this notion. Contracts will also have different visibility identifiers and function types. A Noir function in a program will eventually only be publicly visible or privately visible. This will in turn allow other Noir programs to call such a function (if publicly visible). Contracts on the other hand will have additional rules around what type of functions can call what functions and whether such calls get inlined or not. I am being particularly vague and will refer the reader to Solidities treatment of external and internal functions.

Proposed solution

The proposed solution is to implement the following syntax:

contract Foo {

   fn bar() {}
   
   fn baz() {}
}

The above introduces the contract keyword and defines a private smart contract named Foo. We have two functions defined in Foo which can be regarded as two Noir separate programs. One way to view "bar" and "baz" is that they are compiled as separate "main" functions.

Alternatives considered

No response

Additional context

No response

Submission Checklist

  • Once I hit submit, I will assign this issue to the Project Board with the appropriate tags.
@kevaundray kevaundray added the enhancement New feature or request label Apr 11, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Apr 11, 2023
@kevaundray kevaundray moved this from 📋 Backlog to ✅ Done in Noir Apr 11, 2023
@kevaundray
Copy link
Contributor Author

@iAmMichaelConnor Closing as this has been completed

@Savio-Sou Savio-Sou moved this from ✅ Done to 📋 Backlog in Noir Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

1 participant