通过shell脚本执行ord节点的wallet receive、wallet send、wallet inscription三个命令

实现思路:

1、通过shell脚本中的case语句实现不同命令的选择

2、然后在确定好了命令方法后,我们在依据需要传递我们需要的参数

脚本内容

bash 复制代码
#!/bin/bash

ord_regtest="/root/ord/target/release/ord --cookie-file=/data/btcregtest/data/regtest/.cookie  --rpc-url=127.0.0.1:8540"

function walletreceive {
    local num=$1	
    datetime=`date +%Y%m%d%H%M`
    mv  ord_address /tmp/ord_address_${datetime}
    for i in $(seq 1 $num)
    do
        ${ord_regtest} -r wallet receive |grep -v "{\|}"|awk -F "\"" '{print $4}' >> ord_address 
    done
    cp ord_address /root/address/ord_address_${datetime}
    echo "Successed"
}

function inscription {
    local fee_rate=$1
    local tick=$2
    local amount=$3
    local destination=$4
    sed -i "s/ordi/$tick/" /root/fee_rate_file.json
    sed -i "s/1000/$amount/" /root/fee_rate_file.json
    ${ord_regtest} -r wallet inscribe --fee-rate $fee_rate --file /root/fee_rate_file.json --
destination $destination}

function send {
    local fee_rate=$1
    local address=$2
    local inscription_id=$3
    ${ord_regtest} -r wallet send --fee-rate $fee_rate $address $inscription_id
}

case "$1" in
    "walletreceive")
        walletreceive "$2"
        ;;
    "inscription")
        inscription "$2" "$3" "$4" $5
        ;;
    "send")
        send "$2" "$3" "$4"
        ;;
    *)
        exit
        ;;
esac
其中fee_rate_file.json最原始文本内容
{"p": "brc-20", "op": "transfer", "tick": "tick", "amt": "1000"}

执行命令:

1、walletreceive (生成钱包地址)
bash 复制代码
./ordinals.sh walletreceive num(表示要生成的地址的数量)
2、inscription (对钱包地址的币进行铭刻)
bash 复制代码
./ordinals.sh inscription fee_rate(费率)  tick(币种) amount(币对应的数量)  destination(要对哪个地址的币进行铭刻)

{
  "commit": "12acb3aef15017408432ccdb35ad74e029c078db3eb3d59b74b4c5e29ee65756",
  "inscriptions": [
    {
      "id": "f0f37af3daf6a89bacc467ac4e6e564e931cdce097e70bea74dd76be828fa74bi0",
      "location": "f0f37af3daf6a89bacc467ac4e6e564e931cdce097e70bea74dd76be828fa74b:0:0"
    }
  ],
  "parent": null,
  "reveal": "f0f37af3daf6a89bacc467ac4e6e564e931cdce097e70bea74dd76be828fa74b",
  "total_fees": 15300
}
3、send (将铭刻好的币进行转走)
bash 复制代码
./ordinals.sh send fee_rate(费率)  address(要转出的目标钱包地址)  inscription_id(铭刻id,上一步生成的id值)

{
  "transaction": "87b4db5a90a2316f9a0bb07433573359391c57a121f5cdb5a3f6d90d6c97ac00"
}

总结

1、脚本服务器上必须要有ord命令,且客户端要获取结果必须和脚本在同一个机器上

2、客户端必须时时刻刻手动执行脚本才能获取到结果信息

3、更多详情python编写的方法:python脚本调用ordinals以及BRC20的接口

相关推荐
彭泽布衣1 天前
为什么 mac os .bashrc 没有自动加载?
shell·mac os
Johny_Zhao1 天前
Ubuntu安装部署Zabbix网络监控平台和设备配置添加
linux·网络·mysql·网络安全·信息安全·云计算·apache·zabbix·shell·yum源·系统运维·itsm
嘿嘻哈呀1 天前
命令行解释器中shell、bash和zsh的区别
bash·shell·zsh·命令行解释器
Johny_Zhao2 天前
K8S+nginx+MYSQL+TOMCAT高可用架构企业自建网站
linux·网络·mysql·nginx·网络安全·信息安全·tomcat·云计算·shell·yum源·系统运维·itsm
Johny_Zhao4 天前
思科安全大模型SOC作业应用分析
linux·网络·人工智能·网络安全·ai·信息安全·云计算·shell·devops·cisco·yum源·系统运维·itsm
Johny_Zhao9 天前
阿里云Ansible自动化运维平台部署
linux·人工智能·ai·信息安全·云计算·ansible·shell·yum源·系统运维·itsm
一刀到底21110 天前
从实列中学习linux shell12 通过Shell脚本来优化MySQL数据库性能,特别是慢SQL跟踪和索引优化
linux·数据库·shell
一刀到底21111 天前
从实列中学习linux shell9 如何确认 服务器反应迟钝是因为cpu还是 硬盘io 到底是那个程序引起的。cpu负载多高算高
linux·服务器·shell
Johny_Zhao11 天前
Oracle、MySQL、SQL Server、PostgreSQL、Redis 五大数据库的区别
linux·redis·sql·mysql·信息安全·oracle·云计算·shell·yum源·系统运维
Johny_Zhao12 天前
在Ubuntu Server上安装Checkmk监控系统
linux·人工智能·网络安全·信息安全·云计算·shell·yum源·系统运维·checkmk