-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathpaymaster.ts
28 lines (24 loc) · 1.06 KB
/
paymaster.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { AddressPrefix, privateKeyToAddress } from '@nervosnetwork/ckb-sdk-utils';
import { splitMultiCellsWithSecp256k1 } from '../src/paymaster';
import { Collector } from '../src/collector';
// SECP256K1 private key
const MASTER_SECP256K1_PRIVATE_KEY = '0x0000000000000000000000000000000000000000000000000000000000000001';
const RECEIVER_ADDRESS =
'ckt1qrfrwcdnvssswdwpn3s9v8fp87emat306ctjwsm3nmlkjg8qyza2cqgqqxqyukftmpfang0z2ks6w6syjutass94fujlf09a';
const splitPaymasterCells = async () => {
const collector = new Collector({
ckbNodeUrl: 'https://testnet.ckb.dev/rpc',
ckbIndexerUrl: 'https://testnet.ckb.dev/indexer',
});
const address = privateKeyToAddress(MASTER_SECP256K1_PRIVATE_KEY, { prefix: AddressPrefix.Testnet });
console.log('master address: ', address);
// Split 200 cells whose capacity are 316CKB for the receiver address
await splitMultiCellsWithSecp256k1({
masterPrivateKey: MASTER_SECP256K1_PRIVATE_KEY,
collector,
receiverAddress: RECEIVER_ADDRESS,
capacityWithCKB: 316,
cellAmount: 200,
});
};
splitPaymasterCells();