================ CODE SNIPPETS ================ ### Get Started with iExec Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/index.md Provides a quick start guide to begin building on iExec. The 'Hello World' tutorial offers a hands-on introduction to the platform's capabilities. ```markdown layout: home hero: name: 'Build with iExec’s Privacy Stack ' tagline: 'Build decentralized applications that combine data governance, privacy, and monetization.' image: src: /iexec-illustration-large.webp alt: VitePress actions: - theme: brand text: Get Started link: /get-started/welcome - theme: alt text: Hello World Tutorial link: /get-started/helloWorld ``` -------------------------------- ### Install iExec SDK CLI Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/guides/build-iapp/advanced/quick-start.md Installs the iExec SDK command-line interface globally using npm. It also shows how to check the installed version and access help documentation. ```bash npm -g install iexec iexec --version iexec --help ``` -------------------------------- ### Instantiate Web3Telegram SDK in NodeJS Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/references/web3telegram/getting-started.md Instantiates the Web3Telegram SDK in a NodeJS environment using a private key to get a web3 provider. Ensure your project is compatible with ESM. ```ts import { IExecWeb3telegram, getWeb3Provider } from '@iexec/web3telegram'; // get web3 provider from a private key const web3Provider = getWeb3Provider('YOUR_PRIVATE_KEY'); // instantiate const web3telegram = new IExecWeb3telegram(web3Provider); ``` -------------------------------- ### Install Web3Telegram SDK via Package Managers Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/references/web3telegram/getting-started.md Installs the Web3Telegram SDK using popular package managers. This package is an ESM package and requires your project to also use ESM. ```sh npm install @iexec/web3telegram ``` ```sh yarn add @iexec/web3telegram ``` ```sh pnpm add @iexec/web3telegram ``` ```sh bun add @iexec/web3telegram ``` -------------------------------- ### Install @iexec/web3mail SDK Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/references/web3mail/getting-started.md Installs the iExec Web3Mail SDK using various package managers. This package is an ESM package, requiring your project to also use ESM. ```sh npm install @iexec/web3mail ``` ```sh yarn add @iexec/web3mail ``` ```sh pnpm add @iexec/web3mail ``` ```sh bun add @iexec/web3mail ``` -------------------------------- ### Instantiate Web3Telegram SDK in Browser Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/references/web3telegram/getting-started.md Instantiates the Web3Telegram SDK in a browser environment using the window.ethereum object. Ensure your project is compatible with ESM. ```ts declare global { interface Window { ethereum: any; } } // --- import { IExecWeb3telegram } from '@iexec/web3telegram'; const web3Provider = window.ethereum; // instantiate const web3telegram = new IExecWeb3telegram(web3Provider); ``` -------------------------------- ### Clone Repository and Setup Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/README.md Basic Git commands for forking the repository, cloning the fork, and installing dependencies to begin contributing. ```bash # Fork this repository # Clone your fork and install dependencies (`npm install`) git clone cd documentation npm install # Create a feature branch (`git checkout -b feature/your-feature-name`) git checkout -b feature/my-new-feature # Make your changes and test locally (`npm run dev`) # Submit a pull request ``` -------------------------------- ### Combined Component Usage Example Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/CONTRIBUTING.md An example showcasing the combined usage of `Banner`, VitePress native containers (`info`), `CardWithBorder`, `CardWithoutBorder`, and `tip` containers to structure documentation content effectively. ```markdown ## Installation Guide ::: info Prerequisites Make sure you have Node.js installed before continuing. ::: ### Step 1: Installation ```bash npm install ``` ### Step 2: Configuration Create your .env file based on .env.example. ::: tip Success! Your installation is now complete! ::: ``` -------------------------------- ### Instantiate SDK with Umbrella Module (Browser) Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/references/dataProtector/getting-started.md Instantiates the iExec DataProtector SDK using the umbrella module in a browser environment. This provides access to both core and sharing functionalities. It requires the `window.ethereum` object. ```typescript declare global { interface Window { ethereum: any; } } // ---cut--- import { IExecDataProtector } from '@iexec/dataprotector'; const web3Provider = window.ethereum; // Instantiate using the umbrella module for full functionality const dataProtector = new IExecDataProtector(web3Provider); const dataProtectorCore = dataProtector.core; const dataProtectorSharing = dataProtector.sharing; ``` -------------------------------- ### Instantiate IExecWeb3mail with a Web3 Provider Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/references/web3mail/getting-started.md Demonstrates how to instantiate the IExecWeb3mail SDK using a Web3 provider. Supports both browser environments (using window.ethereum) and NodeJS environments (using a private key). ```ts declare global { interface Window { ethereum: any; } } // --- import { IExecWeb3mail } from '@iexec/web3mail'; const web3Provider = window.ethereum; // instantiate const web3mail = new IExecWeb3mail(web3Provider); ``` ```ts import { IExecWeb3mail, getWeb3Provider } from '@iexec/web3mail'; // get web3 provider from a private key const web3Provider = getWeb3Provider('YOUR_PRIVATE_KEY'); // instantiate const web3mail = new IExecWeb3mail(web3Provider); ``` -------------------------------- ### Verify iExec CLI Installation Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/get-started/helloWorld/3-buildIApp.md Check the installed version of the iExec CLI and view the available commands. This helps ensure the 'iapp' package was installed correctly and is ready for use. ```shell #checking the version iapp --version #checking the available commands iapp --help ``` -------------------------------- ### Instantiate Core Module Only (Browser) Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/references/dataProtector/getting-started.md Instantiates only the Core module of the iExec DataProtector SDK in a browser environment, for projects focusing solely on core data protection functions. It requires the `window.ethereum` object. ```typescript declare global { interface Window { ethereum: any; } } // ---cut--- import { IExecDataProtectorCore } from '@iexec/dataprotector'; const web3Provider = window.ethereum; // Instantiate only the Core module const dataProtectorCore = new IExecDataProtectorCore(web3Provider); ``` -------------------------------- ### Instantiate Sharing Module Only (Browser) Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/references/dataProtector/getting-started.md Instantiates only the Sharing module of the iExec DataProtector SDK in a browser environment, for projects that need access management functions specifically. It requires the `window.ethereum` object. ```typescript declare global { interface Window { ethereum: any; } } // ---cut--- import { IExecDataProtectorSharing } from '@iexec/dataprotector'; const web3Provider = window.ethereum; // Instantiate only the Sharing module const dataProtectorSharing = new IExecDataProtectorSharing(web3Provider); ``` -------------------------------- ### Generate iApp CLI Completion Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/references/iapp-generator/getting-started.md Generates shell auto-completion scripts for the `iapp` command-line interface. This enhances user experience by providing command suggestions and reducing typing errors. ```bash iapp completion ``` -------------------------------- ### Instantiate SDK with Umbrella Module (NodeJS) Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/references/dataProtector/getting-started.md Instantiates the iExec DataProtector SDK using the umbrella module in a NodeJS environment. This provides access to both core and sharing functionalities. It requires a Web3 provider, obtained here using a private key. ```typescript import { IExecDataProtector, getWeb3Provider } from '@iexec/dataprotector'; // Get Web3 provider from a private key const web3Provider = getWeb3Provider('YOUR_PRIVATE_KEY'); // Instantiate using the umbrella module for full functionality const dataProtector = new IExecDataProtector(web3Provider); const dataProtectorCore = dataProtector.core; // access to core methods const dataProtectorSharing = dataProtector.sharing; // access to methods ``` -------------------------------- ### Start Development Server Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/README.md Command to start the local development server for the project. ```bash npm run dev ``` -------------------------------- ### Instantiate Sharing Module Only (NodeJS) Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/references/dataProtector/getting-started.md Instantiates only the Sharing module of the iExec DataProtector SDK in a NodeJS environment, for projects that need access management functions specifically. It requires a Web3 provider, obtained here using a private key. ```typescript import { IExecDataProtectorSharing, getWeb3Provider, } from '@iexec/dataprotector'; // Get Web3 provider from a private key const web3Provider = getWeb3Provider('YOUR_PRIVATE_KEY'); // Instantiate only the Sharing module const dataProtectorSharing = new IExecDataProtectorSharing(web3Provider); ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/README.md Command to install all necessary project dependencies using npm. ```bash npm install ``` -------------------------------- ### Instantiate Singleton Modules Without Provider Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/references/dataProtector/getting-started.md Instantiate the iExec DataProtector SDK's core and sharing modules individually for read-only operations. This method is suitable when only specific read functions are needed and no Web3 provider is available. ```typescript import { IExecDataProtectorSharing, IExecDataProtectorCore, } from '@iexec/dataprotector'; // Instantiate only the Core module for read-only core methods const dataProtectorCore = new IExecDataProtectorCore(); // Instantiate only the Sharing module for read-only sharing methods const dataProtectorSharing = new IExecDataProtectorSharing(); ``` -------------------------------- ### Instantiate Core Module Only (NodeJS) Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/references/dataProtector/getting-started.md Instantiates only the Core module of the iExec DataProtector SDK in a NodeJS environment, for projects focusing solely on core data protection functions. It requires a Web3 provider, obtained here using a private key. ```typescript import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector'; // Get Web3 provider from a private key const web3Provider = getWeb3Provider('YOUR_PRIVATE_KEY'); // Instantiate only the Core module const dataProtectorCore = new IExecDataProtectorCore(web3Provider); ``` -------------------------------- ### Vue.js Setup for iExec Documentation Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/get-started/helloWorld/3-buildIApp.md This script setup block configures a Vue.js application for iExec documentation. It imports necessary components like InfoIcon, CLIDemo, Banner, and Container, and sets up stores and computed properties for managing chain selection and deployment steps. ```vue ``` -------------------------------- ### Vue Setup Imports Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/get-started/helloWorld.md This script block imports necessary components from '@iconify/vue' and local paths for building the iExec DApp tutorial interface. It sets up the foundational elements for the user interface. ```javascript import { Icon } from '@iconify/vue'; import InfoIcon from '@/components/InfoIcon.vue' import Banner from '../components/Banner.vue' import Container from '../components/Container.vue' import CardWithBorder from '../components/CardWithBorder.vue' import CardGrid from '../components/CardGrid.vue' import Badge from '../components/Badge.vue' import TutorialCard from '../components/TutorialCard.vue' ``` -------------------------------- ### Instantiate Umbrella Module Without Provider Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/references/dataProtector/getting-started.md Instantiate the iExec DataProtector SDK using the umbrella module for all read-only functions. This approach provides access to both core and sharing methods through a single instance when no Web3 provider is available. ```typescript import { IExecDataProtector } from '@iexec/dataprotector'; // Instantiate using the umbrella module for read-only functions const dataProtector = new IExecDataProtector(); // Access to read-only core methods const dataProtectorCore = dataProtector.core; // Access to read-only sharing methods const dataProtectorSharing = dataProtector.sharing; ``` -------------------------------- ### Install iExec CLI (npm, yarn, pnpm, bun) Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/get-started/helloWorld/3-buildIApp.md Install the iExec 'iapp' package globally using different package managers. This command-line tool is essential for building, testing, and deploying iExec applications. ```npm npm i -g @iexec/iapp ``` ```yarn yarn global add @iexec/iapp ``` ```pnpm pnpm add -g @iexec/iapp ``` ```bun bun add -g @iexec/iapp ``` -------------------------------- ### iExec Features Overview Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/index.md Outlines the core features of the iExec platform, including a quick start guide, data protection with DataProtector, iApp generation, and decentralized task execution using iExec Workers. ```markdown features: - icon: title: Quick Start details: Jump in and start building on iExec in minutes. link: /get-started/helloWorld - icon: title: Protect & Manage Data details: DataProtector encrypts and allows you to control access to your sensitive data. Ready-to-use privacy toolkit for developers. link: /guides/manage-data/manage-access - icon: title: Build iApp details: iApp Generator builds confidential applications that run in secure TEEs. Custom confidentiality integration without managing infrastructure. link: /guides/build-iapp/build-&-test - icon: vale-report.txt 2>&1 ``` -------------------------------- ### Test iApp Locally Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/references/iapp-generator/building-your-iexec-app.md Provides examples of testing an iApp locally using the 'iapp test' command. It shows how to pass arguments, specify protected data, provide input files via URLs, and set requester secrets. ```bash iapp test --args "input_param=value" --inputFile "http://example.com/data.csv" --requesterSecret "MY_SECRET=12345" ``` -------------------------------- ### Install @iexec/dataprotector-deserializer with Package Managers Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/references/iapp-generator/deserializer.md This snippet shows how to install the @iexec/dataprotector-deserializer package using various package managers like npm, yarn, pnpm, and bun. ```sh npm install @iexec/dataprotector-deserializer ``` ```sh yarn add @iexec/dataprotector-deserializer ``` ```sh pnpm add @iexec/dataprotector-deserializer ``` ```sh bun add @iexec/dataprotector-deserializer ``` -------------------------------- ### Install iExec SDK (pnpm) Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/guides/use-iapp/run-iapp-without-ProtectedData.md Installs the iExec SDK using pnpm, another package manager for Node.js. This ensures the SDK is available for use. ```sh pnpm add iexec ``` -------------------------------- ### Initialize iApp Project with CLI Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/get-started/helloWorld/3-buildIApp.md Bootstrap a new iApp project by creating a directory, navigating into it, and running the `iapp init` command. This sets up the project structure and prompts for project name, programming language (JavaScript/Python), and project type (Hello World/advanced). ```sh mkdir iexec-test cd iexec-test iapp init ``` -------------------------------- ### Install iExec SDK (yarn) Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/guides/use-iapp/run-iapp-without-ProtectedData.md Installs the iExec SDK using yarn, an alternative package manager for Node.js. This step is necessary before utilizing the SDK. ```sh yarn add iexec ``` -------------------------------- ### Install iExec SDK (npm) Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/guides/use-iapp/run-iapp-without-ProtectedData.md Installs the iExec SDK using npm, a package manager for Node.js. This is a prerequisite for using the SDK's functionalities. ```sh npm install iexec ``` -------------------------------- ### Vue Component Setup for Web3Telegram Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/references/web3telegram.md This script setup block is used in a Vue.js component to import the Icon component from '@iconify/vue'. This is likely used for displaying icons within the Web3Telegram interface, such as the demo link. ```javascript import { Icon } from '@iconify/vue'; ``` -------------------------------- ### Commit Changes to Git Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/CONTRIBUTING.md Stages all changes and commits them with a descriptive message. Requires Git. ```bash git add . git commit -m "Add: description of your changes" ``` -------------------------------- ### App Order Configuration in iexec.json Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/guides/build-iapp/manage-access.md An example of how the app order parameters are structured within the `iexec.json` configuration file. ```json { "apporder": { "app": "0xYourAppAddress", "appprice": "1000000000", "volume": "100", "tag": "0x0000000000000000000000000000000000000000000000000000000000000003", "datasetrestrict": "0x0000000000000000000000000000000000000000", "workerpoolrestrict": "0x0000000000000000000000000000000000000000", "requesterrestrict": "0x0000000000000000000000000000000000000000" } } ``` -------------------------------- ### Cloning AI Frameworks Hello World Repository Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/protocol/ai.md Clones the iExec AI Frameworks Hello World repository from GitHub. This is the initial step to access the example Docker configurations for various AI frameworks. ```bash git clone https://github.com/iExecBlockchainComputing/ai-frameworks-hello-world.git cd ai-frameworks-hello-world ``` -------------------------------- ### Initialize iExec Project and Set Up Directory Structure - Bash Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/guides/build-iapp/advanced/build-your-first-sgx-iapp.md Initializes a new iExec project for a Scone-based application and sets up the necessary directory structure and files. This includes creating a project directory, a source directory, and essential configuration files like Dockerfile and sconify.sh. ```bash cd ~/iexec-projects mkdir tee-hello-world-app && cd tee-hello-world-app iexec init --skip-wallet mkdir src touch Dockerfile touch sconify.sh chmod +x sconify.sh ``` -------------------------------- ### Docker Build and Run for TensorFlow Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/protocol/ai.md Builds a Docker image for the TensorFlow example and runs it. This demonstrates how to containerize and execute a TensorFlow application within the iExec environment. ```bash cd tensorflow docker build -t hello-tensorflow . docker run --rm hello-tensorflow ``` -------------------------------- ### Vue.js Script Setup for iExec Project Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/get-started/tooling-and-explorers/bridge.md This snippet demonstrates the setup of a Vue.js component, importing necessary UI components like ImageViewer, CardGrid, and ProjectCard. It also imports various assets including logos and images used within the iExec project, such as the iExec logo, Arbitrum logo, bridge images, and the Halborn logo. ```javascript ``` -------------------------------- ### Docker Build and Run for PyTorch Source: https://github.com/iexecblockchaincomputing/documentation/blob/main/src/protocol/ai.md Builds a Docker image for the PyTorch example and runs it. This showcases the process of containerizing and executing a PyTorch application for iExec. ```bash cd ../pytorch docker build -t hello-pytorch . docker run --rm hello-pytorch ```