Skip to content

Commit 0d8a4ae

Browse files
committed
chore: add docs for contractimport and contractfile macro sha256 verification
1 parent 0e14f5c commit 0d8a4ae

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

soroban-sdk/src/lib.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,22 @@ pub use soroban_sdk_macros::contracterror;
305305
/// `export = false` and do not produce spec entries. See [`_features`] for
306306
/// details.
307307
///
308+
/// ### SHA-256 Verification
309+
///
310+
/// An optional `sha256` parameter can be provided to verify the integrity of
311+
/// the WASM file at compile time. When provided, The macro computes the
312+
/// SHA-256 hash of the WASM file at compile time and produces a compile error
313+
/// if it does not match the provided value.
314+
///
315+
/// ```ignore
316+
/// mod contract_a {
317+
/// soroban_sdk::contractimport!(
318+
/// file = "contract_a.wasm",
319+
/// sha256 = "d5bc0a5b4...",
320+
/// );
321+
/// }
322+
/// ```
323+
///
308324
/// ### Examples
309325
///
310326
/// ```ignore
@@ -1008,6 +1024,19 @@ pub use soroban_sdk_macros::contractspecfn;
10081024
/// into a constant, and so it is usually unnecessary to use [`contractfile`]
10091025
/// directly, unless you specifically want to only load the contract file
10101026
/// without generating a client for it.
1027+
///
1028+
/// ### SHA-256 Verification
1029+
///
1030+
/// Unlike [`contractimport`], `contractfile` **requires** a `sha256`
1031+
/// parameter. The macro computes the SHA-256 hash of the WASM file at compile
1032+
/// time and produces a compile error if it does not match the provided value.
1033+
///
1034+
/// ```ignore
1035+
/// soroban_sdk::contractfile!(
1036+
/// file = "contract_a.wasm",
1037+
/// sha256 = "d5bc0a5b4...",
1038+
/// );
1039+
/// ```
10111040
pub use soroban_sdk_macros::contractfile;
10121041

10131042
/// Panic with the given error.

0 commit comments

Comments
 (0)