### Install Specific Go Version using `go get` Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/contract/prerequisites.md This command demonstrates how to install a specific version of Go (e.g., 1.20.2) using the `go get` command, which is useful when your distribution's Go version is outdated. Note: The original text contains a typo 'downloa2'. ```bash go get golang.org/dl/go1.20.2 go1.20.5 downloa2 ``` -------------------------------- ### Building Sample Oasis Components Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/client-sdk/ts-web/ext-utils/docs/getting-started.md Provides command-line instructions for building the sample dApp page and the sample extension. These commands utilize `npm` and `webpack` to compile the respective projects within the `client-sdk/ts-web/ext-utils` directory. ```Shell npm run sample-ext # Builds the sample extension project. # Located in `client-sdk/ts-web/ext-utils`. npm run sample-page # Builds and serves the sample dApp page locally. # Located in `client-sdk/ts-web/ext-utils`. ``` -------------------------------- ### Example Output of Successful Net Runner Startup Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md Shows the confirmation message displayed after `oasis-net-runner` successfully starts the local network. This message indicates that the client node socket is available, signifying the network is ready for interaction. ```text level=info module=net-runner caller=root.go:152 ts=2021-06-14T08:42:47.219513806Z msg="client node socket available" path=/tmp/minimal-runtime-test/net-runner/network/client-0/internal.sock ``` -------------------------------- ### Oasis Extension API Initialization Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/client-sdk/ts-web/ext-utils/docs/getting-started.md Describes the `oasisExt.ext.ready` function, which is crucial for initializing the extension side of the dApp interface. It registers callbacks that `oasisExt` will invoke when the dApp makes requests, enabling the extension to handle interactions. ```APIDOC oasisExt.ext.ready(callbacks) - Purpose: Initializes the extension and registers callback functions. - Parameters: - callbacks: object - An object containing functions that the `oasisExt` library will call when the dApp makes requests. - Usage Notes: This function sets up the communication channel between the dApp and the extension, allowing the extension to respond to dApp queries. ``` -------------------------------- ### Launching Sample dApp with Custom Extension Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/client-sdk/ts-web/ext-utils/docs/getting-started.md Illustrates how to open the sample dApp page in a browser and connect it to a specific Chrome extension. This is achieved by appending a query parameter to the dApp's local URL, specifying the target extension's ID. ```URL http://localhost:8080/?ext=chrome-extension://(your extension id) ``` -------------------------------- ### Oasis dApp Client API Usage Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/client-sdk/ts-web/ext-utils/docs/getting-started.md Details the core API functions provided by `oasisExt` for dApp development, including establishing connections, listing available keys, and signing transactions. These functions interact directly with the connected browser extension. ```APIDOC oasisExt.connection.ExtConnection(origin_string) - Purpose: Establishes a connection to an Oasis extension. - Parameters: - origin_string: string - The origin string of the extension to interact with. - Usage Notes: Must be called after the `body` element exists (e.g., not in a script in `head` without `defer`). oasisExt.keys.list - Purpose: Retrieves a list of keys available from the connected extension. - Parameters: None (implicitly uses the connection). - Usage Notes: Keys are identified by a 'which' value, whose format may vary by extension. oasisExt.signature.ExtContextSigner - Purpose: Provides functionality to sign transactions using the extension's context signer. - Parameters: (Implicitly uses the connection and key context). - Usage Notes: Used for preparing and submitting transaction bodies. ``` -------------------------------- ### Install Rustup for Rust Toolchain Management Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/contract/prerequisites.md This command installs `rustup`, the recommended tool for managing Rust versions and toolchains, by downloading and executing its initialization script. It sets up the latest stable Rust version. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` -------------------------------- ### Set Up Python Virtual Environment and Dependencies Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/quickstart.mdx This snippet demonstrates how to create a Python virtual environment, activate it, and install the `python-telegram-bot` dependency using `pip` and a `requirements.txt` file. This is a standard practice for managing project dependencies and ensuring a clean development environment. ```shell python -m venv my_env source my_env/bin/activate echo python-telegram-bot > requirements.txt pip install -r requirements.txt ``` -------------------------------- ### Fetch Go Dependencies for Oasis Runtime Client Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md This shell command downloads and installs all necessary Go module dependencies declared in `go.mod` for the client application. ```shell go get ``` -------------------------------- ### Dockerfile for Python Telegram Bot Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/quickstart.mdx This Dockerfile defines the build process for the Python Telegram bot. It starts from a Python Alpine base image, sets the working directory, copies the bot script and requirements, installs Python dependencies, and specifies the entrypoint for running the bot. ```dockerfile FROM python:alpine3.17 WORKDIR /bot COPY ./bot.py ./requirements.txt /bot RUN pip install -r requirements.txt ENTRYPOINT ["python", "bot.py"] ``` -------------------------------- ### Verify and Install Rust Toolchain for Oasis SDK Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/contract/prerequisites.md Run this command within your project directory to automatically detect and install the appropriate Rust toolchain version specified in `rust-toolchain.toml`. It also displays the active toolchain details. ```bash rustup show ``` -------------------------------- ### Build and Run Docker Compose Locally Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/quickstart.mdx These shell commands are used to build the Docker image defined in the `Dockerfile` and `compose.yaml`, and then to start the container locally. `docker compose build` compiles the image, and `docker compose up` launches the service. ```shell docker compose build docker compose up ``` -------------------------------- ### Install Oasis SDK Client Package Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/client-sdk/ts-web/core/docs/getting-started.md This command installs the `@oasisprotocol/client` package using npm, which is the first step to integrate the Oasis SDK into your project. A bundler like webpack is required for web applications. ```sh npm install @oasisprotocol/client ``` -------------------------------- ### Example Output of Failed Runtime Startup Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md Illustrates the typical error messages and log output when attempting to run the Oasis SDK runtime directly without the required Oasis Node sandbox environment. It shows the runtime failing to connect with the worker host. ```text Finished dev [unoptimized + debuginfo] target(s) in 0.08s Running `target/debug/minimal-runtime` {"msg":"Runtime is starting","level":"INFO","ts":"2021-06-09T10:35:10.913154095+02:00","module":"runtime"} {"msg":"Establishing connection with the worker host","level":"INFO","ts":"2021-06-09T10:35:10.913654559+02:00","module":"runtime"} {"msg":"Failed to connect with the worker host","level":"ERRO","ts":"2021-06-09T10:35:10.913723541+02:00","module":"runtime","err":"Invalid argument (os error 22)"} ``` -------------------------------- ### Oasis CLI Commands for ROFL Application Deployment Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/quickstart.mdx This sequence of Oasis CLI commands outlines the steps to initialize, register, build, secure, and deploy a ROFL (ROFL-compose-app) bundle. It covers the full lifecycle from project setup to deployment on a TDX-machine, ensuring secure application execution. ```shell oasis rofl init oasis rofl create oasis rofl build oasis rofl secret set oasis rofl deploy ``` -------------------------------- ### Minimal Runtime Project Directory Structure Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md Illustrates the expected final directory structure of the `minimal-runtime` project after completing the setup. It includes configuration files, Rust source files, and Go test files, providing an overview of the project layout. ```plaintext minimal-runtime ├── .cargo │ └── config.toml # Cargo configuration. ├── Cargo.lock # Rust dependency tree checksums. ├── Cargo.toml # Rust crate defintion. ├── rust-toolchain.toml # Rust toolchain version configuration. ├── src │ ├── lib.rs # The runtime definition. │ └── main.rs # Some boilerplate for building the runtime. └── test ├── go.mod # Go module definition ├── go.sum # Go dependency tree checksums. └── test.go # Test client implementation. ``` -------------------------------- ### Install Specific Go Version using golang.org/dl Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/prerequisites.md These commands install a specific version of Go (e.g., 1.22.5) using the `golang.org/dl` tool. The first command fetches the Go version installer, and the second command downloads and installs the Go SDK. ```go go get golang.org/dl/go1.22.5 go1.22.5 download ``` -------------------------------- ### Initialize Go Module for Oasis Runtime Client Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md This shell command initializes a new Go module, creating the `go.mod` and `go.sum` files, and tidies up module dependencies for the client application. ```shell go mod init example.com/oasisprotocol/minimal-runtime-client go mod tidy ``` -------------------------------- ### Install Dependencies and Compile Smart Contract Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/examples/runtime-sdk/rofl-oracle/oracle/README.md Installs project dependencies using npm and compiles the Hardhat smart contract project, preparing it for deployment. ```shell npm install npx hardhat compile ``` -------------------------------- ### Build Oasis Runtime Client Executable Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md This shell command compiles the Go source code of the client application into an executable binary in the current directory. ```shell go build ``` -------------------------------- ### Initialize New Rust Project with Cargo Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md Initializes a new Rust binary project named `minimal-runtime` using Cargo. This command sets up the basic directory structure and prepares the project for version control. ```bash cargo init minimal-runtime ``` -------------------------------- ### Install Rustup for Rust Toolchain Management Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/prerequisites.md This command installs `rustup`, the recommended tool for managing Rust versions and toolchains, by downloading and executing a shell script from the official rustup.rs domain. It sets up the latest stable Rust version. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` -------------------------------- ### Example Output of Rust Toolchain Verification Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/prerequisites.md This snippet shows an example of the output from `rustup show`, indicating the active Rust toolchain, including the specific nightly version and `rustc` compiler version, overridden by a local `rust-toolchain` file. ```text ... active toolchain ---------------- nightly-2022-08-22-x86_64-unknown-linux-gnu (overridden by '/code/rust-toolchain') rustc 1.65.0-nightly (c0941dfb5 2022-08-21) ``` -------------------------------- ### Verify and Install Rust Toolchain Version Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/prerequisites.md Run this command within your project directory to automatically detect and install the appropriate Rust toolchain version specified in `rust-toolchain.toml`. It also outputs the active toolchain details. ```bash rustup show ``` -------------------------------- ### Encrypt and Store Environment Variable On-Chain Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/quickstart.mdx This command encrypts a sensitive environment variable (e.g., `TOKEN`) and securely stores it on-chain. This ensures that the secret is safely delivered to the bot container when it starts on a TEE provider's node, without exposing it in plain text. ```shell echo -n "$TOKEN" | oasis rofl secret set TOKEN - ``` -------------------------------- ### Install ROFL Build Utilities on Debian-based Linux Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/prerequisites.mdx This command installs essential tools for creating and encrypting partitions, along with QEMU, which are required for advanced ROFL development on Debian-based Linux systems. These utilities are crucial for native ROFL builds and related operations. ```shell sudo apt install squashfs-tools cryptsetup-bin qemu-utils ``` -------------------------------- ### Initialize and Register ROFL App on Oasis Testnet Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/quickstart.mdx This command sequence initializes the `rofl.yaml` manifest file and registers a new ROFL application on the Sapphire Testnet. It's a prerequisite for deploying your bot and sets up the necessary on-chain records. ```shell oasis rofl init oasis rofl create --network testnet ``` -------------------------------- ### Invoke Oasis CLI from Docker (Conservative Setup) Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/prerequisites.mdx This set of commands allows users to run the `oasis` CLI from within the `rofl-dev` Docker image, which is useful when the CLI is not installed locally. It bind-mounts the current directory and the Oasis CLI configuration folder to ensure persistent access to accounts. The `--platform linux/amd64` flag is included for cross-platform compatibility. ```shell docker run --platform linux/amd64 --rm -v .:/src -v ~/.config/oasis:/root/.config/oasis -it ghcr.io/oasisprotocol/rofl-dev:main oasis ``` ```shell docker run --platform linux/amd64 --rm -v .:/src -v "~/Library/Application Support/oasis/":/root/.config/oasis -it ghcr.io/oasisprotocol/rofl-dev:main oasis ``` ```shell docker run --platform linux/amd64 --rm -v .:/src -v %USERPROFILE%/AppData/Local/oasis/:/root/.config/oasis -it ghcr.io/oasisprotocol/rofl-dev:main oasis ``` -------------------------------- ### Execute Oasis Runtime Client Application Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md This shell command runs the compiled `minimal-runtime-client` executable, which connects to an Oasis node, queries balances, performs a transfer, and displays final balances. ```shell ./minimal-runtime-client ``` -------------------------------- ### Install Oasis Runtime Container (orc) Tool Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/reproducibility.md Installs the `orc` command-line utility, which is used to create Oasis Runtime Container bundles. This tool simplifies the packaging of paratime binaries and metadata. ```bash go install github.com/oasisprotocol/oasis-sdk/tools/orc@latest ``` -------------------------------- ### Interactive Prompts for Adding Paratime Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md Following the `paratime add` command, the CLI prompts for additional configuration details. These prompts allow the user to specify a description for the paratime, its denomination symbol, and the number of decimal places for its currency. ```text ? Description: minimal ? Denomination symbol: TEST ? Denomination decimal places: 9 ``` -------------------------------- ### Install and Build npm Packages Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/client-sdk/ts-web/README.md This command initiates the installation of all dependencies for the npm workspace. The `--foreground-scripts` option is vital as it ensures that packages which are depended upon are compiled before the packages that depend on them, effectively managing the build order for TypeScript projects and addressing a known npm issue. ```sh npm i --foreground-scripts ``` -------------------------------- ### Expected Output for Oasis Account Show Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md This output snippet illustrates the detailed information returned when showing an account. It includes the account's address, nonce, and a breakdown of balances for all denominations across the consensus layer and any configured paratimes. ```text Address: oasis1qrec770vrek0a9a5lcrv0zvt22504k68svq7kzve Nonce: 0 === CONSENSUS LAYER (localhost) === Total: 0.0 TEST Available: 0.0 TEST === minimal PARATIME === Balances for all denominations: 1.0 TEST ``` -------------------------------- ### Deploy ROFL App to Testnet Node Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/quickstart.mdx This command deploys the ROFL application to a Testnet node instance offered by one of the ROFL providers. Upon successful execution, your application will be running within the Trusted Execution Environment, ready to receive commands. ```shell oasis rofl deploy ``` -------------------------------- ### Oasis CLI ROFL App Creation Output Example Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/app.mdx This snippet shows an example of the console output after successfully executing the `oasis rofl create` command. It displays the unique identifier assigned to the newly created ROFL application, which is crucial for on-chain interactions. ```text Created ROFL application: rofl1qqn9xndja7e2pnxhttktmecvwzz0yqwxsquqyxdf ``` -------------------------------- ### Implement Basic Python Telegram Bot Logic Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/quickstart.mdx This Python code defines a simple Telegram bot that responds to the `/hello` command. It uses the `python-telegram-bot` library, retrieves the bot token from an environment variable, and sets up a command handler for the 'hello' command, demonstrating asynchronous message handling. ```python import os from telegram import Update from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes async def hello(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: await update.message.reply_text(f'Hello {update.effective_user.first_name}') app = ApplicationBuilder().token(os.getenv("TOKEN")).build() app.add_handler(CommandHandler("hello", hello)) app.run_polling() ``` -------------------------------- ### Podman Compose: Environment Variable Not Considered (Problematic Example) Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/troubleshooting.mdx This YAML snippet demonstrates a `podman-compose` bug where environment variables defined within the `environment` section of a service are not correctly substituted when used directly in the `entrypoint` command. The `CONTRACT_ADDRESS` will be empty in the ROFL. ```YAML services: oracle: platform: linux/amd64 environment: CONTRACT_ADDRESS: 0x5FbDB2315678afecb367f032d93F642f64180aa3 entrypoint: /bin/sh -c 'python main.py $${CONTRACT_ADDRESS}' ``` -------------------------------- ### Install Dependencies and Compile Oracle Smart Contract Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/app.mdx This snippet shows how to install project dependencies using npm and compile the Solidity smart contract for the Oracle application using Hardhat. This is a prerequisite step before deploying the contract. ```shell npm install npx hardhat compile ``` -------------------------------- ### Attempt to Run Oasis SDK Runtime Directly Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md Attempts to execute the built Oasis SDK runtime binary directly. This command is expected to fail because the runtime is designed to operate within a specific sandbox environment provided by the Oasis Node, not as a standalone executable. ```bash cargo run ``` -------------------------------- ### Build Oasis SDK Runtime with Cargo Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md Builds the Oasis SDK runtime using the standard Cargo build process. This command generates a debug binary of the runtime, typically located under `target/debug/minimal-runtime`. ```bash cargo build ``` -------------------------------- ### Docker Compose Configuration for Telegram Bot Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/quickstart.mdx This `compose.yaml` file orchestrates the Docker container for the Telegram bot. It defines a service named `python-telegram-bot`, specifies the build context, sets the image name, defines the platform, and passes the `TOKEN` environment variable to the container. ```yaml services: python-telegram-bot: build: . image: "ghcr.io/oasisprotocol/demo-rofl-tgbot" platform: linux/amd64 environment: - TOKEN=${TOKEN} ``` -------------------------------- ### Deploy Oasis SDK Runtime in Local Development Network Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md Deploys the newly built Oasis SDK runtime into a local development network using `oasis-net-runner` from Oasis Core. This command sets up a small network of local nodes configured to run the specified runtime, creating a temporary directory for network data. ```bash rm -rf /tmp/minimal-runtime-test; mkdir -p /tmp/minimal-runtime-test ${OASIS_CORE_PATH}/oasis-net-runner \ --fixture.default.node.binary ${OASIS_CORE_PATH}/oasis-node \ --fixture.default.runtime.binary target/debug/minimal-runtime \ --fixture.default.runtime.loader ${OASIS_CORE_PATH}/oasis-core-runtime-loader \ --fixture.default.runtime.provisioner unconfined \ --fixture.default.keymanager.binary '' \ --basedir /tmp/minimal-runtime-test \ --basedir.no_temp_dir ``` -------------------------------- ### Submit ROFL Secret and Enclave Signatures On-Chain Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/quickstart.mdx This command submits the encrypted secrets and the enclave IDs (signatures) of the .orc bundle components to the blockchain. This step finalizes the on-chain registration of the ROFL app's components, making them verifiable and ready for deployment. ```shell oasis rofl update ``` -------------------------------- ### Expected Output for Oasis Network Status Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md This JSON snippet illustrates the expected output when checking the network status. A successful setup will show '"status": "ready"' under the 'committee' field, along with an increasing '"latest_round"' value, indicating the runtime is active. ```json "committee": { "status": "ready", "active_version": { "minor": 1 }, "latest_round": 19, "latest_height": 302, "executor_roles": null, ``` -------------------------------- ### Display Account Balance for Test User Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md This command retrieves and displays the balance of a specified test account (e.g., 'test:alice') on the local network. It shows the total and available balances across both the consensus layer and the configured paratime. ```shell oasis account show test:alice --network localhost ``` -------------------------------- ### Example: Generate SGX Signing Data for ORC Bundle Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/reproducibility.md An example of using `orc sgx-gen-sign-data` to generate the SHA256 hash of SIGSTRUCT fields for `bundle.orc`, saving the output to `sigstruct.sha256.bin`. ```bash orc sgx-gen-sign-data bundle.orc > sigstruct.sha256.bin ``` -------------------------------- ### Example Staking Genesis Account Configuration Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/client-sdk/ts-web/rt/playground/README.md This snippet illustrates how individual accounts, such as Alice and Bob, are defined within the staking genesis document. It shows their initial balance and allowances granted to specific runtime addresses, demonstrating the structure for setting up initial network state. ```JSON // Alice account. "oasis1qrec770vrek0a9a5lcrv0zvt22504k68svq7kzve": { "general": { "balance": "100", "allowances": { // Allowance for runtime: 8000000000000000000000000000000000000000000000000000000000000001. "oasis1qz672fmkt32hc3hxqrrwr07falkr22agsqv5dhke": "100" } }, // Bob account. "oasis1qrydpazemvuwtnp3efm7vmfvg3tde044qg6cxwzx": { "general": { "balance": "100", "allowances": { // Allowance for runtime: 8000000000000000000000000000000000000000000000000000000000000001. "oasis1qz672fmkt32hc3hxqrrwr07falkr22agsqv5dhke": "100" } } } ``` -------------------------------- ### Configure Cargo Build and Test Flags for Target Features Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md Configures Cargo to always build and test with specific target CPU platform features (AES-NI and SSE3). This is achieved by setting `rustflags` and `rustdocflags` in the `.cargo/config.toml` file. ```toml [build] rustflags = ["-C", "target-feature=+aes,+ssse3"] rustdocflags = ["-C", "target-feature=+aes,+ssse3"] [test] rustflags = ["-C", "target-feature=+aes,+ssse3"] rustdocflags = ["-C", "target-feature=+aes,+ssse3"] ``` -------------------------------- ### Instantiate Oasis Contract from Code ID Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/contract/hello-world.md Creates a new instance of a deployed contract on the Oasis network. This command requires the 'CODEID' obtained from the upload step and calls the contract's constructor with specified initial arguments. The example shows passing an 'initial_counter' value. ```Shell oasis contract instantiate CODEID '{instantiate: {initial_counter: 42}}' ``` -------------------------------- ### Build ROFL Bundle (.orc) for TEE Deployment Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/quickstart.mdx These commands build the ROFL bundle (.orc file), which packages the `compose.yaml`, specific operating system components, and the hash of a trusted block on the Sapphire chain. This bundle is essential for securely executing the bot inside the Trusted Execution Environment. ```shell oasis rofl build ``` ```shell docker run --platform linux/amd64 --volume .:/src -it ghcr.io/oasisprotocol/rofl-dev:main oasis rofl build ``` -------------------------------- ### Check Local Network Status with Oasis CLI Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md Use this command to verify the status of the configured local network. It helps confirm if the runtime is ready and operational by checking the 'committee' field in the output for a 'status': 'ready' value and an increasing 'latest_round'. ```bash oasis network status --network localhost ``` -------------------------------- ### Build ROFL App using Docker (Preferred Setup) Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/prerequisites.mdx This command utilizes the `rofl-dev` Docker image to build a ROFL application. It mounts the current directory as the source directory (`/src`) inside the container and executes the `oasis rofl build` command. The `--platform linux/amd64` flag is crucial for ensuring compatibility across different host architectures. ```shell docker run --platform linux/amd64 --rm -v .:/src -it ghcr.io/oasisprotocol/rofl-dev:main oasis rofl build ``` -------------------------------- ### Transfer Tokens Between Oasis Accounts Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md This command initiates a token transfer from a source account (e.g., 'test:alice') to a destination account (e.g., 'test:bob') on the specified network. It prompts for a passphrase to unlock the account and then displays the transaction details for confirmation before broadcasting. ```shell oasis account transfer 0.1 test:bob --network localhost --account test:alice ``` -------------------------------- ### Export Telegram Bot Token and Run Python Bot Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/quickstart.mdx This shell snippet shows how to export the Telegram bot API token as an environment variable and then execute the Python bot script. The token is a placeholder and should be replaced with a real token obtained from BotFather for the bot to function correctly. ```shell export TOKEN="0123456789:AAGax-vgGmQsRiwf4WIQI4xq8MMf4WaQI5x" python bot.py ``` -------------------------------- ### Call Method on Instantiated Oasis Contract Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/contract/hello-world.md Invokes a specific method on an already instantiated contract using its 'INSTANCEID'. This example demonstrates calling the 'say_hello' method and passing a 'who' parameter. The arguments depend on the contract's defined methods and their expected inputs. ```Shell oasis contract call INSTANCEID '{say_hello: {who: "me"}}' ``` -------------------------------- ### Add Local Network to Oasis CLI Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md This command adds a new local network configuration to the Oasis CLI. It requires a network name, a path to the local socket file, and allows for optional details like description, denomination symbol, and decimal places to be specified interactively. ```bash oasis network add-local localhost unix:/tmp/minimal-runtime-test/net-runner/network/client-0/internal.sock ? Description: localhost ? Denomination symbol: TEST ? Denomination decimal places: 9 ``` -------------------------------- ### Run SGX ROFL App with Sapphire Localnet Docker Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/features/testing.md This command starts the `sapphire-localnet` Docker container, binding the current directory to `/rofls` inside the container. This allows ROFL applications and ORC bundles to be automatically registered and executed on startup. It also maps ports 8544-8548 from the container to the host. ```shell docker run -it -p8544-8548:8544-8548 -v .:/rofls ghcr.io/oasisprotocol/sapphire-localnet ``` -------------------------------- ### Configure Rust Compilation Flags in .cargo/config.toml Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/troubleshooting.mdx To resolve the missing target feature error, add these default flags to your `.cargo/config.toml` file. This configuration ensures that `+aes` and `+ssse3` are enabled for both build and test commands. ```TOML [build] rustflags = ["-C", "target-feature=+aes,+ssse3"] rustdocflags = ["-C", "target-feature=+aes,+ssse3"] [test] rustflags = ["-C", "target-feature=+aes,+ssse3"] rustdocflags = ["-C", "target-feature=+aes,+ssse3"] ``` -------------------------------- ### Add Minimal Runtime to Oasis CLI Wallet Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md This command integrates a specific runtime, identified by its unique ID, into the Oasis CLI wallet. By default, `oasis-net-runner` assigns a predefined ID to the first provided runtime, which is used here to link the 'minimal' paratime. ```shell oasis paratime add localhost minimal 8000000000000000000000000000000000000000000000000000000000000000 ``` -------------------------------- ### Podman Compose: Workaround for Environment Variable Issue Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/troubleshooting.mdx As a workaround for the `podman-compose` environment variable bug, directly inject the variable's value into the `entrypoint` command. This bypasses the issue of environment variables not being correctly picked up from the `environment` section. ```YAML services: oracle: platform: linux/amd64 entrypoint: /bin/sh -c 'python main.py 0x5FbDB2315678afecb367f032d93F642f64180aa3' ``` -------------------------------- ### Transaction Details for Token Transfer Confirmation Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/minimal-runtime.md This output displays the full details of the transaction that is about to be signed and broadcasted. It includes the transaction version, the method call ('accounts.Transfer'), the encoded body, and authentication information such as signature address spec and fee details, along with interactive prompts and success messages. ```text Unlock your account. ? Passphrase: You are about to sign the following transaction: { "v": 1, "call": { "method": "accounts.Transfer", "body": "omJ0b1UAyND0Wds45cwxynfmbSxEVty+tQJmYW1vdW50gkQF9eEAQA==" }, "ai": { "si": [ { "address_spec": { "signature": { "ed25519": "NcPzNW3YU2T+ugNUtUWtoQnRvbOL9dYSaBfbjHLP1pE=" } }, "nonce": 0 } ], "fee": { "amount": { "Amount": "0", "Denomination": "" }, "gas": 100 } } } Account: test:alice Network: localhost (localhost) Paratime: minimal (minimal) ? Sign this transaction? Yes (In case you are using a hardware-based signer you may need to confirm on device.) Broadcasting transaction... Transaction included in block successfully. Round: 14 Transaction hash: 03a73bd08fb23472673ea45938b0871edd9ecd2cd02b3061d49c0906a772348a Execution successful. ``` -------------------------------- ### Create Alias for Dockerized Oasis CLI Command Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/prerequisites.mdx These commands define a shell alias for the `oasis` command, enabling users to execute the Dockerized Oasis CLI as if it were installed natively. The alias includes necessary bind-mounts for the source directory and the Oasis CLI configuration, ensuring account persistence and seamless operation. ```bash alias oasis='docker run --platform linux/amd64 --rm -v .:/src -v ~/.config/oasis:/root/.config/oasis -it ghcr.io/oasisprotocol/rofl-dev:main oasis' ``` ```bash alias oasis='docker run --platform linux/amd64 --rm -v .:/src -v "~/Library/Application Support/oasis/":/root/.config/oasis -it ghcr.io/oasisprotocol/rofl-dev:main oasis' ``` -------------------------------- ### Podman Compose: `depends_on` Directive Ignored (Problematic Example) Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/troubleshooting.mdx This YAML configuration illustrates another `podman-compose` bug where the `depends_on` directive is ignored. Services like `oracle` will start in parallel with `contracts`, even if `depends_on` is set to wait for `contracts` to complete successfully, leading to potential race conditions. ```YAML services: contracts: image: "ghcr.io/foundry-rs/foundry:latest" platform: linux/amd64 volumes: - ./contracts:/contracts entrypoint: /bin/sh -c 'cd contracts && forge create' oracle: platform: linux/amd64 entrypoint: /bin/sh -c 'python main.py' restart: on-failure depends_on: contracts: condition: service_completed_successfully ``` -------------------------------- ### Initialize Rust Project with Cargo Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/contract/hello-world.md Initializes a new Rust library project named 'hello-world' using Cargo, setting up the basic directory structure and boilerplate for a smart contract. ```bash cargo init --lib hello-world ``` -------------------------------- ### Build WebAssembly Smart Contract for Deployment Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/contract/hello-world.md Compiles the Rust smart contract into a WebAssembly binary (.wasm) optimized for release, targeting the wasm32-unknown-unknown architecture for deployment on chain. ```bash cargo build --target wasm32-unknown-unknown --release ``` -------------------------------- ### Run Unit Tests with Specific RUSTFLAGS Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/contract/hello-world.md Executes unit tests for the smart contract, enabling specific CPU target features (AES and SSSE3) required for local testing on Intel-compatible CPUs. ```sh RUSTFLAGS="-C target-feature=+aes,+ssse3" cargo test ``` -------------------------------- ### Rust Compilation Error: Missing Target Features Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/troubleshooting.mdx This snippet shows a common compilation error encountered when building SGX and TDX-raw ROFLs if the required `aes` and `ssse3` target features are not enabled in the Rust compiler flags. ```Rust error: The following target_feature flags must be set: +aes,+ssse3. --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deoxysii-0.2.4/src/lib.rs:26:1 | 26 | compile_error!("The following target_feature flags must be set: +aes,+ssse3."); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` -------------------------------- ### List ROFL Marketplace Offers Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/deployment.mdx This command lists available ROFL node offers from the default Oasis-managed ROFL provider, detailing specifications like TEE, memory, vCPUs, storage, and hourly pricing. ```shell oasis rofl deploy --show-offers ``` ```shell Using provider: oasis1qp2ens0hsp7gh23wajxa4hpetkdek3swyyulyrmz (oasis1qp2ens0hsp7gh23wajxa4hpetkdek3swyyulyrmz) Offers available from the selected provider: - playground_short [0000000000000001] TEE: tdx | Memory: 4096 MiB | vCPUs: 2 | Storage: 19.53 GiB Price: 5.0 TEST/hour ``` -------------------------------- ### Retrieve ROFL App Identifier via REST API Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/features/rest.md This API endpoint allows retrieval of the current ROFL app's unique identifier. It is a GET request to `/rofl/v1/app/id` and returns the app ID as a plain text string. ```APIDOC Endpoint: /rofl/v1/app/id (GET) Returns: ROFL app identifier as plain text ``` ```text rofl1qqn9xndja7e2pnxhttktmecvwzz0yqwxsquqyxdf ``` -------------------------------- ### Deploy ROFL App to Marketplace Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/deployment.mdx Executes the ROFL app deployment using the default provider and offer. This command automates copying the ROFL bundle to an OCI repository, paying for an offer, and storing the machine ID in a manifest file. ```shell oasis rofl deploy ``` ```shell Using provider: oasis1qp2ens0hsp7gh23wajxa4hpetkdek3swyyulyrmz (oasis1qp2ens0hsp7gh23wajxa4hpetkdek3swyyulyrmz) Pushing ROFL app to OCI repository 'rofl.sh/0ba0712d-114c-4e39-ac8e-b28edffcada8:1747909776'... No pre-existing machine configured, creating a new one... Taking offer: playground_short [0000000000000001] ``` -------------------------------- ### Initialize New ROFL App with Oasis CLI Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/app.mdx Uses the Oasis CLI to create a new ROFL app directory with boilerplate files, including a `compose.yaml` for container orchestration and a `rofl.yaml` manifest. This command sets up the basic structure for a TDX container-based ROFL app, initializing a Git repository and providing default policy settings. ```shell oasis rofl init myapp ``` -------------------------------- ### Build ROFL App Bundle Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/app.mdx These commands demonstrate how to build a ROFL app bundle, which packages the application for deployment and computes its enclave identity. Options are provided for native Linux environments or cross-platform Docker execution. ```shell oasis rofl build ``` ```shell docker run --platform linux/amd64 --volume .:/src -it ghcr.io/oasisprotocol/rofl-dev:main oasis rofl build ``` -------------------------------- ### Build Confidential Rust Smart Contract Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/contract/confidential-smart-contract.md Compiles the Rust-based confidential smart contract for the WebAssembly target, optimizing for release. This command prepares the contract for deployment on the Oasis network. ```shell cargo build --target wasm32-unknown-unknown --release ``` -------------------------------- ### Build Paratime for Intel SGX Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/runtime/reproducibility.md Navigates to the source directory and builds the paratime for Intel SGX targets in release mode. The compiled binaries are placed in `/src/target/x86_64-fortanix-unknown-sgx/release/`. ```bash cd /src cargo build --release --target x86_64-fortanix-unknown-sgx ``` -------------------------------- ### Create ROFL Application with Oasis CLI Source: https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/app.mdx This command initiates the creation of a new ROFL application on the Oasis network. It specifies `testnet` as the target network and `myaccount` as the initial administrator. Upon successful execution, the CLI automatically updates the local `rofl.yaml` manifest with the newly assigned unique application identifier. ```shell oasis rofl create --network testnet --account myaccount ```