Skip to content

Commit d47037c

Browse files
committed
set protocol ID to null in chainSpec
1 parent 79e5042 commit d47037c

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

examples/read.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ async function main() {
2424
if (!chainSpecObj.bootNodes || chainSpecObj.bootNodes.length === 0) {
2525
console.warn("⚠️ No bootnodes found! Smoldot won't be able to sync.");
2626
}
27+
28+
// Set protocolId to null
29+
console.log("Original protocolId:", chainSpecObj.protocolId);
30+
chainSpecObj.protocolId = null;
31+
console.log("Modified protocolId:", chainSpecObj.protocolId);
32+
33+
// Convert back to string
34+
const modifiedChainSpec = JSON.stringify(chainSpecObj);
2735

2836
const keyring = new Keyring({ type: 'sr25519' });
2937
const sudo_pair = keyring.addFromUri('//Alice');
@@ -55,7 +63,7 @@ async function main() {
5563
}
5664
});
5765
await client
58-
.addChain({ chainSpec })
66+
.addChain({ chainSpec: modifiedChainSpec })
5967
.then(async (chain) => {
6068
// Give smoldot a moment to sync
6169
console.log("⏳ Waiting for smoldot to sync...");
@@ -87,15 +95,6 @@ async function main() {
8795
const headerResponse = await chain.nextJsonRpcResponse();
8896
const headerParsed = JSON.parse(headerResponse);
8997
console.log("Current head block number:", parseInt(headerParsed.result.number, 16));
90-
91-
// Now try a simple balance transfer instead of sudo
92-
console.log("Creating a simple balance transfer...");
93-
const bob = keyring.addFromUri('//Bob');
94-
const transferTx = api.tx.balances.transferKeepAlive(bob.address, 1000000000000);
95-
const signedTransfer = await transferTx.signAsync(sudo_pair);
96-
97-
console.log("Submitting transfer transaction...");
98-
chain.sendJsonRpc(`{"jsonrpc":"2.0","id":2,"method":"author_submitAndWatchExtrinsic","params":["${signedTransfer.toHex()}"]}`);
9998
return chain;
10099
})
101100
.then(async (chain) => {

0 commit comments

Comments
 (0)