Skip to content

Commit

Permalink
fix: docs
Browse files Browse the repository at this point in the history
  • Loading branch information
veeso committed Sep 24, 2024
1 parent 887e74e commit 3b77ee3
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 2 deletions.
91 changes: 89 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,101 @@
//! # ord-rs
//!
//! A library for working with Ordinal inscriptions.
//!
//! This library provides a set of tools for working with Ordinal inscriptions, including creating, parsing, and signing transactions.
//! It allows you to work with both BRC20, runes and generic inscriptions.
//!
//! # Get started
//!
//! INSERT TEXT HERE
//! Add the following to your `Cargo.toml`:
//!
//! ```toml
//! ord-rs = "0.3.0"
//! ```
//!
//! In case you want to enable runes support, you can add the following feature:
//!
//! ```toml
//! ord-rs = { version = "0.3.0", features = ["rune"] }
//! ```
//!
//! ## Example
//!
//! An example for creating a BRC20 inscription:
//!
//! ```rust
//! use bitcoin::secp256k1::Secp256k1;
//! use bitcoin::{Address, Amount, FeeRate, Network, PrivateKey, Txid};
//! use ord_rs::wallet::{
//! CreateCommitTransactionArgs, RevealTransactionArgs, SignCommitTransactionArgs,
//! };
//! use ord_rs::{Brc20, OrdTransactionBuilder, Utxo};
//!
//! use std::str::FromStr;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//!
//! let network = Network::Testnet;
//! let ticker = "ordi".to_string();
//! let amount = 1_000;
//!
//! let private_key = PrivateKey::from_wif("cVkWbHmoCx6jS8AyPNQqvFr8V9r2qzDHJLaxGDQgDJfxT73w6fuU")?;
//! let public_key = private_key.public_key(&Secp256k1::new());
//! let sender_address = Address::p2wpkh(&public_key, network).unwrap();
//!
//! let mut builder = OrdTransactionBuilder::p2tr(private_key);
//!
//! let inputs = vec![Utxo {
//! id: Txid::from_str("791b415dc6946d864d368a0e5ec5c09ee2ad39cf298bc6e3f9aec293732cfda7")
//! .unwrap(), // the transaction that funded our wallet
//! index: 1,
//! amount: Amount::from_sat(8_000),
//! }];
//!
//! let commit_tx = builder
//! .build_commit_transaction(
//! network,
//! sender_address.clone(),
//! CreateCommitTransactionArgs {
//! fee_rate: FeeRate::from_sat_per_vb(1).unwrap(),
//! inputs: inputs.clone(),
//! inscription: Brc20::transfer(ticker, amount),
//! txin_script_pubkey: sender_address.script_pubkey(),
//! leftovers_recipient: sender_address.clone(),
//! derivation_path: None,
//! multisig_config: None,
//! },
//! )
//! .await?;
//!
//! let signed_commit_tx = builder
//! .sign_commit_transaction(
//! commit_tx.unsigned_tx,
//! SignCommitTransactionArgs {
//! inputs,
//! txin_script_pubkey: sender_address.script_pubkey(),
//! derivation_path: None,
//! },
//! )
//! .await?;
//!
//! let commit_txid = signed_commit_tx.txid();
//! // TODO: send commit_tx to the network
//!
//! let reveal_transaction = builder
//! .build_reveal_transaction(RevealTransactionArgs {
//! input: ord_rs::wallet::Utxo {
//! id: commit_txid,
//! index: 0,
//! amount: commit_tx.reveal_balance,
//! },
//! recipient_address: sender_address, // NOTE: it's correct, see README.md to read about how transfer works
//! redeem_script: commit_tx.redeem_script,
//! derivation_path: None,
//! })
//! .await?;
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! Ok(())
//! }
//! ```
Expand Down
1 change: 1 addition & 0 deletions src/result.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::OrdError;

/// A type alias for `Result<T, OrdError>`.
pub type OrdResult<T> = std::result::Result<T, OrdError>;

0 comments on commit 3b77ee3

Please sign in to comment.