======================== CODE SNIPPETS ======================== TITLE: Installing @iexec/dataprotector SDK DESCRIPTION: This section provides commands to install the @iexec/dataprotector SDK using various package managers. Ensure you have Node.js v18+ and NPM installed. The package is an ESM package, requiring your project to also use ESM. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/dataProtector/getting-started.md#_snippet_0 LANGUAGE: sh CODE: ``` npm install @iexec/dataprotector ``` LANGUAGE: sh CODE: ``` yarn add @iexec/dataprotector ``` LANGUAGE: sh CODE: ``` pnpm add @iexec/dataprotector ``` LANGUAGE: sh CODE: ``` bun add @iexec/dataprotector ``` ---------------------------------------- TITLE: Installing Web3Telegram SDK DESCRIPTION: These commands demonstrate how to install the `@iexec/web3telegram` SDK using different Node.js package managers. The package is an ESM module, requiring the consuming project to also use ESM. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/web3telegram/getting-started.md#_snippet_0 LANGUAGE: sh CODE: ``` npm install @iexec/web3telegram ``` LANGUAGE: sh CODE: ``` yarn add @iexec/web3telegram ``` LANGUAGE: sh CODE: ``` pnpm add @iexec/web3telegram ``` LANGUAGE: sh CODE: ``` bun add @iexec/web3telegram ``` ---------------------------------------- TITLE: Instantiating IExecWeb3telegram SDK DESCRIPTION: These snippets show how to instantiate the `IExecWeb3telegram` SDK. The browser example uses `window.ethereum` as the Web3 provider, while the Node.js example obtains a provider from a private key using `getWeb3Provider`. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/web3telegram/getting-started.md#_snippet_1 LANGUAGE: ts CODE: ``` declare global { interface Window { ethereum: any; } } // ---cut--- import { IExecWeb3telegram } from '@iexec/web3telegram'; const web3Provider = window.ethereum; // instantiate const web3telegram = new IExecWeb3telegram(web3Provider); ``` LANGUAGE: ts CODE: ``` 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); ``` ---------------------------------------- TITLE: Installing iExec Web3Mail SDK DESCRIPTION: This section provides commands to install the iExec Web3Mail SDK using various package managers. It's a prerequisite for using the SDK and enables blockchain-based email communication functionalities. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/web3mail/getting-started.md#_snippet_0 LANGUAGE: sh CODE: ``` npm install @iexec/web3mail ``` LANGUAGE: sh CODE: ``` yarn add @iexec/web3mail ``` LANGUAGE: sh CODE: ``` pnpm add @iexec/web3mail ``` LANGUAGE: sh CODE: ``` bun add @iexec/web3mail ``` ---------------------------------------- TITLE: Installing iApp Generator CLI DESCRIPTION: These commands demonstrate how to install the iExec iApp Generator command-line interface globally using various Node.js package managers: npm, yarn, pnpm, and bun. Global installation makes the `iapp` command available system-wide for easy access. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/iapp-generator/getting-started.md#_snippet_1 LANGUAGE: npm CODE: ``` npm install -g @iexec/iapp ``` LANGUAGE: yarn CODE: ``` yarn global add @iexec/iapp ``` LANGUAGE: pnpm CODE: ``` pnpm add -g @iexec/iapp ``` LANGUAGE: bun CODE: ``` bun add -g @iexec/iapp ``` ---------------------------------------- TITLE: iApp Project Initialization Prompts (txt) DESCRIPTION: Illustrates the interactive prompts displayed during the `iapp init` command, guiding the user to select project name, language, and project type for a 'Hello World' quick start. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/overview/helloWorld/3-buildIApp.md#_snippet_3 LANGUAGE: txt CODE: ``` ___ _ ____ ____ |_ _| / \ | _ \| _ \ | | / _ \ | |_) | |_) | | | / ___ \| __/| __/ |___/_/ \_\_| |_| ✔ What's your project name? (A folder with this name will be created) … hello-world ✔ Which language do you want to use? › JavaScript ? What kind of project do you want to init? › - Use arrow-keys. Return to submit. ❯ Hello World - iapp quick start advanced ``` ---------------------------------------- TITLE: iApp Project Setup Completion Confirmation (txt) DESCRIPTION: Confirms the successful setup of the iApp project with the chosen language and the generation of an Ethereum wallet used for on-chain iApp creation signing. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/overview/helloWorld/3-buildIApp.md#_snippet_7 LANGUAGE: txt CODE: ``` ✔ [Chosen language] app setup complete. ✔ Generated ethereum wallet (0xD4A28d.........................) ``` ---------------------------------------- TITLE: Verifying Docker Buildx Compatibility (Bash) DESCRIPTION: This command checks if your Docker Buildx installation supports the `linux/amd64` platform, which is crucial for compatibility. If this platform is not listed in the output, an update to your Docker installation is required to proceed. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/iapp-generator/getting-started.md#_snippet_0 LANGUAGE: bash CODE: ``` docker buildx inspect --bootstrap | grep -i platforms ``` ---------------------------------------- TITLE: Instantiating iExec Web3Mail SDK with Web3 Provider (Browser) DESCRIPTION: This snippet demonstrates how to instantiate the iExec Web3Mail SDK in a browser environment using an existing Web3 provider, typically `window.ethereum`. This setup is required for functionalities that interact with the blockchain, such as sending or receiving emails. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/web3mail/getting-started.md#_snippet_1 LANGUAGE: typescript CODE: ``` declare global { interface Window { ethereum: any; } } // ---cut--- import { IExecWeb3mail } from '@iexec/web3mail'; const web3Provider = window.ethereum; // instantiate const web3mail = new IExecWeb3mail(web3Provider); ``` ---------------------------------------- TITLE: Instantiating @iexec/dataprotector SDK (Umbrella Module) in TypeScript DESCRIPTION: This snippet demonstrates how to instantiate the full @iexec/dataprotector SDK, including both core and sharing functionalities. It shows examples for both browser environments (using `window.ethereum`) and Node.js environments (using `getWeb3Provider` with a private key). SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/dataProtector/getting-started.md#_snippet_1 LANGUAGE: ts CODE: ``` 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; ``` LANGUAGE: ts CODE: ``` 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 ``` ---------------------------------------- TITLE: Instantiating @iexec/dataprotector Core Module in TypeScript DESCRIPTION: This snippet illustrates how to instantiate only the `core` module of the @iexec/dataprotector SDK, suitable for projects focused solely on core data protection functions. Examples are provided for browser and Node.js environments. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/dataProtector/getting-started.md#_snippet_2 LANGUAGE: ts CODE: ``` 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); ``` LANGUAGE: ts CODE: ``` 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); ``` ---------------------------------------- TITLE: Instantiating @iexec/dataprotector Sharing Module in TypeScript DESCRIPTION: This snippet shows how to instantiate only the `sharing` module of the @iexec/dataprotector SDK, intended for projects requiring specific access management functions. It includes examples for both browser and Node.js environments. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/dataProtector/getting-started.md#_snippet_3 LANGUAGE: ts CODE: ``` 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); ``` LANGUAGE: ts CODE: ``` 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); ``` ---------------------------------------- TITLE: Verifying iApp CLI Installation (sh) DESCRIPTION: Checks the installed version of the iApp CLI and displays available commands, confirming a successful installation. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/overview/helloWorld/3-buildIApp.md#_snippet_1 LANGUAGE: sh CODE: ``` iapp --version iapp --help ``` ---------------------------------------- TITLE: Installing iApp CLI Tool (npm) DESCRIPTION: Installs the iExec iApp command-line interface globally using npm, making it available system-wide for iApp development. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/overview/helloWorld/3-buildIApp.md#_snippet_0 LANGUAGE: sh CODE: ``` npm i -g @iexec/iapp ``` ---------------------------------------- TITLE: Instantiating IExecOracleFactory SDK DESCRIPTION: These examples show how to import and initialize the `IExecOracleFactory` SDK. The browser example uses `window.ethereum` as a Web3 provider, while the Node.js example derives a signer from a private key to instantiate the factory, requiring a private key from environment variables. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/oracle-factory/getting-started.md#_snippet_1 LANGUAGE: ts CODE: ``` import { IExecOracleFactory } from '@iexec/iexec-oracle-factory-wrapper'; const web3Provider = window.ethereum; // instantiate const factory = new IExecOracleFactory(web3Provider); ``` LANGUAGE: ts CODE: ``` import { IExecOracleFactory, utils } from '@iexec/iexec-oracle-factory-wrapper'; const { PRIVATE_KEY } = process.env; // get web3 provider from a private key const signer = utils.getSignerFromPrivateKey( 'https://bellecour.iex.ec', 'your-private-key' ); const factory = new IExecOracleFactory(signer); ``` ---------------------------------------- TITLE: Generating iApp CLI Auto-completion Script (Bash) DESCRIPTION: After installing the iApp CLI, this command generates the necessary script for shell auto-completion. Users should follow the on-screen instructions provided by the command to integrate it into their specific shell environment (e.g., Bash, Zsh) for enhanced usability. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/iapp-generator/getting-started.md#_snippet_2 LANGUAGE: bash CODE: ``` iapp completion ``` ---------------------------------------- TITLE: Running the iExec Tools Application (NPM) DESCRIPTION: These `npm` commands are used to initialize and run the iExec tools application. `npm install` fetches all project dependencies, `npm run tailwind:watch` starts a process to watch for Tailwind CSS changes (which should run continuously), and `npm run dev` launches the development server for the application. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/README.md#_snippet_1 LANGUAGE: sh CODE: ``` npm install npm run tailwind:watch (keep it running) npm run dev ``` ---------------------------------------- TITLE: Instantiating iExec DataProtector SDK Read-Only with Umbrella Module (TypeScript) DESCRIPTION: This snippet illustrates how to instantiate the iExec DataProtector SDK using its main umbrella module for read-only functions. This single instantiation provides access to all underlying read-only core and sharing methods, simplifying the setup for applications that don't require a Web3 provider. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/dataProtector/getting-started.md#_snippet_5 LANGUAGE: TypeScript CODE: ``` 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; ``` ---------------------------------------- TITLE: Instantiating iExec Web3Mail SDK without Web3 Provider (Node.js) DESCRIPTION: This snippet demonstrates how to instantiate the iExec Web3Mail SDK in a Node.js environment without a Web3 provider. This setup is ideal for applications that only need to perform read operations and do not require blockchain write access. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/web3mail/getting-started.md#_snippet_4 LANGUAGE: typescript CODE: ``` import { IExecWeb3mail, getWeb3Provider } from '@iexec/web3mail'; // instantiate const web3mail = new IExecWeb3mail(); ``` ---------------------------------------- TITLE: Instantiating iExec DataProtector SDK Read-Only with Singleton Modules (TypeScript) DESCRIPTION: This snippet demonstrates how to instantiate specific read-only modules of the iExec DataProtector SDK (Core and Sharing) independently. This approach is suitable for applications that only require read functionalities and do not need a Web3 provider, allowing for granular control over module instantiation. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/dataProtector/getting-started.md#_snippet_4 LANGUAGE: TypeScript CODE: ``` 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(); ``` ---------------------------------------- TITLE: Instantiating iExec Web3Mail SDK with Web3 Provider (Node.js) DESCRIPTION: This snippet shows how to instantiate the iExec Web3Mail SDK in a Node.js environment. It uses `getWeb3Provider` to derive a Web3 provider from a private key, which is essential for blockchain interactions like sending messages. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/web3mail/getting-started.md#_snippet_2 LANGUAGE: typescript CODE: ``` 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); ``` ---------------------------------------- TITLE: Instantiating iExec Web3Mail SDK without Web3 Provider (Browser) DESCRIPTION: This snippet illustrates how to instantiate the iExec Web3Mail SDK in a browser environment without a Web3 provider. This configuration is suitable for projects that only require read-only functionalities from the SDK, such as fetching public data. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/web3mail/getting-started.md#_snippet_3 LANGUAGE: typescript CODE: ``` import { IExecWeb3mail } from '@iexec/web3mail'; // instantiate const web3mail = new IExecWeb3mail(); ``` ---------------------------------------- TITLE: Installing IExec Oracle Factory SDK DESCRIPTION: These snippets demonstrate how to install the `@iexec/iexec-oracle-factory-wrapper` package using various Node.js package managers. It's crucial to note that this package is an ESM package, requiring the consuming project to also use ESM. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/oracle-factory/getting-started.md#_snippet_0 LANGUAGE: sh CODE: ``` npm install @iexec/iexec-oracle-factory-wrapper ``` LANGUAGE: sh CODE: ``` yarn add @iexec/iexec-oracle-factory-wrapper ``` LANGUAGE: sh CODE: ``` pnpm add @iexec/iexec-oracle-factory-wrapper ``` LANGUAGE: sh CODE: ``` bun add @iexec/iexec-oracle-factory-wrapper ``` ---------------------------------------- TITLE: Installing DataProtector Developer Tool - npm DESCRIPTION: This command installs the `@iexec/dataprotector` package using npm, which is the first step to integrate the iExec DataProtector developer tool into your project. It provides all necessary functionalities for decentralized confidential computing. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/overview/helloWorld/2-protectData.md#_snippet_1 LANGUAGE: sh CODE: ``` npm install @iexec/dataprotector ``` ---------------------------------------- TITLE: Vue.js Component Setup with Icon Import DESCRIPTION: This snippet illustrates the basic setup for a Vue.js component using ``` ---------------------------------------- TITLE: Installing DataProtector Deserializer Package DESCRIPTION: These commands install the `@iexec/dataprotector-deserializer` package using different Node.js package managers. This package is essential for deserializing protected data in iExec TEE Dapps. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/dataProtector/advanced/iApp/deserializer.md#_snippet_0 LANGUAGE: Shell CODE: ``` npm install @iexec/dataprotector-deserializer ``` LANGUAGE: Shell CODE: ``` yarn add @iexec/dataprotector-deserializer ``` LANGUAGE: Shell CODE: ``` pnpm add @iexec/dataprotector-deserializer ``` LANGUAGE: Shell CODE: ``` bun add @iexec/dataprotector-deserializer ``` ---------------------------------------- TITLE: Importing CouponCode Component in Vue.js Setup Script DESCRIPTION: This snippet demonstrates how to import a Vue component named `CouponCode` from a relative path within a Vue 3 ` ``` ---------------------------------------- TITLE: Initializing iExec iApp Project (Shell) DESCRIPTION: This command initiates the iApp Generator CLI, guiding the user through a step-by-step process to set up a new iApp project. It prompts for essential details such as the project name, preferred programming language (e.g., JavaScript, Python), and the desired project mode (Basic for 'Hello-World' or Advanced for full debug capabilities). SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/iapp-generator/building-your-iexec-app.md#_snippet_0 LANGUAGE: sh CODE: ``` iapp init ``` ---------------------------------------- TITLE: Instantiating iExec SDK with Injected Provider (JavaScript) DESCRIPTION: This snippet shows how to initialize the iExec SDK by importing `IExec` and passing `window.ethereum` as the `ethProvider`. This setup allows the SDK to interact with the iExec platform using an injected Web3 provider (e.g., MetaMask), enabling operations like managing RLC tokens and interacting with the iExec sidechain. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/overview/how-to-pay-for-web3mail.md#_snippet_1 LANGUAGE: JavaScript CODE: ``` import { IExec } from 'iexec'; // connect injected provider const iexec = new IExec({ ethProvider: window.ethereum }); ``` ---------------------------------------- TITLE: Specifying addOnlyAppWhitelist Parameter in TypeScript DESCRIPTION: This example highlights the `addOnlyAppWhitelist` parameter, which is the address of the whitelist where the dApp will be added. It demonstrates its usage within the `addAppToAddOnlyAppWhitelist` method call. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/dataProtector/advanced/apps-whitelist/addAppToAddOnlyAppWhitelist.md#_snippet_2 LANGUAGE: TypeScript CODE: ``` import { IExecDataProtectorSharing, getWeb3Provider, } from '@iexec/dataprotector'; const web3Provider = getWeb3Provider('PRIVATE_KEY'); const dataProtectorSharing = new IExecDataProtectorSharing(web3Provider); const isAddedToAddAppToAddOnlyAppWhitelist = await dataProtectorSharing.addAppToAddOnlyAppWhitelist({ addOnlyAppWhitelist: '0x123abc...', app: '0x127ahs...', }); ``` ---------------------------------------- TITLE: Setting HTTP Method for Oracle API Request in TypeScript DESCRIPTION: This snippet demonstrates setting the `method` parameter for the API request. The `method` specifies the HTTP verb (e.g., 'GET', 'POST') to be used when the oracle fetches data from the specified URL. Here, it's set to 'GET'. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/oracle-factory/methods/createOracle.md#_snippet_2 LANGUAGE: TypeScript CODE: ``` import { IExecOracleFactory } from '@iexec/iexec-oracle-factory-wrapper'; const web3Provider = {} as any; const factory = new IExecOracleFactory(web3Provider); const createOracleObservable = factory.createOracle({ url: 'https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd', method: 'GET', headers: { authorization: '%API_KEY%', }, dataType: 'number', JSONPath: '$.ethereum.usd', apiKey: 'MY_TEST_API_KEY', }); ``` ---------------------------------------- TITLE: Specifying addOnlyAppWhitelist Parameter DESCRIPTION: This example illustrates the `addOnlyAppWhitelist` parameter, an `AddressOrENS` representing the smart contract address of the whitelist containing applications permitted to consume the protected data. A common value is `0x256bcd881c33bdf9df952f2a0148f27d439f2e64`. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/dataProtector/dataProtectorSharing/collection/addToCollection.md#_snippet_4 LANGUAGE: TypeScript CODE: ``` import { IExecDataProtectorSharing, getWeb3Provider, } from '@iexec/dataprotector'; const web3Provider = getWeb3Provider('PRIVATE_KEY'); const dataProtectorSharing = new IExecDataProtectorSharing(web3Provider); const { txHash } = await dataProtectorSharing.addToCollection({ collectionId: 12, protectedData: '0x123abc...', addOnlyAppWhitelist: '0xba46d6...', }); ``` ---------------------------------------- TITLE: Prompt for iApp Project Type Selection (txt) DESCRIPTION: Presents the interactive prompt for choosing the iApp project template, recommending 'Hello World' for quick discovery or 'advanced' for experienced users. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/overview/helloWorld/3-buildIApp.md#_snippet_6 LANGUAGE: txt CODE: ``` ? What kind of project do you want to init? › - Use arrow-keys. Return to submit. ❯ Hello World - iapp quick start advanced ``` ---------------------------------------- TITLE: Specifying API URL for Oracle Creation in TypeScript DESCRIPTION: This snippet illustrates how to define the `url` parameter when creating an oracle. The `url` specifies the API endpoint from which the oracle will fetch data. In this example, it points to the CoinGecko API for Ethereum price data. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/oracle-factory/methods/createOracle.md#_snippet_1 LANGUAGE: TypeScript CODE: ``` import { IExecOracleFactory } from '@iexec/iexec-oracle-factory-wrapper'; const web3Provider = {} as any; const factory = new IExecOracleFactory(web3Provider); const createOracleObservable = factory.createOracle({ url: 'https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd', method: 'GET', headers: { authorization: '%API_KEY%', }, dataType: 'number', JSONPath: '$.ethereum.usd', apiKey: 'MY_TEST_API_KEY', }); ``` ---------------------------------------- TITLE: Retrieving Rentals by Renter Address in iExec (TypeScript) DESCRIPTION: This example illustrates how to use the `getRentals` method with the `renterAddress` parameter to retrieve all active rentals associated with a specific user's address. The `renterAddress` parameter is of type `AddressOrENS`. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/dataProtector/dataProtectorSharing/read/getRentals.md#_snippet_2 LANGUAGE: TypeScript CODE: ``` import { IExecDataProtectorSharing, getWeb3Provider, } from '@iexec/dataprotector'; const web3Provider = getWeb3Provider('PRIVATE_KEY'); const dataProtectorSharing = new IExecDataProtectorSharing(web3Provider); const userActiveRentals = await dataProtectorSharing.getRentals({ renterAddress: '0x246bdf...', }); ``` ---------------------------------------- TITLE: Including Past Rentals in iExec (TypeScript) DESCRIPTION: This example shows how to use the `includePastRentals` parameter with the `getRentals` method to retrieve both active and past rentals for a specified renter address. By default, this parameter is `false`, returning only active rentals. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/dataProtector/dataProtectorSharing/read/getRentals.md#_snippet_4 LANGUAGE: TypeScript CODE: ``` import { IExecDataProtectorSharing, getWeb3Provider, } from '@iexec/dataprotector'; const web3Provider = getWeb3Provider('PRIVATE_KEY'); const dataProtectorSharing = new IExecDataProtectorSharing(web3Provider); const userRentals = await dataProtectorSharing.getRentals({ renterAddress: '0x246bdf...', includePastRentals: true, }); ``` ---------------------------------------- TITLE: Specifying price Parameter for Protected Data Sale (TypeScript) DESCRIPTION: This example focuses on the `price` parameter, which defines the asking price in nano RLC (nRLC) for the protected data. This is a required numerical parameter for the `setProtectedDataForSale` method, determining the cost for buyers. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/dataProtector/dataProtectorSharing/selling/setProtectedDataForSale.md#_snippet_3 LANGUAGE: TypeScript CODE: ``` import { IExecDataProtectorSharing, getWeb3Provider, } from '@iexec/dataprotector'; const web3Provider = getWeb3Provider('PRIVATE_KEY'); const dataProtectorSharing = new IExecDataProtectorSharing(web3Provider); const setForSaleResult = await dataProtectorSharing.setProtectedDataForSale({ protectedData: '0x123abc...', price: 2, // 2 nRLC }); ``` ---------------------------------------- TITLE: Filtering Protected Data by Rentable Status (TypeScript) DESCRIPTION: This example shows how to retrieve protected data that is marked as rentable. The `isRentable` parameter, a `boolean`, filters results to include only data available for rent. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/dataProtector/dataProtectorSharing/read/getProtectedDataInCollections.md#_snippet_6 LANGUAGE: TypeScript CODE: ``` import { IExecDataProtectorSharing, getWeb3Provider, } from '@iexec/dataprotector'; const web3Provider = getWeb3Provider('PRIVATE_KEY'); const dataProtectorSharing = new IExecDataProtectorSharing(web3Provider); const rentableProtectedData = await dataProtectorSharing.getProtectedDataInCollections({ isRentable: true, // [!code focus] }); ``` ---------------------------------------- TITLE: Initializing iApp Project Directory (sh) DESCRIPTION: Creates a new directory and initializes an iApp project within it using the `iapp init` command, setting up the basic project structure. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/overview/helloWorld/3-buildIApp.md#_snippet_2 LANGUAGE: sh CODE: ``` mkdir iexec-test cd iexec-test iapp init ``` ---------------------------------------- TITLE: Deserializing Values with IExecDataProtectorDeserializer in Node.js DESCRIPTION: This snippet demonstrates how to initialize the `IExecDataProtectorDeserializer` and use its `getValue` method to deserialize values of different types (boolean and string) from a specified path within protected data. It shows the basic setup and two calls to `getValue`. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/dataProtector/advanced/iApp/deserializer/getValue.md#_snippet_0 LANGUAGE: TypeScript CODE: ``` import { IExecDataProtectorDeserializer } from '@iexec/dataprotector-deserializer'; const deserializer = new IExecDataProtectorDeserializer(); const value1 = await deserializer.getValue('path.to.value1', 'bool'); const value2 = await deserializer.getValue('path.to.value2', 'string'); ``` ---------------------------------------- TITLE: Configuring IPFS Gateway URL for Downloads - IExecDataProtector - TypeScript DESCRIPTION: This example shows how to configure a custom `ipfsGateway` URL for content downloads with `IExecDataProtector`. After initializing a `web3Provider`, a specific IPFS gateway URL is passed in the options, allowing the SDK to retrieve content from a custom IPFS gateway, primarily for checking uploaded data. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/dataProtector/advanced/advanced-configuration.md#_snippet_5 LANGUAGE: TypeScript CODE: ``` const web3Provider = getWeb3Provider('PRIVATE_KEY'); // ---cut--- const dataProtector = new IExecDataProtector(web3Provider, { ipfsGateway: 'https://ipfs-gateway.v8-bellecour.iex.ec', // [!code focus] }); ``` ---------------------------------------- TITLE: Specifying optional path Parameter (TypeScript) DESCRIPTION: This example demonstrates the optional `path` parameter, a `string` type, used when the protected data is a zip file. It allows specifying a particular file within the zip to be extracted and returned as the result, simplifying access to specific content within a bundled protected data asset. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/dataProtector/dataProtectorSharing/consume/consumeProtectedData.md#_snippet_4 LANGUAGE: TypeScript CODE: ``` import { IExecDataProtectorSharing, getWeb3Provider, } from '@iexec/dataprotector'; const web3Provider = getWeb3Provider('PRIVATE_KEY'); const dataProtectorSharing = new IExecDataProtectorSharing(web3Provider); // ---cut--- const consumeProtectedDataResult = await dataProtectorSharing.consumeProtectedData({ protectedData: '0x123abc...', app: '0x456def...', path: 'my-content', // [!code focus] }); ``` ---------------------------------------- TITLE: Prompt for iApp Project Name (txt) DESCRIPTION: Shows the interactive prompt for entering the desired project name during iApp initialization, which creates a new folder. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/overview/helloWorld/3-buildIApp.md#_snippet_4 LANGUAGE: txt CODE: ``` ? What's your project name? (A folder with this name will be created) ... ``` ---------------------------------------- TITLE: Specifying collectionId Parameter DESCRIPTION: This example highlights the `collectionId` parameter, a required number representing the ID of the collection to which the protected data will be added. It's crucial for directing the data to the correct collection. SOURCE: https://github.com/iexecblockchaincomputing/documentation-tools/blob/main/tools/dataProtector/dataProtectorSharing/collection/addToCollection.md#_snippet_2 LANGUAGE: TypeScript CODE: ``` import { IExecDataProtectorSharing, getWeb3Provider, } from '@iexec/dataprotector'; const web3Provider = getWeb3Provider('PRIVATE_KEY'); const dataProtectorSharing = new IExecDataProtectorSharing(web3Provider); const { txHash } = await dataProtectorSharing.addToCollection({ collectionId: 12, protectedData: '0x123abc...', addOnlyAppWhitelist: '0x541abc...', }); ``` ---------------------------------------- TITLE: Importing Icon Component in Vue.js DESCRIPTION: This snippet demonstrates how to import the `Icon` component from the `@iconify/vue` library within a Vue.js `