This page explains how to download, install, and use Blockstream’s Green Development Kit (GDK) with AMP assets.
GDK enables you to develop solutions that benefit from the infrastructure that supports the Blockstream Green mobile and desktop wallets.
The page provides a link to some example Python code that creates a GDK wallet with a Managed Assets sub account. This allows the wallet to be capable of holding Blockstream AMP issued assets.
Using GDK in this way is useful for anyone wanting to hold AMP assets outside of Green mobile or Green desktop. It can be used to automate wallet processes involving AMP assets. If you need an example covering some common features needed by those who act as custodians of AMP assets on behalf of others, please contact us.
The linked example below covers:
- Logging with an existing 24 word mnemonic or generating a new mnemonic.
- Set a pin for the wallet and login with the pin.
- Check and set the wallet’s Two Factor Authentication (2FA) status.
- Handle calls to methods that use 2FA, such as creating a spending transaction.
- Handle events in the Green notification queue, such as new blocks.
- Get a new address and an address pointer.
- Send an asset from the wallet to a Liquid address.
- Get all wallet related transactions from Green, or only ones from a certain block height.
Blockstream’s Green Development Kit (GDK) is a cross-platform library for Blockstream Green wallets that can currently be used through Python and Java wrappers.
The GDK documentation can be used to expand the example further. A good example of a well-featured client application using GDK is green-cli. An example of using green-cli can be found in the GDK Command Line Example section.
Create a new directory named
Within that directory, create a new file named
gdk-example-python.py and copy and paste the example code from the GDK repository’s AMP example into it. Save the file.
From the terminal, move into the new directory:
Create a virtual environment (optional):
virtualenv -p python3 venv
If you did use a virtual environment, activate it:
You may prefer to build and install GDK from source but it is simpler to download and install the GDK python wheel for your platform from the GDK release page.
If the version provided in the releases page does not match your Python version you will have to build GDK and use the build options to specify the version you have.
On the release page note that the ‘cp’ in the name refers to the Python version you have installed. You can check the version you have installed by running:
For example for a Python 3.9.* install on a 64 bit Linux platform you would download
greenaddress-0.0.55-cp39-cp39-linux_x86_64.whl, move it to the
gdk-example-python directory and install it using pip:
pip install greenaddress-0.0.55-cp39-cp39-linux_x86_64.whl
Now you can run the example code:
Updated about 1 year ago