Skip to content

Instantly share code, notes, and snippets.

@ShiningRay
Last active April 25, 2024 16:39
Show Gist options
  • Save ShiningRay/4ecb588f3ed2350fb36647b94209daef to your computer and use it in GitHub Desktop.
Save ShiningRay/4ecb588f3ed2350fb36647b94209daef to your computer and use it in GitHub Desktop.
ckb
cell = Cell.last
target = 'ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqtgydapmyadqh2h6lndq3eef52h5uq4nnq827utn'
tx = Transaction.new
tx.inputs = [cell]
tx.cell_deps = [
{
"out_point": {
"tx_hash": "0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37",
"index": '0x0'
},
"dep_type": "dep_group"
}
]
tx.witnesses = []
# transfer to target
o1 = tx.outputs.new
o1.capacity = 20000000000
o1.lock_script = CkbUtils.parse_address(target).script
# change and fee
o2 = tx.outputs.new
o2.capacity = cell.capacity - o1.capacity - 500
o2.lock_script = cell.lock_script
tx.save
cell = Cell.last
target = 'ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqtgydapmyadqh2h6lndq3eef52h5uq4nnq827utn'
tx = Transaction.new
tx.inputs = [cell]
tx.cell_deps = [
{
"out_point": {
"tx_hash": "0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37",
"index": '0x0'
},
"dep_type": "dep_group"
}
]
tx.witnesses = []
# transfer to target
o1 = tx.outputs.new
o1.capacity = 20000
o1.lock_script = CkbUtils.parse_address(target).script
# change and fee
o2 = tx.outputs.new
o2.capacity = cell.capacity - o1.capacity - 500
o2.lock_script = cell.lock_script
tx.save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment