Create a Subnet with a Crowdloan
This page describes creating a subnet via crowdloan on a locally deployed Bittensor chain. We will use the Polkadot‑JS web app to submit extrinsics.
See also Crowdloans Overview
The following steps will take us through the lifecycle of a subnet creation crowdloan:
- First, we will create a crowdloan for a subnet. This is a special contract that will conditionally create the subnet if enough funds are raised (this threshold is called a crowdloan's cap).
- Next, we will contribute enough funds for the crowdloan to reach its cap.
- Next we must finalize the crowdloan, which executes the action wrapped inside the crowdloan—the creation of the subnet.
- Finally, we will verify the successful creation of the subnet by starting its emissions and observing the flow of liquidity to validator and creator hotkeys.
Prerequisites
- A locally running subtensor development chain. For more information, see run a local Bittensor blockchain instance.
- Polkadot‑JS browser app and Polkadot‑JS browser extension installed.
- An accessible 'Alice' wallet (see: Provision Wallets for Local Deploy)
Step 1: Connect Polkadot‑JS to your local chain
- Open the Polkadot‑JS app.
- In the network selector, choose Development → custom endpoint
ws://127.0.0.1:9944. - Confirm your local chain metadata loads and your test accounts appear in the Accounts tab. To do this, see create and import accounts to the Polkadot-JS extension.
If the web app does not connect to your local chain, your browser’s privacy or security settings may be blocking it. Try adjusting those settings and reconnecting.
Step 2: Generate call hash
Before creating the crowdloan, you must first generate the hash that registers the subnet and creates a dedicated proxy for the designated beneficiary. To begin:
-
Go to Developer → Extrinsics.
-
Under “using the selected account”, pick the crowdloan "
creator" account. -
Under “submit the following extrinsic”, choose module
subtensorModule, callregisterLeasedNetwork(emissionsShare, endBlock). -
Fill the parameters:
emissionsShare: choose a percentage, e.g, 30.endBlock: leave as none.
-
Copy the hex code shown in the encoded call data field. You will use this to create the crowdloan in the next step.
Do not submit the transaction after entering the parameters. Only copy the encoded call data once all parameters are provided.
Step 3: Create a crowdloan
We will create a campaign whose purpose is to register a leased subnet on finalize.
-
Go to Developer → Extrinsics.
-
Under “using the selected account”, pick the crowdloan "
creator" account. -
Under “submit the following extrinsic”, choose module
crowdloan, callcreate. -
Fill the parameters:
deposit: choose an amount (e.g.,10,000,000,000= 10 TAO on default dev config)min_contribution: e.g.,100,000,000(0.1 TAO)cap: e.g.,2,000,000,000,000(2000 TAO)end: pick a block height in the near future (e.g., current + 5000)call: put the hex code of the encoded call data saved from the previous step.target_address: leave as None.
info- Set the
capvalue higher than the projected subnet lock cost plus proxy deposit (and a small fee buffer). On most dev setups the baseline lock cost is 1,000 TAO (1,000,000,000,000 RAO). Ifcapequals the lock cost exactly, the lease coldkey may lack enough to pay proxy deposits and finalize can fail with insufficient balance. - Crowdloans must have a duration between 7 days (50,400 blocks minimum) and 60 days (432,000 blocks maximum) on production chains. Therefore, the
endvalue must be set at least 50,400 blocks and at most 432,000 blocks after the current block. This limitation also applies on testnet and mainnet.
-
Click Submit Transaction and sign with the
creatoraccount.
Get the crowdloan ID
Crowdloan IDs are allocated sequentially, starting from 0, with each new crowdloan assigned the next incremental ID. There is no extrinsic to list created crowdloans. Therefore, to check the identity of crowdloans created, you must use one of these methods.
-
From Events:
- Navigate to the block explorer after submitting the crowdload transaction.
- In the Explorer tab, find the block in which the transaction occured.
- In the Events panel, locate the
crowdloan.createextrinsic. Thecrowdloan.Createdevent payload includescrowdloanIdthat represents the ID of the crowdloan.
-
From storage:
- From the Developer dropdown, navigate to Chain state → Storage.
- Click the selected state query menu and select
crowdloan.nextCrowdloanId. - Click the + icon to run the query.
tipThis query returns the ID assigned to the next crowdloan that will be created. Subtract 1 from the returned value to determine the total number of crowdloans that currently exist.
-
From the JS console:
- From the Developer dropdown, navigate to Javascript.
- Next, paste the following code block in the editor and run:
// List all existing crowdloan ids
const keys = await api.query.crowdloan.crowdloans.keys();
console.log(keys.map((k) => k.args[0].toNumber()));
Step 4: Contribute to the crowdloan
All contributions must occur before the defined end block and will be clipped to the cap value provided.
To contribute to the crowdloan, repeat the following steps for each contributor account:
- From the Developer dropdown, navigate to Extrinsics
- Under “using the selected account”, select the crowdloan "contributor(s)" account.
- Under “submit the following extrinsic