Skip to content

Conversation

@hakymulla
Copy link

@hakymulla hakymulla commented Jul 27, 2025

What

closes #2048

automatically creates and funds a key on testnet when none is provided for testnet.

// before 
stellar contract deploy --wasm ../soroban-hello-world/target/wasm32v1-none/release/hello_world.wasm
error: the following required arguments were not provided:
  --source-account <SOURCE_ACCOUNT>

Usage: stellar contract deploy --source-account <SOURCE_ACCOUNT> <--wasm <WASM>|--wasm-hash <WASM_HASH>> [-- <CONTRACT_CONSTRUCTOR_ARGS>...]

For more information, try '--help'.

// After
stellar contract deploy --wasm ../soroban-hello-world/target/wasm32v1-none/release/hello_world.wasm
ℹ️  Skipping install because wasm already installed
ℹ️  Using wasm hash c803e2c6e0dd242b72a4fcbaa916a0541e7bdfde55740b95f64429d611fb2c23
ℹ️  Simulating deploy transaction…
ℹ️  Transaction hash is a222c5018bbf6908010f67cab97be992da54594edc1a85f8df11162cb634fbf2
🔗 https://stellar.expert/explorer/testnet/tx/a222c5018bbf6908010f67cab97be992da54594edc1a85f8df11162cb634fbf2
ℹ️  Signing transaction: a222c5018bbf6908010f67cab97be992da54594edc1a85f8df11162cb634fbf2
🌎 Submitting deploy transaction…
🔗 https://stellar.expert/explorer/testnet/contract/CA2HYU6OLNI2B5JULUWTJW53TBW55QWQU4JX2UEERFFDQHJ7BNZHH5UT
✅ Deployed!
CA2HYU6OLNI2B5JULUWTJW53TBW55QWQU4JX2UEERFFDQHJ7BNZHH5UT

Why

It Randomly generates a key and funds it meaning that devs getting started would have less setup to do.

Known limitations

Still have to supply the --wasm flag

@github-project-automation github-project-automation bot moved this to Backlog (Not Ready) in DevX Jul 27, 2025
@hakymulla hakymulla changed the title automatically fund a key on testnet Add automatically fund a key on testnet Jul 27, 2025
@hakymulla hakymulla marked this pull request as ready for review July 28, 2025 05:31
@fnando
Copy link
Member

fnando commented Jul 28, 2025

Hi! I see where you're coming from, but we're avoiding to do too many magical things that users may not be aware of. In your case, the best way of doing quite the same would be creating a key, then using stellar keys use NAME, like this:

$ stellar keys generate default --fund --global
✅ Key saved with alias default in "/Users/fnando/.config/stellar/identity/default.toml"
✅ Account default funded on "Standalone Network ; February 2017"

$ stellar keys use default
ℹ️ The default source account is set to `default`

From now on, you don't have to use --source at all. Same thing can be done for the network; use stellar network use testnet and you're done.

You can see how your env is set up by using stellar env.

@hakymulla
Copy link
Author

Hi @fnando, i don't quite understand what you mean in comparison with the issue message.

Do you mean the Users must run

$ stellar keys generate default --fund --global

and

stellar keys use default

which is quite different from what the issue states (flow would mean that devs getting started would have less to do upfront before a stellar contract deploy would just work), please do clarify.
Thanks.

short = 's',
visible_alias = "source",
env = "STELLAR_ACCOUNT",
default_value = "default"
Copy link
Member

@leighmcculloch leighmcculloch Jul 30, 2025

Choose a reason for hiding this comment

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

What if instead of introducing a magic value, we leveraged the env var by setting the env var at a high level. The idea I suggested in the issue was less about having a magic 'default', but more about identifying when a default key hasn't been set via the use command, and there are no generated keys, and creating a key and then setting it as if the use command had been called. Outputting messages saying it is doing that.

Copy link
Author

Choose a reason for hiding this comment

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

ooh, so to be clear If no STELLAR_ACCOUNT is set and no default key exists, the source_account method should create and set a default key?

Copy link
Member

Choose a reason for hiding this comment

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

That's what I meant in the original issue I think.

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

Labels

None yet

Projects

Status: Backlog (Not Ready)

Development

Successfully merging this pull request may close these issues.

Automatically fund a key on testnet when one is not set

3 participants