Skip to content

Instantly share code, notes, and snippets.

@shmn7iii
shmn7iii / ion_did_on_testnet.rb
Created October 11, 2022 10:24
ION で DID を作成
require 'sidetree'
require 'bitcoin'
require 'net/http'
require 'json'
include Bitcoin::Opcodes
# 鍵生成
recovery_key = Sidetree::Key.generate
update_key = Sidetree::Key.generate
signing_key = Sidetree::Key.generate(id: 'signing-key')
@shmn7iii
shmn7iii / metadata_token_with_tapyrusrb.rb
Last active May 25, 2022 03:08
tapyrusrbでMetadata付きトークン。手数料に関する処理は省略。
# Metadata
metadata = 'test_metadata'
# convert to hex
metadata = metadata.unpack("H*")[0]
# transaction
tx = Tapyrus::Tx.new
# inputは省略
@shmn7iii
shmn7iii / get_op_return_from_transaction.rb
Last active May 25, 2022 03:05
トランザクションからメタデータ(OP_RETURN)を引っ張ってくるよ
txid = 'xxxx'
tx_payload = Glueby::Internal::RPC.client.getrawtransaction(txid, 0)
tx = Tapyrus::Tx.parse_from_payload(tx_payload.htb)
op_return_data = nil
tx.outputs.each do |txout|
next if txout.op_return_data.nil?
op_return_data = txout.op_return_data.bth
end