From 52d2e9296d657896d3be1cb278485d9867ee2c84 Mon Sep 17 00:00:00 2001 From: Jane Wang Date: Tue, 26 Nov 2024 13:28:19 -0500 Subject: [PATCH 1/2] Addd testnet to mainnet tutorial --- .../getting-started/testnet-to-mainnet.mdx | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 docs/build/smart-contracts/getting-started/testnet-to-mainnet.mdx diff --git a/docs/build/smart-contracts/getting-started/testnet-to-mainnet.mdx b/docs/build/smart-contracts/getting-started/testnet-to-mainnet.mdx new file mode 100644 index 000000000..f9043cbd7 --- /dev/null +++ b/docs/build/smart-contracts/getting-started/testnet-to-mainnet.mdx @@ -0,0 +1,86 @@ +--- +sidebar_position: 50 +title: 5. Move from Testnet to Mainnet +description: Move from Testnet to Miannet. +pagination_next: build/apps/dapp-frontend +--- + + + + + + + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { getPlatform } from "@site/src/helpers/getPlatform"; + +## Moving a Contract from Testnet to Mainnet + +This guide outlines the process for securely deploying Soroban smart contracts from testnet to mainnet using GitHub Actions and Github Attestation for source code validation. + +## Steps to Deploy + +### 1. Set Up Contract Source Validation + +- Configure your GitHub repository for automated source validation. +- Create a workflow file `.github/workflows/release.yml` in your repository. + +Example workflow: + +```yaml +name: Build and Release # arbitrary name +on: + push: + tags: + - "v*" # triggered whenever a new tag (prefixed with "v") is pushed + +permissions: # required permissions + id-token: write + contents: write + attestations: write + +jobs: + release-contract-a: + uses: stellar-expert/soroban-build-workflow/.github/workflows/release.yml@main + with: + release_name: ${{ github.ref_name }} # git tag as unique release name + release_description: "Contract release" # text to attach to the release + relative_path: '["src/my-awesome-contract"]' # relative contract path + package: "my-awesome-contract" # package name to build + make_target: "build-dependencies" # make target to invoke + secrets: # authentication tokens will be automatically created by GitHub + release_token: ${{ secrets.GITHUB_TOKEN }} # don't modify this line +``` + +### 2. Compile and Validate Contract + +- Trigger the workflow by pushing a new tag (e.g., `v1.0`). +- The workflow will: + - Compile the contract to WASM. + - Publish a GitHub release with build artifacts. + - Generate a GitHub attestation, linking the WASM to the source code. + +```bash + stellar contract build \ + --meta name="Contract Name" \ + --meta description="Descripton of the contract" + --meta source="https://api.github.com/repos//" +``` + +### 3. Deploy to Mainnet + +- Retrieve the compiled WASM from the GitHub release. +- Deploy the WASM to the Stellar mainnet using the Soroban CLI: + +```bash + stellar contract deploy --source-acount --wasm --network mainnet +``` + +### 4. Verify Contract Authenticity + +Use the GitHub API to confirm the WASM's source: Retrieve attestation via: `https://api.github.com/repos///attestations/sha256:` Ensure the source code and commit hash match the deployed contract. + +## Up next + +Ready to turn these deployed contracts into a simple web application? Head over to the [Build a Dapp Frontend section](../../apps/dapp-frontend.mdx). From cdc22f263a6d599bfc45f38b8545c607092ba4c5 Mon Sep 17 00:00:00 2001 From: Bri <92327786+briwylde08@users.noreply.github.com> Date: Mon, 2 Dec 2024 09:47:02 -0700 Subject: [PATCH 2/2] editorial --- docs/build/guides/testing/unit-tests.mdx | 2 ++ .../getting-started/testnet-to-mainnet.mdx | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/build/guides/testing/unit-tests.mdx b/docs/build/guides/testing/unit-tests.mdx index dc70ccfed..87b7e902d 100644 --- a/docs/build/guides/testing/unit-tests.mdx +++ b/docs/build/guides/testing/unit-tests.mdx @@ -25,6 +25,7 @@ fn test() { assert_eq!(client.increment(), 3); } ``` + Ref: https://github.com/stellar/soroban-examples/blob/main/increment/src/test.rs :::tip @@ -42,6 +43,7 @@ The Env created at the beginning of the test is not a simulation of the Soroban It's a simple test, but it's a complete test. There's a full environment setup, used, and torn down in the test, and it happens fast. The Rust test harness runs all the tests for a contract in parallel and each will have its own isolated contract environment. Most tests, even integration tests and fuzz tests, will look very similar to this unit test. They'll do four things: + 1. Create an environment, the `Env`. 2. Register the contract(s) to be tested. 3. Invoke functions using a client. diff --git a/docs/build/smart-contracts/getting-started/testnet-to-mainnet.mdx b/docs/build/smart-contracts/getting-started/testnet-to-mainnet.mdx index f9043cbd7..f68389b14 100644 --- a/docs/build/smart-contracts/getting-started/testnet-to-mainnet.mdx +++ b/docs/build/smart-contracts/getting-started/testnet-to-mainnet.mdx @@ -1,7 +1,7 @@ --- sidebar_position: 50 title: 5. Move from Testnet to Mainnet -description: Move from Testnet to Miannet. +description: Move from Testnet to Mainnet pagination_next: build/apps/dapp-frontend --- @@ -17,7 +17,7 @@ import { getPlatform } from "@site/src/helpers/getPlatform"; ## Moving a Contract from Testnet to Mainnet -This guide outlines the process for securely deploying Soroban smart contracts from testnet to mainnet using GitHub Actions and Github Attestation for source code validation. +This guide outlines the process for securely deploying Stellar smart contracts from Testnet to Mainnet using GitHub Actions and Github Attestation for source code validation. ## Steps to Deploy @@ -57,9 +57,9 @@ jobs: - Trigger the workflow by pushing a new tag (e.g., `v1.0`). - The workflow will: - - Compile the contract to WASM. + - Compile the contract to Wasm. - Publish a GitHub release with build artifacts. - - Generate a GitHub attestation, linking the WASM to the source code. + - Generate a GitHub attestation, linking the Wasm to the source code. ```bash stellar contract build \ @@ -70,8 +70,8 @@ jobs: ### 3. Deploy to Mainnet -- Retrieve the compiled WASM from the GitHub release. -- Deploy the WASM to the Stellar mainnet using the Soroban CLI: +- Retrieve the compiled Wasm from the GitHub release. +- Deploy the Wasm to the Stellar Mainnet using the Stellar CLI: ```bash stellar contract deploy --source-acount --wasm --network mainnet @@ -79,7 +79,7 @@ jobs: ### 4. Verify Contract Authenticity -Use the GitHub API to confirm the WASM's source: Retrieve attestation via: `https://api.github.com/repos///attestations/sha256:` Ensure the source code and commit hash match the deployed contract. +Use the GitHub API to confirm the Wasm's source: Retrieve attestation via: `https://api.github.com/repos///attestations/sha256:` Ensure the source code and commit hash match the deployed contract. ## Up next