Syntax
Parameters
Optional path to the Soroban SDK crate. Use this if you’ve renamed the crate in your
Cargo.toml.Set to
true when implementing a trait marked with #[contracttrait]. This enables proper trait implementation and client generation.Generated Code
The#[contractimpl] macro generates:
- Contract function exports for the Soroban environment
- Client implementations for each public function
- Argument types for each function
- Contract specification entries
- Function registration code for test utilities
Visibility
Onlypub functions within the impl block are exported as contract functions. Private functions are not accessible from outside the contract.
Example
Define a contract with one function,hello, and call it from within a test using the generated client.
See Also
#[contract]- Mark the contract type- Writing Contracts Guide - Complete contract development guide