MCPcopy Index your code
hub / github.com/bitfinity-network/ord-rs

github.com/bitfinity-network/ord-rs @v0.3.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.3.0 ↗ · + Follow
221 symbols 434 edges 34 files 41 documented · 19% updated 21mo ago★ 332 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ord-rs

A library for working with Ordinal inscriptions.

Status

Done

  • [x] inscription: Brc20 and Nft inscription types.
  • [x] wallet: Transaction builder, signer, and parser.

TODO

  • [ ] indexer: Scans the Bitcoin blockchain to catalog, organize, and provide information about Ordinal inscriptions.

build-test

Get started

Examples

Deploy

You can see the example in examples/deploy.rs to see how to deploy a BRC20 token:

cargo run --example deploy --
  -T <tick>
  -a <total-supply>
  -l <mint-limit>
  -p <WIF private key>
  -n <network>
  <tx_input_id:tx_input_index> <tx_input_id:tx_input_index> <tx_input_id:tx_input_index>

Mint

You can see the example in examples/mint.rs to see how to mint BRC20 tokens to your address.

cargo run --example mint --
  -T <tick>
  -a <mint-amount>
  -p <WIF private key>
  -n <network>
  <tx_input_id:tx_input_index> <tx_input_id:tx_input_index> <tx_input_id:tx_input_index>

Transfer

You can use the example in examples/transfer.rs to transfer BRC20 token to another address.

To transfer tokens run the following command:

cargo run --example transfer --
  -T <tick>
  -a <token amount>
  -p <WIF private key>
  -n <network>
  <tx_input_id:tx_input_index> <tx_input_id:tx_input_index> <tx_input_id:tx_input_index> 

An example:

cargo run --example transfer --
  -T ordi 
  -a 100 
  -p "xxxxx" 
  -n testnet 
  "b6d2f6ebbf791f58cf5c15ca7ef936dc5485b27360c5e10c55b0170cf7429468:1" "f9832ed4eaf8eb32f619fe0e24f6ab352a73c16ee456b03792f13c6329e6a1e4:1"

Then you need to send the UTXO to the actual recipient of the transaction. Let's say the previous command returned this output:

Reveal transaction broadcasted: a9d7b9b6062a3609e9526b46540c6702185e612a2936f6382bf3b910cdab5b8f

Then to send the transfer to the recipient, run the following command:

cargo run --example send-inscription --
  -t tb1qg0707euju8jmjr0f2erdukcttwwc0lt7p4at93 
  -p "xxxx" 
  -n test 
  -i "a9d7b9b6062a3609e9526b46540c6702185e612a2936f6382bf3b910cdab5b8f:0" "0c86a1ba63234546c234a6e253a0844bb693d8093dc65a6cf28f200d475bd675:1"

Where -i takes the reveal transaction and then, the positional arguments are the transactions which will fund the fees for the transaction.

How transfers works

The transfer involves two steps actually, let's see an example where Alice sends 100 ordi to Bob:

  1. First the Alice sends a commit transaction from her source address to a random P2TR derived from her
  2. Then Alice reveals the inscription in the reveal transaction from the P2TR address to her source address.
  3. Finally, Alice sends the UTXO from the reveal transaction to Bob's Address.

Inscription parsing

In order to parse an inscription you can use the OrdParser::parse function, which will use the parse function from the Inscription trait, for the given Inscription type.

For example, given the transaction ff314aebaa91a3f10cfba576d3be958127aba982d29146735e612869567e7808 from the testnet, we'll parse a valid Brc20.

let transaction = get_transaction_by_id(
    "ff314aebaa91a3f10cfba576d3be958127aba982d29146735e612869567e7808",
    bitcoin::Network::Testnet,
)
.await
.unwrap();

let inscription: Brc20 = OrdParser::parse(&transaction).unwrap().unwrap();
assert_eq!(inscription, Brc20::transfer("mona", 100));

References

License

See license in LICENSE

Legal notice

Finity Technologies encourages developers to evaluate their own regulatory obligations when using this code, including, but not limited to, those related to compliance.

THE CODE (THE “CODE”) PROVIDED BY FINITY TECHNOLOGIES LTD (THE “COMPANY”) IS PROVIDED ON AN AS IS BASIS. THE COMPANY DOES NOT GIVE ANY WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE AND/OR NONINFRINGEMENT. IN NO EVENT SHALL THE COMPANY BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE CODE, AND/OR THE USE OF OR OTHER DEALINGS IN THE CODE.

USERS SHOULD BE AWARE OF THE RISKS ASSOCIATED WITH USING OPEN-SOURCE CODE WHICH INCLUDE, BUT ARE NOT LIMITED TO, LACK OF SECURITY, OPERATIONAL INSUFFICIENCIES, SOFTWARE QUALITY. BY USING THE CODE USERS ACCEPT THESE RISKS. FOR THE AVOIDANCE OF DOUBT, THE COMPANY IS NOT RESPONSIBLE FOR AND ACCEPTS NO LIABILITY FOR ANY LOSS WHICH RESULTS FROM ANY SUCH RISK MATERIALISING OR ANY OTHER ISSUE WITH THE CODE.

Extension points exported contracts — how you extend this code

Inscription (Interface)
The `Inscription` trait defines the behavior necessary for handling Bitcoin Ordinal inscriptions within the context of c [3 …
src/inscription.rs
BtcTxSigner (Interface)
(no doc) [1 implementers]
src/wallet/builder/signer.rs

Core symbols most depended-on inside this repo

estimate_vbytes
called by 12
src/utils/fees.rs
broadcast_transaction
called by 9
examples/utils/rpc_client.rs
estimate_transaction_fees
called by 7
src/utils/fees.rs
bytes_to_push_bytes
called by 7
src/utils/push_bytes.rs
encode
called by 7
src/wallet/builder.rs
sign_commit_transaction
called by 7
src/wallet/builder.rs
build_commit_transaction_with_fixed_fees
called by 7
src/wallet/builder.rs
build_reveal_transaction
called by 6
src/wallet/builder.rs

Shape

Function 91
Method 81
Class 39
Enum 8
Interface 2

Languages

Rust100%

Modules by API surface

src/inscription/nft.rs27 symbols
src/wallet/parser/envelope.rs25 symbols
src/wallet/builder.rs25 symbols
src/wallet/builder/signer.rs21 symbols
src/inscription/iid.rs20 symbols
src/wallet/parser.rs19 symbols
src/inscription/brc20.rs16 symbols
src/utils/fees.rs15 symbols
src/wallet/builder/rune.rs9 symbols
src/utils/test_utils/rpc_client.rs6 symbols
examples/utils/rpc_client.rs6 symbols
src/utils/test_utils.rs3 symbols

For agents

$ claude mcp add ord-rs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page