Create a Keychain
Overview
To become a Keychain operator, you need to create and configure a Keychain entity on-chain, as shown in this guide.
In the steps below, you'll interact with a local chain. To become an actual Keychain operator, you need to join Buenavista instead. However, we recommend running a local chain first to test your configuration.
You can skip this guide and test a preconfigured Keychain. Just run a local node using our just script and start fulfilling requests.
1. Run a node
-
Run a local chain as explained here: Run a local chain.
For the rest of this guide, we'll assume you have a running Warden Protocol node with a local account (key) that has a few WARD tokens. You'll use these tokens to fund the Keychain and its Writers.
-
The next steps require your local account name, or key name. You can check the list of available keys by executing this command:
wardend keys listtipIf you used our
justscript to run the node with default settings, the local account name isshulgin. -
Check the local account balance to make sure it has funds:
- Default node settings
- Custom node settings
wardend query bank balances shulginwardend query bank balances my-key-name -
In some of the commands, you'll also need to specify your chain ID. The actual value depends on the configuration you used when running your node.
To check your chain ID, run this:
wardend statusSee the
networkfield in the output.tipIf you used our
justscript to run the node with default settings, the chain ID iswarden_1337-1.
2. Register a Keychain
The following steps show how to register a new Keychain entity on-chain.
-
Run this command to create a new Keychain:
- Default node settings
- Custom node settings
wardend tx warden new-keychain \
--name 'my-keychain-name' \
--from shulgin \
--chain-id warden_1337-1wardend tx warden new-keychain \
--name 'my-keychain-name' \
--from my-key-name \
--chain-id chain_123-1Specify the required details:
name: The Keychain namefrom: Your local account name (key name)chain-id: The ID of the chain you're running
Optionally, you can also set the following:
description: The Keychain descriptionkeychain-fees: Keychain fees in aWARD (0.000000000000000001 WARD)key_req: A fee for creating a key pairsig_req: A fee for signing a transaction
- For more settings, see
wardend tx warden new-keychain --help.
-
Confirm the transaction. A new Keychain object will be created on-chain.
-
Every Keychain is created with a Keychain ID that identifies it in key and signature requests and collects fees from users. You'll need this ID to operate your Keychain. Run the following command and check the
idfield in the output:wardend query warden keychainskeychains:
- admins:
- warden1h7akmejqcrafp3mfpjqamghh89kzmkgjzsy3mc
creator: warden1h7akmejqcrafp3mfpjqamghh89kzmkgjzsy3mc
description: my-keychain-description
fees:
key_req:
- amount: "100"
denom: award
sig_req:
- amount: "1"
denom: award
id: "1"
name: my-keychain-name
pagination:
total: "1"
3. Add a Keychain Writer
A Keychain Writer is an account that can write Keychain results (public keys and signatures) to the chain. The Keychain Writers list is essentially an allowlist of accounts that can interact on behalf of the Keychain.
To add a Keychain Writer, take these steps:
-
Create a new key (account) with a preferred name:
wardend keys add my-keychain-writer-nameThe output should look like this:
- address: warden18my6wqsrf5ek85znp8x202wwyg8rw4fqhy54k2
name: my-keychain-writer-name
pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A2cECb3ziw5/LzUBUZIChyek3bnGQv/PSXHAH28xd9/Q"}'
type: local
**Important** write this mnemonic phrase in a safe place. It is the only way to recover your account if you ever forget your password.
virus boat radio apple pilot ask vault exhaust again state doll stereo slide exhibit scissors miss attack boat budget egg bird mask more trick -
Write down the mnemonic phrase and the address of the new account. You'll need this information to interact with the chain and restore the account. Note that only this address will be able to publish signatures and public keys on behalf of the Keychain.
-
Fund the account by running the command below. After
send, specify your key name. Also set the Keychain Writer name and chain ID:- Default node settings
- Custom node settings
wardend tx bank send shulgin \
$(wardend keys show --address my-keychain-writer-name) \
1000000000000000000award \
--chain-id warden_1337-1wardend tx bank send my-key-name \
$(wardend keys show --address my-keychain-writer-name) \
1000000000000000000award \
--chain-id chain_123-1To check the Keychain Writer balance, run this:
wardend query bank balances my-keychain-writer-nametipIn this example, we used
$(wardend keys show --address my-keychain-writer-name)to get the Keychain Writer address by its name. Alternatively, you can just specify the address obtained in the previous step. -
Finally, add the Writer account to your Keychain. In the
--fromflag, specify your key name. Also set the Keychain ID from Step 2.3, your Keychain writer name, and the chain ID:- Default node settings
- Custom node settings
wardend tx warden add-keychain-writer \
--from shulgin --keychain-id 1 \
--writer $(wardend keys show --address my-keychain-writer-name) \
--chain-id warden_1337-1wardend tx warden add-keychain-writer --from my-key-name \
--keychain-id 1 --writer \
$(wardend keys show --address my-keychain-writer-name) \
--chain-id chain_123-1To check the result, get the list of Keychains:
wardend query warden keychainsIn the output, find your Keychain and check the
writerslist:keychains:
- admins:
- warden1h7akmejqcrafp3mfpjqamghh89kzmkgjzsy3mc
creator: warden1h7akmejqcrafp3mfpjqamghh89kzmkgjzsy3mc
description: my-keychain-description
fees:
key_req:
- amount: "100"
denom: award
sig_req:
- amount: "1"
denom: award
id: "1"
name: my-keychain-name
writers:
- warden18my6wqsrf5ek85znp8x202wwyg8rw4fqhy54k2
pagination:
total: "1"
Next steps
The next steps depend on your goals:
- To become an actual Keychain operator, join Buenavista and create a Keychain there.
- To start fulfilling key and signature requests, follow this guide: Fulfill requests from CLI.
- To start building a Keychain service, follow Build a Keychain app.