Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function main (): Promise {
const provider = new WsProvider(ws);
const api = await ApiPromise.create({ provider });
const [chain, props] = await Promise.all([
api.rpc.system.chain(),
api.rpc.system.properties()
]);
// output the chain info, for easy re-use
console.error(`// Generated via 'yarn run chain:info ${ws}'\n\nexport default {\n chain: '${chain.toString()}',\n genesisHash: '${api.genesisHash.toHex()}',\n specVersion: ${api.runtimeVersion.specVersion.toNumber()},\n ss58Format: ${props.ss58Format.unwrapOr(42)},\n tokenDecimals: ${props.tokenDecimals.unwrapOr(0)},\n tokenSymbol: '${props.tokenSymbol.unwrapOr('UNIT')}',\n metaCalls: '${Buffer.from(api.runtimeMetadata.asCallsOnly.toU8a()).toString('base64')}'\n};`);
// show any missing types
api.runtimeMetadata.getUniqTypes(false);
}