This project generates a type-safe smart contract client in TypeScript for the Algorand Blockchain that wraps the application client in AlgoKit Utils. It does this by reading an ARC-0032 application spec file.
To be able to consume the generated file you need to include it in a TypeScript project that has (at least) the following package installed:
npm install @algorandfoundation/[email protected]
To use the generator:
npx --yes @algorandfoundation/algokit-client-generator generate -a ./application.json -o ./client.generated.ts
There are a range of examples that you can look at to see a source smart contract ({contract.py}
), the generated client (client.ts
) and some tests that demonstrate how you can use the client (client.spec.ts
).
If you want to contribute to this project the following information will be helpful.
-
Clone this repository locally
-
Install pre-requisites:
- Install
AlgoKit
- Link: Ensure you can executealgokit --version
. - Bootstrap your local environment; run
algokit bootstrap all
within this folder, which will:- Install
Poetry
- Link: The minimum required version is1.2
. Ensure you can executepoetry -V
and get1.2
+ - Run
poetry install
in the root directory, which will set up a.venv
folder with a Python virtual environment and also install all Python dependencies - Run
npm install
- Install
- Install
-
Open the project and start debugging / developing via:
- VS Code
- Open the repository root in VS Code
- Install recommended extensions
- Run tests via test explorer
- IDEA (e.g. PyCharm)
- Open the repository root in the IDE
- It should automatically detect it's a Poetry project and set up a Python interpreter and virtual environment.
- Run tests
- Other
- Open the repository root in your text editor of choice
- Run
npm run test
- VS Code
- If you update to the latest source code and there are new dependencies you will need to run
algokit bootstrap all
again - Follow step 3 above
In the examples
folder there is a series of example contracts along with their generated client. These contracts are built using Beaker.
If you want to make changes to any of the smart contract examples and re-generate the ARC-0032 application.json files then change the corresponding examples/{contract}/{contract}.py
file and then run:
poetry run python -m examples
Or in Visual Studio Code you can use the default build task (Ctrl+Shift+B).
This project uses GitHub Actions to define CI/CD workflows, which are located in the .github/workflows
folder.
Making any changes to the generated code will result in the approval tests failing. The approval tests work by generating a version of client
and outputting it to ./examples/APP_NAME/client.generated.ts
then comparing to the approved version ./examples/APP_NAME/client.ts
. If you
make a change and break the approval tests, you will need to update the approved version by overwriting it with the generated version.
You can run npm run update-approvals
to update all approved clients in one go.