Skip to content

Instantly share code, notes, and snippets.

View shaojunda's full-sized avatar
🏠
Working from home

shaojunda shaojunda

🏠
Working from home
  • Cryptape
  • HangZhou
View GitHub Profile
{
"inputs":[
{
"since":"0x0",
"previous_output":{
"index":"0x0",
"tx_hash":"0xbfd1434d944c1c7a8efa6db0b5afd726cb986987c7d7369a347f44d7a1d3b899"
}
}
],
issuer_lock = issuer.enterprise_user.ec_key_pair.default_lock_script
api = CkbSdkApiService.instance
cota_type_script = CKB::Types::Script.new(code_hash: api.cota_script_code_hash, args: issuer_lock.compute_hash[0..41], hash_type: api.cota_script_hash_type)
cota_type_filter = CKB::Indexer::Types::SearchKeyFilter.new(script: cota_type_script)
cota_search_key = CKB::Indexer::Types::SearchKey.new(issuer_lock, "lock", filter: cota_type_filter)
cota_collector = Collectors::CkbCollector.new(search_key: cota_search_key)
cell = cota_collector.collect.to_a.first
{:version=>"0x0", :cell_deps=>[{:out_point=>{:tx_hash=>"0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37", :index=>"0x0"}, :dep_type=>"dep_group"}, {:out_point=>{:tx_hash=>"0x46a7625a76cf7401eff1dfe4f46138be69316518c9771c9f780a428843c6b5b1", :index=>"0x0"}, :dep_type=>"code"}, {:out_point=>{:tx_hash=>"0x2dfcab7790f3cabffe5cb349546dac8918b409481828218cc162f9de5754116f", :index=>"0x0"}, :dep_type=>"dep_group"}], :header_deps=>[], :inputs=>[{:previous_output=>{:tx_hash=>"0x6f6544eb1d62123c690b203992c312b13c71909311d797f39b7327d1ba43fd85", :index=>"0x0"}, :since=>"0x0"}, {:previous_output=>{:tx_hash=>"0xe16c9aa7ab6828a3850fcf3d20f1525bc006d2b366e01efff115d42a24746646", :index=>"0x1"}, :since=>"0x0"}], :outputs=>[{:capacity=>"0x37e11d600", :lock=>{:code_hash=>"0x1157470ca9de091c21c262bf0754b777f3529e10d2728db8f6b4e04cfc2fbb5f", :args=>"0x", :hash_type=>"data"}, :type=>{:code_hash=>"0x9302db6cc1344b81a5efee06962abcb40427ecfcbe69d471b01b2658ed948075", :args=>"0xf9910364e0ca81a0e074f3aa42fe78cfcc880

不使用 Type ID 部署可升级脚本

部署 always success script

api = CKB::API.new
wallet = CKB::Wallets::NewWallet.new(api: api, from_addresses: "ckt1qyqvsv5240xeh85wvnau2eky8pwrhh4jr8ts8vyj37")
always_success_data = File.read("/your-path-to/always_success")
tx_generator = wallet.generate("ckt1qyqvsv5240xeh85wvnau2eky8pwrhh4jr8ts8vyj37", 8000*10**8, {data: CKB::Utils.bin_to_hex(always_success_data)})
always_success_tx = wallet.sign(tx_generator, "0xd00c06bfd800d27397002dca6fb0993d5ba6399b4238b2f29ee9deb97593d2bc")

always_success_tx_hash = api.send_transaction(always_success_tx) # 0xa055eba9f93a9f0c49aa6983990cce5dc9c83f3c998e0bb6dbd09fb9b75f76b1
b = api.get_block_by_number(200)
# block 的结构
#<CKB::Types::Block:0x00007fb54980e0c0
@header=
#<CKB::Types::BlockHeader:0x00007fb54980e138
@dao="0x01000000000000004411a07ccde123000066b4450b1804000063324fbf6a0000",
@difficulty="0x100",
@epoch="0",
@hash="0x9cb72acc3098b3f5f873a4815779dd90b494b5d24246a2c79c049fed9e990a84",
@shaojunda
shaojunda / introrx.md
Created December 12, 2017 07:49 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
$(function() {
var imgArray = [];
var currentPage = 1;
var frameId = 1;
var decoratePic = "";
var gid = $("#gid").val();
$("#framePic").on("click", function() {
chooseHandler("framePic");
})
function chooseHandler(chooseType) {
$(function() {
var imgArray = [];
var currentPage = 1;
var frameId = 1;
var decoratePic = "";
var gid = $("#gid").val();
$("#framePic").on("click", function() {
chooseHandler("framePic");
})
function chooseHandler(chooseType) {
#imageViewer {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.94);
display: flex;
justify-content: center;
align-items: center;
class Job < ApplicationRecord
belongs_to :user
validates :title, presence: true
validates :wage_upper_bound, presence: true, numericality: {greater_than: 0}
validates :wage_lower_bound, presence: true, numericality: {greater_than: 0}
# validates :wage_lower_bound, numericality: {greater_than: 0}
scope :show_public, -> { where("is_hidden = 'false'") } # :is_hidden => false
scope :recent, -> { order(created_at: :desc) }