stellar-registry
Stellar cross-contract calls simplified.
Say you've got:
- a contract deployed on Stellar's testnet or mainnet
- a registered name for this contract in Stellar Registry (example: the
unverifiedregistry on testnet, which is registered in the official (verified) registry with the nameunverified) - a Wasm hash that is also in Stellar Registry (example: the
registryWasm used by theunverifiedcontract above)
For now, the stellar_registry crate exports one macro: import_contract_client!
This macro takes the name of the Wasm binary from Stellar Registry:
use soroban_sdk; // needs to be in-scope
import_contract_client!;
This creates a registry module, equivalent to running:
...and then importing the Wasm with soroban_sdk like:
Within a method, you can now instantiate the client as usual, using the contract ID of the desired contract (such as the unverified contract above):
If you don't want your macro making network calls
First, you should know that this macro doesn't make a network call first. It starts by looking in the current Cargo project's target directory for a .wasm file with the given name. Only if it fails to find one will it run stellar registry download to download the Wasm before importing it.
If you want to avoid network calls in your build-time macro logic, you can set environment variable STELLAR_NO_REGISTRY to 1.
Future
Eventually, this crate will also export an import_contract! macro which will allow importing the contract by name, rather than only the Wasm by name. This will simplify the client creation logic shown above.
Follow progress at https://github.com/theahaco/scaffold-stellar/issues/419