KDA Module Fetcher is a versatile and automated tool designed to streamline the process of fetching and organizing KDA (Kadena) smart contract modules. This script fetches every module that is deployed on a given chain under a given namespace.
Disclaimer: This script only works with nodes having the AllowReadsInLocal option enabled.
- Dynamic Configuration: Substitute placeholders in YAML templates with user-provided values.
- Automated JSON Generation: Utilize the
kda gencommand to generate JSON configurations. - Module Fetching: Execute
kda localto retrieve KDA module data based on the generated JSON. - Organized Output: Parse the JSON output and create structured
.pactfiles within namespace-specific directories. - Flexible Usage: Fetch modules from any chain and any namespace. It is configured for testnet by default but can easily be used in other networks as well
Before using the KDA Module Fetcher, ensure you have the following installed and configured on your system:
-
Python 3.7+
- Verify installation:
python3 --version
- Verify installation:
-
KDA Tool (
kda-tool)- Installation instructions can be found here.
- Ensure
kda-toolis accessible in your system's PATH.
-
Git (for cloning the repository)
- Verify installation:
git --version
- Verify installation:
-
Clone the Repository:
git clone https://github.com/yourusername/kda-module-fetcher.git cd kda-module-fetcher
Make the Script Executable:
chmod +x fetch_namespace_modules.pyBasic Usage with Default Arguments:
./fetch_namespace_modules.pyThis command uses the default network URL (https://testnet.mindsend.xyz), chain (0), and namespace (n_9b079bebc8a0d688e4b2f4279a114148d6760edf).
Specify a Different Chain and Namespace:
./fetch_namespace_modules.py --chain "1" --namespace "n_abcdef123456"The script reads a YAML template file (fetch-modules.ktpl by default) containing placeholders like {{{chain}}} and {{{namespace}}}. These placeholders are dynamically replaced with the values provided via command-line arguments.
Using the substituted YAML file, the script executes the kda gen command to generate a corresponding JSON configuration file (temp_fetch_module_code.json).
The script then runs the kda local command with the generated JSON and specified network URL to retrieve module information.
The JSON output from kda local is parsed to extract each module's name and code.
Temporary files (substituted_config.ktpl and temp_fetch_module_code.json) are deleted after processing to maintain a clean workspace.
This repo welcomes forks, PRs and issues !
This project is licensed under the MIT License.