### Basic Escrow Deployment Example Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/smart-escrows.md Example of a basic smart escrow deployment with destination, amount, wallet, and network specified. ```bash bedrock escrow deploy --destination rXXX... --amount 1000000 --wallet sXXX... --network local ``` -------------------------------- ### Quick Start: Smart Contract Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/getting-started.md Initialize, build, and deploy a Smart Contract project. ```bash bedrock init my-contract --primitives contract && cd my-contract bedrock node start bedrock build bedrock deploy --network local # Note the contract address and wallet seed bedrock call hello --wallet --network local ``` -------------------------------- ### Quick Start: Smart Escrow Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/getting-started.md Initialize, build, and manage a Smart Escrow project. ```bash bedrock init my-escrow --primitives escrow && cd my-escrow bedrock node start bedrock build bedrock escrow deploy --destination --amount 1000000 --wallet --network local bedrock escrow status --network local bedrock escrow finish --wallet --network local ``` -------------------------------- ### Initialize Development Environment Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/local-node.md Workflow for creating a new project and starting the local node. ```bash bedrock init my-contract cd my-contract bedrock node start bedrock node status # WebSocket: ws://localhost:6006 ``` -------------------------------- ### Bedrock Development Workflow (Bash) Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/smart-vaults.md A step-by-step guide for developing and deploying smart vaults using Bedrock, covering project creation, local node setup, building, funding, deployment, and interaction. ```bash # 1. Create project bedrock init my-vault --primitives vault && cd my-vault # 2. Start local node bedrock node start # 3. Edit vault logic # vault/src/lib.rs # 4. Build bedrock build # 5. Fund a wallet bedrock faucet --network local # 6. Deploy bedrock vault deploy --asset XRP --wallet --network local # 7. Deposit bedrock vault deposit --amount 1000000 --wallet --network local # 8. Check status bedrock vault status --network local # 9. Withdraw bedrock vault withdraw \ --amount 500000 \ --destination
\ --wallet \ --network local ``` -------------------------------- ### Install Bedrock from Source Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/getting-started.md Clone the repository and build the Bedrock binary manually. ```bash # Clone the repository git clone https://github.com/XRPL-Commons/bedrock.git cd bedrock # Build and install go build -o bedrock cmd/bedrock/main.go sudo mv bedrock /usr/local/bin/ # Verify installation bedrock --help ``` -------------------------------- ### Install Rust Source: https://github.com/xrpl-commons/bedrock/blob/main/README.md Use the official rustup script to install the Rust toolchain. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` -------------------------------- ### Install Rust Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/getting-started.md Install the Rust toolchain if it is not already present on the system. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source $HOME/.cargo/env ``` -------------------------------- ### Bedrock Configuration Files Source: https://github.com/xrpl-commons/bedrock/blob/main/llms.txt Configuration examples for different project types. ```toml [project] name = "my-contract" version = "0.1.0" primitives = ["contract"] [build] source = "contract/src/lib.rs" output = "contract/target/wasm32-unknown-unknown/release" target = "wasm32-unknown-unknown" [contracts.main] source = "contract/src/lib.rs" abi = "contract/build/abi.json" [local_node] config_dir = ".bedrock/node-config" docker_image = "transia/cluster:latest" ledger_interval = 1000 [networks.local] url = "ws://localhost:6006" network_id = 63456 faucet_url = "http://localhost:8080/faucet" [networks.alphanet] url = "wss://alphanet.nerdnest.xyz" network_id = 21465 faucet_url = "https://alphanet.faucet.nerdnest.xyz/accounts" ``` ```toml [project] name = "my-escrow" version = "0.1.0" primitives = ["escrow"] [escrows.main] source = "escrow/src/lib.rs" output = "escrow/target/wasm32v1-none/release" [local_node] docker_image = "willemolding/rippled:smart-vaults.0" ``` ```toml [project] name = "my-vault" version = "0.1.0" primitives = ["vault"] [vaults.main] source = "vault/src/lib.rs" output = "vault/target/wasm32v1-none/release" [local_node] docker_image = "willemolding/rippled:smart-vaults.0" ``` -------------------------------- ### Install Bedrock Binary Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/getting-started.md Download and install the latest Bedrock release binary to /usr/local/bin/. ```bash curl -sSfL https://raw.githubusercontent.com/XRPL-Commons/Bedrock/main/install.sh | sh ``` -------------------------------- ### Configure Bedrock Project Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/smart-escrows.md Example structure for the bedrock.toml configuration file. ```toml [project] name = "my-escrow" version = "0.1.0" primitives = ["escrow"] [escrows.main] source = "escrow/src/lib.rs" output = "escrow/target/wasm32v1-none/release" [local_node] config_dir = ".bedrock/node-config" docker_image = "willemolding/rippled:smart-vaults.0" ledger_interval = 1000 [networks.local] url = "ws://localhost:6006" network_id = 63456 faucet_url = "http://localhost:8080/faucet" [networks.alphanet] url = "wss://alphanet.nerdnest.xyz" network_id = 21465 faucet_url = "https://alphanet.faucet.nerdnest.xyz/accounts" [wallets] keystore = ".wallets/keystore.json" ``` -------------------------------- ### Initialize and Deploy Smart Contract Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/quick-reference.md Initializes a new contract project, starts the local node, and deploys to the local network. ```bash bedrock init my-app --primitives contract && cd my-app bedrock node start bedrock deploy --network local bedrock call hello --wallet --network local ``` -------------------------------- ### Quick Start: Smart Vault Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/getting-started.md Initialize, build, and manage a Smart Vault project. ```bash bedrock init my-vault --primitives vault && cd my-vault bedrock node start bedrock build bedrock vault deploy --asset XRP --wallet --network local bedrock vault deposit --amount 1000000 --wallet --network local bedrock vault status --network local ``` -------------------------------- ### Start Local XRPL Node Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/local-node.md Initializes and starts the local rippled Docker container based on bedrock.toml configuration. ```bash bedrock node start ``` -------------------------------- ### Initialize a Bedrock project Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/commands-reference.md Create a new project directory using the init command. Use flags to specify primitives or templates, or run without flags for an interactive setup. ```bash bedrock init [project-name] [flags] ``` ```bash bedrock init my-project # Interactive bedrock init my-contract --primitives contract # Smart contract bedrock init my-escrow --primitives escrow # Smart escrow bedrock init my-vault --primitives vault # Smart vault bedrock init my-project --primitives contract,escrow # Multiple primitives bedrock init my-vault -p vault -t vault-whitelist # With template ``` -------------------------------- ### Configure Local Node Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/local-node.md Example configuration for the local node within bedrock.toml. ```toml [local_node] config_dir = ".bedrock/node-config" docker_image = "transia/cluster:latest" ledger_interval = 1000 ``` -------------------------------- ### Verify Prerequisites Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/getting-started.md Check that the required development tools are installed and meet the minimum version requirements. ```bash go version # Should show 1.21+ node --version # Should show v18+ rustc --version # Should show 1.70+ cargo --version ``` -------------------------------- ### Start, Status, Logs, and Stop Local XRPL Node Source: https://context7.com/xrpl-commons/bedrock/llms.txt Manage a local XRPL development node running in Docker. This command group allows starting, checking the status, viewing logs, and stopping the isolated node environment. Docker is a prerequisite. ```bash # Start local XRPL node (requires Docker) bedrock node start # Check node status bedrock node status # Output: # Local XRPL Node Status # =================================== # Status: Running # Container: a1b2c3d4e5f6 # Image: transia/alphanet:latest # Ports: # - 6006->6006/tcp (WebSocket) # - 5005->5005/tcp (JSON-RPC) # - 51235->51235/tcp (Peer) # # Endpoints: # WebSocket: ws://localhost:6006 # RPC: http://localhost:5005 # View container logs bedrock node logs # Stop the local node bedrock node stop # Local node endpoints available after start: # - WebSocket: ws://localhost:6006 # - Faucet: http://localhost:8080/faucet # Example: Connect from JavaScript # const { Client } = require('@transia/xrpl'); # const client = new Client('ws://localhost:6006'); # await client.connect(); ``` -------------------------------- ### Complete Bedrock Smart Contract Example Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/abi-generation.md A full implementation example showing how to integrate Bedrock ABI annotations with the #[wasm_export] macro in a Rust smart contract. This demonstrates the standard structure for defining multiple functions with parameters and return types. ```rust #![cfg_attr(target_arch = "wasm32", no_std)] #[cfg(not(target_arch = "wasm32"))] extern crate std; use xrpl_wasm_macros::wasm_export; use xrpl_wasm_std::host::trace::trace; /// @xrpl-function register /// @flag 0 /// @param name VL - Domain name to register /// @param resolver ACCOUNT - Resolver address /// @flag 1 /// @param duration UINT64 - Registration duration in seconds /// @return UINT32 - Status code #[wasm_export] fn register(name: Blob, resolver: AccountId, duration: u64) -> u32 { let _ = trace("Registering domain..."); 0 } /// @xrpl-function transfer /// @param name VL - Domain name to transfer /// @param new_owner ACCOUNT - New owner address #[wasm_export] fn transfer(name: Blob, new_owner: AccountId) -> i32 { let _ = trace("Transferring domain..."); 0 } ``` -------------------------------- ### Escrow Deployment with Time Constraints Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/smart-escrows.md Deploy a smart escrow with time-based constraints for cancellation and finishing. This example uses the alphanet network. ```bash bedrock escrow deploy --destination rXXX... --amount 1000000 \ --cancel-after 1234567 --finish-after 1234000 \ --wallet sXXX... --network alphanet ``` -------------------------------- ### Build and Run Local Node Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/smart-vaults.md Compile the WASM logic and start a local XRPL node configured for smart vault development. ```bash bedrock build ``` ```bash bedrock node start ``` -------------------------------- ### Verify Docker Status Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/smart-escrows.md Ensure Docker is running before starting the node. Use `docker ps` to check. ```bash docker ps ``` -------------------------------- ### Bedrock TOML Configuration Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/smart-vaults.md Example configuration file for a Bedrock vault project, specifying project details, vault sources, local node settings, and network configurations. ```toml [project] name = "my-vault" version = "0.1.0" primitives = ["vault"] [vaults.main] source = "vault/src/lib.rs" output = "vault/target/wasm32v1-none/release" [local_node] config_dir = ".bedrock/node-config" docker_image = "willemolding/rippled:smart-vaults.0" ledger_interval = 1000 [networks.local] url = "ws://localhost:6006" network_id = 63456 faucet_url = "http://localhost:8080/faucet" [networks.alphanet] url = "wss://alphanet.nerdnest.xyz" network_id = 21465 faucet_url = "https://alphanet.faucet.nerdnest.xyz/accounts" [wallets] keystore = ".wallets/keystore.json" ``` -------------------------------- ### Check Node.js version Source: https://github.com/xrpl-commons/bedrock/blob/main/CLAUDE.md Displays the installed Node.js version to ensure it meets the project's requirement (18+). ```bash node --version ``` -------------------------------- ### Initialize Project Source: https://github.com/xrpl-commons/bedrock/blob/main/README.md Create a new smart contract project structure. ```bash bedrock init my-contract cd my-contract ``` -------------------------------- ### Initialize and Manage Smart Escrow Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/quick-reference.md Sets up an escrow project, builds the primitive, and handles deployment and finalization. ```bash bedrock init my-escrow --primitives escrow && cd my-escrow bedrock node start bedrock build bedrock escrow deploy --destination --amount 1000000 --wallet --network local bedrock escrow finish --wallet --network local ``` -------------------------------- ### Initialize a New Escrow Project Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/smart-escrows.md Use this command to create a new escrow project with the necessary primitives. Navigate into the created directory to proceed. ```bash bedrock init my-escrow --primitives escrow cd my-escrow ``` -------------------------------- ### Initialize a Project Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/getting-started.md Create a new project using interactive mode or by specifying primitives and templates directly. ```bash # Interactive mode — prompts you to select a primitive bedrock init my-project # Or specify directly bedrock init my-contract --primitives contract bedrock init my-escrow --primitives escrow bedrock init my-vault --primitives vault # With a specific template bedrock init my-vault --primitives vault --template vault-whitelist # Multiple primitives in one project bedrock init my-project --primitives contract,escrow ``` -------------------------------- ### CLI Command: init Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/commands-reference.md Initializes a new Bedrock project directory with optional primitives and templates. ```APIDOC ## CLI Command: init ### Description Creates a new Bedrock project directory. Can be run in interactive mode or with specific primitives and templates. ### Usage `bedrock init [project-name] [flags]` ### Parameters - **project-name** (string) - Required - Name of the project directory to create - **--primitives** (string) - Optional - Comma-separated primitives (contract, escrow, vault) - **--template** (string) - Optional - Project template ``` -------------------------------- ### Initialize Escrow Project Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/smart-escrows.md Command to initialize a new escrow project using the oracle template. ```bash bedrock init my-escrow --primitives escrow --template escrow-oracle ``` -------------------------------- ### Deploy Options Source: https://github.com/xrpl-commons/bedrock/blob/main/README.md Configure deployment behavior and network targets. ```bash bedrock deploy # Smart deploy (auto-build + ABI) bedrock deploy --skip-build # Skip building bedrock deploy --skip-abi # Skip ABI generation bedrock deploy --network alphanet # Deploy to alphanet bedrock deploy --wallet sXXX... # Use specific wallet ``` -------------------------------- ### Install WASM Target for Contracts Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/building-contracts.md Command to add the `wasm32-unknown-unknown` target to your Rust toolchain, required for contract development. ```bash rustup target add wasm32-unknown-unknown ``` -------------------------------- ### Verify Rust Toolchain Versions Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/building-contracts.md Commands to check the installed versions of `rustc` and `cargo`, and verify that the necessary WASM targets are present. ```bash rustc --version # 1.70.0 or later cargo --version # 1.70.0 or later rustup target list | grep wasm32-unknown-unknown # (installed) rustup target list | grep wasm32v1-none # (installed, for escrow/vault) ``` -------------------------------- ### Initialize a Smart Vault Project Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/smart-vaults.md Use the Bedrock CLI to scaffold a new vault project with the required directory structure. ```bash bedrock init my-vault --primitives vault cd my-vault ``` -------------------------------- ### Install WASM Target for Escrows and Vaults Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/building-contracts.md Command to add the `wasm32v1-none` target to your Rust toolchain, necessary for building escrows and vaults. ```bash rustup target add wasm32v1-none ``` -------------------------------- ### Escrow Deployment Configuration Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/quick-reference.md Required and optional parameters for deploying a smart escrow. ```bash bedrock escrow deploy \ --destination # Beneficiary (required) --amount # Amount (required) --wallet # Wallet seed or jade name --network local # Target network --cancel-after # Cancel after time --finish-after # Finish after time ``` -------------------------------- ### CLI Command: deploy Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/commands-reference.md Deploys a smart contract to the specified XRPL network. ```APIDOC ## CLI Command: deploy ### Description Deploys a smart contract to an XRPL network. Requires a wallet and network configuration. ### Usage `bedrock deploy [flags]` ### Parameters - **--network** (string) - Optional - Target network (local, alphanet) - **--wallet** (string) - Optional - Wallet seed or jade name - **--skip-build** (boolean) - Optional - Skip automatic contract rebuild - **--skip-abi** (boolean) - Optional - Skip ABI generation - **--abi** (string) - Optional - Path to ABI file - **--algorithm** (string) - Optional - Cryptographic algorithm (secp256k1, ed25519) ``` -------------------------------- ### Check Docker container status Source: https://github.com/xrpl-commons/bedrock/blob/main/CLAUDE.md Verifies if Docker containers are running, which is a prerequisite for starting the local XRPL node. ```bash docker ps ``` -------------------------------- ### Initialize and Manage Smart Vault Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/quick-reference.md Sets up a vault project, builds the primitive, and manages deposits and withdrawals. ```bash bedrock init my-vault --primitives vault && cd my-vault bedrock node start bedrock build bedrock vault deploy --asset XRP --wallet --network local bedrock vault deposit --amount 1000000 --wallet --network local bedrock vault withdraw --amount 500000 --destination --wallet --network local ``` -------------------------------- ### Project Initialization Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/quick-reference.md Commands to initialize new Bedrock projects, including specific types like escrow and vault. ```APIDOC ## Project Initialization ### Initialize New Project ```bash bedrock init ``` ### Initialize Escrow Project ```bash bedrock init -p escrow ``` ### Initialize Vault Project ```bash bedrock init -p vault ``` ``` -------------------------------- ### Add wasm32 target for Rust builds Source: https://github.com/xrpl-commons/bedrock/blob/main/CLAUDE.md Installs the `wasm32-unknown-unknown` target for the Rust toolchain, which is necessary for compiling smart contracts to WebAssembly for the XRPL. ```bash rustup target add wasm32-unknown-unknown ``` -------------------------------- ### Deploy smart contracts Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/commands-reference.md Deploy a compiled smart contract to the XRPL network. Requires network and wallet configuration. ```bash bedrock deploy [flags] ``` ```bash bedrock deploy # Deploy to alphanet bedrock deploy --network local # Deploy to local node bedrock deploy --wallet sEd7... # Use specific wallet bedrock deploy --skip-build # Skip rebuild ``` -------------------------------- ### Define XRPL Smart Contracts in Rust Source: https://github.com/xrpl-commons/bedrock/blob/main/CLAUDE.md Example structure for a Rust smart contract using the xrpl-wasm framework. Demonstrates the use of the wasm_export macro and trace logging. ```rust #![cfg_attr(target_arch = "wasm32", no_std)] #[cfg(not(target_arch = "wasm32"))] extern crate std; use xrpl_wasm_macros::wasm_export; use xrpl_wasm_std::host::trace::trace; /// @xrpl-function my_function #[wasm_export] fn my_function() -> i32 { let _ = trace("Hello from XRPL Smart Contract!"); 0 } ``` -------------------------------- ### Build XRPL Commons Bedrock Project (Release) Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/building-contracts.md Use this command for building the project in release mode, which is the default for `bedrock build`. ```bash cargo build --target wasm32-unknown-unknown --release ``` -------------------------------- ### Contract Deployment Options Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/quick-reference.md Common flags for customizing the deployment process of smart contracts. ```bash bedrock deploy # Default (alphanet, auto-build) bedrock deploy --network local # Local node bedrock deploy --wallet # Specific wallet bedrock deploy --skip-build # Skip rebuild ``` -------------------------------- ### Execute Development Workflow Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/smart-escrows.md Standard sequence of commands for creating, building, and managing an escrow project. ```bash # 1. Create project bedrock init my-escrow --primitives escrow && cd my-escrow # 2. Start local node bedrock node start # 3. Edit escrow logic # escrow/src/lib.rs # 4. Build bedrock build # 5. Fund a wallet bedrock faucet --network local # 6. Deploy bedrock escrow deploy \ --destination \ --amount 1000000 \ --wallet \ --network local # 7. Check status bedrock escrow status --network local # 8. Finish (release) bedrock escrow finish --wallet --network local # 9. Or cancel bedrock escrow cancel --wallet --network local ``` -------------------------------- ### Initialize Vault Project (Bash) Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/smart-vaults.md Command to initialize a new Bedrock project with the vault primitive and the vault-whitelist template. ```bash bedrock init my-vault --primitives vault --template vault-whitelist ``` -------------------------------- ### CLI Command: build Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/commands-reference.md Compiles Rust source code into WebAssembly for the configured primitives. ```APIDOC ## CLI Command: build ### Description Compiles Rust source to WebAssembly. By default, builds all primitives configured in the project. ### Usage `bedrock build [flags]` ### Parameters - **--release** (boolean) - Optional - Build in release mode (optimized) - **--type** (string) - Optional - Build specific primitive (contract, escrow, vault) ``` -------------------------------- ### Bedrock Development and Deployment Workflow Source: https://context7.com/xrpl-commons/bedrock/llms.txt A comprehensive workflow for initializing a project, managing a local node, and deploying contracts to local or testnet environments. It includes steps for contract building, testing, and wallet management using the Jade system. ```bash # Terminal 1: Start local development environment bedrock init my-contract cd my-contract bedrock node start # Terminal 2: Development cycle # 1. Build the contract bedrock build # 2. Deploy to local node bedrock deploy --network local # 3. Test the contract bedrock call rContract... hello --wallet sXXX... --network local # 4. Make changes to contract/src/lib.rs, then redeploy bedrock deploy --network local # 5. When ready for testnet bedrock deploy --network alphanet # 6. Call on testnet bedrock call rContract... myFunction \ --wallet sXXX... \ --network alphanet \ --params '{"key":"value"}' # Using saved wallets workflow bedrock jade new dev-wallet bedrock faucet --wallet $(bedrock jade export dev-wallet | grep Seed | awk '{print $2}') bedrock deploy --wallet sXXX... --network alphanet ``` -------------------------------- ### Deploy Smart Escrow Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/smart-escrows.md Deploy a smart escrow to the XRPL. You will need the beneficiary address, amount, and your wallet seed. Save the owner address and escrow sequence from the output. ```bash bedrock escrow deploy \ --destination \ --amount 1000000 \ --wallet \ --network local ``` -------------------------------- ### Build Options Source: https://github.com/xrpl-commons/bedrock/blob/main/README.md Configure build mode for the contract. ```bash bedrock build # Build in release mode (default) bedrock build --debug # Build in debug mode (faster, larger) ``` -------------------------------- ### Project Initialization Source: https://github.com/xrpl-commons/bedrock/blob/main/CLAUDE.md Initializes a new Bedrock project with a specified name, creating the necessary file structure and boilerplate code. ```APIDOC ## Initialize Project ### Description Creates a new project structure with `bedrock.toml`, `contract/` directory, and boilerplate Rust code. ### Method CLI Command ### Endpoint `bedrock init ` ### Parameters #### Path Parameters - **project-name** (string) - Required - The name of the project to create. ### Request Example ```bash bedrock init my-contract ``` ``` -------------------------------- ### Build XRPL Commons Bedrock Project (Debug) Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/building-contracts.md Use this command for building the project in debug mode. This is useful during development for faster build times. ```bash cargo build --target wasm32-unknown-unknown ``` -------------------------------- ### Configure Bedrock Project Source: https://github.com/xrpl-commons/bedrock/blob/main/README.md Define project metadata, build targets, and network endpoints in the bedrock.toml file. ```toml [project] name = "my-contract" version = "0.1.0" [build] source = "contract/src/lib.rs" target = "wasm32-unknown-unknown" [networks.local] url = "ws://localhost:6006" faucet_url = "http://localhost:8080/faucet" [networks.alphanet] url = "wss://alphanet.nerdnest.xyz" faucet_url = "https://alphanet.faucet.nerdnest.xyz/accounts" ``` -------------------------------- ### Build All Primitives Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/building-contracts.md Executes the build command without any flags to compile all configured primitives in the project. ```bash bedrock build ``` -------------------------------- ### Initialize and Build Bedrock Projects Source: https://github.com/xrpl-commons/bedrock/blob/main/CLAUDE.md Commands to scaffold a new smart contract project and compile Rust code into WebAssembly. Supports both release and debug build configurations. ```bash # Create a new project bedrock init # Build in release mode (optimized, smaller WASM) bedrock build # Build in debug mode (faster compilation) bedrock build --release=false ``` -------------------------------- ### Import Jade Wallet Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/commands-reference.md Imports an existing wallet from a seed into local encrypted storage. ```bash bedrock jade import [--algorithm secp256k1|ed25519] ``` -------------------------------- ### Deploy Contract Source: https://github.com/xrpl-commons/bedrock/blob/main/README.md Deploy the contract to a specified network using a wallet seed. ```bash # Deploy to local node bedrock deploy --network local # Deploy to alphanet (testnet) bedrock deploy --network alphanet # Deploy with specific wallet bedrock deploy --wallet sXXX... ``` -------------------------------- ### Node and Utility Commands Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/quick-reference.md Commands for managing the local node, cleaning build artifacts, and managing wallets. ```APIDOC ## Node and Utility Commands ### Manage Local Node ```bash bedrock node start/stop ``` ### Create New Wallet (Jade) ```bash bedrock jade new ``` ### Get Testnet Funds ```bash bedrock faucet ``` ### Clean Build Artifacts ```bash bedrock clean ``` ``` -------------------------------- ### Escrow Deployment Options Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/quick-reference.md Detailed options for deploying smart escrows, including destination, amount, and timing. ```APIDOC ## Escrow Deploy Options ### Required Parameters - **--destination** ``: Beneficiary address (required) - **--amount** ``: Amount to escrow (required) ### Optional Parameters - **--wallet** ``: Wallet seed or Jade name - **--network** ``: Target network (default: alphanet) - **--cancel-after** ``: Time after which escrow can be canceled - **--finish-after** ``: Time after which escrow can be finished ``` -------------------------------- ### Execute Development Workflow Commands Source: https://github.com/xrpl-commons/bedrock/blob/main/README.md Commands for managing local nodes, building contracts, and deploying to networks. ```bash # Terminal 1: Start local node bedrock node start # Terminal 2: Develop and test bedrock build # Build contract bedrock deploy --local # Deploy to local node bedrock call rXXX... hello --wallet sXXX... # Test function # Make changes to contract... bedrock deploy --local # Redeploy (auto-rebuilds) ``` ```bash # 1. Build and deploy to alphanet bedrock deploy --network alphanet # Save the output: # Wallet Seed: sXXX... # Contract Account: rContract123... # 2. Call your contract bedrock call rContract123... myFunction \ --wallet sXXX... \ --network alphanet ``` -------------------------------- ### Deployment Options Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/quick-reference.md Options available for deploying smart contracts, including network selection and build skipping. ```APIDOC ## Deployment Options (Contracts) ### Default Deployment ```bash bedrock deploy ``` ### Deploy to Local Node ```bash bedrock deploy --network local ``` ### Deploy with Specific Wallet ```bash bedrock deploy --wallet ``` ### Skip Build During Deployment ```bash bedrock deploy --skip-build ``` ``` -------------------------------- ### CLI Command: call Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/commands-reference.md Executes a function on a deployed smart contract. ```APIDOC ## CLI Command: call ### Description Calls a function on a deployed smart contract using the provided parameters and wallet. ### Usage `bedrock call [flags]` ### Parameters - **contract** (string) - Required - The contract's XRPL account address - **function** (string) - Required - Name of the function to call - **--wallet** (string) - Required - Wallet seed or jade name - **--network** (string) - Optional - Target network - **--params** (string) - Optional - JSON string of function parameters - **--params-file** (string) - Optional - Path to JSON file with parameters - **--gas** (number) - Optional - Computation allowance - **--fee** (number) - Optional - Transaction fee in drops - **--abi** (string) - Optional - Path to ABI file - **--algorithm** (string) - Optional - Cryptographic algorithm ``` -------------------------------- ### CLI Command: add Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/commands-reference.md Adds a new primitive (contract, escrow, or vault) to an existing Bedrock project. ```APIDOC ## CLI Command: add ### Description Adds a specified primitive to an existing project. ### Usage `bedrock add [flags]` ### Parameters - **primitive** (string) - Required - Primitive to add: contract, escrow, or vault - **--template** (string) - Optional - Template for the new primitive ``` -------------------------------- ### Bedrock Build Configuration Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/building-contracts.md Defines the source file and compilation target for Bedrock builds within the `bedrock.toml` configuration file. ```toml [build] source = "contract/src/lib.rs" target = "wasm32-unknown-unknown" ``` -------------------------------- ### Create New Jade Wallet Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/commands-reference.md Generates, encrypts, and stores a new XRPL wallet locally. ```bash bedrock jade new [--algorithm secp256k1|ed25519] ``` -------------------------------- ### Project File Structure Overview Source: https://github.com/xrpl-commons/bedrock/blob/main/CLAUDE.md Illustrates the typical directory and file layout for an XRPL Commons Bedrock project, showing configuration, source code, build artifacts, and ABI definitions. ```tree my-contract/ ├── bedrock.toml # Project configuration ├── contract/ │ ├── Cargo.toml # Rust dependencies │ └── src/ │ └── lib.rs # Smart contract code ├── abi.json # Generated ABI (after deploy) └── target/ └── wasm32-unknown-unknown/ └── release/ └── contract.wasm ``` -------------------------------- ### Node Management Source: https://github.com/xrpl-commons/bedrock/blob/main/README.md Control the local XRPL node lifecycle. ```bash bedrock node start # Start local XRPL node bedrock node stop # Stop local node bedrock node status # Check if running bedrock node logs # View node logs (coming soon) ``` -------------------------------- ### Deploy Smart Escrow Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/commands-reference.md Deploys a smart escrow with a WASM condition using the specified network and wallet. ```bash bedrock escrow deploy [flags] ``` ```bash bedrock escrow deploy --destination rXXX... --amount 1000000 --wallet sXXX... --network local ``` -------------------------------- ### Troubleshoot Bedrock Environment Source: https://github.com/xrpl-commons/bedrock/blob/main/README.md Commands to resolve common issues with dependencies, build targets, and configuration. ```bash # Check Node.js version node --version # Should be 18+ # Manually install dependencies cd ~/.cache/bedrock/modules npm install ``` ```bash # Add wasm32 target rustup target add wasm32-unknown-unknown # Update Rust rustup update ``` ```bash # Check Docker is running docker ps # View Docker logs docker logs bedrock-xrpl-node # Restart Docker daemon ``` ```bash # Make sure you're in a Bedrock project directory ls bedrock.toml # Or initialize a new project bedrock init my-project ``` -------------------------------- ### Manage Local XRPL Nodes and Wallets Source: https://github.com/xrpl-commons/bedrock/blob/main/CLAUDE.md Utilities for managing local Docker-based XRPL nodes and the Jade wallet system. Includes commands for wallet creation, import, export, and node lifecycle management. ```bash # Start local XRPL node bedrock node start # Create new wallet bedrock jade new # List wallets bedrock jade list ``` -------------------------------- ### Request Testnet Funds from Faucet Source: https://context7.com/xrpl-commons/bedrock/llms.txt Obtain testnet funds for XRPL development and testing using the `bedrock faucet` command. This command can generate a new wallet and fund it, fund a specific address, or use an existing wallet seed. It supports local and alphanet networks. ```bash # Generate a new wallet and fund it automatically bedrock faucet # Fund a specific address bedrock faucet --address rMyAddress123... # Fund using an existing wallet seed bedrock faucet --wallet sEd7... # Fund on local network bedrock faucet --network local # Fund with ed25519 wallet bedrock faucet --algorithm ed25519 # Faucet endpoints: # - Local: http://localhost:8080/faucet # - Alphanet: https://alphanet.faucet.nerdnest.xyz/accounts ``` -------------------------------- ### Deploying Contracts Source: https://github.com/xrpl-commons/bedrock/blob/main/CLAUDE.md Deploys compiled smart contracts to an XRPL network. Supports various networks and deployment options. ```APIDOC ## Deploy Contracts ### Description Deploys compiled smart contracts to an XRPL network. Supports deployment to alphanet (default), local nodes, and allows specifying a wallet. Options to skip auto-build or ABI generation are available. ### Method CLI Command ### Endpoint `bedrock deploy` ### Query Parameters - **network** (string) - Optional - The network to deploy to. Defaults to `alphanet`. Can be `local` or `alphanet`. - **wallet** (string) - Optional - The seed of the wallet to use for deployment. If not specified, a new wallet might be created. - **skip-build** (boolean) - Optional - If set, skips the automatic build process before deployment. - **skip-abi** (boolean) - Optional - If set, skips the automatic ABI generation. ### Important Deployment Details - **Deployment Fee**: 100 XRP (100,000,000 drops). - **ABI Generation**: Automatically generated from Rust annotations. - **Wallet**: A new wallet is created if none is specified. ### Request Example ```bash # Deploy to alphanet (default) bedrock deploy # Deploy to local node bedrock deploy --network local # Deploy with a specific wallet seed bedrock deploy --wallet "your_wallet_seed_here" # Deploy skipping the build step bedrock deploy --skip-build ``` ``` -------------------------------- ### Implement Escrow Oracle Logic in Rust Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/smart-escrows.md Demonstrates reading ledger objects from WASM to query an oracle and conditionally release an escrow based on a price threshold. ```rust #![cfg_attr(target_arch = "wasm32", no_std)] #[cfg(not(target_arch = "wasm32"))] extern crate std; use xrpl_wasm_stdlib::core::keylets::oracle_keylet; use xrpl_wasm_stdlib::core::locator::Locator; use xrpl_wasm_stdlib::core::types::account_id::AccountID; use xrpl_wasm_stdlib::host::error_codes::match_result_code; use xrpl_wasm_stdlib::host::trace::{trace_num, trace_data, DataRepr}; use xrpl_wasm_stdlib::host::{self, Result, Result::Ok, Result::Err}; use xrpl_wasm_stdlib::{r_address, sfield}; // TODO: Replace with your oracle owner address const ORACLE_OWNER: AccountID = AccountID(r_address!("rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh")); const ORACLE_DOCUMENT_ID: u32 = 1; pub fn get_price_from_oracle(slot: i32) -> Result { let mut locator = Locator::new(); locator.pack(sfield::PriceDataSeries); locator.pack(0); locator.pack(sfield::AssetPrice); let mut data: [u8; 8] = [0; 8]; let result_code = unsafe { host::get_ledger_obj_nested_field( slot, locator.as_ptr(), locator.num_packed_bytes(), data.as_mut_ptr(), data.len(), ) }; let _ = trace_data("get_price_from_oracle: data=", &data, DataRepr::AsHex); match match_result_code(result_code, || data) { Ok(asset_bytes) => { let price = u64::from_le_bytes(asset_bytes); let _ = trace_num("get_price_from_oracle: asset_price=", price as i64); Ok(price) } Err(error) => { let _ = trace_num("Error getting asset_price", error.code() as i64); Err(error) } } } #[unsafe(no_mangle)] pub extern "C" fn finish() -> i32 { let oracle_keylet = match oracle_keylet(&ORACLE_OWNER, ORACLE_DOCUMENT_ID) { Ok(keylet) => keylet, Err(error) => { let _ = trace_num("finish: oracle_keylet error_code=", error.code() as i64); return error.code(); } }; let slot: i32; unsafe { slot = host::cache_ledger_obj(oracle_keylet.as_ptr(), oracle_keylet.len(), 0); let _ = trace_num("finish: cache_ledger_obj slot=", slot as i64); if slot < 0 { let _ = trace_num("finish: cache_ledger_obj failed, returning 0", 0); return 0; }; } let price = match get_price_from_oracle(slot) { Ok(v) => v, Err(e) => return e.code(), }; (price > 1) as i32 // Release escrow if price > 1 } ``` -------------------------------- ### Jade Wallet Management Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/quick-reference.md Commands for creating, importing, and managing encrypted wallets. ```bash bedrock jade new # Create encrypted wallet bedrock jade import # Import from seed bedrock jade list # List all wallets bedrock jade export # Show seed bedrock jade remove # Delete wallet ``` -------------------------------- ### Faucet Operations Source: https://github.com/xrpl-commons/bedrock/blob/main/CLAUDE.md Requests testnet funds for wallets or specific addresses. ```APIDOC ## Faucet Operations ### Description Requests testnet funds from the faucet. Can be used to generate a new wallet with funds, or to fund an existing address or wallet. ### Method CLI Command ### Endpoint `bedrock faucet` ### Query Parameters - **address** (string) - Optional - The XRPL address to send funds to. - **wallet** (string) - Optional - The seed of the wallet to receive funds. **Note**: If neither `--address` nor `--wallet` is provided, a new wallet will be generated and funded. ### Request Example ```bash # Request testnet funds (generates a new wallet) bedrock faucet # Request funds for a specific address bedrock faucet --address "r...your_address_here" # Request funds using a wallet seed bedrock faucet --wallet "your_wallet_seed_here" ``` ``` -------------------------------- ### Connect to Node via JavaScript Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/local-node.md Connect to the local node using the @transia/xrpl client library. ```javascript const { Client } = require('@transia/xrpl'); const client = new Client('ws://localhost:6006'); await client.connect(); ``` -------------------------------- ### Add Primitives to Existing Project Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/getting-started.md Extend an existing project by adding new primitives or templates. ```bash bedrock add escrow bedrock add vault --template vault-whitelist bedrock add contract --template token ``` -------------------------------- ### Build Primitives Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/getting-started.md Compile all primitives or a specific type within the project. ```bash # Build all primitives in the project bedrock build # Build a specific primitive bedrock build --type contract bedrock build --type escrow bedrock build --type vault ``` -------------------------------- ### Bedrock Project Configuration (bedrock.toml) Source: https://github.com/xrpl-commons/bedrock/blob/main/CLAUDE.md Defines the project's configuration settings using TOML format. It includes project metadata, build paths, local node settings, and network configurations for different environments like local and alphanet. ```toml [project] name = "my-contract" version = "0.1.0" authors = ["Your Name"] [build] source = "contract/src/lib.rs" output = "contract/target/wasm32-unknown-unknown/release" target = "wasm32-unknown-unknown" [local_node] config_dir = ".bedrock/node-config" docker_image = "transia/alphanet:latest" ledger_interval = 1000 [networks.local] url = "ws://localhost:6006" network_id = 63456 faucet_url = "http://localhost:8080/faucet" [networks.alphanet] url = "wss://alphanet.nerdnest.xyz" network_id = 21465 faucet_url = "https://alphanet.faucet.nerdnest.xyz/accounts" ``` -------------------------------- ### Build project primitives Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/commands-reference.md Compile Rust source code into WebAssembly. By default, this builds all configured primitives in the project. ```bash bedrock build [flags] ``` ```bash bedrock build # Build all primitives bedrock build --type contract # Build only contract bedrock build --type escrow # Build only escrow bedrock build --type vault # Build only vault bedrock build --release=false # Debug build (faster) ``` -------------------------------- ### bedrock vault deploy Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/smart-vaults.md Creates a smart vault with WASM logic on the XRPL. ```APIDOC ## POST /vault/deploy ### Description Creates a smart vault with WASM logic. ### Method POST ### Endpoint `/vault/deploy` ### Parameters #### Query Parameters - **--asset** (string) - Optional - Asset currency code. Defaults to `XRP`. - **--issuer** (string) - Required for non-XRP assets - Asset issuer. - **--max-capacity** (integer) - Optional - Maximum vault capacity. - **--wallet** (string) - Required - Wallet seed or jade name. - **--network** (string) - Optional - Network to deploy on (`local`, `alphanet`). Defaults to `local`. - **--fee** (integer) - Optional - Transaction fee in drops. - **--skip-build** (boolean) - Optional - Skip building WASM. Defaults to `false`. ### Request Example ```bash # XRP vault bedrock vault deploy --asset XRP --wallet sXXX... --network local # IOU vault bedrock vault deploy --asset USD --issuer rXXX... --wallet sXXX... --network alphanet # With capacity limit bedrock vault deploy --asset XRP --max-capacity 1000000000 --wallet sXXX... ``` ### Response #### Success Response (200) - **vault_id** (string) - The ID of the newly created vault. #### Response Example ```json { "vault_id": "a1b2c3d4e5f67890" } ``` ``` -------------------------------- ### Vault Deployment Configuration Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/quick-reference.md Parameters for configuring asset types and capacity during vault deployment. ```bash bedrock vault deploy \ --asset XRP # Asset (default: XRP) --issuer # Issuer (for non-XRP) --max-capacity # Max capacity --wallet # Wallet seed or jade name --network local # Target network ``` -------------------------------- ### Smart Contract Structure Source: https://github.com/xrpl-commons/bedrock/blob/main/llms.txt Basic template for an XRPL smart contract. ```rust #![cfg_attr(target_arch = "wasm32", no_std)] #[cfg(not(target_arch = "wasm32"))] extern crate std; use xrpl_wasm_macros::wasm_export; use xrpl_wasm_std::host::trace::trace; /// @xrpl-function hello #[wasm_export] fn hello() -> i32 { let _ = trace("Hello from XRPL Smart Contract!"); 0 } ``` -------------------------------- ### List Jade Wallets Source: https://github.com/xrpl-commons/bedrock/blob/main/docs/guide/commands-reference.md Displays all wallets stored in the local Jade system. ```bash bedrock jade list ```