Skip to main content

Getting Started with Python

Safe Password Storage

In a production setup, do not store passwords in the host's environment variables or in the source code. See our backup and security recommendations for production setups.

Requirements

Install the Library

Clone the Repository

You can clone the wallet.rs client library by running the following command:

git clone https://github.com/iotaledger/wallet.rs

Change to the Python Binding Directory

After you have cloned the repository, you should change directory to wallet.rs/bindings/python/native. You can do so by running the following command:

cd wallet.rs/bindings/python/native

(optional) Create and use a virtual environment

If you want to isolate the library from the rest of your system, you can create a virtual environment by running the following commands:

python3 -m venv iota_wallet_venv
Linux and macOS
source iota_wallet_venv/bin/activate
Windows
.\iota_wallet_venv\Scripts\activate

Install the Required Dependencies and Build the Wheel

Once you have cloned the library, and moved to the binding's directory, you should install dependencies and build the wheel file.

You can do so by running the following commands:

pip install -r requirements-dev.txt
pip install .

(optional) Deactivate the virtual environment

If you want to deactivate the virtual environment, you should run the following command from the virtual environment:

deactivate

Use the Library

After you have installed the library, you can create a IotaWallet instance and interact with it.

from iota_wallet import IotaWallet, StrongholdSecretManager

# This example creates a new database and account

client_options = {
'nodes': ['https://api.testnet.shimmer.network'],
}

# Shimmer coin type
coin_type = 4219

secret_manager = StrongholdSecretManager("wallet.stronghold", "some_hopefully_secure_password")

wallet = IotaWallet('./alice-database', client_options, coin_type, secret_manager)

# Store the mnemonic in the Stronghold snapshot, this only needs to be done once
account = wallet.store_mnemonic("flame fever pig forward exact dash body idea link scrub tennis minute " +
"surge unaware prosper over waste kitten ceiling human knife arch situate civil")

account = wallet.create_account('Alice')
print(account)

What's Next?

Now that you are up and running, you can get acquainted with the library using its how-to guides and the repository's code examples.