Skip to content

Commit 4c6f0d9

Browse files
Add cookbook about adding meta on contract build (#2280)
1 parent 30c87ed commit 4c6f0d9

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

cmd/crates/soroban-test/tests/it/integration/cookbook.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,22 @@ fn run_command(
8282
modified_args.push(key_xdr.to_string());
8383
skip_next = true;
8484
}
85+
"--manifest-path" => {
86+
// this defaults to the hello_world manifest path in fixtures/test-wasms
87+
let hello_world_manifest_path = get_repo_root()
88+
.join("cmd")
89+
.join("crates")
90+
.join("soroban-test")
91+
.join("tests")
92+
.join("fixtures")
93+
.join("test-wasms")
94+
.join("hello_world")
95+
.join("Cargo.toml");
96+
modified_args.push(arg.to_string());
97+
modified_args.push(hello_world_manifest_path.display().to_string());
98+
skip_next = true;
99+
}
100+
85101
"<DURABILITY>" => {
86102
modified_args.push("persistent".to_string());
87103
skip_next = false;

cookbook/contract-build-meta.mdx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: Add meta data to contract WASM on build
3+
hide_table_of_contents: true
4+
description: Include meta data in the contract WASM byte code on build
5+
custom_edit_url: https://github.com/stellar/stellar-cli/edit/main/cookbook/contract-build-meta.mdx
6+
---
7+
8+
To build a smart contract, use the `stellar contract build` command. The `--meta` option will allow you to add additional meta data entries to the `contractmetav0` custom section of the resulting WASM file at build time.
9+
10+
```bash cookbooktest.ignore
11+
export SHA=$(git rev-parse HEAD)
12+
```
13+
14+
```bash
15+
stellar contract build \
16+
--manifest-path ./cmd/crates/soroban-test/tests/fixtures/test-wasms/hello_world/Cargo.toml \
17+
--meta source_repo=https://github.com/stellar/stellar-cli \
18+
--meta commit_sha=$SHA
19+
```
20+
21+
You can then use `stellar contract info meta` to see the meta data:
22+
23+
```bash
24+
stellar contract info meta \
25+
--wasm target/wasm32v1-none/release/test_hello_world.wasm
26+
```
27+
28+
```bash cookbooktest.ignore
29+
Contract meta:
30+
• rsver: 1.91.0 (Rust version)
31+
• rssdkver: 23.0.1#510d3feb724c2b01d7e7ab7652f03b9f8efc3f35 (Soroban SDK version and its commit hash)
32+
• cliver: 23.1.4#v20.0.0-646-g70895dd66fb7dbf2f4c2a81cf38546512ba4198e-dirty
33+
• source_repo: https://github.com/stellar/stellar-cli
34+
• commit_sha: c6f881689d3f4936cb3262089eb70142e9ca9c91
35+
```

0 commit comments

Comments
 (0)