### rrelayer CLI Help Example Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/getting-started/installation.mdx Demonstrates how to access detailed help for a specific rrelayer command, such as the 'new' command. ```bash rrelayer new --help ``` -------------------------------- ### Install rrelayer-ts and viem (npm, pnpm, bun) Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/sdk/framework-guides/typescript/viem.mdx Installs the rrelayer-ts and viem libraries using different package managers. Ensure you have Node.js and a compatible package manager installed. ```bash npm i rrelayer-ts viem ``` ```bash pnpm i rrelayer-ts viem ``` ```bash bun i rrelayer-ts viem ``` -------------------------------- ### rrelayer Basic Authentication Setup Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/migration/defender-to-rrelayer.mdx Example of how to set up rrelayer client with Basic Authentication. This method provides full access to the rrelayer API, contrasting with Defender's scoped API keys. ```typescript const client = createClient({ serverUrl: 'https://your-rrelayer-instance.com', auth: { username: process.env.RRELAYER_AUTH_USERNAME!, password: process.env.RRELAYER_AUTH_PASSWORD!, }, }); ``` -------------------------------- ### Get Text Signing History API Example Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/api/sign.mdx This example demonstrates how to retrieve the history of text messages signed by a relayer. It uses a GET request and supports pagination with limit and offset parameters. ```bash curl "https://your-rrelayer.com/signing/relayers/6ba7b810-9dad-11d1-80b4-00c04fd430c8/text-history?limit=10" \ -u "username:password" ``` -------------------------------- ### API Key Auth Setup and Allowlist Retrieval (TypeScript) Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/sdk/relayers/node.mdx Illustrates how to initialize the rrelayer client using an API Key for authentication. This method is simpler for server-to-server communication. It also includes an example of fetching the allowlist. The 'rrelayer' package is required. ```typescript // config.ts import { createRelayerClient, TransactionSpeed } from 'rrelayer'; export let relayerClient = createRelayerClient({ serverUrl: 'http://localhost:8000', relayerId: '94afb207-bb47-4392-9229-ba87e4d783cb', apiKey: 'YOUR_API_KEY', // This is optional it defaults to fast and is a fallback // You can override this with the transaction request speed: TransactionSpeed.FAST, }); ... // get-allowlist.ts import { relayerClient } from './config'; // returns a PagingResult<`0x${string}`> - import { PagingResult } from 'rrelayer'; let allowlist = await relayerClient.allowlist.get({ limit: 100, offset: 0, }); ``` -------------------------------- ### Development vs Production Authentication Setup Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/api/authentication.mdx Compares the authentication configuration for development and production environments. Development uses simple credentials, while production utilizes environment variables for security. Includes examples for setting environment variables. ```yaml api_config: authentication_username: 'admin' authentication_password: 'password' ``` ```yaml api_config: authentication_username: '${RRELAYER_AUTH_USERNAME}' authentication_password: '${RRELAYER_AUTH_PASSWORD}' ``` ```bash export RRELAYER_AUTH_USERNAME="admin_$(openssl rand -hex 16)" export RRELAYER_AUTH_PASSWORD="$(openssl rand -base64 32)" ``` -------------------------------- ### Clone rrelayer Repository Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/deploying/gcp.mdx Downloads the rrelayer project source code from its GitHub repository. Requires git to be installed. ```bash git clone https://github.com/joshstevens19/rrelayer.git ``` -------------------------------- ### Basic Auth: rrelayer SDK Client Setup (TypeScript) Source: https://github.com/joshstevens19/rrelayer/blob/master/sdk/typescript/README.md Demonstrates how to set up an rrelayer client using basic authentication with username and password. It utilizes environment variables for credentials and retrieves a relayer client instance. Ensure the 'rrelayer' package is installed and dotenv is configured for environment variables. ```typescript import { createClient, TransactionSpeed } from 'rrelayer'; import * as dotenv from "dotenv"; dotenv.config(); // Client also holds some admin methods in which API keys cannot do export const client = createClient({ serverUrl: 'http://localhost:8000', auth: { username: process.env.RRELAYER_AUTH_USERNAME!, password: process.env.RRELAYER_AUTH_PASSWORD!, }, }); // returns a AdminRelayerClient - import { AdminRelayerClient } from 'rrelayer' export const relayer = await client.getRelayerClient( // The relayer id you want to connect to '94afb207-bb47-4392-9229-ba87e4d783cb', // This is optional it defaults to fast TransactionSpeed.FAST ); ``` -------------------------------- ### Simulate and Write Contract Transaction (TypeScript) Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/sdk/framework-guides/typescript/viem.mdx This snippet demonstrates how to simulate a contract call using `publicClient.simulateContract` and then execute the transaction using `walletClient.writeContract`. It requires `publicClient`, `walletClient` from a configuration file and the contract's ABI. ```typescript import { publicClient, walletClient } from './config'; import { wagmiAbi } from './abi'; const { request } = await publicClient.simulateContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: wagmiAbi, functionName: 'mint', }); await walletClient.writeContract(request); ``` ```typescript export const wagmiAbi = [ ... { inputs: [], name: "mint", outputs: [], stateMutability: "nonpayable", type: "function", }, ... ] as const; ``` -------------------------------- ### Setup RelayerSigner with Basic Authentication Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/sdk/framework-guides/rust/alloy.mdx This Rust code configures and creates a RelayerSigner using basic authentication (username and password). It loads credentials from environment variables, sets up the AdminRelayerClientConfig with server and provider URLs, relayer ID, and authentication details, then initializes the signer automatically fetching the address. ```rust use std::sync::Arc; use eyre::Result; use rrelayer::{ AdminRelayerClient, AdminRelayerClientConfig, AdminRelayerClientAuth, RelayerSigner, TransactionSpeed, RelayerId }; use dotenvy::dotenv; use std::env; pub async fn create_relayer_signer() -> Result { dotenv().ok(); let username = env::var("RRELAYER_AUTH_USERNAME") .expect("RRELAYER_AUTH_USERNAME must be set"); let password = env::var("RRELAYER_AUTH_PASSWORD") .expect("RRELAYER_AUTH_PASSWORD must be set"); let config = AdminRelayerClientConfig { server_url: "http://localhost:8000".to_string(), provider_url: "https://eth.llamarpc.com".to_string(), relayer_id: RelayerId::from_str("94afb207-bb47-4392-9229-ba87e4d783cb")?, auth: CreateClientAuth { username, password, }, // This is optional it defaults to fast and is a fallback // You can override this with the transaction request speed: Some(TransactionSpeed::FAST), }; let client = Arc::new(AdminRelayerClient::new(config)); // Auto-fetch address from relayer let signer = RelayerSigner::from_admin_client_auto_address( client, Some(1), // mainnet chain ID ).await?; Ok(signer) } ``` -------------------------------- ### Install rrelayer CLI Source: https://context7.com/joshstevens19/rrelayer/llms.txt Installs the rrelayer command-line interface using a shell script. This is the primary method for setting up the rrelayer service. ```bash curl -L https://rrelayer.xyz/install.sh | bash ``` -------------------------------- ### Install rrelayer Helm Chart Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/deploying/gcp.mdx Deploys the rrelayer application to the GKE cluster using a Helm chart. Requires Helm to be installed and configured, and a customized values.yaml file. ```bash helm install rrelayer ./helm/rrelayer -f helm/rrelayer/values.yaml ``` -------------------------------- ### Sign Text Message API Example Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/api/sign.mdx This example demonstrates how to sign a plain text message using the Signing API. It requires authentication and sends a POST request with the text to be signed. ```bash curl -X POST https://your-rrelayer.com/signing/relayers/6ba7b810-9dad-11d1-80b4-00c04fd430c8/message \ -u "username:password" \ -H "Content-Type: application/json" \ -d '{ "text": "Hello, World! Please sign this message to authenticate." }' ``` -------------------------------- ### Install rrelayer SDK using BUN Source: https://github.com/joshstevens19/rrelayer/blob/master/sdk/typescript/README.md This snippet illustrates how to install the rrelayer SDK using the BUN runtime and package manager. BUN is a fast JavaScript runtime that also includes a built-in bundler and package manager. ```bash bun i rrelayer ``` -------------------------------- ### Initialize and Start rrelayer Project Source: https://context7.com/joshstevens19/rrelayer/llms.txt Commands to initialize a new rrelayer project, clone an existing one to a different network, and start the relayer service. ```bash # Create new rrelayer project rrelayer new # Clone existing relayer to another network rrelayer clone --relayer-id --name --network # Start the relayer service rrelayer start ``` -------------------------------- ### Setup RelayerSigner with API Key Authentication Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/sdk/framework-guides/rust/alloy.mdx This Rust code sets up a RelayerSigner using API key authentication. It defines the RelayerClientConfig with the server URL, relayer ID, and the API key. The signer is then initialized using RelayerSigner::from_relayer_client_auto_address, which automatically fetches the relayer's address. ```rust use std::sync::Arc; use eyre::Result; use rrelayer::{ RelayerClient, RelayerClientConfig, RelayerClientAuth, RelayerId, RelayerSigner, TransactionSpeed }; pub async fn create_relayer_signer() -> Result { let relayer_id = RelayerId::from_str("94afb207-bb47-4392-9229-ba87e4d783cb")?; let config = RelayerClientConfig { server_url: "http://localhost:8000".to_string(), relayer_id: relayer_id.clone(), auth: RelayerClientAuth::ApiKey { api_key: "your-api-key-here".to_string() }, // This is optional it defaults to fast and is a fallback // You can override this with the transaction request speed: Some(TransactionSpeed::FAST), }; let client = Arc::new(RelayerClient::new(config)); // Auto-fetch address from relayer let signer = RelayerSigner::from_relayer_client_auto_address( client, Some(1), // mainnet chain ID ).await?; Ok(signer) } ``` -------------------------------- ### Rust API Key Auth Client Setup and Usage Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/sdk/sign/rust.mdx Illustrates how to initialize a RelayerClient using an API key for authentication. The example includes setting the server URL, relayer ID, API key, and optionally the transaction speed, followed by a call to retrieve signed typed data history. Dependencies include the 'rrelayer' and 'anyhow' crates. ```rust use anyhow::Result; use rrelayer::{ CreateRelayerClientConfig, PagingContext, PagingResult, RelayerClient, RelayerId, SignedTypedDataHistory, TransactionSpeed, create_relayer_client, }; use std::str::FromStr; async fn get_relayer_client() -> Result { let relayer: RelayerClient = create_relayer_client(CreateRelayerClientConfig { server_url: "http://localhost:8000".to_string(), relayer_id: RelayerId::from_str("94afb207-bb47-4392-9229-ba87e4d783cb")?, api_key: "YOUR_API_KEY".to_string(), // This is optional it defaults to fast and is a fallback // You can override this with the transaction request speed: Some(TransactionSpeed::FAST), }); Ok(relayer) } async fn example() -> Result<()> { let relayer_client = get_relayer_client().await?; let result: PagingResult = relayer_client.sign().typed_data_history(&PagingContext { limit: 100, offset: 0 }).await?; println!("{:?}", result); Ok(()) } ``` -------------------------------- ### Create Viem Clients with Basic Authentication Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/sdk/framework-guides/typescript/viem.mdx Creates a wallet client and a public client using rrelayer-ts with basic authentication (username and password). It requires environment variables for authentication credentials and connects to a specified relayer ID. The relayer's chain and HTTP transport are configured for Viem. ```typescript import { createClient, TransactionSpeed } from 'rrelayer'; import { createWalletClient, createPublicClient, custom } from 'viem'; import * as dotenv from 'dotenv'; dotenv.config(); let client = createClient({ serverUrl: 'http://localhost:8000', auth: { username: process.env.RRELAYER_AUTH_USERNAME!, password: process.env.RRELAYER_AUTH_PASSWORD!, }, }); const relayer = await client.getRelayerClient( // The relayer id you want to connect to '94afb207-bb47-4392-9229-ba87e4d783cb', // This is optional it defaults to fast // As you are using viems native interface, all your tx will be sent at this speed TransactionSpeed.FAST ); let chain = await relayer.getViemChain(); export const walletClient = createWalletClient({ account: await relayer.address(), chain, transport: custom(relayer.ethereumProvider()), }); export const publicClient = createPublicClient({ chain, transport: await client.getViemHttp(chain.id), }); ``` -------------------------------- ### Install rrelayer SDK using PNPM Source: https://github.com/joshstevens19/rrelayer/blob/master/sdk/typescript/README.md This snippet shows how to install the rrelayer SDK using the PNPM package manager. PNPM is an alternative to NPM known for its efficient disk space usage and faster installs. ```bash pnpm i rrelayer ``` -------------------------------- ### Install rrelayer CLI Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/getting-started/installation.mdx Installs the rrelayer command-line interface. Supports installing the latest version or a specific version. Requires Git BASH or WSL on Windows. ```bash curl -L https://rrelayer.xyz/install.sh | bash ``` ```bash curl -L https://rrelayer.xyz/install.sh | bash -s -- --version ``` -------------------------------- ### Install rrelayer CLI Source: https://github.com/joshstevens19/rrelayer/blob/master/crates/cli/README.md Installs the rrelayer CLI using a curl script. This method is recommended for most users. Note that Windows users require Git BASH or WSL for installation. ```bash curl -L https://rrelayer.xyz/install.sh | bash ``` -------------------------------- ### Install rrelayer SDK using NPM Source: https://github.com/joshstevens19/rrelayer/blob/master/sdk/typescript/README.md This snippet demonstrates how to install the rrelayer SDK using the Node Package Manager (NPM). This is a common method for integrating JavaScript/TypeScript libraries into a project. ```bash npm i rrelayer ``` -------------------------------- ### Rust Create Relayer Client Example Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/sdk/relayers/rust.mdx Provides an asynchronous function `get_relayer_client` to create and configure a `RelayerClient`. It demonstrates setting up the server URL, Relayer ID, API key, and optionally transaction speed. The `example` function shows how to use this client to fetch relayer information. ```rust use anyhow::Result; use rrelayer::{ create_relayer_client, CreateRelayerClientConfig, Relayer, RelayerClient, RelayerId, TransactionSpeed, }; use std::str::FromStr; async fn get_relayer_client() -> Result { let relayer: RelayerClient = create_relayer_client(CreateRelayerClientConfig { server_url: "http://localhost:8000".to_string(), relayer_id: RelayerId::from_str("94afb207-bb47-4392-9229-ba87e4d783cb")?, api_key: "YOUR_API_KEY".to_string(), // This is optional it defaults to fast and is a fallback // You can override this with the transaction request speed: Some(TransactionSpeed::FAST), }); Ok(relayer) } async fn example() -> Result<()> { let relayer_client = get_relayer_client().await?; let result: Relayer = relayer_client.get_info().await?; println!("{:?}", result); Ok(()) } ``` -------------------------------- ### rrelayer.yaml Advanced Configuration Example Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/config/index.mdx An example of an advanced rrelayer.yaml configuration file. This file defines network settings, automatic top-up configurations for native and ERC20 tokens, and permissions for relayers. It also includes webhook configurations and rate limits. ```yaml name: first-rrelayer description: 'my first rrelayer' api_config: port: 3000 authentication_username: ${RRELAYER_AUTH_USERNAME} authentication_password: ${RRELAYER_AUTH_PASSWORD} signing_provider: aws_secret_manager: id: 'testing-josh-relayer' key: 'seed' region: 'eu-west-1' networks: - name: sepolia_ethereum chain_id: 11155111 provider_urls: - https://sepolia.gateway.tenderly.co block_explorer_url: https://sepolia.etherscan.io max_gas_price_multiplier: 4 gas_bump_blocks_every: slow: 10 medium: 5 fast: 4 super_fast: 2 automatic_top_up: from: relayer: address: '0x655B2B8861D7E911D283A05A5CAD042C157106DA' internal_only: false relayers: - '0x1C09DF15FB12656420033EB58067EC9406EF0E26' - '0x6F3E343161C4B905342015AD20A5C492ADFB730E' - '0x68333AE8A21E1F768B20DB409486BE2D569A5258' native: min_balance: '50' top_up_amount: '100' erc20_tokens: - address: '0x99bba657f2bbc93c02d617f8ba121cb8fc104acf' min_balance: '100' top_up_amount: '500' permissions: - relayers: - '0x1c09df15fb12656420033eb58067ec9406ef0e26' allowlist: - '0x70997970C51812dc3A010C7d01b50e0d17dc79C8' disable_native_transfer: false - relayers: - '0x6f3e343161c4b905342015ad20a5c492adfb730e' allowlist: - '0x70997970C51812dc3A010C7d01b50e0d17dc79C8' - '0x70e0ba845a1a0f2da3359c97e0285013525ffc49' disable_native_transfer: true disable_personal_sign: false disable_typed_data_sign: false disable_transactions: false - relayers: - '0x6f3e343161c4b905342015ad20a5c492adfb730c' api_keys: - ${API_KEY_1} - ${API_KEY_2} disable_native_transfer: true webhooks: - endpoint: http://localhost:8546/webhook shared_secret: ${RRELAYER_WEBHOOK_SHARED_SECRET} networks: - sepolia_ethereum rate_limits: user_limits: per_relayer: interval: 'minute' transactions: 1 signing_operations: 1 global: interval: 'minute' transactions: 3 signing_operations: 3 ``` -------------------------------- ### Send Transaction with Viem Wallet Client Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/sdk/framework-guides/typescript/viem.mdx Sends a cryptocurrency transaction using the Viem wallet client. This example shows sending Ether to a specified address. Ensure the wallet client is properly initialized and has sufficient funds. ```typescript import { walletClient } from './config'; const hash = await walletClient.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }); ``` -------------------------------- ### Example rrelayer Project Initialization Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/getting-started/create-new-project.mdx Demonstrates the interactive process of creating a new rrelayer project. Shows user inputs for project name, description, and Docker support, followed by a success message. ```bash Initializing new rrelayer project... Enter project name: MyFirstRelayer Enter project description (skip by pressing Enter): My first rrelayer project Do you want Docker support out of the box (will make it easy to run)? [Y/n]: Y Project 'MyFirstRelayer' initialized successfully! note we advise to not use the RAW_DANGEROUS_MNEMONIC in production and use one of the secure key management signing keys. Alongside replace RRELAYER_AUTH_USERNAME and RRELAYER_AUTH_PASSWORD in the .env ``` -------------------------------- ### Initialize and Deploy Railway Project (Bash) Source: https://github.com/joshstevens19/rrelayer/blob/master/providers/railway/README.md Initializes a new Railway project named 'rrelayer-example', logs into the Railway CLI, and deploys the project with a detached service. It also adds a PostgreSQL database to the project. ```bash railway login railway init --name rrelayer-example railway up --detach railway link --name rrelayer-example --environment production railway add --database postgres ``` -------------------------------- ### Get Allowlist Addresses Example Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/api/relayers.mdx Provides an example of how to retrieve the list of allowed recipient addresses for a specific relayer. This is done via a GET request to the allowlists endpoint, requiring authentication. ```bash curl https://your-rrelayer.com/relayers/6ba7b810-9dad-11d1-80b4-00c04fd430c8/allowlists \ -u "username:password" ``` -------------------------------- ### Install rrelayer using npm, pnpm, or bun Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/sdk/installation/node.mdx Install the rrelayer package using your preferred Node.js package manager. This snippet shows the installation commands for npm, pnpm, and bun, ensuring compatibility with different project setups. ```bash npm i rrelayer ``` ```bash pnpm i rrelayer ``` ```bash bun i rrelayer ``` -------------------------------- ### Start rrelayer Project with Docker Integration Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/getting-started/create-new-project.mdx This command initiates the rrelayer project. It automatically starts the PostgreSQL Docker Compose file if the database connection fails and a docker-compose.yml is present. Ensure Docker is running before executing this command. The output logs show the startup process, including Docker container management, database schema application, gas price collection, and the relayer becoming available. ```bash rrelayer start ``` -------------------------------- ### curl Example for GET /transactions/status/{transaction_id} Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/api/transactions.mdx Example of how to use curl to check the status of a transaction using the RRelayer API. Requires basic authentication. ```bash curl https://your-rrelayer.com/transactions/status/550e8400-e29b-41d4-a716-446655440000 \ -u "username:password" ``` -------------------------------- ### Basic Auth Setup and Allowlist Retrieval (TypeScript) Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/sdk/relayers/node.mdx Demonstrates how to configure the rrelayer client using Basic Authentication with username and password loaded from environment variables. It also shows how to retrieve an allowlist using the configured client. Dependencies include 'rrelayer' and 'dotenv'. ```typescript // config.ts import { createClient, TransactionSpeed } from 'rrelayer'; import * as dotenv from "dotenv"; dotenv.config(); const client = createClient({ serverUrl: 'http://localhost:8000', auth: { username: process.env.RRELAYER_AUTH_USERNAME!, password: process.env.RRELAYER_AUTH_PASSWORD!, }, }); export const relayerClient = await client.getRelayerClient( // The relayer id you want to connect to '94afb207-bb47-4392-9229-ba87e4d783cb', // This is optional it defaults to fast and is a fallback // You can override this with the transaction request TransactionSpeed.FAST ); ... // get-allowlist.ts import { relayerClient } from './config'; // returns a PagingResult<`0x${string}`> - import { PagingResult } from 'rrelayer'; let allowlist = await relayerClient.allowlist.get({ limit: 100, offset: 0, }); ``` -------------------------------- ### curl Example for GET /transactions/{transaction_id} Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/api/transactions.mdx Example of how to use curl to fetch transaction details from the RRelayer API. Requires basic authentication with username and password. ```bash curl https://your-rrelayer.com/transactions/550e8400-e29b-41d4-a716-446655440000 \ -u "username:password" ``` -------------------------------- ### Docker Usage: Running Rrelayer with an Existing Project Source: https://github.com/joshstevens19/rrelayer/blob/master/README.md Illustrates how to run rrelayer with an existing project using Docker. It requires setting the `PROJECT_PATH` environment variable to point to the project directory and then mounts this path into the container. The `start` command initiates the rrelayer service for the specified project. ```bash export PROJECT_PATH=/path/to/your/project docker run -it -v $PROJECT_PATH:/app/project ghcr.io/joshstevens19/rrelayer start ``` -------------------------------- ### Get Application URL using NodePort (Kubectl) Source: https://github.com/joshstevens19/rrelayer/blob/master/helm/rrelayer/templates/NOTES.txt This command sequence retrieves the application URL for a Kubernetes service of type NodePort. It exports the NodePort and Node IP, then echoes the constructed URL. It relies on `kubectl` being installed and configured, and the service type being 'NodePort'. ```bash export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "rrelayer.fullname" . }}) export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORT ``` -------------------------------- ### Set Privy Credentials in .env File Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/config/signing-providers/privy.mdx This example demonstrates how to set the Privy `app_id` and `app_secret` as environment variables in a `.env` file. These credentials are required for Privy to authenticate and manage wallets for your application. ```bash PRIVY_APP_ID=YOUR_PRIVY_APP_ID PRIVY_APP_SECRET=YOUR_PRIVY_APP_SECRET ``` -------------------------------- ### Sign Text with Viem Wallet Client Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/sdk/framework-guides/typescript/viem.mdx Signs a given string message using the Viem wallet client obtained from rrelayer-ts. This function requires the wallet client to be previously configured with authentication details. ```typescript import { walletClient } from './config'; const message = await walletClient.signMessage({ message: 'sign me!', }); ``` -------------------------------- ### Rust Basic Auth Client Setup and Usage Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/sdk/sign/rust.mdx Demonstrates how to set up an AdminRelayerClient using basic authentication (username and password from environment variables) and then performs a sample API call to fetch signed typed data history. It requires the 'rrelayer' and 'anyhow' crates, and uses 'dotenvy' for environment variable loading. ```rust use anyhow::Result; use rrelayer::{ AdminRelayerClient, CreateClientAuth, CreateClientConfig, PagingContext, PagingResult, RelayerId, SignedTypedDataHistory, TransactionSpeed, create_client, }; use std::str::FromStr; use dotenvy::dotenv; use std::env; async fn get_relayer_client() -> Result { dotenv().ok(); let username = env::var("RRELAYER_AUTH_USERNAME") .expect("RRELAYER_AUTH_USERNAME must be set"); let password = env::var("RRELAYER_AUTH_PASSWORD") .expect("RRELAYER_AUTH_PASSWORD must be set"); let client = create_client(CreateClientConfig { server_url: "http://localhost:8000".to_string(), auth: CreateClientAuth { username, password, }, }); let relayer_client: AdminRelayerClient = client .get_relayer_client( &RelayerId::from_str("94afb207-bb47-4392-9229-ba87e4d783cb")?, // This is optional it defaults to fast and is a fallback // You can override this with the transaction request Some(TransactionSpeed::FAST), ) .await?; Ok(relayer_client) } async fn example() -> Result<()> { let relayer_client = get_relayer_client().await?; let result: PagingResult = relayer_client.sign().typed_data_history(&PagingContext { limit: 100, offset: 0 }).await?; println!("{:?}", result); Ok(()) } ``` -------------------------------- ### Get Relayer Information with TypeScript Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/sdk/relayers/node.mdx Retrieves information about a specific relayer using the rrelayer client. This function returns a promise that resolves to a Relayer object or null if the relayer is not found. Ensure the 'rrelayer' package is installed and configured correctly. ```typescript import { createRelayerClient, TransactionSpeed, Relayer } from 'rrelayer'; export let relayerClient = createRelayerClient({ serverUrl: 'http://localhost:8000', relayerId: '94afb207-bb47-4392-9229-ba87e4d783cb', apiKey: 'YOUR_API_KEY', speed: TransactionSpeed.FAST, }); // get-relayer.ts // returns a Relayer | null let info: Relayer | null = await relayerClient.getInfo(); ``` -------------------------------- ### Initialize and Deploy Railway Project Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/deploying/railway.mdx Initializes a new Railway project and deploys the service. This involves logging into Railway, creating a project with a specified name, and then deploying the service detached. ```bash railway login railway init --name rrelayer-example railway up --detach railway link ``` -------------------------------- ### Sign Typed Data with Viem Wallet Client Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/sdk/framework-guides/typescript/viem.mdx Signs structured data (typed data) using the Viem wallet client. This is useful for more complex signing scenarios where data has a specific schema. Ensure the wallet client is correctly configured. ```typescript import { walletClient } from './config'; const signature = await walletClient.signTypedData({ domain: { name: 'Ether Mail', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC', }, types: { Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' }, ], Mail: [ { name: 'from', type: 'Person' }, { name: 'to', type: 'Person' }, { name: 'contents', type: 'string' }, ], }, primaryType: 'Mail', message: { from: { name: 'Cow', wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826', }, to: { name: 'Bob', wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', }, contents: 'Hello, Bob!', }, }); ``` -------------------------------- ### Complete RRelayer Production Configuration with HSM Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/config/signing-providers/pkcs11.mdx A full example of RRelayer configuration for a production environment using a PKCS#11 HSM. This setup specifies the necessary parameters for connecting to and utilizing the hardware security module for signing operations. ```yaml name: production-rrelayer description: 'Production rrelayer with HSM' api_config: port: 3000 authentication_username: ${RRELAYER_AUTH_USERNAME} authentication_password: ${RRELAYER_AUTH_PASSWORD} signing_provider: pkcs11: library_path: '/usr/lib/pkcs11/cloudhsm-pkcs11.so' pin: '${HSM_PIN}' slot_id: 1 identity: 'prod-relay-01' ``` -------------------------------- ### Create Relayer SDK Example in Rust Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/sdk/relayers/rust.mdx Demonstrates how to create a new relayer using the rrelayer SDK. It includes setting up authentication, configuring the client, and making the create relayer call. Requires environment variables for authentication credentials. ```rust use anyhow::Result; use rrelayer::{ Client, CreateClientAuth, CreateClientConfig, CreateRelayerResult, TransactionSpeed, create_client, }; use dotenvy::dotenv; use std::env; async fn get_client() -> Result { dotenv().ok(); let username = env::var("RRELAYER_AUTH_USERNAME") .expect("RRELAYER_AUTH_USERNAME must be set"); let password = env::var("RRELAYER_AUTH_PASSWORD") .expect("RRELAYER_AUTH_PASSWORD must be set"); let client = create_client(CreateClientConfig { server_url: "http://localhost:8000".to_string(), auth: CreateClientAuth { username, password, }, }); Ok(client) } async fn example() -> Result<()> { let client = get_client().await?; let result: CreateRelayerResult = client.relayer().create(11155111, "fancy_relayer").await?; println!("{:?}", result); let relayer_client = client.get_relayer_client(&result.id, Some(TransactionSpeed::FAST)).await?; Ok(()) } ``` -------------------------------- ### Basic Auth - Rust SDK Configuration Source: https://github.com/joshstevens19/rrelayer/blob/master/crates/sdk/README.md Configures and creates a relayer client using basic authentication with username and password from environment variables. This method provides access to administrative functions. It requires the `dotenvy` crate for loading environment variables and the `rrelayer` crate for client creation. ```rust use std::str::FromStr; use rrelayer::{CreateClientAuth, CreateClientConfig, RelayerId, TransactionSpeed, create_client, AdminRelayerClient}; use dotenvy::dotenv; use std::env; // Client also exposes some admin methods in which API keys cannot do let client = create_client(CreateClientConfig { server_url: "http://localhost:8000".to_string(), auth: CreateClientAuth { username: env::var("RRELAYER_AUTH_USERNAME") .expect("RRELAYER_AUTH_USERNAME must be set"), password: env::var("RRELAYER_AUTH_PASSWORD") .expect("RRELAYER_AUTH_PASSWORD must be set"), }, }); let relayer: AdminRelayerClient = client.get_relayer_client( &RelayerId::from_str("94afb207-bb47-4392-9229-ba87e4d783cb")?, Some(TransactionSpeed::FAST), ).await?; ``` -------------------------------- ### Use Custom Rate Limit Key in Bash Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/api/transactions.mdx This example shows how to send a transaction using `curl` and specify a custom rate limiting key via the `x-rrelayer-rate-limit-key` header. This allows for granular control over rate limiting per user or client. Requires `curl` to be installed and network access to the rrelayer. ```bash curl -X POST https://your-rrelayer.com/transactions/relayers/0x742d35.../send \ -H "x-rrelayer-rate-limit-key: user-12345" \ -u "username:password" \ -H "Content-Type: application/json" \ -d '{"to": "0x...", "value": "1000000000000000000"}' ``` -------------------------------- ### Basic Authentication Example (cURL) Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/api/authentication.mdx Demonstrates how to use cURL for Basic Authentication with RRelayer. It shows the command-line usage and the expected Authorization header format. Basic authentication is configured via rrelayer.yaml. ```bash curl https://your-rrelayer.com/relayers \ -u "username:password" ``` ```text Authorization: Basic ``` ```yaml api_config: port: 3000 authentication_username: '${RRELAYER_AUTH_USERNAME}' authentication_password: '${RRELAYER_AUTH_PASSWORD}' ``` -------------------------------- ### Create Client with Basic Authentication Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/sdk/create-client-authentication/rust.mdx This snippet demonstrates how to create an AdminRelayerClient using basic authentication with a username and password. It retrieves credentials from environment variables and configures the server URL. This client provides access to admin methods not available with API keys. ```rust use std::str::FromStr; use rrelayer::{CreateClientAuth, CreateClientConfig, RelayerId, TransactionSpeed, create_client, AdminRelayerClient}; use dotenvy::dotenv; use std::env; // Client also exposes some admin methods in which API keys cannot do async fn get_client() -> Result { let client = create_client(CreateClientConfig { server_url: "http://localhost:8000".to_string(), auth: CreateClientAuth { username: env::var("RRELAYER_AUTH_USERNAME") .expect("RRELAYER_AUTH_USERNAME must be set"), password: env::var("RRELAYER_AUTH_PASSWORD") .expect("RRELAYER_AUTH_PASSWORD must be set"), }, }); Ok(client) } // create the admin relayer client - you use this to send transactions async fn get_relayer_client() -> Result { let client = get_client(); let relayer_client: AdminRelayerClient = client .get_relayer_client( &RelayerId::from_str("94afb207-bb47-4392-9229-ba87e4d783cb")?, // This is optional it defaults to fast and is a fallback // You can override this with the transaction request Some(TransactionSpeed::FAST), ) .await?; Ok(relayer_client) } ``` -------------------------------- ### Docker Deployment: Pre-built Image Source: https://context7.com/joshstevens19/rrelayer/llms.txt Demonstrates how to deploy and utilize the rrelayer service using a pre-built Docker image from GitHub Container Registry (ghcr.io). Includes commands for pulling the image, running CLI commands within a container, creating new projects, and starting the relayer service with persistent storage. ```bash # Pull image docker pull ghcr.io/joshstevens19/rrelayer # Run CLI commands docker run -it -v $PWD:/app/project ghcr.io/joshstevens19/rrelayer --help # Create new project docker run -it -v $PWD:/app/project ghcr.io/joshstevens19/rrelayer new # Start relayer service export PROJECT_PATH=/path/to/your/project docker run -it -v $PROJECT_PATH:/app/project ghcr.io/joshstevens19/rrelayer start ``` -------------------------------- ### Send EIP-1559 Transaction Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/integration/sdk/framework-guides/rust/alloy.mdx This example shows how to send an EIP-1559 transaction using Alloy and the `RelayerProvider`. It fetches EIP-1559 fee estimates (base fee and priority fee) to construct the transaction. Key dependencies are `alloy`, `rrelayer`, `tokio`, and `eyre`. The function requires access to blockchain fee data and a signer. ```rust use alloy::{ primitives::{Address, U256}, providers::{ProviderBuilder, Provider}, rpc::types::TransactionRequest, network::TransactionBuilder, }; use rrelayer::with_relayer; use std::str::FromStr; use eyre::Result; #[tokio::main] async fn main() -> Result<()> { let signer = create_relayer_signer().await?; // Create HTTP provider let rpc_url = "https://eth.llamarpc.com".parse()?; let http_provider = ProviderBuilder::new().on_http(rpc_url); let relayer_provider = with_relayer(http_provider, signer.clone()); let to = Address::from_str("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045")?; let value = U256::from(500000000000000000u64); // 0.5 ETH // Get EIP-1559 fee estimates let fee_history = relayer_provider.inner().get_fee_history(10, "latest".into(), &[25.0]).await?; let base_fee = fee_history.base_fee_per_gas.last().unwrap(); let max_priority_fee = U256::from(2_000_000_000u64); // 2 gwei tip let max_fee = base_fee * 2 + max_priority_fee; // 2x base fee + tip // Get nonce let nonce = relayer_provider.inner().get_transaction_count(signer.address()).await?; // Build EIP-1559 transaction let tx_request = TransactionRequest::default() .with_from(signer.address()) .with_to(to) .with_value(value) .with_gas_limit(21000) .with_max_fee_per_gas(max_fee) .with_max_priority_fee_per_gas(max_priority_fee) .with_nonce(nonce); println!("📋 EIP-1559 Transaction:"); println!(" Base Fee: {} gwei", base_fee / U256::from(1_000_000_000u64)); println!(" Max Fee: {} gwei", max_fee / U256::from(1_000_000_000u64)); println!(" Priority Fee: {} gwei", max_priority_fee / U256::from(1_000_000_000u64)); // Send via relayer using the TransactionRequest let tx_id = relayer_provider .send_transaction(&tx_request) .await?; println!("✅ EIP-1559 transaction sent: {}", tx_id); Ok(()) } ``` -------------------------------- ### Create and Use RRelayer Client (TypeScript) Source: https://github.com/joshstevens19/rrelayer/blob/master/documentation/rrelayer/docs/pages/getting-started/create-new-project.mdx Demonstrates how to create an RRelayer client instance using environment variables for authentication and then use it to sign a text message. Ensure you have the 'rrelayer' package installed and your environment variables (RRELAYER_AUTH_USERNAME, RRELAYER_AUTH_PASSWORD) are set. ```typescript // config.ts import { createClient } from 'rrelayer'; import * as dotenv from "dotenv"; dotenv.config(); const client = createClient({ serverUrl: 'http://localhost:8000', auth: { username: process.env.RRELAYER_AUTH_USERNAME!, password: process.env.RRELAYER_AUTH_PASSWORD!, }, }); export const relayerClient = await client.getRelayerClient( // The relayer id you want to connect to '94afb207-bb47-4392-9229-ba87e4d783cb', // This is optional it defaults to fast and is a fallback // You can override this with the transaction request TransactionSpeed.FAST ); ... // sign-text.ts import { relayerClient } from './config'; // Using a framework like viem and ethers is recommended here. Look under framework guides > TypeScript for them. // returns a SignTextResult - import { SignTextResult } from 'rrelayer'; let result = await relayerClient.sign.text('sign this message'); console.log(result) // result { // messageSigned: "Hello, World! Please sign this message to authenticate.", // signature: "0x8f3e5d2a1c4b7e9f6d8a2c5e1f4b7d9a3c6e8f1a4b7d9e2c5f8a1d4e7b9c2f5a8d1e4b7c9f2a5d8e1b4c7f9a2e5d8b1f4c7e9d2a5f8e1c4b7d9f2a5e8c1b", // signedBy: "0x7a0f605c8366373764760673020b6b2d8574f3f2" // } ``` -------------------------------- ### Get Gas Prices with rrelayer Client Source: https://context7.com/joshstevens19/rrelayer/llms.txt Fetches current gas prices for a specified network, primarily Ethereum mainnet in the example. It returns the base fee, maximum priority fee per gas, and maximum fee per gas. Handles cases where gas prices might not be available. ```typescript // Get current gas prices for network const gasPrices = await client.network.getGasPrices(1); // Ethereum mainnet if (gasPrices) { console.log('Base fee:', gasPrices.baseFee); console.log('Max priority fee:', gasPrices.maxPriorityFeePerGas); console.log('Max fee per gas:', gasPrices.maxFeePerGas); } ```