Creating a spore with Secp256k1 lock

In this walkthrough, we will get hands-on with the process of constructing and sending spore/cluster transactions on the Testnet (Aggron) by using the Secp256k1Blake160 lock for these transactions.

Ingredients:

Steps:

Step 1: Environment Setup

Directions:

  1. Open your terminal and clone the spore-sdk repository:

git clone <https://github.com/ShookLyngs/spore-sdk.git>
  1. Navigate to your spore-sdk directory (make sure to replace the pathname with yours) :

cd ~/projects/spore-sdk
  1. Install dependencies by running the command:

pnpm i
  1. Once installed, build your local packages with:

pnpm run build:packages

Your environment setup is now ready if all commands execute without errors!

Step 2: Explore the Example

Directions:

In your terminal, navigate to the Spore Secp256k1 examples directory:

cd examples/secp256k1

You will find the example code stored in examples/secp256k1/apis. Feel free to experiment with the code.

Step 3: Construct and Send a Spore Transaction

Directions:

To create a spore on-chain, execute the apis/createSpore.ts example by running the command:

ts-node apis/createSpore.ts

This script will construct and send a transaction to create a spore on-chain. If successful, a Transaction Hash will be returned. You can use this hash to review your transaction details on the CKB Explorer.

What's Next?

Congratulations! You've successfully constructed and sent a spore/cluster transaction on Testnet (Aggron) and used the Secp256k1Blake160 lock for your transactions. Use these Spore examples as a starting point to further explore and develop with the Spore SDK. Keep experimenting!


(Optional) Customize Configurations

Ingredients:

  • Terminal

  • Spore Secp256k1 example

  • Your testing accounts (optional)

Directions:

If you wish to use your testing accounts or modify the SporeConfig of the examples, you can do so in the examples/secp256k1/utils/config.ts file:

// Inside utils/config.ts

export const defaultSporeConfig: SporeConfig = {
  /* Your custom SporeConfig */
};

export const accounts: string[] = [
  /* Your private keys */
];
(Optional) Use Your Own Accounts

Ingredients:

  • Terminal

  • Spore Secp256k1 example

  • Generator Tool website

  • Nervos Faucet website

Directions:

If you prefer to start with a clean environment for testing, you can replace the default testing private keys with your own in the examples/secp256k1/utils/config.ts file:

// Inside utils/config.ts

export const accounts: string[] = [
  /* Your private keys */
];
  1. To generate a new private key for testing, open the Generator Tool website, click the refresh icon to generate a new account, and copy the generated account's Private Key (256-bit) from the Private/Public Key block. Replace one of the default testing private keys in the examples/secp256k1/utils/config.ts file with this new key.

  2. To claim faucet for your new account, copy the generated account's Nervos CKB Address from the Default Lock (Secp256k1-Blake160) - Testnet block, open the Nervos Faucet website, paste the address into the address input, and click the Claim button. Wait for the faucet process to complete.

Your Feedback Matters!

Get in touch by:

Last updated