fireblocks-config
Installation
Cargo
- Install the rust toolchain in order to have cargo installed by following this guide.
- run
cargo install fireblocks-config
Usage
Creating a Configuration File
Create a TOML configuration file with your Fireblocks settings:
# config.toml
= "your-api-key-here"
= "path/to/your/private-key.pem"
= "https://sandbox-api.fireblocks.io/v1"
[]
= "Table" # Options: Table, Json, Yaml
[]
= 120 # Timeout in seconds
= 5 # Polling interval in seconds
= "0" # Vault ID
Configuration Overrides
You can layer multiple configuration files for different environments:
Base configuration (config.toml):
= "sandbox-key"
= "keys/sandbox.pem"
= "https://sandbox-api.fireblocks.io/v1"
[]
= "0"
Production override (prod.toml):
= "production-key"
= "keys/production.pem"
= "https://api.fireblocks.io/v1"
Load with overrides in your code:
use FireblocksConfig;
// Load base config with production overrides
let config = with_overrides?;
# Ok::
Environment Variables
All configuration values can be overridden using environment variables with the FIREBLOCKS_ prefix:
Note: Use double underscores (__) to access nested configuration sections.
Alternative: Embedded Secret
Instead of using a file path, you can embed the private key directly in the configuration:
= "your-api-key"
= "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----"
= "https://api.fireblocks.io/v1"
GPG Encrypted Keys
If compiled with the gpg feature, you can use GPG-encrypted private key files:
= "your-api-key"
= "path/to/encrypted-key.pem.gpg"
= "https://api.fireblocks.io/v1"
Configuration Priority
Configuration values are loaded in the following order (later values override earlier ones):
- Base configuration file
- Override configuration files (in order specified)
- Environment variables (
FIREBLOCKS_*)
Configuration Tips
Tilde Expansion
The configuration supports ~ for home directory expansion in file paths:
= "your-api-key"
= "~/fireblocks/keys/production.pem"
= "https://api.fireblocks.io/v1"
Vault ID Format
Note that the vault field expects a string value, not a number:
[]
= "0" # Correct: string value
# vault = 0 # Incorrect: numeric value
Feature Flags
XDG Base Directory Support
To enable XDG Base Directory specification support for automatic config loading:
# Install with XDG support
# Or add to Cargo.toml
With XDG support enabled, you can load configs from standard locations:
use FireblocksConfig;
// Load from ~/.config/fireblocks/default.toml
let config = init?;
// Load default + production profile from ~/.config/fireblocks/production.toml
let config = init_with_profiles?;
// Layer multiple profiles: default -> staging -> production
let config = init_with_profiles?;
# Ok::
Config file locations:
- Default:
~/.config/fireblocks/default.toml - Profiles:
~/.config/fireblocks/{profile}.toml
GPG Support
To enable GPG-encrypted private key support, install with the gpg feature:
# Install with GPG support
# Or add to Cargo.toml
With GPG support enabled, you can use encrypted key files:
= "your-api-key"
= "path/to/encrypted-key.pem.gpg"
= "https://api.fireblocks.io/v1"
Development
Prerequisites
- Rust Nightly: Required for code formatting with advanced features
Getting Started
-
Clone the repository
-
Build and test
# Build the project # Run tests (requires valid Fireblocks credentials in .env) # Format code (requires nightly)
Code Formatting
This project uses advanced Rust formatting features that require nightly:
# Format all code
# Check formatting
License
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
See CONTRIBUTING.md.