### Install Dependencies and Setup Project Source: https://docs.openzeppelin.com/defender/guide/meta-tx Clone the repository, navigate to the guide's directory, and install project dependencies using Yarn. Configure your environment variables with your Defender API credentials and a private key for local testing. ```bash git clone https://github.com/openzeppelin/workshops.git cd workshops/25-defender-metatx-api/ yarn ``` ```dotenv PRIVATE_KEY="0xabc" API_KEY="abc" API_SECRET="abc" ``` -------------------------------- ### Set up Environment for Docker Installation Source: https://docs.openzeppelin.com/monitor/1.3.x Copies the example environment file and prompts to edit it with your specific configurations for Docker deployment. ```bash cp .env.example .env # Edit .env file with your configuration ``` -------------------------------- ### Initial Project Setup and Build Source: https://docs.openzeppelin.com/monitor/1.3.x/contribution Clones the repository, navigates into the directory, builds the project using Cargo, and sets up environment variables by copying the example configuration. ```bash # Clone and set up the repository git clone https://github.com/openzeppelin/openzeppelin-monitor cd openzeppelin-monitor # Build the project cargo build # Set up environment variables cp .env.example .env ``` -------------------------------- ### Initial Project Setup and Build Source: https://docs.openzeppelin.com/monitor/contribution Clones the OpenZeppelin Monitor repository, navigates into the directory, builds the project using Cargo, and sets up environment variables by copying the example configuration. ```bash git clone https://github.com/openzeppelin/openzeppelin-monitor cd openzeppelin-monitor cargo build cp .env.example .env ``` -------------------------------- ### Install Dependencies and Prepare Environment Source: https://docs.openzeppelin.com/contracts-compact Install project dependencies using yarn and prepare the Compact environment. The SKIP_ZK=true flag is used to skip Zero-Knowledge related setups. ```bash nvm install && \ yarn && \ SKIP_ZK=true yarn compact ``` -------------------------------- ### Install and Run App Dependencies Source: https://docs.openzeppelin.com/defender/guide/meta-tx Install project dependencies using yarn and start the application. This is typically done after cloning the project repository. ```bash $ cd app $ yarn $ yarn start ``` -------------------------------- ### Install Server Dependencies Source: https://docs.openzeppelin.com/contracts/5.x/learn/webauthn-smart-accounts Navigate to the server directory and install viem and @types/node. ```bash pnpm install viem pnpm install -D @types/node ``` -------------------------------- ### Install Client Dependencies Source: https://docs.openzeppelin.com/contracts/5.x/learn/webauthn-smart-accounts Navigate to the client directory and install necessary dependencies like viem and ox. ```bash cd client pnpm install viem ox ``` -------------------------------- ### Initialize Foundry Project and Install Dependencies Source: https://docs.openzeppelin.com/defender/tutorial/deploy Sets up a new Foundry project, installs forge-std, and adds OpenZeppelin's upgradeable contracts and upgrades plugin. Ensure Foundry is installed before running. ```bash forge init deploy-tutorial && cd deploy-tutorial && forge install foundry-rs/forge-std && forge install OpenZeppelin/openzeppelin-foundry-upgrades && forge install OpenZeppelin/openzeppelin-contracts-upgradeable ``` -------------------------------- ### Start Client Development Server Source: https://docs.openzeppelin.com/contracts/5.x/learn/webauthn-smart-accounts Starts the client development server. Ensure you are in the 'client' directory. ```shell cd client pnpm dev ``` -------------------------------- ### Install Module Source: https://docs.openzeppelin.com/contracts/5.x/api/account Installs a module of a specific type with optional initialization data. Ensure the module type is supported and the module is not already installed. ```solidity function _installModule(uint256 moduleTypeId, address module, bytes initData) internal # Installs a module of the given type with the given initialization data. For the fallback module type, the `initData` is expected to be the (packed) concatenation of a 4-byte selector and the rest of the data to be sent to the handler when calling `IERC7579Module.onInstall`. Requirements: * Module type must be supported. See `AccountERC7579.supportsModule`. Reverts with `ERC7579Utils.ERC7579UnsupportedModuleType`. * Module must be of the given type. Reverts with `ERC7579Utils.ERC7579MismatchedModuleTypeId`. * Module must not be already installed. Reverts with `ERC7579Utils.ERC7579AlreadyInstalledModule`. Emits a ` IERC7579ModuleConfig.ModuleInstalled` event. ``` -------------------------------- ### Copy Solana Kamino Deposit Monitor Configuration Source: https://docs.openzeppelin.com/monitor/1.3.x/quickstart Copy the example monitor configuration file for Solana Kamino deposits. This is necessary if you haven't run the automated setup script. ```bash cp examples/config/monitors/solana_kamino_deposit.json config/monitors/solana_kamino_deposit.json ``` -------------------------------- ### Start OpenZeppelin Monitor with Docker Compose Source: https://docs.openzeppelin.com/monitor Starts the OpenZeppelin Monitor services using Docker Compose. Includes options to start with or without the metrics profile. ```bash # without metrics profile ( METRICS_ENABLED=false by default ) docker compose up -d # With metrics enabled docker compose --profile metrics up -d ``` -------------------------------- ### Install Truffle and Upgrades Plugin Source: https://docs.openzeppelin.com/upgrades-plugins/migrate-from-cli Install Truffle and the OpenZeppelin Upgrades plugin for Truffle. ```bash npm install --save-dev truffle npx truffle init npm install --save-dev @openzeppelin/truffle-upgrades ``` -------------------------------- ### Install Stellar Adapter Source: https://docs.openzeppelin.com/ecosystem-adapters/getting-started Install the Stellar adapter and shared types package for Soroban. ```bash pnpm add @openzeppelin/adapter-stellar @openzeppelin/ui-types ``` -------------------------------- ### Install Coverage Tools Source: https://docs.openzeppelin.com/monitor/1.3.x/testing Installs the necessary components for generating code coverage reports. ```bash rustup component add llvm-tools-preview cargo install cargo-llvm-cov ``` -------------------------------- ### cURL GET Request Example Source: https://docs.openzeppelin.com/relayer/1.4.x/api/callPluginGet Basic cURL command to invoke a plugin via GET. Ensure the plugin is enabled for GET requests. ```curl curl -X GET "https://docs.openzeppelin.com/api/v1/plugins/string/call?route=string" ``` -------------------------------- ### JavaScript Example for Health Check Source: https://docs.openzeppelin.com/relayer/1.3.x/api/health Example of how to make a GET request to the /health endpoint using JavaScript. ```javascript "string" ``` -------------------------------- ### cURL GET Request Example Source: https://docs.openzeppelin.com/relayer/1.4.x/api/callpluginget Demonstrates how to make a GET request to the plugin call endpoint, including the route parameter. ```curl curl -X GET "https://docs.openzeppelin.com/api/v1/plugins/string/call?route=string" ``` ```curl curl -X GET "https://docs.openzeppelin.com/api/v1/plugins/string/call?route=string" \ -H "Authorization: Bearer " ``` -------------------------------- ### Unpacking the GSN Starter Kit Source: https://docs.openzeppelin.com/contracts/5.x/learn/sending-gasless-transactions Use this command to quickly set up a new dApp with GSN meta-transaction support pre-configured. ```bash oz unpack gsn ``` -------------------------------- ### Get Balance with DefenderRelayProvider (ethers.js) Source: https://docs.openzeppelin.com/defender/manage/relayers Leverage the DefenderRelayProvider for ethers.js to interact with the network. This example shows how to get an account's balance using the provider. ```javascript const provider = new DefenderRelayProvider(credentials); const balance = await provider.getBalance('0x6b175474e89094c44da98b954eedeac495271d0f'); ``` -------------------------------- ### Initialize Project and Add Submodule Source: https://docs.openzeppelin.com/contracts-compact Set up a new project directory and add the OpenZeppelin Contracts for Compact as a git submodule. ```bash mkdir my-project cd my-project git init && \ git submodule add https://github.com/OpenZeppelin/compact-contracts.git ``` -------------------------------- ### PaymasterSigner Example Usage Source: https://docs.openzeppelin.com/community-contracts/api/account Example of creating a custom paymaster by inheriting from PaymasterSigner and a specific signer type like SignerECDSA. It includes EIP712 domain setup. ```solidity contract MyPaymasterECDSASigner is PaymasterSigner, SignerECDSA { constructor(address signerAddr) EIP712("MyPaymasterECDSASigner", "1") SignerECDSA(signerAddr) {} } ``` -------------------------------- ### List All Metric Names (Python) Source: https://docs.openzeppelin.com/relayer/api/listMetrics A Python example demonstrating how to fetch metric names using the requests library. Ensure you have the library installed (`pip install requests`). ```python import requests response = requests.get("https://docs.openzeppelin.com/metrics") print(response.json()) ``` -------------------------------- ### Copy Example Configuration Files Source: https://docs.openzeppelin.com/monitor/1.3.x Copy example configuration files for various monitors, networks, triggers, and filters to your project's config directory. ```bash # EVM Configuration cp examples/config/monitors/evm_transfer_usdc.json config/monitors/evm_transfer_usdc.json cp examples/config/networks/ethereum_mainnet.json config/networks/ethereum_mainnet.json # Stellar Configuration cp examples/config/monitors/stellar_swap_dex.json config/monitors/stellar_swap_dex.json cp examples/config/networks/stellar_mainnet.json config/networks/stellar_mainnet.json # Solana Configuration cp examples/config/monitors/solana_kamino_deposit.json config/monitors/solana_kamino_deposit.json cp examples/config/networks/solana_mainnet.json config/networks/solana_mainnet.json # Notification Configuration cp examples/config/triggers/slack_notifications.json config/triggers/slack_notifications.json cp examples/config/triggers/email_notifications.json config/triggers/email_notifications.json # Filter Configuration cp examples/config/filters/evm_filter_block_number.sh config/filters/evm_filter_block_number.sh cp examples/config/filters/stellar_filter_block_number.sh config/filters/stellar_filter_block_number.sh ``` -------------------------------- ### onInstall Source: https://docs.openzeppelin.com/community-contracts/api/account Initializes the module's configuration when installed by an account, registering the account with the module. ```APIDOC ## onInstall(initData) ### Description Sets up the module's initial configuration when installed by an account. The account calling this function becomes registered with the module. The `initData` may be `abi.encode(uint32(initialDelay), uint32(initialExpiration))`. The delay will be set to the maximum of this value and the minimum delay if provided. Otherwise, the delay will be set to `ERC7579DelayedExecutor.minSetback` and `ERC7579DelayedExecutor.defaultExpiration` respectively. Behaves as a no-op if the module is already installed. ### Method public ### Parameters - **initData** (bytes) - Initialization data, optionally encoding `(uint32, uint32)` for initial delay and expiration. ### Requirements - The account (i.e `msg.sender`) must implement the `IERC7579ModuleConfig` interface. - `initData` must be empty or decode correctly to `(uint32, uint32)`. ``` -------------------------------- ### Retrieve All Metric Names (C#) Source: https://docs.openzeppelin.com/relayer/1.3.x/api/list_metrics C# code snippet using HttpClient to get metric names. This example shows how to perform an asynchronous HTTP GET request and deserialize the JSON response. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class MetricsClient { public static async Task GetMetricsAsync() { using (HttpClient client = new HttpClient()) { try { HttpResponseMessage response = await client.GetAsync("https://docs.openzeppelin.com/metrics"); response.EnsureSuccessStatusCode(); // Throw if HTTP status code is not 2xx string responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } catch (HttpRequestException e) { Console.WriteLine($"Request error: {e.Message}"); } } } public static void Main(string[] args) { GetMetricsAsync().Wait(); } } ``` -------------------------------- ### Get Voting Delay Source: https://docs.openzeppelin.com/contracts-cairo/3.x/api/governance Internal function to retrieve the voting delay, which is the time between proposal creation and the start of voting. ```rust voting_delay(self: @ContractState) → u64 internal ``` -------------------------------- ### Plugin Configuration Example Source: https://docs.openzeppelin.com/relayer/1.4.x/plugins An example of how to declare a plugin in the `./config/config.json` file. It includes basic settings like id, path, and optional configurations. ```json { "plugins": [ { "id": "my-plugin", "path": "my-plugin.ts", "timeout": 30, "emit_logs": false, "emit_traces": false, "raw_response": false, "allow_get_invocation": false, "config": { "featureFlagExample": true }, "forward_logs": false } ] } ``` -------------------------------- ### Install ERC7579 Validator Module Source: https://docs.openzeppelin.com/contracts/5.x/api/account Example of initializing an AccountERC7579 contract with a validator module. This is crucial for enabling transaction validation. ```Solidity contract MyAccountERC7579 is AccountERC7579, Initializable { function initializeAccount(address validator, bytes calldata validatorData) public initializer { _installModule(MODULE_TYPE_VALIDATOR, validator, validatorData); } } ``` -------------------------------- ### Monitor Configuration References Example Source: https://docs.openzeppelin.com/monitor/1.3.x Demonstrates how monitor configurations reference network and trigger configurations. Ensure all referenced slugs and trigger keys exist in their respective files to prevent monitor startup failures. ```json { "slug": "ethereum_mainnet", ... } ``` ```json { "large_transfer_slack": { ... } } ``` ```json { "networks": ["ethereum_mainnet"], "triggers": ["large_transfer_slack"], ... } ``` -------------------------------- ### Run OpenZeppelin Monitor with Check Source: https://docs.openzeppelin.com/monitor/1.3.x/local-evm-testing Validates the monitor's configuration without starting the service. Useful for debugging setup issues. ```bash cargo run -- --check ``` -------------------------------- ### Implement AccountERC7579 with Initializer Source: https://docs.openzeppelin.com/community-contracts/account-modules Example of an AccountERC7579 contract that installs a validator module during initialization. Ensure the validator address and its data are correctly provided. ```solidity // contracts/MyAccountERC7579.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.27; import {AccountERC7579} from "@openzeppelin/contracts/account/extensions/draft-AccountERC7579.sol"; import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol"; import {MODULE_TYPE_VALIDATOR} from "@openzeppelin/contracts/interfaces/draft-IERC7579.sol"; import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol"; contract MyAccountERC7579 is Initializable, AccountERC7579 { function initializeAccount(address validator, bytes calldata validatorData) public initializer { // Install a validator module to handle signature verification _installModule(MODULE_TYPE_VALIDATOR, validator, validatorData); } } ``` -------------------------------- ### Clone and Run Automated Setup Script Source: https://docs.openzeppelin.com/monitor/quickstart Clones the OpenZeppelin Monitor repository and makes the automated setup script executable. This script handles building the application, copying configurations, and optionally running the monitor. ```bash git clone https://github.com/openzeppelin/openzeppelin-monitor cd openzeppelin-monitor ``` ```bash chmod +x setup_and_run.sh ``` ```bash ./setup_and_run.sh ``` -------------------------------- ### Successful JSON Response Source: https://docs.openzeppelin.com/relayer/1.4.x/api/callPluginGet Example of a successful JSON response when a plugin is invoked via GET. The 'data' field will contain the plugin's response. ```json { "data": null, "error": "string", "metadata": { "logs": [ { "level": "log", "message": "string" } ], "traces": [ null ] }, "pagination": { "current_page": 0, "per_page": 0, "total_items": 0 }, "success": true } ``` -------------------------------- ### Install Full OpenZeppelin UI Kit Packages Source: https://docs.openzeppelin.com/tools/uikit/getting-started Install packages for full UI Kit functionality, including transaction form rendering and wallet integration. ```bash pnpm add @openzeppelin/ui-types @openzeppelin/ui-utils @openzeppelin/ui-styles \ @openzeppelin/ui-components @openzeppelin/ui-react @openzeppelin/ui-renderer ``` -------------------------------- ### Retrieve Metric Details (C#) Source: https://docs.openzeppelin.com/relayer/api/metricdetail Example in C# for fetching metric details. This snippet utilizes `HttpClient` to send a GET request, including the necessary `Authorization` header. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class MetricDetail { public static async Task Main(string[] args) { using (var client = new HttpClient()) { client.DefaultRequestHeaders.Add("Authorization", "Bearer "); var response = await client.GetAsync("https://docs.openzeppelin.com/metrics/string"); var responseString = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseString); } } } ``` -------------------------------- ### onInstall Source: https://docs.openzeppelin.com/community-contracts/api/account Sets up the module's initial configuration when installed by an account. It can include signers and threshold for multisignature functionality. This function can only be called once per account. ```APIDOC ## onInstall ### Description Sets up the module's initial configuration when installed by an account. See `ERC7579DelayedExecutor.onInstall`. Besides the delay setup, the `initdata` can include `signers` and `threshold`. The initData should be encoded as: `abi.encode(bytes[] signers, uint64 threshold)` If no signers or threshold are provided, the multisignature functionality will be disabled until they are added later. An account can only call onInstall once. If called directly by the account, the signer will be set to the provided data. Future installations will behave as a no-op. ### Method `onInstall(bytes initData)` ### Parameters #### Request Body - **initData** (bytes) - Required - Encoded data for signers and threshold. ``` -------------------------------- ### Retrieve Metric Details (Python) Source: https://docs.openzeppelin.com/relayer/api/metricdetail A Python example for fetching metric details. This script uses the `requests` library to send a GET request with the appropriate authorization header. ```python import requests url = "https://docs.openzeppelin.com/metrics/string" headers = { 'Authorization': 'Bearer ' } response = requests.request("GET", url, headers=headers) print(response.text) ``` -------------------------------- ### onInstall Source: https://docs.openzeppelin.com/community-contracts/api/account Sets up the module's initial configuration when installed by an account. This can include signer weights. The initData should be encoded as: `abi.encode(bytes[] signers, uint64 threshold, uint64[] weights)`. If weights are not provided, signers default to weight 1. An account can only call onInstall once. ```APIDOC ## onInstall(bytes initData) ### Description Sets up the module's initial configuration when installed by an account. Besides the standard delay and signer configuration, this can also include signer weights. The initData should be encoded as: `abi.encode(bytes[] signers, uint64 threshold, uint64[] weights)` If weights are not provided but signers are, all signers default to weight 1. An account can only call onInstall once. If called directly by the account, the signer will be set to the provided data. Future installations will behave as a no-op. ### Method `public` ``` -------------------------------- ### Initialize OpenZeppelin Project Source: https://docs.openzeppelin.com/contracts/5.x/learn/sending-gasless-transactions Use the OpenZeppelin CLI to initialize a new project. Follow the prompts to set up your project structure for contract development and deployment. ```bash npx oz init ``` -------------------------------- ### Retrieve Metric Details (JavaScript) Source: https://docs.openzeppelin.com/relayer/api/metricdetail Example of how to retrieve metric details using JavaScript. This snippet demonstrates making a GET request to the API endpoint with the necessary authorization header. ```javascript const options = { method: 'GET', headers: { Authorization: 'Bearer ' } }; fetch('https://docs.openzeppelin.com/metrics/string', options) .then(response => { if (!response.ok) { throw new Error('Network response was not ok ' + response.statusText); } return response.text(); }) .then(data => { console.log(data); }) .catch(error => { console.error('There has been a problem with your fetch operation:', error); }); ``` -------------------------------- ### Copy Environment File Source: https://docs.openzeppelin.com/monitor/1.3.x/quickstart Copies the example environment file to `.env` for local configuration. Customize this file with your specific settings. ```bash cp .env.example .env ``` -------------------------------- ### Retrieve All Metric Names (Java) Source: https://docs.openzeppelin.com/relayer/1.3.x/api/list_metrics Java example using Apache HttpClient to fetch metric names. This demonstrates making an HTTP GET request and processing the JSON response. ```java import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import java.io.IOException; public class GetMetrics { public static void main(String[] args) { try (CloseableHttpClient client = HttpClients.createDefault()) { HttpGet request = new HttpGet("https://docs.openzeppelin.com/metrics"); try (CloseableHttpResponse response = client.execute(request)) { String jsonResponse = EntityUtils.toString(response.getEntity()); System.out.println(jsonResponse); } } catch (IOException e) { e.printStackTrace(); } } } ``` -------------------------------- ### Retrieve Signer Details (cURL) Source: https://docs.openzeppelin.com/relayer/1.2.x/api/getSigner Example using cURL to make a GET request to retrieve signer details. Ensure to replace the placeholder token with your actual authorization token. ```curl curl -X GET "https://docs.openzeppelin.com/api/v1/signers/string" \ -H "Authorization: Bearer " ``` -------------------------------- ### Start Server Development Server Source: https://docs.openzeppelin.com/contracts/5.x/learn/webauthn-smart-accounts Starts the server development server. Ensure you are in the 'server' directory and have sourced your environment variables. ```shell cd server source .env pnpm dev ``` -------------------------------- ### Make Setup Script Executable Source: https://docs.openzeppelin.com/monitor/1.3.x/quickstart Grants execute permissions to the `setup_and_run.sh` script, allowing it to be run for automated setup. ```bash chmod +x setup_and_run.sh ``` -------------------------------- ### Run Bob Node on Paseo Testnet Source: https://docs.openzeppelin.com/substrate-runtimes/guides/quick_start Start the 'Bob' node as a collator on the Paseo testnet. This is a similar setup to the 'Alice' node but with different base path and RPC port. ```bash ./target/release/generic-template-node \ --bob \ --collator \ --force-authoring \ --chain raw-parachain-chainspec.json \ --base-path \ --port 40333 \ --rpc-port 8845 \ -- \ --execution wasm \ --chain \ --port 30343 \ --rpc-port 9977 \ --sync fast-unsafe ``` -------------------------------- ### Install Defender as Code Template Source: https://docs.openzeppelin.com/defender/dac Initialize a new Serverless project using the pre-configured Defender as Code template. Ensure you have access to the repository. ```bash sls install --url https://github.com/OpenZeppelin/defender-as-code/tree/main/template -n my-service ``` -------------------------------- ### Plugin Configuration Example Source: https://docs.openzeppelin.com/relayer/plugins Example of how to configure a plugin in the `config.json` file. Specifies plugin ID, path, timeout, and logging options. ```json "plugins": [ { "id": "my-plugin", "path": "my-plugin.ts", "timeout": 30, "emit_logs": false, "emit_traces": false, "raw_response": false, "allow_get_invocation": false, "config": { "featureFlagExample": true } "forward_logs": false } ] ``` -------------------------------- ### Create Key-Value Store Source: https://docs.openzeppelin.com/tools/uikit/storage Utilizes KeyValueStorage for simple settings and flags. Similar to EntityStorage, it requires a Dexie database instance and a table name. The example shows setting and getting a theme preference. ```typescript import { KeyValueStorage, createDexieDatabase } from '@openzeppelin/ui-storage'; import Dexie from 'dexie'; const MY_SCHEMA = { settings: 'key' }; const db = createDexieDatabase(new Dexie('my-app'), MY_SCHEMA); class AppSettings extends KeyValueStorage { constructor() { super(db, 'settings'); } } const settings = new AppSettings(); await settings.set('theme', 'dark'); const theme = await settings.get('theme'); // 'dark' ``` -------------------------------- ### Install Dependencies and Build Project Source: https://docs.openzeppelin.com/ui-builder/exporting-and-history After downloading the exported project, install its dependencies and build the project using pnpm. ```bash pnpm install && pnpm build ``` -------------------------------- ### Get Unwrap Conversion Rate Source: https://docs.openzeppelin.com/confidential-contracts/api/interfaces Returns the conversion rate between the underlying token and the wrapped token. For example, a rate of 1000 means 1000 underlying units equal 1 wrapped unit. ```solidity rate() → uint256 ``` -------------------------------- ### Install Minimal OpenZeppelin UI Kit Packages Source: https://docs.openzeppelin.com/tools/uikit/getting-started Install the core UI Kit packages for component library and type system usage. ```bash pnpm add @openzeppelin/ui-types @openzeppelin/ui-utils @openzeppelin/ui-components @openzeppelin/ui-styles ``` -------------------------------- ### Install Module Source: https://docs.openzeppelin.com/contracts/5.x/api/account Public function to install a module of a specified type onto the smart account, including initialization data. ```Solidity installModule(uint256 moduleTypeId, address module, bytes initData) public ``` -------------------------------- ### List Transactions cURL Example Source: https://docs.openzeppelin.com/relayer/1.2.x/api/listTransactions This cURL command demonstrates how to make a GET request to the list transactions endpoint. Ensure you replace 'string' with the actual relayer ID and provide a valid bearer token. ```curl curl -X GET "https://docs.openzeppelin.com/api/v1/relayers/string/transactions/?page=0&per_page=0" \ -H "Authorization: Bearer " ``` -------------------------------- ### Get Wrapping Rate Source: https://docs.openzeppelin.com/confidential-contracts/api/token Returns the conversion rate between the underlying ERC20 token and the wrapped ERC7984 token. For example, a rate of 1000 means 1000 underlying units equal 1 wrapped unit. ```solidity rate() → uint256 public # Returns the rate at which the underlying token is converted to the wrapped token. For example, if the `rate` is 1000, then 1000 units of the underlying token equal 1 unit of the wrapped token. ``` -------------------------------- ### Create Project Directory Source: https://docs.openzeppelin.com/contracts/5.x/learn/webauthn-smart-accounts Initializes the main project directory for the WebAuthn tutorial and navigates into it. This structure will hold all related contracts, server, shared, and client code. ```shell mkdir webauthn-tutorial cd webauthn-tutorial ``` -------------------------------- ### Get Pending Default Admin Delay and Effect Schedule Source: https://docs.openzeppelin.com/contracts/api/access Returns a tuple of `newDelay` and an effect schedule. After the `schedule` passes, the `newDelay` will get into effect immediately for every new `AccessControlDefaultAdminRules.defaultAdmin` transfer started with `AccessControlDefaultAdminRules.beginDefaultAdminTransfer`. A zero value only in `effectSchedule` indicates no pending delay change. A zero value only for `newDelay` means that the next `AccessControlDefaultAdminRules.defaultAdminDelay` will be zero after the effect schedule. ```solidity pendingDefaultAdminDelay() → uint48 newDelay, uint48 effectSchedule external # Returns a tuple of `newDelay` and an effect schedule. After the `schedule` passes, the `newDelay` will get into effect immediately for every new `AccessControlDefaultAdminRules.defaultAdmin` transfer started with `AccessControlDefaultAdminRules.beginDefaultAdminTransfer`. A zero value only in `effectSchedule` indicates no pending delay change. A zero value only for `newDelay` means that the next `AccessControlDefaultAdminRules.defaultAdminDelay` will be zero after the effect schedule. ``` -------------------------------- ### Anti-Sandwich Mechanism Description Source: https://docs.openzeppelin.com/uniswap-hooks/api/general The anti-sandwich mechanism prevents trades from getting better prices than those available at the start of the block. For currency0 to currency1 swaps (zeroForOne = true), the pool uses the standard xy=k curve. For currency1 to currency0 swaps (zeroForOne = false), the price is fixed to the beginning-of-block price to thwart manipulation. ```text Calculates the unspecified amount based on the pool state at the beginning of the block. This prevents sandwich attacks by ensuring trades can't get better prices than what was available at the start of the block. Note that the calculated unspecified amount could either be input or output, depending if it's an exactInput or outputOutput swap. In cases of zeroForOne == true, the target unspecified amount is not applicable, and the max uint256 value is returned as a flag only. The anti-sandwich mechanism works such as: * For currency0 to currency1 swaps (zeroForOne = true): The pool behaves normally with xy=k curve. * For currency1 to currency0 swaps (zeroForOne = false): The price is fixed at the beginning-of-block price, which prevents attackers from manipulating the price within a block. ``` -------------------------------- ### List All Available Metrics (Go) Source: https://docs.openzeppelin.com/relayer/1.4.x/api/listMetrics A Go example for retrieving the list of available metric names. This shows how to make the HTTP request and parse the JSON response. ```go package main import ( "encoding/json" "fmt" "log" "github.com/go-resty/resty/v2" ) func main() { resp, err := resty.New().R().Get("https://docs.openzeppelin.com/metrics") if err != nil { log.Fatalf("Error making request: %v", err) } var metrics []string err = json.Unmarshal(resp.Body(), &metrics) if err != nil { log.Fatalf("Error unmarshalling response: %v", err) } fmt.Println("Available metrics:") for _, metric := range metrics { fmt.Printf("- %s\n", metric) } } ``` -------------------------------- ### Get Default Admin Delay Source: https://docs.openzeppelin.com/contracts/api/access Returns the delay required to schedule the acceptance of a `AccessControlDefaultAdminRules.defaultAdmin` transfer started. This delay will be added to the current timestamp when calling `AccessControlDefaultAdminRules.beginDefaultAdminTransfer` to set the acceptance schedule. If a delay change has been scheduled, it will take effect as soon as the schedule passes, making this function returns the new delay. ```solidity defaultAdminDelay() → uint48 external # Returns the delay required to schedule the acceptance of a `AccessControlDefaultAdminRules.defaultAdmin` transfer started. This delay will be added to the current timestamp when calling `AccessControlDefaultAdminRules.beginDefaultAdminTransfer` to set the acceptance schedule. If a delay change has been scheduled, it will take effect as soon as the schedule passes, making this function returns the new delay. See `AccessControlDefaultAdminRules.changeDefaultAdminDelay`. ``` -------------------------------- ### Run OpenZeppelin Monitor with Options Source: https://docs.openzeppelin.com/monitor/1.3.x Demonstrates running the OpenZeppelin Monitor executable with various command-line options for logging, metrics, and configuration checking. ```bash # Enable logging to file ./openzeppelin-monitor --log-file ``` ```bash # Enable metrics server ./openzeppelin-monitor --metrics ``` ```bash # Validate configuration files without starting the service ./openzeppelin-monitor --check ``` -------------------------------- ### Unpack OpenZeppelin Starter Kit Source: https://docs.openzeppelin.com/contracts/5.x/learn/building-a-dapp Use the `oz unpack` command to quickly set up a preconfigured dapp project. This command downloads and unpacks a starter kit, providing a foundation for your application. ```bash $ oz unpack starter ✓ Kit downloaded and unpacked The kit is ready to use. Quick Start Run your local blockchain: > ganache-cli --deterministic Initialize the OpenZeppelin project: > openzeppelin init app Go to the client directory: > cd client Run the React app: > npm run start Continue in your browser! More at https://github.com/OpenZeppelin/starter-kit/tree/stable ``` -------------------------------- ### Check Module Installation Source: https://docs.openzeppelin.com/contracts/5.x/api/account Checks if a module of a specific type is installed. Reverts if the module is not installed. ```solidity function _checkModule(uint256 moduleTypeId, address module, bytes additionalContext) internal # Checks if the module is installed. Reverts if the module is not installed. ``` -------------------------------- ### Create Contract Instance with OpenZeppelin CLI Source: https://docs.openzeppelin.com/contracts/5.x/learn/sending-gasless-transactions Deploy your contract to a local development network using the OpenZeppelin CLI. This process includes selecting the contract, network, and initializing it by calling the `initialize()` function. ```bash $ openzeppelin create ✓ Compiled contracts with solc 0.5.9 (commit.e560f70d) ? Pick a contract to instantiate Counter ? Pick a network development All contracts are up to date ? Call a function to initialize the instance after creating it? Yes ? Select which function * initialize() ✓ Instance created at 0xCfEB869F69431e42cdB54A4F4f105C19C080A601 ``` -------------------------------- ### Install OpenZeppelin Contracts with npm (Latest Audited) Source: https://docs.openzeppelin.com/contracts/5.x Installs the latest audited release of OpenZeppelin Contracts using npm. This is the default version installed when running `npm install @openzeppelin/contracts`. ```bash $ npm install @openzeppelin/contracts ``` -------------------------------- ### Install Optional UI Kit Packages Source: https://docs.openzeppelin.com/tools/uikit/getting-started Install optional packages for IndexedDB persistence and the dev CLI for Tailwind wiring. ```bash # IndexedDB persistence (address book, settings, etc.) pnpm add @openzeppelin/ui-storage ``` ```bash # Dev CLI for Tailwind wiring and local development pnpm add -D @openzeppelin/ui-dev-cli ``` -------------------------------- ### Install Foundry Source: https://docs.openzeppelin.com/monitor/1.3.x/local-evm-testing Installs the Foundry toolchain, including Anvil, Forge, and Cast. Ensure you have curl and bash installed. ```bash curl -L https://foundry.paradigm.xyz | bash foundryup ``` -------------------------------- ### Install Dependencies Source: https://docs.openzeppelin.com/relayer/1.3.x Install the necessary Rust dependencies for the OpenZeppelin Relayer. Ensure you have Rust 2021 edition, version 1.88 or later installed. ```bash cargo build ```