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

Starknet-rs Deployment: Checking Transaction Status for Subsequent Invocation #389

Open
omarespejel opened this issue May 22, 2023 · 2 comments

Comments

@omarespejel
Copy link

Hey! Big fan of starknet-rs here.

We're currently authoring tutorials about starknet-rs for the StarkNet Book. As part of this effort, we're developing a function that deploys a contract and then calls upon this newly deployed contract, all within the same script.

To ensure seamless operation, we need to verify that the contract deployment transaction has been accepted on L2 before we proceed to the invocation part. Could you recommend the best approach for confirming a transaction's status on L2 using starknet-rs?

I can imagine something like:

SequencerGatewayProvider::starknet_alpha_goerli()
            .wait_for_tx(BlockId::Pending, &transaction_hash, None)
            .unwrap();

Specifically, we're looking for a function or method that efficiently fetches the status of a specific transaction hash, and then allows further execution only if the status is 'Accepted' on L2.

Thank you for your time and support.

Best Regards,

@xJonathanLEI
Copy link
Owner

Thanks for reaching out and I'm glad you like the library :)

Transaction watching isn't something that's built-in right now, and applications must implement their own watching logic. For example, this is how it's currently implemented in starkli:

https://github.com/xJonathanLEI/starkli/blob/caaa498df772ac68a1ea3965d74d5ca02dcaa0d1/src/utils.rs#L11_L40

This feature should be part of starknet-rs though. I'd imagine a dedicated TransactionWatcher type that can be either manually constructed or converted from any transaction submission response tyoes. And with this type users should be able to configure poll interval, timeout, and expected transaction status.

That said, as of today, a naive loop as demostrated in the starkli example above should be the best way.

I'll leave this issue open for tracking the implementation of this feature.

@omarespejel
Copy link
Author

omarespejel commented May 23, 2023

Thanks for the speedy response, @xJonathanLEI! Thank you for referencing me to the watch_tx function, I will be employing a similar logic in the Book tutorial! Our goal is to get more persons to use starknet-rs.

Also, your insights make sense - a built-in TransactionWatcher could be a strong addition to starknet-rs. For now, using the simple loop from starkli seems like our best bet for the Book. Looking forward to tracking the progress of this feature.

Thanks for keeping the conversation open!

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

No branches or pull requests

2 participants