-
Notifications
You must be signed in to change notification settings - Fork 215
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
Add constructor support to Solidity contracts #1672
Comments
Just to make sure I understand this correctly, There are a few things I’m unsure about:
|
@tareknaser |
Alright, here’s what I understand about the desired behavior:
I’ve tried a few approaches to handle the second point, but they haven’t worked out so far:
I’m continuing to debug, but I wanted to share these notes in case there’s a simpler approach that I might be missing. Do you have any suggestions? |
@tareknaser You are doing a great job!
, and use
U see that the constructor is named What needs to be done is two things: Does that answer your question? |
Thanks for mentioning
So, it's safe to say that both Also, is the function let constructor = binary.module.get_function("__unnamed_1").unwrap(); ?
I'm not sure I fully understand this part. If a user defines their own version of Something related that I found while looking into how this is implemented in |
Soroban protocol 21 did not support constructors (functions exposed by the contract, which the Vm calls upon contract deployment).
That means that a developer would have to call
init
manually from the command line.init
is a function that Solang embeds in Solidity contracts, which loops over storage variables and initializes them. (By calling another functionstorage_initializer
)solang/src/emit/soroban/mod.rs
Line 254 in 5176166
What needs to be done:
Upgrade protocol version in contract to be 22, and change the name
init
to__constructor
, and add testsThe text was updated successfully, but these errors were encountered: