Continuing our posts for developers, we’d like to introduce you to our tools available to Python developers: our Python SDK and command line tool.
Cloning the SDK to Your Local Machine
To install the SDK on your local machine first make a folder and clone the SDK repo into the folder using the command below:
Python Virtual Environments and Packages
The SDK requires Python3. We recommend using Python virtual environments (venv) to handle the Python requirements needed to run the SDK. You can learn more about virtual environments here.
To create a virtual environment use the command below:
python3 -m venv venv
To activate the environment use this command:
To install the dependencies required to run the SDK run the following command (inside the folder where you cloned the SDK repository):
pip install -r requirements.txt
In the future, when you return to the project you created, don’t forget to run “source venv/bin/activate” again.
Making an Account Via the Command Line Client
Once you have the SDK running you will probably want to make an account (a key pair) and fill up your account with some Testnet tokens from our Token Faucet.
You can create a wallet using our command line tool, like so:
./aecli wallet "*wallet-path-and-name*" create
Where *wallet-path-and-name* is a path and wallet name like “/Users/some-user/projects/aeternity/aepp-sdk-python/wallet-name”
When the wallet is successfully created you will see its address in the print output, like so:
Wallet address________________ ak$2WZwyV3tJWQWd62FAtjKszmZS5oJU3cRHLGdH46KpNU99EVYCq
You need the address of your account/wallet to receive Testnet tokens.
To receive tokens, go to https://faucet.aepps.com, paste your address in the input field, and click “Top up!” Once the tokens have been added to your account you can check your account balance using this command (where *wallet-path-and-name* is a path and wallet name like “/Users/some-user/projects/aeternity/aepp-sdk-python/wallet-name”):
./aecli wallet "*wallet-path-and-name*" balance
After you input the command above and enter your account password you will see the available token balance on your screen!
Using the SDK
Incorporating the SDK Into Your Project
To incorporate the SDK into your project code you simply need to import the SDK modules, which you will be using, in your .py files, like so:
from aeternity.epoch import EpochClient
from aeternity.config import Config
In our Python SDK tutorial on dev.aepps.com we have provided code examples for: a simple spend transaction, using the naming system, Oracle operator and Oracle client. You can review or download the code examples here.
We welcome and encourage community members writing developer tutorials like the one above! The æternity forum user imae.one already wrote a tutorial very similar to this one and posted it in the Forum. If you would like to write a tutorial on a dev tools topic of your choice, feel free to contact us email@example.com, with a proposal for a topic (or topics), which you would like to cover. You will be rewarded 🙂
Up to now we’ve been working on developing the best possible interface for æternity. We’re almost at the point of supporting all of the features of the blockchain, so now we’re going to work on improving the SDK. Ideas that we’re planning for the future include: setting the number of blocks to wait before returning, so as to confirm that the transactions are permanently written to the chain, integration with popular IDEs, better examples and more. If you have feedback on what we should do to improve the SDKs, please email us at firstname.lastname@example.org and let us know.
Interested in æternity? Get in touch: