Options
All
  • Public
  • Public/Protected
  • All
Menu

Package common-scripts

@ckb-lumos/common-scripts

Common script implementation for lumos. Includes secp256k1_blake2b lock script, secp256k1_blake160_multisig lock script, dao type script, sudt type script now.

LocktimePool script includes secp256k1_blake160_multisig cells which with locktime in lock args (which args total length is 28 bytes, last 8 bytes is a since format locktime in BigUInt64LE encode) and DAO step2 cells.

common script allows you to transfer capacity from fromInfos to an address. It will use locktime pool cells first by default.

deploy script provides generateDeployWithDataTx, generateDeployWithTypeIdTx and generateUpgradeTypeIdDataTx, these generators help in the process of deploying contracts.

p2pkh scripts generates message for signing P2PKH transaction.

Usage

common script support new lock scripts provided by user, and pw-lock shows how to do it.

Following script will show how to use common script to transfer capacity to another address. secp256k1_blake160, secp256k1_blake160_multisig and locktime_pool script are similar to common, and common maybe a better choose.

const { common } = require('@ckb-lumos/common-scripts');
const { sealTransaction } = require("@ckb-lumos/helpers")
const { Indexer } = require("@ckb-lumos/ckb-indexer")

// We can use Indexer module as cell provider
const indexer = new Indexer("http://127.0.0.1:8114");

const tipHeader = {
  compactTarget: '0x20010000',
  dao: '0x49bfb20771031d556c8480d47f2a290059f0ac7e383b6509006f4a772ed50200',
  epoch: '0xa0006002b18',
  hash: '0x432451e23c26f45eaceeedcc261764d6485ea5c9a204ac55ad755bb8dec9a079',
  nonce: '0x8199548f8a5ac7a0f0caef1620f37b79',
  number: '0x1aef6',
  parentHash: '0x63594a64108f19f6aed53d0dca9ab4075aac4379cb80b2097b0deac8fc16fd3b',
  proposalsHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
  timestamp: '0x172f6b9a4cf',
  transactions_root: '0x282dbadcd49f3e229d997875f37f4e4f19cb4f04fcf762e9639145aaa667b6f8',
  extra_hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
  version: '0x0'
}

const fromInfos = [
  "ckb1qyqwyxfa75whssgkq9ukkdd30d8c7txct0gq5f9mxs",
  {
    R: 0,
    M: 1,
    publicKeyHashes: ["0x36c329ed630d6ce750712a477543672adab57f4c"],
  },
]

let txSkeleton = TransactionSkeleton({ cellProvider: indexer })

// If using secp256k1_blake160_multisig lock script, put MultisigScript to `fromInfos` for generate signing messages.
// By default, `common.transfer` will use cells with locktime firstly. `tipHeader` is required when you want to spent cells with locktime.
txSkeleton = await common.transfer(
  txSkeleton,
  fromInfos,
  "ckb1qyqrdsefa43s6m882pcj53m4gdnj4k440axqdt9rtd",
  BigInt(3500 * 10 ** 8),
  tipHeader,
)

// Or you want to use cells without locktime firstly.
txSkeleton = await common.transfer(
  txSkeleton,
  fromInfos,
  "ckb1qyqrdsefa43s6m882pcj53m4gdnj4k440axqdt9rtd",
  BigInt(3500 * 10 ** 8),
  tipHeader,
  { useLocktimeCellsFirst: false }
)

// When you want to pay fee for transaction, just call `payFee`.
txSkeleton = await common.payFee(
  txSkeleton,
  fromInfos,
  BigInt(1*10**8),
  tipHeader,
)

// `prepareSigningEntries` will generate message for signing.
// Signing messages will fill in `txSkeleton.signingEntries`.
txSkeleton = await common.prepareSigningEntries(
  txSkeleton
)

// Then you can sign messages in order and get contents.
// NOTE: lumos not provided tools for generate signatures now.
// Call `sealTransaction` to get a transaction.
const tx = sealTransaction(txSkeleton, contents)

// Then you can send tx to a CKB node via RPC `send_transaction`.

Following script will show how to use DAO script.

const { dao } = require("@ckb-lumos/common-scripts")

let txSkeleton = TransactionSkeleton({ cellProvider: indexer })

// First, deposit capacity to dao.
txSkeleton = await dao.deposit(
  txSkeleton,
  "ckb1qyqrdsefa43s6m882pcj53m4gdnj4k440axqdt9rtd", // will gather inputs from this address.
  "ckb1qyqwyxfa75whssgkq9ukkdd30d8c7txct0gq5f9mxs", // will generate a dao cell with lock of this address.
  BigInt(1000*10**8),
)

// Using `listDaoCells` to list all deposited cells.
const daoDepositedCells = await dao.listDaoCells(
  indexer,
  "ckb1qyqwyxfa75whssgkq9ukkdd30d8c7txct0gq5f9mxs",
  "deposit",
)

// Or using `CellCollector`
const daoDepositedCellCollector = new dao.CellCollector(
  "ckb1qyqwyxfa75whssgkq9ukkdd30d8c7txct0gq5f9mxs",
  indexer,
  "deposit",
)

for await (const inputCell of daoDepositedCellCollector.collect()) {
  console.log(inputCell)
}

// And pick one to withdraw.
// `fromInfo` only required for multisig script.
txSkeleton = await dao.withdraw(
  txSkeleton,
  daoDepositedCells[0],
)

// Then if want to unlock dao withdrew cells, just use `common.transfer`.

Following script will show how to use sUDT script.

const { sudt } = require("@ckb-lumos/common-scripts")
let txSkeleton = TransactionSkeleton({ cellProvider: indexer })

// issue an sudt token, will use the second param address to generate sudt token(it's lock hash).
txSkeleton = await sudt.issueToken(
  txSkeleton,
  "ckb1qyqrdsefa43s6m882pcj53m4gdnj4k440axqdt9rtd",
  10000n,
);

// and transfer sUDT
const sudtToken = "0x1f2615a8dde4e28ca736ff763c2078aff990043f4cbf09eb4b3a58a140a0862d"
txSkeleton = await sudt.transfer(
  txSkeleton,
  ["ckb1qyqrdsefa43s6m882pcj53m4gdnj4k440axqdt9rtd"],
  sudtToken,
  "ckb1qyqwyxfa75whssgkq9ukkdd30d8c7txct0gq5f9mxs",
  1000n,
  "ckb1qyqrdsefa43s6m882pcj53m4gdnj4k440axqdt9rtd",
);

Following script will show how to use deploy script.

const { generateDeployWithDataTx, generateDeployWithTypeIdTx, generateUpgradeTypeIdDataTx, payFee } = require("@ckb-lumos/common-scripts");
const { Indexer } = require("@ckb-lumos/ckb-indexer");
const { initializeConfig, predefined } = require("@ckb-lumos/config-manager");
const { parseAddress } = require("@ckb-lumos/helpers");

initializeConfig(predefined.AGGRON4);

const CKB_RPC_URL = "http://localhost:8114";
const CKB_INDEXER_URL = "http://localhost:8116";
const indexer = new Indexer(CKB_INDEXER_URL, CKB_RPC_URL);

const address = "ckt1qyqptxys5l9vk39ft0hswscxgseawc77y2wqlr558h";
// Lock script of the deploy account
const outputScriptLock = parseAddress(address);
// Binary data you want to deploy
const scriptBinary = Uint8Array.of(1);

let deployOptions = {
  cellProvider: indexer,
  scriptBinary: scriptBinary,
  outputScriptLock: outputScriptLock,
}

// Ganarate txSkeleton for deploying with data.
let txSkeleton = await generateDeployWithDataTx(deployOptions);
// Or if you want to delpoy with Type ID so that you can upgarde the contract in the future.
let txSkeleton = await generateDeployWithTypeIdTx(deployOptions);

// Pay transaction fee.
txSkeleton = await payFee(txSkeleton, address, txFee);
// Then you can sign and seal the transaction for sending.


// To upgrade a contract with Type ID, add its Type ID to deployOptions.
const typeId = {
  codeHash: '0x00000000000000000000000000000000000000000000000000545950455f4944',
  hashType: 'type',
  args: '0x7abcd9f949a16b40ff5b50b56e62d2a6a007e544d8491bb56476693b6c45fd27'
}
const upgradeOptions = {
  cellProvider: cellProvider,
  scriptBinary: scriptBinary,
  outputScriptLock: outputScriptLock,
  typeId: typeId
}
// Ganarate txSkeleton for upgrading.
let upgradeTxSkeleton = await generateUpgradeTypeIdDataTx(upgradeOptions);

Check omni lock example and pw lock example for how to use p2pkh script.

Index

Classes

Interfaces

Type aliases

Variables

Functions

Object literals

Type aliases

FromInfo

FromInfo

Group

Group: { index: number; lock: Script; message: Hash }

Type declaration

Group

Group: { index: number; lock: Script; message: Hash }

Type declaration

LockScriptInfosType

LockScriptInfosType: { _customInfos: LockScriptInfo[]; _predefinedInfos: LockScriptInfo[]; configHashCode: number; infos: LockScriptInfo[] }

Type declaration

LockScriptInfosType

LockScriptInfosType: { _customInfos: LockScriptInfo[]; _predefinedInfos: LockScriptInfo[]; configHashCode: number; infos: LockScriptInfo[] }

Type declaration

OmnilockInfo

OmnilockInfo: { auth: { content: BytesLike; flag: "ETHEREUM" | "SECP256K1_BLAKE160" } }

Type declaration

  • auth: { content: BytesLike; flag: "ETHEREUM" | "SECP256K1_BLAKE160" }
    • content: BytesLike

      if auth flag is SECP256K1_BLAKE160, content is publicKeyToBlake160(secp256k1Pubkey) if auth flag is ETHEREUM, content is Ethereum address

    • flag: "ETHEREUM" | "SECP256K1_BLAKE160"

OmnilockInfo

OmnilockInfo: { auth: { content: BytesLike; flag: "ETHEREUM" | "SECP256K1_BLAKE160" } }

Type declaration

  • auth: { content: BytesLike; flag: "ETHEREUM" | "SECP256K1_BLAKE160" }
    • content: BytesLike

      if auth flag is SECP256K1_BLAKE160, content is publicKeyToBlake160(secp256k1Pubkey) if auth flag is ETHEREUM, content is Ethereum address

    • flag: "ETHEREUM" | "SECP256K1_BLAKE160"

ThunkOrValue

ThunkOrValue<T>: T | (() => T)

Type parameters

  • T

ThunkOrValue

ThunkOrValue<T>: T | (() => T)

Type parameters

  • T

Token

Token: Hash

Token

Token: Hash

Variables

CKBHasher

CKBHasher: CKBHasher

CKBHasher

CKBHasher: CKBHasher

CKBHasher

CKBHasher: CKBHasher

Const CellCollector

Const CellCollector

Const CellCollector

Const CellCollector

Const CellCollector

Const CellCollector

CellCollector: CellCollectorConstructor = class CellCollectorimplements CellCollectorType{private cellCollector: CellCollectorType;private config: Config;public readonly fromScript: Script;constructor(fromInfo: FromInfo,cellProvider: CellProvider,{config = undefined,queryOptions = {},}: Options & {queryOptions?: QueryOptions;} = {}) {if (!cellProvider) {throw new Error(`Cell provider is missing!`);}config = config || getConfig();this.fromScript = parseFromInfo(fromInfo, { config }).fromScript;this.config = config;queryOptions = {...queryOptions,lock: this.fromScript,type: queryOptions.type || "empty",};this.cellCollector = cellProvider.collector(queryOptions);}async *collect(): AsyncGenerator<Cell> {if (!isSecp256k1Blake160Script(this.fromScript, this.config)) {return;}for await (const inputCell of this.cellCollector.collect()) {yield inputCell;}}}

Const CellCollector

CellCollector: CellCollectorConstructor = class CellCollectorimplements CellCollectorType{private cellCollector: CellCollectorType;private config: Config;public readonly fromScript: Script;public readonly multisigScript?: HexString;constructor(fromInfo: FromInfo,cellProvider: CellProvider,{config = undefined,queryOptions = {},}: Options & {queryOptions?: QueryOptions;} = {}) {if (!cellProvider) {throw new Error(`Cell provider is missing!`);}config = config || getConfig();const result = parseFromInfo(fromInfo, { config });this.fromScript = result.fromScript;this.multisigScript = result.multisigScript;this.config = config;queryOptions = {...queryOptions,lock: this.fromScript,type: queryOptions.type || "empty",};this.cellCollector = cellProvider.collector(queryOptions);}async *collect(): AsyncGenerator<Cell> {if (!isSecp256k1Blake160MultisigScript(this.fromScript, this.config)) {return;}for await (const inputCell of this.cellCollector.collect()) {yield inputCell;}}}

Const CellCollector

CellCollector: CellCollectorConstructor = class CellCollectorimplements CellCollectorType{private cellCollectors: List<CellCollectorType>;private config: Config;private rpc: RPC;private tipHeader?: Header;private tipSinceValidationInfo?: SinceValidationInfo;public readonly fromScript: Script;public readonly multisigScript?: HexString;constructor(fromInfo: FromInfo,cellProvider: CellProvider,{config = undefined,queryOptions = {},tipHeader = undefined,NodeRPC = RPC,}: Options & {queryOptions?: QueryOptions;tipHeader?: Header;NodeRPC?: typeof RPC;} = {}) {if (!cellProvider) {throw new Error(`Cell provider is missing!`);}config = config || getConfig();const result = parseFromInfo(fromInfo, { config });const fromScript = result.fromScript;this.multisigScript = result.multisigScript;this.fromScript = fromScript;this.config = config;this.tipHeader = tipHeader;if (tipHeader) {// TODO: `median_timestamp` is not provided now!this.tipSinceValidationInfo = {blockNumber: tipHeader.number,epoch: tipHeader.epoch,median_timestamp: "",};}this.rpc = new NodeRPC(cellProvider.uri!);queryOptions = {...queryOptions,lock: this.fromScript,};let cellCollectors = List<CellCollectorType>([]);if (isSecp256k1Blake160MultisigScript(fromScript, config)) {const lock: Script = {codeHash: fromScript.codeHash,hashType: fromScript.hashType,args: fromScript.args.slice(0, 42),};// multisig with locktime, not daocellCollectors = cellCollectors.push(cellProvider.collector({lock,argsLen: queryOptions.argsLen || 28,type: queryOptions.type || "empty",data: queryOptions.data || "0x",}));// multisig without locktime, daoif (!queryOptions.type &&(!queryOptions.data || queryOptions.data === "any")) {cellCollectors = cellCollectors.push(cellProvider.collector({lock,type: generateDaoScript(config),data: "any",}));// multisig with locktime, daocellCollectors = cellCollectors.push(cellProvider.collector({lock,argsLen: 28,type: generateDaoScript(config),data: "any",}));}} else if (isSecp256k1Blake160Script(fromScript, config)) {// secp256k1_blake160, daoif (!queryOptions.type &&(!queryOptions.data || queryOptions.data === "any")) {cellCollectors = cellCollectors.push(cellProvider.collector({lock: fromScript,type: generateDaoScript(config),data: "any",}));}}this.cellCollectors = cellCollectors;}async *collect(): AsyncGenerator<LocktimeCell> {for (const cellCollector of this.cellCollectors) {for await (const inputCell of cellCollector.collect()) {const lock = inputCell.cellOutput.lock;let since: PackedSince | undefined;let maximumCapacity: BI | undefined;let depositBlockHash: Hash | undefined;let withdrawBlockHash: Hash | undefined;let sinceValidationInfo: SinceValidationInfo | undefined;// multisigif (lock.args.length === 58) {const header = (await this.rpc.getHeader(inputCell.blockHash!))!;since ="0x" + _parseMultisigArgsSinceCompatible(lock.args).toString(16);// TODO: `median_timestamp` not provided now!sinceValidationInfo = {epoch: header.epoch,blockNumber: header.number,median_timestamp: "",};}// daoif (isDaoScript(inputCell.cellOutput.type, this.config)) {if (inputCell.data === "0x0000000000000000") {continue;}const transactionWithStatus = (await this.rpc.getTransaction(inputCell.outPoint!.txHash))!;withdrawBlockHash = transactionWithStatus.txStatus.blockHash;const transaction = transactionWithStatus.transaction;// eslint-disable-next-line @typescript-eslint/no-unused-varsconst depositOutPoint =transaction.inputs[+inputCell.outPoint!.index].previousOutput;depositBlockHash = (await this.rpc.getTransaction(depositOutPoint!.txHash))!.txStatus.blockHash!;const depositBlockHeader = await this.rpc.getHeader(depositBlockHash);const withdrawBlockHeader = await this.rpc.getHeader(withdrawBlockHash!);let daoSince: PackedSince ="0x" +calculateDaoEarliestSinceCompatible(depositBlockHeader!.epoch,withdrawBlockHeader!.epoch).toString(16);maximumCapacity = calculateMaximumWithdrawCompatible(inputCell,depositBlockHeader!.dao,withdrawBlockHeader!.dao);const withdrawEpochValue = parseEpoch(withdrawBlockHeader!.epoch);const fourEpochsLater = {number: withdrawEpochValue.number + 4,length: withdrawEpochValue.length,index: withdrawEpochValue.index,};daoSince = maximumAbsoluteEpochSince(daoSince,generateAbsoluteEpochSince(fourEpochsLater));// if multisig with locktimeif (since) {const multisigSince = parseSinceCompatible(since);if (!(multisigSince.relative === false &&multisigSince.type === "epochNumber")) {// throw new Error(// "Multisig since not an absolute-epoch-number since format!"// );// skip multisig with locktime in non-absolute-epoch-number format, can't unlock itcontinue;}try {since = maximumAbsoluteEpochSince(daoSince, since);} catch {since = daoSince;}} else {since = daoSince;}}if (parseSinceCompatible(since!).type === "blockTimestamp" ||(this.tipHeader &&!validateSince(since!,this.tipSinceValidationInfo!,// TODO: modify the parameter type of `validateSince`// eslint-disable-next-line @typescript-eslint/no-non-null-assertionsinceValidationInfo!))) {continue;}const result = {...inputCell,since: since!,depositBlockHash: depositBlockHash,withdrawBlockHash: withdrawBlockHash,sinceValidationInfo,};result.cellOutput.capacity ="0x" +(maximumCapacity || BI.from(inputCell.cellOutput.capacity)).toString(16);yield result;}}}}

Const CellCollector

CellCollector: CellCollectorConstructor = class CellCollectorimplements CellCollectorType{private cellCollector: CellCollectorType;private config: Config;public readonly fromScript: Script;constructor(fromInfo: FromInfo,cellProvider: CellProvider,{config = undefined,queryOptions = {},}: Options & {queryOptions?: QueryOptions;} = {}) {if (!cellProvider) {throw new Error(`Cell provider is missing!`);}config = config || getConfig();this.fromScript = parseFromInfo(fromInfo, { config }).fromScript;this.config = config;queryOptions = {...queryOptions,lock: this.fromScript,type: queryOptions.type || "empty",};this.cellCollector = cellProvider.collector(queryOptions);}async *collect(): AsyncGenerator<Cell> {if (!isOmnilockScript(this.fromScript, this.config)) {return;}for await (const inputCell of this.cellCollector.collect()) {yield inputCell;}}}

Const CellCollector

CellCollector: CellCollectorConstructor = class CellCollectorimplements CellCollectorType{private cellCollector: BaseCellCollectorType;private config: Config;public readonly fromScript: Script;constructor(fromInfo: FromInfo,cellProvider: CellProvider,{config = undefined,queryOptions = {},}: Options & {queryOptions?: QueryOptions;} = {}) {if (!cellProvider) {throw new Error(`Cell provider is missing!`);}config = config || getConfig();this.fromScript = parseFromInfo(fromInfo, { config }).fromScript;this.config = config;queryOptions = {...queryOptions,lock: this.fromScript,type: queryOptions.type || "empty",};this.cellCollector = cellProvider.collector(queryOptions);}async *collect(): AsyncGenerator<Cell> {if (!isAcpScript(this.fromScript, this.config)) {return;}for await (const inputCell of this.cellCollector.collect()) {yield inputCell;}}}

Const DAO_LOCK_PERIOD_EPOCHS_COMPATIBLE

DAO_LOCK_PERIOD_EPOCHS_COMPATIBLE: BI = BI.from(180)

Const DEPOSIT_DAO_DATA

DEPOSIT_DAO_DATA: HexString = "0x0000000000000000"

Const Identity

Identity: Codec<Uint8Array, string, string | ArrayLike<number> | ArrayBuffer, string | ArrayLike<number> | ArrayBuffer> & { __isFixedCodec__: true; byteLength: number } = createFixedHexBytesCodec(21)

Const OMNILOCK_SIGNATURE_PLACEHOLDER

OMNILOCK_SIGNATURE_PLACEHOLDER: string

Const OMNILOCK_SIGNATURE_PLACEHOLDER

OMNILOCK_SIGNATURE_PLACEHOLDER: string = `0x${"00".repeat(omnilock.OmnilockWitnessLock.pack({ signature: SECP_SIGNATURE_PLACEHOLDER }).byteLength)}`

Const OmniIdentity

OmniIdentity: Codec<Uint8Array, {} & {}, {} & {}, string | ArrayLike<number> | ArrayBuffer> = table({identity: Identity,proofs: SmtProofEntryVec,},["identity", "proofs"])

Const OmniIdentityOpt

OmniIdentityOpt: OptionCodec<Codec<Uint8Array, {} & {}, {} & {}, string | ArrayLike<number> | ArrayBuffer>> = option(OmniIdentity)

Const OmnilockWitnessLock

OmnilockWitnessLock: Codec<Partial<Pick<{ omni_identity: ({} & {}) | undefined; preimage: string | undefined; signature: string | undefined }, "signature" | "omni_identity" | "preimage">> & Pick<{ omni_identity: ({} & {}) | undefined; preimage: string | undefined; signature: string | undefined }, never>, Partial<Pick<{ omni_identity: ({} & {}) | undefined; preimage: string | ArrayBuffer | ArrayLike<number> | undefined; signature: string | ArrayBuffer | ArrayLike<number> | undefined }, "signature" | "omni_identity" | "preimage">> & Pick<{ omni_identity: ({} & {}) | undefined; preimage: string | ArrayBuffer | ArrayLike<number> | undefined; signature: string | ArrayBuffer | ArrayLike<number> | undefined }, never>>

Const OmnilockWitnessLock

OmnilockWitnessLock: Codec<Uint8Array, {} & {}, {} & {}, string | ArrayLike<number> | ArrayBuffer> = table({signature: BytesOpt,omni_identity: OmniIdentityOpt,preimage: BytesOpt,},["signature", "omni_identity", "preimage"])

Const SECP_SIGNATURE_PLACEHOLDER

SECP_SIGNATURE_PLACEHOLDER: "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" = "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

Const SECP_SIGNATURE_PLACEHOLDER

SECP_SIGNATURE_PLACEHOLDER: "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" = "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

ScriptValue

ScriptValue: ScriptValue

ScriptValue

ScriptValue: ScriptValue

ScriptValue

ScriptValue: ScriptValue

ScriptValue

ScriptValue: ScriptValue

ScriptValue

ScriptValue: ScriptValue

ScriptValue

ScriptValue: ScriptValue

ScriptValue

ScriptValue: ScriptValue

ScriptValue

ScriptValue: ScriptValue

Const SmtProof

SmtProof: Codec<Uint8Array, string, string | ArrayLike<number> | ArrayBuffer, string | ArrayLike<number> | ArrayBuffer> = byteVecOf(Hexify)

Const SmtProofEntry

SmtProofEntry: Codec<Uint8Array, {} & {}, {} & {}, string | ArrayLike<number> | ArrayBuffer> = table({mask: byteOf(Hexify),proof: SmtProof,},["mask", "proof"])

Const SmtProofEntryVec

SmtProofEntryVec: Codec<Uint8Array, ({} & {})[], ({} & {})[], string | ArrayLike<number> | ArrayBuffer> = vector(SmtProofEntry)

Const _default

_default: { CellCollector: CellCollectorConstructor; injectCapacity: typeof injectCapacity; prepareSigningEntries: typeof prepareSigningEntries; setupInputCell: typeof setupInputCell; setupOutputCell: typeof setupOutputCell; withdraw: typeof withdraw }

Type declaration

Const _default

_default: { __tests__: { _commonTransfer: typeof _commonTransfer; calculateFee: typeof calculateFee; calculateFeeCompatible: typeof calculateFeeCompatible; generateLockScriptInfos: typeof generateLockScriptInfos; getLockScriptInfos: typeof getLockScriptInfos; getTransactionSize: typeof getTransactionSize; getTransactionSizeByTx: typeof getTransactionSizeByTx; resetLockScriptInfos: typeof resetLockScriptInfos }; injectCapacity: typeof injectCapacity; payFee: typeof payFee; payFeeByFeeRate: typeof payFeeByFeeRate; prepareSigningEntries: typeof prepareSigningEntries; registerCustomLockScriptInfos: typeof registerCustomLockScriptInfos; setupInputCell: typeof setupInputCell; transfer: typeof transfer }

Type declaration

Const _default

_default: { CellCollector: typeof CellCollector; calculateDaoEarliestSince: typeof calculateDaoEarliestSince; calculateDaoEarliestSinceCompatible: typeof calculateDaoEarliestSinceCompatible; calculateMaximumWithdraw: typeof calculateMaximumWithdraw; calculateMaximumWithdrawCompatible: typeof calculateMaximumWithdrawCompatible; deposit: typeof deposit; listDaoCells: typeof listDaoCells; unlock: typeof unlock; withdraw: typeof withdraw }

Type declaration

Const _default

_default: { __tests__: { calculateTxFee: typeof calculateTxFee }; compareScriptBinaryWithOnChainData: typeof compareScriptBinaryWithOnChainData; generateDeployWithDataTx: typeof generateDeployWithDataTx; generateDeployWithTypeIdTx: typeof generateDeployWithTypeIdTx; generateUpgradeTypeIdDataTx: typeof generateUpgradeTypeIdDataTx }

Type declaration

Const _default

_default: { addCellDep: typeof addCellDep; ensureScript: typeof ensureScript; generateDaoScript: typeof generateDaoScript; isAcpAddress: typeof isAcpAddress; isAcpScript: typeof isAcpScript; isDaoScript: typeof isDaoScript; isSecp256k1Blake160Address: typeof isSecp256k1Blake160Address; isSecp256k1Blake160MultisigAddress: typeof isSecp256k1Blake160MultisigAddress; isSecp256k1Blake160MultisigScript: typeof isSecp256k1Blake160MultisigScript; isSecp256k1Blake160Script: typeof isSecp256k1Blake160Script; isSudtScript: typeof isSudtScript; prepareSigningEntries: typeof prepareSigningEntries }

Type declaration

Const _default

_default: { CellCollector: CellCollectorConstructor; injectCapacity: typeof injectCapacity; payFee: typeof payFee; prepareSigningEntries: typeof prepareSigningEntries; setupInputCell: typeof setupInputCell; transfer: typeof transfer; transferCompatible: typeof transferCompatible }

Type declaration

Const _default

_default: { CellCollector: CellCollectorConstructor; injectCapacity: typeof injectCapacity; multisigArgs: typeof multisigArgs; payFee: typeof payFee; prepareSigningEntries: typeof prepareSigningEntries; serializeMultisigScript: typeof serializeMultisigScript; setupInputCell: typeof setupInputCell; transfer: typeof transfer; transferCompatible: typeof transferCompatible }

Type declaration

Const _default

_default: { CellCollector: CellCollectorConstructor; injectCapacity: typeof injectCapacity; injectCapacityWithoutChange: typeof injectCapacityWithoutChange; injectCapacityWithoutChangeCompatible: typeof injectCapacityWithoutChangeCompatible; payFee: typeof payFee; prepareSigningEntries: typeof prepareSigningEntries; setupInputCell: typeof setupInputCell; transfer: typeof transfer; transferCompatible: typeof transferCompatible }

Type declaration

Const _default

_default: { issueToken: typeof issueToken; ownerForSudt: typeof ownerForSudt; transfer: typeof transfer }

Type declaration

Const _default

_default: { CellCollector: CellCollectorConstructor; OmnilockWitnessLock: Codec<Partial<Pick<{ omni_identity: ({} & {}) | undefined; preimage: string | undefined; signature: string | undefined }, "signature" | "omni_identity" | "preimage">> & Pick<{ omni_identity: ({} & {}) | undefined; preimage: string | undefined; signature: string | undefined }, never>, Partial<Pick<{ omni_identity: ({} & {}) | undefined; preimage: string | ArrayBuffer | ArrayLike<number> | undefined; signature: string | ArrayBuffer | ArrayLike<number> | undefined }, "signature" | "omni_identity" | "preimage">> & Pick<{ omni_identity: ({} & {}) | undefined; preimage: string | ArrayBuffer | ArrayLike<number> | undefined; signature: string | ArrayBuffer | ArrayLike<number> | undefined }, never>>; createOmnilockScript: typeof createOmnilockScript; prepareSigningEntries: typeof prepareSigningEntries; setupInputCell: typeof setupInputCell }

Type declaration

  • CellCollector: CellCollectorConstructor
  • OmnilockWitnessLock: Codec<Partial<Pick<{ omni_identity: ({} & {}) | undefined; preimage: string | undefined; signature: string | undefined }, "signature" | "omni_identity" | "preimage">> & Pick<{ omni_identity: ({} & {}) | undefined; preimage: string | undefined; signature: string | undefined }, never>, Partial<Pick<{ omni_identity: ({} & {}) | undefined; preimage: string | ArrayBuffer | ArrayLike<number> | undefined; signature: string | ArrayBuffer | ArrayLike<number> | undefined }, "signature" | "omni_identity" | "preimage">> & Pick<{ omni_identity: ({} & {}) | undefined; preimage: string | ArrayBuffer | ArrayLike<number> | undefined; signature: string | ArrayBuffer | ArrayLike<number> | undefined }, never>>
  • createOmnilockScript: typeof createOmnilockScript
  • prepareSigningEntries: typeof prepareSigningEntries
  • setupInputCell: typeof setupInputCell

Const _default

_default: { anyoneCanPay: { CellCollector: CellCollectorConstructor; injectCapacity: injectCapacity; prepareSigningEntries: prepareSigningEntries; setupInputCell: setupInputCell; setupOutputCell: setupOutputCell; withdraw: withdraw }; common: { __tests__: { _commonTransfer: (txSkeleton: Record<TransactionSkeletonInterface> & {}, fromInfos: FromInfo[], amount: bigint, minimalChangeCapacity: bigint, __namedParameters?: { config: undefined | Config; enableDeductCapacity: undefined | false | true }) => Promise<{ capacity: bigint; changeCapacity: bigint; txSkeleton: Record<TransactionSkeletonInterface> & {} }>; calculateFee: (size: number, feeRate: bigint) => bigint; calculateFeeCompatible: (size: number, feeRate: string | number | bigint | BI) => BI; generateLockScriptInfos: (__namedParameters?: { config: undefined | Config }) => void; getLockScriptInfos: () => { _customInfos: LockScriptInfo[]; _predefinedInfos: LockScriptInfo[]; configHashCode: number; infos: LockScriptInfo[] }; getTransactionSize: (txSkeleton: Record<TransactionSkeletonInterface> & {}) => number; getTransactionSizeByTx: (tx: Transaction) => number; resetLockScriptInfos: () => void }; injectCapacity: injectCapacity; payFee: payFee; payFeeByFeeRate: payFeeByFeeRate; prepareSigningEntries: prepareSigningEntries; registerCustomLockScriptInfos: registerCustomLockScriptInfos; setupInputCell: setupInputCell; transfer: transfer }; dao: { CellCollector: CellCollector; calculateDaoEarliestSince: calculateDaoEarliestSince; calculateDaoEarliestSinceCompatible: calculateDaoEarliestSinceCompatible; calculateMaximumWithdraw: calculateMaximumWithdraw; calculateMaximumWithdrawCompatible: calculateMaximumWithdrawCompatible; deposit: deposit; listDaoCells: listDaoCells; unlock: unlock; withdraw: (txSkeleton: Record<TransactionSkeletonInterface> & {}, fromInput: Cell, fromInfo?: string | MultisigScript | ACP | CustomScript | undefined, __namedParameters?: { config: undefined | Config }) => Promise<Record<TransactionSkeletonInterface> & {}> }; locktimePool: { CellCollector: CellCollectorConstructor; injectCapacity: injectCapacity; injectCapacityWithoutChange: (txSkeleton: Record<TransactionSkeletonInterface> & {}, fromInfos: FromInfo[], amount: bigint, tipHeader: Header, minimalChangeCapacity: bigint, __namedParameters: { LocktimeCellCollector: undefined | CellCollectorConstructor; config: undefined | Config; enableDeductCapacity: undefined | false | true }) => Promise<{ capacity: bigint; changeCapacity: bigint; txSkeleton: Record<TransactionSkeletonInterface> & {} }>; injectCapacityWithoutChangeCompatible: (txSkeleton: Record<TransactionSkeletonInterface> & {}, fromInfos: FromInfo[], amount: string | number | bigint | BI, tipHeader: Header, minimalChangeCapacity: string | number | bigint | BI, __namedParameters: { LocktimeCellCollector: undefined | CellCollectorConstructor; config: undefined | Config; enableDeductCapacity: undefined | false | true }) => Promise<{ capacity: BI; changeCapacity: BI; txSkeleton: Record<TransactionSkeletonInterface> & {} }>; payFee: payFee; prepareSigningEntries: prepareSigningEntries; setupInputCell: setupInputCell; transfer: transfer; transferCompatible: transferCompatible }; secp256k1Blake160: { CellCollector: CellCollectorConstructor; injectCapacity: injectCapacity; payFee: payFee; prepareSigningEntries: prepareSigningEntries; setupInputCell: setupInputCell; transfer: transfer; transferCompatible: transferCompatible }; secp256k1Blake160Multisig: { CellCollector: CellCollectorConstructor; injectCapacity: injectCapacity; multisigArgs: multisigArgs; payFee: payFee; prepareSigningEntries: prepareSigningEntries; serializeMultisigScript: serializeMultisigScript; setupInputCell: setupInputCell; transfer: transfer; transferCompatible: transferCompatible }; sudt: { issueToken: issueToken; ownerForSudt: ownerForSudt; transfer: transfer } }

Type declaration

ckbHash

ckbHash: ckbHash

ckbHash

ckbHash: ckbHash

computeScriptHash

computeScriptHash: computeScriptHash

generateAbsoluteEpochSince

generateAbsoluteEpochSince: generateAbsoluteEpochSince

maximumAbsoluteEpochSince

maximumAbsoluteEpochSince: maximumAbsoluteEpochSince

parseEpoch

parseEpoch: parseEpoch

parseSince

parseSince: parseSince

validateSince

validateSince: validateSince

Functions

_addDaoCellDep

_checkDaoScript

  • _checkDaoScript(config: Config): void
  • Parameters

    Returns void

_checkFromInfoSince

  • Parameters

    Returns void

_commonTransfer

  • _commonTransfer(txSkeleton: TransactionSkeletonType, fromInfos: FromInfo[], amount: bigint, minimalChangeCapacity: bigint, __namedParameters?: { config: undefined | Config; enableDeductCapacity: undefined | false | true }): Promise<{ capacity: bigint; changeCapacity: bigint; txSkeleton: TransactionSkeletonType }>
  • Parameters

    • txSkeleton: TransactionSkeletonType
    • fromInfos: FromInfo[]
    • amount: bigint
    • minimalChangeCapacity: bigint
    • Optional __namedParameters: { config: undefined | Config; enableDeductCapacity: undefined | false | true }
      • config: undefined | Config
      • enableDeductCapacity: undefined | false | true

    Returns Promise<{ capacity: bigint; changeCapacity: bigint; txSkeleton: TransactionSkeletonType }>

_commonTransfer

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • fromInfos: FromInfo[]
    • amount: bigint
    • minimalChangeCapacity: bigint
    • Default value __namedParameters: { config: undefined | Config; enableDeductCapacity: boolean } = {}
      • config: undefined | Config
      • enableDeductCapacity: boolean

    Returns Promise<{ capacity: bigint; changeCapacity: bigint; txSkeleton: TransactionSkeletonType }>

_commonTransferCompatible

  • Parameters

    Returns Promise<{ capacity: BI; changeCapacity: BI; txSkeleton: TransactionSkeletonType }>

_deductCapacityCompatible

_generateSudtScript

  • Parameters

    Returns Script

_parseMultisigArgsSinceCompatible

  • _parseMultisigArgsSinceCompatible(args: HexString): BI
  • Parameters

    Returns BI

_transferCompatible

addCellDep

addCellDep

bytesToHex

  • bytesToHex(bytes: Uint8Array): string
  • Parameters

    • bytes: Uint8Array

    Returns string

calcRawTxHash

calculateCodeHashByBin

  • calculateCodeHashByBin(scriptBin: Uint8Array): string
  • Parameters

    • scriptBin: Uint8Array

    Returns string

calculateDaoEarliestSince

  • calculateDaoEarliestSince(depositBlockHeaderEpoch: HexString, withdrawBlockHeaderEpoch: HexString): bigint
  • calculate a withdraw dao cell minimal unlock since

    Parameters

    • depositBlockHeaderEpoch: HexString

      depositBlockHeader.epoch

    • withdrawBlockHeaderEpoch: HexString

      withdrawBlockHeader.epoch

    Returns bigint

calculateDaoEarliestSince

  • calculateDaoEarliestSince(depositBlockHeaderEpoch: HexString, withdrawBlockHeaderEpoch: HexString): bigint
  • calculate a withdraw dao cell minimal unlock since

    Parameters

    • depositBlockHeaderEpoch: HexString

      depositBlockHeader.epoch

    • withdrawBlockHeaderEpoch: HexString

      withdrawBlockHeader.epoch

    Returns bigint

calculateDaoEarliestSinceCompatible

  • calculateDaoEarliestSinceCompatible(depositBlockHeaderEpoch: HexString, withdrawBlockHeaderEpoch: HexString): BI
  • calculate a withdraw dao cell minimal unlock since

    Parameters

    • depositBlockHeaderEpoch: HexString

      depositBlockHeader.epoch

    • withdrawBlockHeaderEpoch: HexString

      withdrawBlockHeader.epoch

    Returns BI

calculateDaoEarliestSinceCompatible

  • calculateDaoEarliestSinceCompatible(depositBlockHeaderEpoch: HexString, withdrawBlockHeaderEpoch: HexString): BI
  • calculate a withdraw dao cell minimal unlock since

    Parameters

    • depositBlockHeaderEpoch: HexString

      depositBlockHeader.epoch

    • withdrawBlockHeaderEpoch: HexString

      withdrawBlockHeader.epoch

    Returns BI

calculateFee

  • calculateFee(size: number, feeRate: bigint): bigint
  • Parameters

    • size: number
    • feeRate: bigint

    Returns bigint

calculateFee

  • calculateFee(size: number, feeRate: bigint): bigint
  • Parameters

    • size: number
    • feeRate: bigint

    Returns bigint

calculateFee

  • calculateFee(size: number, feeRate: BIish): BI
  • Parameters

    • size: number
    • feeRate: BIish

    Returns BI

calculateFeeCompatible

  • calculateFeeCompatible(size: number, feeRate: BIish): BI
  • Parameters

    • size: number
    • feeRate: BIish

    Returns BI

calculateFeeCompatible

  • calculateFeeCompatible(size: number, feeRate: BIish): BI
  • Parameters

    • size: number
    • feeRate: BIish

    Returns BI

calculateMaximumWithdraw

  • calculate maximum withdraw capacity when unlock

    Parameters

    • withdrawCell: Cell

      withdrawCell or depositCell

    • depositDao: PackedDao

      depositBlockHeader.dao

    • withdrawDao: PackedDao

      withdrawBlockHeader.dao

    Returns bigint

calculateMaximumWithdraw

  • calculate maximum withdraw capacity when unlock

    Parameters

    • withdrawCell: Cell

      withdrawCell or depositCell

    • depositDao: PackedDao

      depositBlockHeader.dao

    • withdrawDao: PackedDao

      withdrawBlockHeader.dao

    Returns bigint

calculateMaximumWithdrawCompatible

  • calculate maximum withdraw capacity when unlock

    Parameters

    • withdrawCell: Cell

      withdrawCell or depositCell

    • depositDao: PackedDao

      depositBlockHeader.dao

    • withdrawDao: PackedDao

      withdrawBlockHeader.dao

    Returns BI

calculateMaximumWithdrawCompatible

  • calculate maximum withdraw capacity when unlock

    Parameters

    • withdrawCell: Cell

      withdrawCell or depositCell

    • depositDao: PackedDao

      depositBlockHeader.dao

    • withdrawDao: PackedDao

      withdrawBlockHeader.dao

    Returns BI

calculateTxFee

calculateTxFee

calculateTxHash

  • Parameters

    Returns string

checkLimit

  • Parameters

    Returns void

checkLimit

  • Parameters

    Returns void

collectInput

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • inputCell: Cell
    • Optional fromInfo: FromInfo
    • Default value __namedParameters: { config: undefined | Config; defaultWitness: string; since: undefined | string } = {}
      • config: undefined | Config
      • defaultWitness: string
      • since: undefined | string

    Returns Promise<TransactionSkeletonType>

collectInputCompatible

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • inputCell: Cell
    • Optional fromInfo: FromInfo
    • Default value __namedParameters: { config: undefined | Config; defaultWitness: string; needCapacity: undefined | string | number | bigint | BI; since: undefined | string } = {}
      • config: undefined | Config
      • defaultWitness: string
      • needCapacity: undefined | string | number | bigint | BI
      • since: undefined | string

    Returns Promise<{ availableCapacity: BI; txSkeleton: TransactionSkeletonType }>

compareScriptBinaryWithOnChainData

  • compareScriptBinaryWithOnChainData(scriptBinary: Uint8Array, outPoint: OutPoint, rpc: RPC): Promise<boolean>
  • Parameters

    Returns Promise<boolean>

compareScriptBinaryWithOnChainData

  • compareScriptBinaryWithOnChainData(scriptBinary: Uint8Array, outPoint: OutPoint, rpc: RPC): Promise<boolean>
  • Parameters

    Returns Promise<boolean>

completeTx

createOmnilockScript

createOmnilockScript

createP2PKHMessageGroup

  • Return an array of messages as well as their corresponding position indexes and locks for signing a P2PKH transaction. For more details, please see: https://github.com/nervosnetwork/ckb-system-scripts/wiki/How-to-sign-transaction

    Parameters

    • tx: TransactionSkeletonType

      TxSkeleton with all input cells' witnessArgs.lock filled with 0.

    • locks: Script[]

      Locks you want to sign, e.g. you don't need to sign ACP cells.

    • Optional __namedParameters: { thunkableHasher: undefined | Hasher | (() => T) }
      • thunkableHasher: undefined | Hasher | (() => T)

    Returns Group[]

    An array of Group containing: lock of the input cell you need to sign, message for signing, witness index of this message (first index of the input cell with this lock).

createP2PKHMessageGroup

  • Return an array of messages as well as their corresponding position indexes and locks for signing a P2PKH transaction. For more details, please see: https://github.com/nervosnetwork/ckb-system-scripts/wiki/How-to-sign-transaction

    Parameters

    • tx: TransactionSkeletonType

      TxSkeleton with all input cells' witnessArgs.lock filled with 0.

    • locks: Script[]

      Locks you want to sign, e.g. you don't need to sign ACP cells.

    • Default value __namedParameters: { thunkableHasher: Hasher | (() => T) } = {}
      • thunkableHasher: Hasher | (() => T)

    Returns Group[]

    An array of Group containing: lock of the input cell you need to sign, message for signing, witness index of this message (first index of the input cell with this lock).

Const defaultCkbHasher

  • defaultCkbHasher(): { digest: any; update: any }
  • Returns { digest: any; update: any }

    • digest: function
      • digest(): Uint8Array
      • Returns Uint8Array

    • update: function
      • Parameters

        • message: Uint8Array

        Returns CKBHasher

defaultLogger

  • defaultLogger(level: string, message: string): void
  • Parameters

    • level: string
    • message: string

    Returns void

deposit

deposit

ensureScript

  • ensureScript(script: Script, config: Config, scriptType: "SECP256K1_BLAKE160" | "SECP256K1_BLAKE160_MULTISIG" | "DAO" | "OMNILOCK"): void
  • Parameters

    • script: Script
    • config: Config
    • scriptType: "SECP256K1_BLAKE160" | "SECP256K1_BLAKE160_MULTISIG" | "DAO" | "OMNILOCK"

    Returns void

ensureScript

  • ensureScript(script: Script, config: Config, scriptType: "SECP256K1_BLAKE160" | "SECP256K1_BLAKE160_MULTISIG" | "DAO" | "OMNILOCK"): void
  • Parameters

    • script: Script
    • config: Config
    • scriptType: "SECP256K1_BLAKE160" | "SECP256K1_BLAKE160_MULTISIG" | "DAO" | "OMNILOCK"

    Returns void

epochSinceCompatible

  • epochSinceCompatible(__namedParameters: { index: string | number | bigint | BI; length: string | number | bigint | BI; number: string | number | bigint | BI }): BI
  • Parameters

    • __namedParameters: { index: string | number | bigint | BI; length: string | number | bigint | BI; number: string | number | bigint | BI }
      • index: string | number | bigint | BI
      • length: string | number | bigint | BI
      • number: string | number | bigint | BI

    Returns BI

extractDaoDataCompatible

  • extractDaoDataCompatible(dao: PackedDao): {}
  • Parameters

    Returns {}

    • [key: string]: BI

extractDaoDataCompatible

  • extractDaoDataCompatible(dao: PackedDao): {}
  • Parameters

    Returns {}

    • [key: string]: BI

findCellsByLock

  • Parameters

    Returns Promise<Cell[]>

generateDaoScript

  • Parameters

    Returns Script

generateDaoScript

  • Parameters

    Returns Script

generateDeployWithDataTx

  • Generate txSkeleton for writing binary data to CKB, usually for deploying contracts. This generator only supports SECP256K1_BLAKE160 and SECP256K1_BLAKE160_MULTISIG currently.

    Parameters

    Returns Promise<DeployResult>

generateDeployWithDataTx

  • Generate txSkeleton for writing binary data to CKB, usually for deploying contracts. This generator only supports SECP256K1_BLAKE160 and SECP256K1_BLAKE160_MULTISIG currently.

    Parameters

    Returns Promise<DeployResult>

generateDeployWithTypeIdTx

generateDeployWithTypeIdTx

generateLockScriptInfos

  • generateLockScriptInfos(__namedParameters?: { config: undefined | Config }): void
  • Parameters

    • Optional __namedParameters: { config: undefined | Config }

    Returns void

generateLockScriptInfos

  • generateLockScriptInfos(__namedParameters?: { config: undefined | Config }): void
  • Parameters

    • Default value __namedParameters: { config: undefined | Config } = {}

    Returns void

generateUpgradeTypeIdDataTx

generateUpgradeTypeIdDataTx

getDataHash

  • getDataHash(outPoint: OutPoint, rpc: RPC): Promise<string>
  • Parameters

    Returns Promise<string>

getLockScriptInfos

getLockScriptInfos

getScriptConfig

getScriptConfigByDataHash

getScriptConfigByTypeHash

getTransactionSize

  • Parameters

    Returns number

getTransactionSize

  • Parameters

    Returns number

getTransactionSize

  • Parameters

    Returns number

getTransactionSizeByTx

  • Parameters

    Returns number

getTransactionSizeByTx

  • Parameters

    Returns number

getTransactionSizeByTx

  • Parameters

    Returns number

groupInputs

  • groupInputs(inputs: Cell[], locks: Script[]): Map<string, number[]>
  • Parameters

    Returns Map<string, number[]>

hashWitness

  • hashWitness(hasher: { update: (value: HexString | ArrayBuffer) => unknown }, witness: HexString): void
  • Hash a witness in a hasher

    Parameters

    • hasher: { update: (value: HexString | ArrayBuffer) => unknown }

      The hasher object which should have a update method.

      • update: (value: HexString | ArrayBuffer) => unknown
          • Parameters

            Returns unknown

    • witness: HexString

      witness data, the inputs to hasher will derived from it

    Returns void

hashWitness

  • hashWitness(hasher: { update: (value: HexString | ArrayBuffer) => unknown }, witness: HexString): void
  • Hash a witness in a hasher

    Parameters

    • hasher: { update: (value: HexString | ArrayBuffer) => unknown }

      The hasher object which should have a update method.

      • update: (value: HexString | ArrayBuffer) => unknown
          • Parameters

            Returns unknown

    • witness: HexString

      witness data, the inputs to hasher will derived from it

    Returns void

injectCapacity

injectCapacity

injectCapacity

  • Inject capacity from fromAddress to target output.

    Parameters

    Returns Promise<TransactionSkeletonType>

injectCapacity

  • Inject capacity from fromInfo to target output.

    Parameters

    Returns Promise<TransactionSkeletonType>

injectCapacity

injectCapacity

  • Inject capacity from fromAddress to target output.

    Parameters

    Returns Promise<TransactionSkeletonType>

injectCapacity

  • Inject capacity from fromInfo to target output.

    Parameters

    Returns Promise<TransactionSkeletonType>

injectCapacity

injectCapacity

injectCapacity

injectCapacity

injectCapacityWithoutChange

injectCapacityWithoutChange

injectCapacityWithoutChangeCompatible

injectCapacityWithoutChangeCompatible

isAcpAddress

  • Parameters

    Returns boolean

isAcpAddress

  • Parameters

    Returns boolean

isAcpScript

  • Parameters

    Returns boolean

isAcpScript

  • Parameters

    Returns boolean

isDaoScript

  • isDaoScript(script: Script | undefined, config: Config): boolean
  • Parameters

    Returns boolean

isDaoScript

  • isDaoScript(script: Script | undefined, config: Config): boolean
  • Parameters

    Returns boolean

isMultisigFromInfo

  • isMultisigFromInfo(fromInfo: FromInfo): fromInfo is MultisigScript
  • Parameters

    Returns fromInfo is MultisigScript

isOmnilockAddress

  • Parameters

    Returns boolean

isOmnilockAddress

  • Parameters

    Returns boolean

isOmnilockScript

  • Parameters

    Returns boolean

isOmnilockScript

  • Parameters

    Returns boolean

isSecp256k1Blake160Address

  • isSecp256k1Blake160Address(address: Address, config: Config): boolean
  • Parameters

    Returns boolean

isSecp256k1Blake160Address

  • isSecp256k1Blake160Address(address: Address, config: Config): boolean
  • Parameters

    Returns boolean

isSecp256k1Blake160MultisigAddress

  • isSecp256k1Blake160MultisigAddress(address: Address, config: Config): boolean
  • Parameters

    Returns boolean

isSecp256k1Blake160MultisigAddress

  • isSecp256k1Blake160MultisigAddress(address: Address, config: Config): boolean
  • Parameters

    Returns boolean

isSecp256k1Blake160MultisigScript

  • isSecp256k1Blake160MultisigScript(script: Script, config: Config): boolean
  • Parameters

    Returns boolean

isSecp256k1Blake160MultisigScript

  • isSecp256k1Blake160MultisigScript(script: Script, config: Config): boolean
  • Parameters

    Returns boolean

isSecp256k1Blake160Script

  • isSecp256k1Blake160Script(script: Script, config: Config): boolean
  • Parameters

    Returns boolean

isSecp256k1Blake160Script

  • isSecp256k1Blake160Script(script: Script, config: Config): boolean
  • Parameters

    Returns boolean

isSudtScript

  • isSudtScript(script: Script | undefined, config: Config): boolean
  • Parameters

    Returns boolean

isSudtScript

  • isSudtScript(script: Script | undefined, config: Config): boolean
  • Parameters

    Returns boolean

issueToken

issueToken

listDaoCells

  • listDaoCells(cellProvider: CellProvider, fromAddress: Address, cellType: "all" | "deposit" | "withdraw", __namedParameters?: { config: undefined | Config }): AsyncIterator<Cell>
  • list DAO cells,

    Parameters

    • cellProvider: CellProvider
    • fromAddress: Address
    • cellType: "all" | "deposit" | "withdraw"
    • Optional __namedParameters: { config: undefined | Config }

    Returns AsyncIterator<Cell>

listDaoCells

  • listDaoCells(cellProvider: CellProvider, fromAddress: Address, cellType: "all" | "deposit" | "withdraw", __namedParameters?: { config: undefined | Config }): AsyncIterator<Cell>
  • list DAO cells,

    Parameters

    • cellProvider: CellProvider
    • fromAddress: Address
    • cellType: "all" | "deposit" | "withdraw"
    • Default value __namedParameters: { config: undefined | Config } = {}

    Returns AsyncIterator<Cell>

multisigArgs

  • Parameters

    Returns HexString

    lock script args

multisigArgs

  • Parameters

    Returns HexString

    lock script args

ownerForSudt

  • Compute sudt token by owner from info.

    Parameters

    • fromInfo: FromInfo
    • Optional __namedParameters: { config: undefined | Config }

    Returns Token

ownerForSudt

  • Compute sudt token by owner from info.

    Parameters

    • fromInfo: FromInfo
    • Default value __namedParameters: { config: undefined | Config } = {}

    Returns Token

parseEpochCompatible

  • parseEpochCompatible(epoch: BIish): { index: BI; length: BI; number: BI }
  • Parameters

    Returns { index: BI; length: BI; number: BI }

    • index: BI
    • length: BI
    • number: BI

parseFromInfo

  • parseFromInfo(fromInfo: FromInfo, __namedParameters?: { config: undefined | Config }): { customData?: HexString; destroyable?: undefined | false | true; fromScript: Script; multisigScript?: HexString }
  • Parameters

    • fromInfo: FromInfo
    • Optional __namedParameters: { config: undefined | Config }

    Returns { customData?: HexString; destroyable?: undefined | false | true; fromScript: Script; multisigScript?: HexString }

    • Optional customData?: HexString
    • Optional destroyable?: undefined | false | true
    • fromScript: Script
    • Optional multisigScript?: HexString

parseFromInfo

  • parseFromInfo(fromInfo: FromInfo, __namedParameters?: { config: undefined | Config }): { customData?: HexString; destroyable?: undefined | false | true; fromScript: Script; multisigScript?: HexString }
  • Parameters

    • fromInfo: FromInfo
    • Default value __namedParameters: { config: undefined | Config } = {}

    Returns { customData?: HexString; destroyable?: undefined | false | true; fromScript: Script; multisigScript?: HexString }

    • Optional customData?: HexString
    • Optional destroyable?: undefined | false | true
    • fromScript: Script
    • Optional multisigScript?: HexString

payFee

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • fromInfos: FromInfo[]
    • amount: BIish
    • Optional tipHeader: Header
    • Optional __namedParameters: { config: undefined | Config; enableDeductCapacity: undefined | false | true; useLocktimeCellsFirst: undefined | false | true }
      • config: undefined | Config
      • enableDeductCapacity: undefined | false | true
      • useLocktimeCellsFirst: undefined | false | true

    Returns Promise<TransactionSkeletonType>

payFee

payFee

payFee

payFee

payFee

payFee

payFee

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • fromInfos: FromInfo[]
    • amount: BIish
    • Optional tipHeader: Header
    • Default value __namedParameters: { config: undefined | Config; enableDeductCapacity: boolean; useLocktimeCellsFirst: boolean } = {}
      • config: undefined | Config
      • enableDeductCapacity: boolean
      • useLocktimeCellsFirst: boolean

    Returns Promise<TransactionSkeletonType>

payFeeByFeeRate

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • fromInfos: FromInfo[]
    • feeRate: BIish
    • Optional tipHeader: Header
    • Optional __namedParameters: { config: undefined | Config; enableDeductCapacity: undefined | false | true; useLocktimeCellsFirst: undefined | false | true }
      • config: undefined | Config
      • enableDeductCapacity: undefined | false | true
      • useLocktimeCellsFirst: undefined | false | true

    Returns Promise<TransactionSkeletonType>

payFeeByFeeRate

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • fromInfos: FromInfo[]
    • feeRate: BIish
    • Optional tipHeader: Header
    • Default value __namedParameters: { config: undefined | Config; enableDeductCapacity: boolean; useLocktimeCellsFirst: boolean } = {}
      • config: undefined | Config
      • enableDeductCapacity: boolean
      • useLocktimeCellsFirst: boolean

    Returns Promise<TransactionSkeletonType>

prepareSigningEntries

prepareSigningEntries

prepareSigningEntries

prepareSigningEntries

  • prepare for txSkeleton signingEntries, will update txSkeleton.get("signingEntries")

    Parameters

    Returns TransactionSkeletonType

prepareSigningEntries

  • prepare for txSkeleton signingEntries, will update txSkeleton.get("signingEntries")

    Parameters

    Returns TransactionSkeletonType

prepareSigningEntries

prepareSigningEntries

  • prepare for txSkeleton signingEntries, will update txSkeleton.get("signingEntries")

    Parameters

    Returns TransactionSkeletonType

prepareSigningEntries

  • prepare for txSkeleton signingEntries, will update txSkeleton.get("signingEntries")

    Parameters

    Returns TransactionSkeletonType

prepareSigningEntries

  • prepare for txSkeleton signingEntries, will update txSkeleton.get("signingEntries")

    Parameters

    Returns TransactionSkeletonType

prepareSigningEntries

prepareSigningEntries

prepareSigningEntries

  • prepare for txSkeleton signingEntries, will update txSkeleton.get("signingEntries")

    Parameters

    Returns TransactionSkeletonType

prepareSigningEntries

prepareSigningEntries

registerCustomLockScriptInfos

  • Parameters

    Returns void

registerCustomLockScriptInfos

  • Parameters

    Returns void

resetLockScriptInfos

  • resetLockScriptInfos(): void
  • Returns void

resetLockScriptInfos

  • resetLockScriptInfos(): void
  • Returns void

resolveThunk

  • Type parameters

    • T

    Parameters

    Returns T

serializeMultisigScript

  • serializeMultisigScript(__namedParameters: { M: number; R: number; publicKeyHashes: string[] }): HexString
  • Parameters

    • __namedParameters: { M: number; R: number; publicKeyHashes: string[] }
      • M: number
      • R: number
      • publicKeyHashes: string[]

    Returns HexString

    serialized multisig script

serializeMultisigScript

  • serializeMultisigScript(__namedParameters: { M: number; R: number; publicKeyHashes: string[] }): HexString
  • Parameters

    • __namedParameters: { M: number; R: number; publicKeyHashes: string[] }
      • M: number
      • R: number
      • publicKeyHashes: string[]

    Returns HexString

    serialized multisig script

setupInputCell

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • inputCell: Cell
    • Optional _fromInfo: FromInfo
    • Optional __namedParameters: { config: undefined | Config; defaultWitness: undefined | string; since: undefined | string }
      • config: undefined | Config
      • defaultWitness: undefined | string
      • since: undefined | string

    Returns Promise<TransactionSkeletonType>

setupInputCell

  • A function to transfer input to output, and add input & output to txSkeleton. And it will deal with cell deps and witnesses too. (Add the input required cell deps and witnesses.) It should be noted that the output must be added to the end of txSkeleton.get("outputs").

    Parameters

    • txSkeleton: TransactionSkeletonType
    • inputCell: Cell
    • Optional fromInfo: FromInfo
    • Optional __namedParameters: { config: undefined | Config; defaultWitness: undefined | string; since: undefined | string }
      • config: undefined | Config
      • defaultWitness: undefined | string
      • since: undefined | string

    Returns Promise<TransactionSkeletonType>

setupInputCell

  • Setup input cell infos, such as cell deps and witnesses.

    Parameters

    • txSkeleton: TransactionSkeletonType
    • inputCell: Cell
    • Optional _fromInfo: FromInfo
    • Optional __namedParameters: { config: undefined | Config; defaultWitness: undefined | string; since: undefined | string }
      • config: undefined | Config
      • defaultWitness: undefined | string
      • since: undefined | string

    Returns Promise<TransactionSkeletonType>

setupInputCell

  • Setup input cell infos, such as cell deps and witnesses.

    Parameters

    • txSkeleton: TransactionSkeletonType
    • inputCell: Cell
    • Optional fromInfo: FromInfo
    • Optional __namedParameters: { config: undefined | Config; defaultWitness: undefined | string; requireMultisigScript: undefined | false | true; since: undefined | string }
      • config: undefined | Config
      • defaultWitness: undefined | string
      • requireMultisigScript: undefined | false | true
      • since: undefined | string

    Returns Promise<TransactionSkeletonType>

setupInputCell

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • inputCell: Cell
    • Optional fromInfo: FromInfo
    • Optional __namedParameters: { config: undefined | Config; defaultWitness: undefined | string; since: undefined | string }
      • config: undefined | Config
      • defaultWitness: undefined | string
      • since: undefined | string

    Returns Promise<TransactionSkeletonType>

setupInputCell

  • Setup input cell infos, such as cell deps and witnesses.

    Parameters

    • txSkeleton: TransactionSkeletonType
    • inputCell: Cell
    • Optional _fromInfo: FromInfo
    • Optional __namedParameters: { config: undefined | Config; defaultWitness: undefined | string; since: undefined | string }
      • config: undefined | Config
      • defaultWitness: undefined | string
      • since: undefined | string

    Returns Promise<TransactionSkeletonType>

setupInputCell

  • Setup input cell infos, such as cell deps and witnesses.

    Parameters

    • txSkeleton: TransactionSkeletonType
    • inputCell: Cell
    • Optional _fromInfo: FromInfo
    • Default value __namedParameters: { config: undefined | Config; defaultWitness: string; since: undefined | string } = {}
      • config: undefined | Config
      • defaultWitness: string
      • since: undefined | string

    Returns Promise<TransactionSkeletonType>

setupInputCell

  • Setup input cell infos, such as cell deps and witnesses.

    Parameters

    • txSkeleton: TransactionSkeletonType
    • inputCell: Cell
    • Optional fromInfo: FromInfo
    • Default value __namedParameters: { config: undefined | Config; defaultWitness: string; requireMultisigScript: boolean; since: undefined | string } = {}
      • config: undefined | Config
      • defaultWitness: string
      • requireMultisigScript: boolean
      • since: undefined | string

    Returns Promise<TransactionSkeletonType>

setupInputCell

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • inputCell: Cell
    • Optional fromInfo: FromInfo
    • Default value __namedParameters: { config: undefined | Config; defaultWitness: string; since: undefined | string } = {}
      • config: undefined | Config
      • defaultWitness: string
      • since: undefined | string

    Returns Promise<TransactionSkeletonType>

setupInputCell

  • A function to transfer input to output, and add input & output to txSkeleton. And it will deal with cell deps and witnesses too. (Add the input required cell deps and witnesses.) It should be noted that the output must be added to the end of txSkeleton.get("outputs").

    Parameters

    • txSkeleton: TransactionSkeletonType
    • inputCell: Cell
    • Optional fromInfo: FromInfo
    • Default value __namedParameters: { config: undefined | Config; defaultWitness: undefined | string; since: undefined | string } = {}
      • config: undefined | Config
      • defaultWitness: undefined | string
      • since: undefined | string

    Returns Promise<TransactionSkeletonType>

setupInputCell

  • Setup input cell infos, such as cell deps and witnesses.

    Parameters

    • txSkeleton: TransactionSkeletonType
    • inputCell: Cell
    • Optional _fromInfo: FromInfo
    • Default value __namedParameters: { config: undefined | Config; defaultWitness: string; since: undefined | string } = {}
      • config: undefined | Config
      • defaultWitness: string
      • since: undefined | string

    Returns Promise<TransactionSkeletonType>

setupInputCell

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • inputCell: Cell
    • Optional _fromInfo: FromInfo
    • Default value __namedParameters: { config: undefined | Config; defaultWitness: string; since: undefined | string } = {}
      • config: undefined | Config
      • defaultWitness: string
      • since: undefined | string

    Returns Promise<TransactionSkeletonType>

setupOutputCell

setupOutputCell

transfer

transfer

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • fromAddress: Address
    • toAddress: Address | null | undefined
    • amount: bigint
    • Optional options: undefined | { assertAmountEnough?: undefined | true; config?: Config; requireToAddress?: undefined | false | true }

    Returns Promise<TransactionSkeletonType>

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • fromAddress: Address
    • toAddress: Address | null | undefined
    • amount: bigint
    • options: { assertAmountEnough: false; config?: Config; requireToAddress?: undefined | false | true }
      • assertAmountEnough: false
      • Optional config?: Config
      • Optional requireToAddress?: undefined | false | true

    Returns Promise<[TransactionSkeletonType, bigint]>

transfer

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • fromInfo: FromInfo
    • toAddress: Address | undefined
    • amount: bigint
    • Optional options: undefined | { assertAmountEnough?: undefined | true; config?: Config; requireToAddress?: undefined | false | true }

    Returns Promise<TransactionSkeletonType>

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • fromInfo: FromInfo
    • toAddress: Address | undefined
    • amount: bigint
    • options: { assertAmountEnough: false; config?: Config; requireToAddress?: undefined | false | true }
      • assertAmountEnough: false
      • Optional config?: Config
      • Optional requireToAddress?: undefined | false | true

    Returns Promise<[TransactionSkeletonType, bigint]>

transfer

transfer

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • fromInfos: FromInfo[]
    • sudtToken: Token
    • toAddress: Address
    • amount: BIish
    • Optional changeAddress: Address

      if not provided, will use first fromInfo

    • Optional capacity: BIish
    • Optional tipHeader: Header
    • Optional __namedParameters: { LocktimePoolCellCollector: any; config: undefined | Config; splitChangeCell: undefined | false | true }
      • LocktimePoolCellCollector: any
      • config: undefined | Config
      • splitChangeCell: undefined | false | true

    Returns Promise<TransactionSkeletonType>

transfer

  • transfer capacity from secp256k1_blake160 script cells

    Parameters

    • txSkeleton: TransactionSkeletonType
    • fromAddress: Address
    • toAddress: Address | null | undefined
    • amount: bigint
    • Optional options: undefined | { assertAmountEnough?: undefined | true; config?: Config; requireToAddress?: undefined | false | true }

    Returns Promise<TransactionSkeletonType>

  • transfer capacity from secp256k1_blake160 script cells

    Parameters

    • txSkeleton: TransactionSkeletonType
    • fromAddress: Address
    • toAddress: Address | null | undefined
    • amount: bigint
    • options: { assertAmountEnough: false; config?: Config; requireToAddress?: undefined | false | true }
      • assertAmountEnough: false
      • Optional config?: Config
      • Optional requireToAddress?: undefined | false | true

    Returns Promise<[TransactionSkeletonType, bigint]>

transfer

  • transfer capacity from multisig script cells

    Parameters

    • txSkeleton: TransactionSkeletonType
    • fromInfo: FromInfo

      fromAddress or fromMultisigScript, if this address new to txSkeleton inputs, must use fromMultisigScript

    • toAddress: Address | undefined
    • amount: bigint

      transfer CKB capacity in shannon.

    • Optional options: undefined | { assertAmountEnough?: undefined | true; config?: Config; requireToAddress?: undefined | false | true }

    Returns Promise<TransactionSkeletonType>

  • transfer capacity from multisig script cells

    Parameters

    • txSkeleton: TransactionSkeletonType
    • fromInfo: FromInfo
    • toAddress: Address | undefined
    • amount: bigint
    • options: { assertAmountEnough: false; config?: Config; requireToAddress?: undefined | false | true }
      • assertAmountEnough: false
      • Optional config?: Config
      • Optional requireToAddress?: undefined | false | true

    Returns Promise<[TransactionSkeletonType, bigint]>

transfer

transfer

transfer

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • fromInfos: FromInfo[]
    • sudtToken: Token
    • toAddress: Address
    • amount: BIish
    • Optional changeAddress: Address

      if not provided, will use first fromInfo

    • Optional capacity: BIish
    • Optional tipHeader: Header
    • Default value __namedParameters: { LocktimePoolCellCollector: any; config: undefined | Config; splitChangeCell: boolean } = {}
      • LocktimePoolCellCollector: any
      • config: undefined | Config
      • splitChangeCell: boolean

    Returns Promise<TransactionSkeletonType>

transferCompatible

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • fromAddress: Address
    • toAddress: Address | null | undefined
    • amount: BIish
    • Optional options: undefined | { assertAmountEnough?: undefined | true; config?: Config; requireToAddress?: undefined | false | true }

    Returns Promise<TransactionSkeletonType>

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • fromAddress: Address
    • toAddress: Address | null | undefined
    • amount: BIish
    • options: { assertAmountEnough: false; config?: Config; requireToAddress?: undefined | false | true }
      • assertAmountEnough: false
      • Optional config?: Config
      • Optional requireToAddress?: undefined | false | true

    Returns Promise<[TransactionSkeletonType, BI]>

transferCompatible

  • Parameters

    Returns Promise<TransactionSkeletonType>

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • fromInfo: FromInfo
    • toAddress: Address | undefined
    • amount: BIish
    • options: { assertAmountEnough: false; config?: Config; requireToAddress?: undefined | false | true }
      • assertAmountEnough: false
      • Optional config?: Config
      • Optional requireToAddress?: undefined | false | true

    Returns Promise<[TransactionSkeletonType, BI]>

transferCompatible

transferCompatible

  • transfer capacity from secp256k1_blake160 script cells

    Parameters

    • txSkeleton: TransactionSkeletonType
    • fromAddress: Address
    • toAddress: Address | null | undefined
    • amount: BIish
    • Optional options: undefined | { assertAmountEnough?: undefined | true; config?: Config; requireToAddress?: undefined | false | true }

    Returns Promise<TransactionSkeletonType>

  • transfer capacity from secp256k1_blake160 script cells

    Parameters

    • txSkeleton: TransactionSkeletonType
    • fromAddress: Address
    • toAddress: Address | null | undefined
    • amount: BIish
    • options: { assertAmountEnough: false; config?: Config; requireToAddress?: undefined | false | true }
      • assertAmountEnough: false
      • Optional config?: Config
      • Optional requireToAddress?: undefined | false | true

    Returns Promise<[TransactionSkeletonType, BI]>

transferCompatible

  • Parameters

    Returns Promise<TransactionSkeletonType>

  • Parameters

    • txSkeleton: TransactionSkeletonType
    • fromInfo: FromInfo
    • toAddress: Address | undefined
    • amount: BIish
    • options: { assertAmountEnough: false; config?: Config; requireToAddress?: undefined | false | true }
      • assertAmountEnough: false
      • Optional config?: Config
      • Optional requireToAddress?: undefined | false | true

    Returns Promise<[TransactionSkeletonType, BI]>

transferCompatible

unlock

unlock

updateCellDeps

updateOutputs

verifyFromInfo

  • verifyFromInfo(fromInfo: FromInfo, __namedParameters?: { config: undefined | Config }): void
  • Parameters

    • fromInfo: FromInfo
    • Default value __namedParameters: { config: undefined | Config } = {}

    Returns void

withdraw

withdraw

withdraw

withdraw

Object literals

Const Hexify

Hexify: object

pack

pack: bytify = bytify

unpack

unpack: hexify = hexify

Const lockScriptInfos

lockScriptInfos: object

infos includes predefined and customized.

_customInfos

_customInfos: never[] = []

_predefinedInfos

_predefinedInfos: never[] = []

configHashCode

configHashCode: number = 0

infos

  • Returns LockScriptInfo[]

Generated using TypeDoc