Skip to content

Update contract constructor documentation - #2741

Merged
leighmcculloch merged 4 commits into
mainfrom
init
Aug 13, 2026
Merged

leighmcculloch merged 4 commits into
mainfrom
init

Conversation

@leighmcculloch

@leighmcculloch leighmcculloch commented Aug 12, 2026 •

Copy link
Copy Markdown
Member

What

Update Soroban documentation and examples to use __constructor deployment arguments and deploy_v2 or register instead of post-deployment initialization.

Why

The existing examples describe the pre-constructor initialization flow, which no longer matches current practices.

Related stellar/soroban-examples#412

@leighmcculloch
leighmcculloch marked this pull request as ready for review August 12, 2026 10:54
Copilot AI balanced review requested due to automatic review settings August 12, 2026 10:54

Copilot AI left a comment

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.

Pull request overview

Updates Soroban documentation to use atomic contract constructors instead of post-deployment initialization.

Changes:

  • Renames initialization functions to __constructor.
  • Passes constructor arguments through register, deploy_v2, and CLI deployment.
  • Updates deployment guidance and examples.

Recommendation: NEEDS-CHANGES — complete the migration in the remaining BLS signature and authorization examples.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
docs/learn/migrate/evm/smart-contract-deployment.mdx Migrates vault deployment to constructor arguments.
docs/learn/fundamentals/contract-development/contract-interactions/cross-contract.mdx Documents constructor deployment APIs.
docs/build/guides/storage/choosing-the-right-storage.mdx Converts storage initialization to a constructor.
docs/build/guides/auth/check-auth-tutorials.mdx Passes account signers during registration.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@ElliotFriend ElliotFriend left a comment

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 looks great! thank you for submitting the changes!

i left one question, but it's more a reflection of my own curiosity. certainly, it's not a blocker, and you are welcome to merge whenever you're ready.


let client = create_client(&env);
client.init(&pk);
let contract_id = env.register(IncrementContract, IncrementContractArgs::__constructor(&pk));

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.

question about this one: doesn't the "normal" register pattern go more like env.register(IncrementContract, (&pk,));?

I see that this change does indeed reflect the source code in the examples repo, but I'm curious why this pattern is used here, but not in other places?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The pattern was introduced or the feature was introduced at some time and people people can use either approach. The advantage of using the args is that it gives you a typed function to pass the values through so you know you're gonna get the types right and the number of parameters right whereas you're sort of winging it when you're using a tuple but the tuple approach is very valid valid too

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The pattern was introduced or the feature was introduced at some time and people people can use either approach. The advantage of using the args is that it gives you a typed function to pass the values through so you know you're gonna get the types right and the number of parameters right whereas you're sort of winging it when you're using a tuple but the tuple approach is very valid valid too

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm gonna leave this as is because this is what's used in the example that's being referenced. We should probably think about maybe normalizing the examples and the docs usage of it. Or you, know this, is also minor enough that it it maybe doesn't matter.

@leighmcculloch
leighmcculloch merged commit b27bf6a into main Aug 13, 2026
9 checks passed
@leighmcculloch
leighmcculloch deleted the init branch August 13, 2026 22:31
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.

3 participants