Skip to main content

Universal TON wallet

Project description

Installation

To use wton package (comming soon)

One can install wton by "pip" (a package manager) by simply running the following commands:

mkdir ~/tonworkdir & cd ~/tonworkdir
python -m venv venv
source venv/bin/activate
pip install wton
wton init
wton --help

WARNING: One can ignore installation of a virtual environment but we highly recommend to use it not to affect the global python packages.

To contribute

Simply clone this repository and see "Development" section bellow.

Usage

wton-interactive

To start interactive session. Hasn't been implemented yet.


wton-gui

To start interactive session. Hasn't been implemented yet.


wton

Basic commands

Initialize environment

$ wton init

It sets the required files structure in a current directory:

.wton
├── config.yaml
├── whitelist.json
├── keystores
│   ├── *.keystore
├── tonlibjson
│   ├── keystore
│   │   ├── *.blkstate
│   ├── mainnet.json
│   ├── testnet.json
│   ├── configs_info.yaml

tonlibjson directory is used when a person uses tonlibjson provider. When one uses toncenter setup it is not required.

Check package version

$ wton --version
wton, version 0.0.1

Get help info for ANY command

$ wton --help
Usage: wton [OPTIONS] COMMAND [ARGS]...

Options:
  --version      Show the version and exit.
  -c, --config   Use specific config.yaml file.
  -h, --help     Show this message and exit.

Commands:
  config    Controls config parameters.
  whitelist   Operate with whitelist.
  contract  Operate with contracts.
  init      Initialize .wton workdir in a current directory.
  keystore  Operate with keystores
  wallet    Operate with wallets

Config

Config is the file 'config.yaml' where one can change required settings of the wton package.

All fields:

Name Description
wton.keystore_name name of the keystore a person wants to use.
wton.provider toncenter/tonlibjson to access TON.
wton.workdir directory where whitelist and keystores are stored
provider.toncenter.api_key a person's api key for toncenter api
provider.toncenter.base_url url to request (in case one deployed their own toncenter)
provider.tonlibjson.config_path tonlibjson config (in case one deployed their own liteservers)
provider.tonlibjson.configs_auto_update wton requests configs updates from official github repo once a day
provider.tonlibjson.cdll_path in case one have compiled own version of a tonlibjson
provider.tonlibjson.workdir directory where tonlibjson keystore and configs are stored

List values of current config setup

$ wton config --current-setup
wton.workdir=/path/.wton
provider.tonlibjson.workdir=/path/.wton/tonlibjson
...

List all configs and their values

$ wton config --list
/home/.config/wton/config.yaml  provider.tonlibjson.workdir=/path/.wton/tonlibjson
/home/.config/wton/config.yaml  wton.workdir=/path/.wton/
/path/to/workdir/.wton/config.yaml  wton.workdir=/path/.wton
...

Get config value

$ wton config --local wton.provider
toncenter

Set config value

$ wton config --global wton.provider tonlibjson

Unset config value

$ wton config --file ~/.config/wton/config.yaml --unset wton.provider

Download latest TON testnet/mainnet configs

$ wton config --update-ton-configs

Switch between testnet/mainnet configs for the current provider

$ wton config --local --network testnet

Whitelist

Whitelist stores addresses with names linked to them so one does not transfer money to an incorrect address.

Add a whitelist (name, address) to the whitelist.json

$ wton whitelist add main EQB3wZaZJTzRKt+9Ny1+AqdNdq9WIUV6goBhxZqad6XH0oBx

Get address of a whitelist

$ wton whitelist get main
EQB3wZaZJTzRKt+9Ny1+AqdNdq9WIUV6goBhxZqad6XH0oBx

List all whitelist contacts

$ wton whitelist list --versbose
| Name  |                     Address                      |     State     |      Balance       |
| :---: | :----------------------------------------------: | :-----------: | :----------------: |
| bank  | EQAhE3sLxHZpsyZ_HecMuwzvXHKLjYx4kEUehhOy2JmCcHCT |    active     | 
531223394.35714173 |
| main  | EQB3wZaZJTzRKt+9Ny1+AqdNdq9WIUV6goBhxZqad6XH0oBx | uninitialized |         0          |

One can redirect the output of this command into .md file to get a nice table.

$ wton whitelist list --versbose > whitelist.md
Name Address State Balance
bank EQAhE3sLxHZpsyZ_HecMuwzvXHKLjYx4kEUehhOy2JmCcHCT active 531223394.35714173
main EQB3wZaZJTzRKt+9Ny1+AqdNdq9WIUV6goBhxZqad6XH0oBx uninitialized 0

Keystore

Keystore is a file where wton stores all wallets information.

Create new keystore

$ wton keystore new myCompanyName1.keystore --password MY_SECRET_PASSWORD

A person can also specify WTON_KEYSTORE_PASSWORD. If one does not want to use it they must not forget to unset it.

$ export WTON_KEYSTORE_PASSWORD=MY_SECRET_PASSWORD
$ unset WTON_KEYSTORE_PASSWORD

Without either --password flag or environment variable one will be forced to enter the password in a hidden way.

$ wton keystore new myCompanyName1.keystore
Password []:

List of keystores

$ wton keystore list
myCompanyName1.keystore
myCompanyName2.keystore

Wallet

Create a wallet locally

$ wton wallet create \
    burner \
    --workchain 0 \
    --version v3r2 \
    --comment "Burner - active wallet for daily usage" \
    --save-to-whitelist burner

Get wallet information

$ wton wallet list --versbose
|  Name  | Version |  WC   |                     Address                      |     State     | Balance |
| :----: | :-----: | :---: | :----------------------------------------------: | :-----------: | :-----: |
|  main  |  v3r2   |   0   | EQDmT2DmF4TdnocLahvwPTEL0/xxTCusR7DsAEVCfZUQ2iA8 | uninitialized |    0    |
| burner |  v3r2   |   0   | EQDK8GHxZUcIhq52a8S4c-l2Ce1PEPcz4sqi0qeXsGUw49Mt | uninitialized |    0    |

One can redirect the output of this command into .md file to get a nice table.

$ wton wallet list --versbose > wallets.md
Name Version WC Address State Balance
main v3r2 0 EQDmT2DmF4TdnocLahvwPTEL0/xxTCusR7DsAEVCfZUQ2iA8 uninitialized 0
burner v3r2 0 EQDK8GHxZUcIhq52a8S4c-l2Ce1PEPcz4sqi0qeXsGUw49Mt uninitialized 0

Initialize wallet address as a wallet contract

WARNING: To initialize a wallet one must send some TON coins to their wallet's address through any interface (web wallet, telegram wallet, etc.). To validate whether balance has been changed one can run "wton wallet list --versbose" or "wton contract --wallet NAME info" and check the balance field.

$ wton wallet init burner

At that moment wallet's 'state' field should be 'active'.

Transfer TON coins from the wallet to the whitelist contact

$ wton wallet transfer main friendName 24.5 --message "Birthday present!" --ignore-errors 0 --pay-gas-separately 0 --destroy-if-zero 1 --transfer-all 1

Contract

Contract allows a person to interact with abstract addresses.

Get information about an address

One can query contract by whitelist name/wallet name/abstract address

$ wton contract --whitelist bank info
@type: raw.fullAccountState
balance: 531223393958066941
code: te6cckECKQEAA/cAART/APSkE/S88sgLAQIBIAIDAgFIBAUE2vIgxwCOgzDbPOCDCNcYIPkBAdMH2zwiwAAToVNxePQOb6Hyn9s8VBq6+RDyoAb0BCD5AQHTH1EYuvKq0z9wUwHwCgHCCAGDCryx8mhTFYBA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IyAH5SML6OIF8D+ACTItdKmALTB9QC+wAC6DJwyMoAQBSAQPRDAvAHjhdxyMsAFMsHEssHWM8BWM8WQBOAQPRDAeIBII6KEEUQNEMA2zztVJJfBuIoABzIyx/LB8sHyz/0APQAyc+7oJU=
data: te6cckEBCwEA5wACHQAAAAEFA2JIYo0AAAAA4AECAgHLAwQAE6AxKLsWAAAAACACASAFBgBD0hjXSLxNT0/5NIH9QcOZRdVYe44qotijXq+Z7uktm6lgBAIBIAcIAgEgCQoAQyyRVFPHNrdpK1tMdvOpDmrux6At6Ydsil7uWJwQRyOhgCAAQwd3bNaR++E+iR7W29FUYcCYsblcgir2Bb6NwzHn1FVxACAAQzgX3I3jBXNLDIo60FJk6XZaBKOdvgPdmXOqYSph92bXwCAAQx+MZxR866FwDTUD5UwIIPll9PguUhDpoyJKd2yPP60YQCCZhU9l
last_transaction_id: {'@type': 'internal.transactionId', 'lt': '28158895000005', 'hash': 'n/Od4tUI78l4XBR9hHS6Y+ORYW3bbInugiHlaKNxlk0='}
block_id: {'@type': 'ton.blockIdExt', 'workchain': -1, 'shard': '-9223372036854775808', 'seqno': 20850197, 'root_hash': 'k/+E+fwSizIM/nAJSIQCmRFjlUHEhMSSh+TBxChbpHY=', 'file_hash': 'SDuvK4eGPQzRGuqZU0UPzPi9+G4DWr4sK+3tQ2tp3dg='}
frozen_hash: 
sync_utime: 1653594345
@extra: 1653594364.911616:1:0.28059912601502424
state: active

Get sequential number of an address

$ wton contract --wallet burner seqno
132

Development

To run the package during development time, create /PATH/TO/PERSON/venv/bin/wton file and add the following code:

#!/PATH/TO/PERSON/venv/bin/python
# -*- coding: utf-8 -*-
import re
import sys

sys.path.append("/PATH/TO/PERSON/FOLDER/WITH/wton")

from wton.ui.direct_cli import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

Makefile commands:

make devenv  - Install requirements
make ci      - Run tests
make build   - Build the package
make publish - Publish to the PyPi

To install the build

pip install dist/wton-0.0.1-py3-none-any.whl

To build tonlibjson check out the scripts (linux/mac) in the directory: ./devtools/build_tonlibjson/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wton-0.0.4.tar.gz (59.8 kB view details)

Uploaded Source

Built Distribution

wton-0.0.4-py3-none-any.whl (73.8 kB view details)

Uploaded Python 3

File details

Details for the file wton-0.0.4.tar.gz.

File metadata

  • Download URL: wton-0.0.4.tar.gz
  • Upload date:
  • Size: 59.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.11

File hashes

Hashes for wton-0.0.4.tar.gz
Algorithm Hash digest
SHA256 2d2bc70be8418cf6664ca5273e806b159654c06a83e4522077c09d82a550666d
MD5 2c8edc4a94091e964a5b54a2d9c7eb57
BLAKE2b-256 cbe5eb7af15252fbbbf75721c8515554a42a46fc110c328a231ae5c514c24d29

See more details on using hashes here.

File details

Details for the file wton-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: wton-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 73.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.11

File hashes

Hashes for wton-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0180b9cdfb5f602237694e73be1cae90e75be830ec62345cf5c90aef8d731eda
MD5 81db5449f846ae91719ece02d26908c1
BLAKE2b-256 c3a38a11f5f9101a4ec8d7aa282cdebe4ab68ba389e27a153382ef4baa8d23ae

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page