tons


Nametons JSON
Version 0.0.32 PyPI version JSON
download
home_page
SummaryTON Stash - secure TON wallet
upload_time2022-10-04 09:19:57
maintainer
docs_urlNone
authortonfactory.org
requires_python>=3.8
licenseApache 2.0
keywords ton wallet ton wallet blockchain security safety
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            > WARNING: some commands may be upgraded or changed

# Functionality and examples

Easy installation with a single command for non developers
```bash
sh -c "$(curl -sSfL https://raw.githubusercontent.com/tonfactory/temp_tons_install/master/install)"
```

Installation with pip3
```bash
$ pip3 install tons
$ tons init
```
> WARNING: for better user experience use virtual environment (python3 -m venv venv & source venv/bin/activate)

tons encrypts all your wallets info in a keystore file using your password. Create an encrypted keystore and select it as a current keystore.

```bash
$ tons keystore new myKeystore
Password []:

$ tons config tons.keystore_name myKeystore
```


Create any type of a TON wallet

```bash
$ tons wallet create \
	PocketMoney \
	--version v4r2 \
	--workchain 0 \
	--subwallet-id 0 \
	--comment “My main wallet” \
	--save-to-whitelist myPocketMoney
```


Add your contacts to a whitelist
```bash
$ tons whitelist add myBestFriend EQBP5aEPlmFNr4eS3DJw2ydC4X_hOumwZoqCcJgHVSQHjZWW
```


Transfer money from the wallet to a whitelist contact
```bash
$ tons transfer PockeyMoney myBestFriend 10 --message “Happy birthday!”
```


# Features


Switch between mainnet and testnet
```bash
$ tons config --network mainnet
```


Keystore, wallet, whitelist commands support CRUD (create, read, update, delete). Some examples

```bash
$ tons wallet get oldWallet
Raw address: 0:4fe5a10f96614daf8792dc3270db2742e17fe13ae9b0668a827098075524078d
Nonbounceable address: UQBP5aEPlmFNr4eS3DJw2ydC4X_hOumwZoqCcJgHVSQHjchT
Bounceable address: EQBP5aEPlmFNr4eS3DJw2ydC4X_hOumwZoqCcJgHVSQHjZWW
Version: v4r2
Workchain: 0
Comment: None

$ tons wallet delete oldWallet
Are you sure you want to delete oldWallet wallet? [y/N]: y

$ tons whitelist edit myBestFriend --name myFriend
``` 


Backup and restore your keystores

```bash
$ tons keystore backup ./myKeystore.backup
Password []: 
Backup stores keys in UNENCRYPTED FORM. Are you sure want to export unencrypted keys to disk? [y/N]: y

$ tons keystore restore myRestoredKeystore ./myKeystore.backup
Password []:
```

Export your wallet mnemonic words and import them in any official TON wallet

```bash
$ tons wallet reveal PocketMoney
Password []: 
cliff spin hawk artefact language volume subway surround nuclear lawn weird arrest mule cube impact crash abandon slender turn basic sentence actor you fix
```

Import wallet from mnemonic phrase 

```bash
$ tons wallet import-from-mnemonics restoredWallet v4r2 0 "cliff spin hawk artefact language volume subway surround nuclear lawn weird arrest mule cube impact crash abandon slender turn basic sentence actor you fix"
```

Export your wallet to .addr and .pk files

```bash
$ tons wallet to-addr-pk PocketMoney ./destinationDir/
Password []:
```

List all wallets and whitelist contacts with verbose information. Also, you can redirect output into a .md file to see a nice table.

```bash
$ tons wallet list --verbose
|   Name   | Version | WC |                     Address                      |       Comment        |  State   |    Balance    |
|:--------:|:-------:|:--:|:------------------------------------------------:|:--------------------:|:--------:|:-------------:|
|  PockeyMoney  |   v4r2  | 0  | EQBP5aEPlmFNr4eS3DJw2ydC4X_hOumwZoqCcJgHVSQHjZWW | None |  Active  | 1.095236369 |
|  Another wallet  |   v3r2  | 0  | EQCS9ZmXTu-VlDLIsjcQMpMjF0PSdA_aTD6MqCHlaLUoTARS |         None         |  Active  |  1.095236369  |

$ tons whitelist list -v  > myContacts.md
```

For daily usage you may prefer our tons-interactive version

```bash
$ tons-interactive
[✓] Pick command: Keystores
[✓] Pick command: Open keystore
[✓] Choose keystore to use: good.keystore
[?] Pick command: List wallets
 > List wallets
   Transfer
   Create wallet
   Init wallet
   Get wallet
   Edit wallet
   Delete wallet
   Reveal wallet mnemonics
   Import from mnemonics
   Wallet to .addr and .pk
   Backup keystore
   Back
```


# Development

A person can deploy smart-contracts using tons. There are three options: send-boc, send-internal, send-external.

**send-internal**
```bash
$ tons dev send-internal ./scripts/deploy.py deploy_through_internal MY_WALLET_NAME 0.1 --wait
```
 
```python
# ./scripts/deploy.py example. 
# Function must receive WalletContract and  return (str, Optional[Cell], Optional[Cell]) values.

from typing import Optional

from tonsdk.contract.wallet import WalletContract
from tonsdk.boc import Cell
from tonsdk.contract.token.ft import JettonMinter


def deploy_through_internal(wallet: WalletContract) -> (str, Optional[Cell], Optional[Cell]):
    minter = JettonMinter(admin_address=wallet.address,
                          jetton_content_uri="URL",
                          jetton_wallet_code_hex='CODE')

    return minter.address.to_string(), minter.create_state_init()["state_init"], None
```

**send-external**
```bash
$ tons dev send-external ./scripts/deploy.py deploy_through_external --wait
```

```python
# ./scripts/deploy.py example. 
# Function must receive nothing and return (str, Cell) values.
from tonsdk.contract.wallet import WalletContract, WalletVersionEnum, Wallets
from tonsdk.boc import Cell


def deploy_through_external() -> (str, Cell):
        wallet_workchain = 0
        wallet_version = WalletVersionEnum.v3r2
        wallet_mnemonics = "YOUR 24 ... WORDS".split(" ")

        _mnemonics, _pub_k, _priv_k, wallet = Wallets.from_mnemonics(
            wallet_mnemonics, wallet_version, wallet_workchain)
        return wallet.address.to_string(), wallet.create_init_external_message()["message"]
```

*Note: to deploy a wallet one can use '$ tons wallet WALLET_NAME init'*

**send-boc**
```bash
$ tons dev send-boc ./generated-through-fif.boc --wait
```

# Integrations

Example of automatic salary payment, you may use cron to run pay_salary.sh
```bash
$ cat employee.info
employee1 EQDvtizebIVTGYASXgjYX5sHfkGLW8aFTa7wfYCyARIpARB0 10
employee2 EQA-Ri7Oftdjq--NJmuJrFJ1YqxYk6t2K3xIFKw3syhIUgUe 20
employee3 EQCNLRRZkvoqAW6zwYyy_BVwOBcMnwqvyrSpm8WnACdzXuu3 15.5

$ cat pay_salary.sh
cd ~/team_workspace/ton/
source venv/bin/activate
tons config --local tons.keystore_name yandex

input="./employees.info"
while IFS= read -r line
do
    stringarray=($line)
    name=${stringarray[0]}
    addr=${stringarray[1]}
    salary=${stringarray[2]}

    tons wallet transfer SalaryWallet $name $salary --wait
done < "$input"
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "tons",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "TON,wallet,TON wallet,blockchain,security,safety",
    "author": "tonfactory.org",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/32/1d/457b9d47267098668a691776c54e2bd5015fde35d14bf9eede97eb6d0722/tons-0.0.32.tar.gz",
    "platform": null,
    "description": "> WARNING: some commands may be upgraded or changed\n\n# Functionality and examples\n\nEasy installation with a single command for non developers\n```bash\nsh -c \"$(curl -sSfL https://raw.githubusercontent.com/tonfactory/temp_tons_install/master/install)\"\n```\n\nInstallation with pip3\n```bash\n$ pip3 install tons\n$ tons init\n```\n> WARNING: for better user experience use virtual environment (python3 -m venv venv & source venv/bin/activate)\n\ntons encrypts all your wallets info in a keystore file using your password. Create an encrypted keystore and select it as a current keystore.\n\n```bash\n$ tons keystore new myKeystore\nPassword []:\n\n$ tons config tons.keystore_name myKeystore\n```\n\n\nCreate any type of a TON wallet\n\n```bash\n$ tons wallet create \\\n\tPocketMoney \\\n\t--version v4r2 \\\n\t--workchain 0 \\\n\t--subwallet-id 0 \\\n\t--comment \u201cMy main wallet\u201d \\\n\t--save-to-whitelist myPocketMoney\n```\n\n\nAdd your contacts to a whitelist\n```bash\n$ tons whitelist add myBestFriend EQBP5aEPlmFNr4eS3DJw2ydC4X_hOumwZoqCcJgHVSQHjZWW\n```\n\n\nTransfer money from the wallet to a whitelist contact\n```bash\n$ tons transfer PockeyMoney myBestFriend 10 --message \u201cHappy birthday!\u201d\n```\n\n\n# Features\n\n\nSwitch between mainnet and testnet\n```bash\n$ tons config --network mainnet\n```\n\n\nKeystore, wallet, whitelist commands support CRUD (create, read, update, delete). Some examples\n\n```bash\n$ tons wallet get oldWallet\nRaw address: 0:4fe5a10f96614daf8792dc3270db2742e17fe13ae9b0668a827098075524078d\nNonbounceable address: UQBP5aEPlmFNr4eS3DJw2ydC4X_hOumwZoqCcJgHVSQHjchT\nBounceable address: EQBP5aEPlmFNr4eS3DJw2ydC4X_hOumwZoqCcJgHVSQHjZWW\nVersion: v4r2\nWorkchain: 0\nComment: None\n\n$ tons wallet delete oldWallet\nAre you sure you want to delete oldWallet wallet? [y/N]: y\n\n$ tons whitelist edit myBestFriend --name myFriend\n``` \n\n\nBackup and restore your keystores\n\n```bash\n$ tons keystore backup ./myKeystore.backup\nPassword []: \nBackup stores keys in UNENCRYPTED FORM. Are you sure want to export unencrypted keys to disk? [y/N]: y\n\n$ tons keystore restore myRestoredKeystore ./myKeystore.backup\nPassword []:\n```\n\nExport your wallet mnemonic words and import them in any official TON wallet\n\n```bash\n$ tons wallet reveal PocketMoney\nPassword []: \ncliff spin hawk artefact language volume subway surround nuclear lawn weird arrest mule cube impact crash abandon slender turn basic sentence actor you fix\n```\n\nImport wallet from mnemonic phrase \n\n```bash\n$ tons wallet import-from-mnemonics restoredWallet v4r2 0 \"cliff spin hawk artefact language volume subway surround nuclear lawn weird arrest mule cube impact crash abandon slender turn basic sentence actor you fix\"\n```\n\nExport your wallet to .addr and .pk files\n\n```bash\n$ tons wallet to-addr-pk PocketMoney ./destinationDir/\nPassword []:\n```\n\nList all wallets and whitelist contacts with verbose information. Also, you can redirect output into a .md file to see a nice table.\n\n```bash\n$ tons wallet list --verbose\n|   Name   | Version | WC |                     Address                      |       Comment        |  State   |    Balance    |\n|:--------:|:-------:|:--:|:------------------------------------------------:|:--------------------:|:--------:|:-------------:|\n|  PockeyMoney  |   v4r2  | 0  | EQBP5aEPlmFNr4eS3DJw2ydC4X_hOumwZoqCcJgHVSQHjZWW | None |  Active  | 1.095236369 |\n|  Another wallet  |   v3r2  | 0  | EQCS9ZmXTu-VlDLIsjcQMpMjF0PSdA_aTD6MqCHlaLUoTARS |         None         |  Active  |  1.095236369  |\n\n$ tons whitelist list -v  > myContacts.md\n```\n\nFor daily usage you may prefer our tons-interactive version\n\n```bash\n$ tons-interactive\n[\u2713] Pick command: Keystores\n[\u2713] Pick command: Open keystore\n[\u2713] Choose keystore to use: good.keystore\n[?] Pick command: List wallets\n > List wallets\n   Transfer\n   Create wallet\n   Init wallet\n   Get wallet\n   Edit wallet\n   Delete wallet\n   Reveal wallet mnemonics\n   Import from mnemonics\n   Wallet to .addr and .pk\n   Backup keystore\n   Back\n```\n\n\n# Development\n\nA person can deploy smart-contracts using tons. There are three options: send-boc, send-internal, send-external.\n\n**send-internal**\n```bash\n$ tons dev send-internal ./scripts/deploy.py deploy_through_internal MY_WALLET_NAME 0.1 --wait\n```\n \n```python\n# ./scripts/deploy.py example. \n# Function must receive WalletContract and  return (str, Optional[Cell], Optional[Cell]) values.\n\nfrom typing import Optional\n\nfrom tonsdk.contract.wallet import WalletContract\nfrom tonsdk.boc import Cell\nfrom tonsdk.contract.token.ft import JettonMinter\n\n\ndef deploy_through_internal(wallet: WalletContract) -> (str, Optional[Cell], Optional[Cell]):\n    minter = JettonMinter(admin_address=wallet.address,\n                          jetton_content_uri=\"URL\",\n                          jetton_wallet_code_hex='CODE')\n\n    return minter.address.to_string(), minter.create_state_init()[\"state_init\"], None\n```\n\n**send-external**\n```bash\n$ tons dev send-external ./scripts/deploy.py deploy_through_external --wait\n```\n\n```python\n# ./scripts/deploy.py example. \n# Function must receive nothing and return (str, Cell) values.\nfrom tonsdk.contract.wallet import WalletContract, WalletVersionEnum, Wallets\nfrom tonsdk.boc import Cell\n\n\ndef deploy_through_external() -> (str, Cell):\n        wallet_workchain = 0\n        wallet_version = WalletVersionEnum.v3r2\n        wallet_mnemonics = \"YOUR 24 ... WORDS\".split(\" \")\n\n        _mnemonics, _pub_k, _priv_k, wallet = Wallets.from_mnemonics(\n            wallet_mnemonics, wallet_version, wallet_workchain)\n        return wallet.address.to_string(), wallet.create_init_external_message()[\"message\"]\n```\n\n*Note: to deploy a wallet one can use '$ tons wallet WALLET_NAME init'*\n\n**send-boc**\n```bash\n$ tons dev send-boc ./generated-through-fif.boc --wait\n```\n\n# Integrations\n\nExample of automatic salary payment, you may use cron to run pay_salary.sh\n```bash\n$ cat employee.info\nemployee1 EQDvtizebIVTGYASXgjYX5sHfkGLW8aFTa7wfYCyARIpARB0 10\nemployee2 EQA-Ri7Oftdjq--NJmuJrFJ1YqxYk6t2K3xIFKw3syhIUgUe 20\nemployee3 EQCNLRRZkvoqAW6zwYyy_BVwOBcMnwqvyrSpm8WnACdzXuu3 15.5\n\n$ cat pay_salary.sh\ncd ~/team_workspace/ton/\nsource venv/bin/activate\ntons config --local tons.keystore_name yandex\n\ninput=\"./employees.info\"\nwhile IFS= read -r line\ndo\n    stringarray=($line)\n    name=${stringarray[0]}\n    addr=${stringarray[1]}\n    salary=${stringarray[2]}\n\n    tons wallet transfer SalaryWallet $name $salary --wait\ndone < \"$input\"\n```\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "TON Stash - secure TON wallet",
    "version": "0.0.32",
    "split_keywords": [
        "ton",
        "wallet",
        "ton wallet",
        "blockchain",
        "security",
        "safety"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "60ef832ddbcf50e98cc4f2f0771ac395",
                "sha256": "9a9747b5aba725adafe4edd8212ad3d36adbb6a029850fe6da307a6b774d33dc"
            },
            "downloads": -1,
            "filename": "tons-0.0.32-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "60ef832ddbcf50e98cc4f2f0771ac395",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 88796,
            "upload_time": "2022-10-04T09:19:54",
            "upload_time_iso_8601": "2022-10-04T09:19:54.411467Z",
            "url": "https://files.pythonhosted.org/packages/15/07/c7707e1bd9d5d5d9a2b03f4c1f4a83b9daa07fdd9241b239e37556114fa2/tons-0.0.32-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "36da0407b7e13e8255c2e2ceaa109ab4",
                "sha256": "6803fc235492b2720e0290be4b00914ad9432fe9dc3f1a698c327c10bb1c3933"
            },
            "downloads": -1,
            "filename": "tons-0.0.32.tar.gz",
            "has_sig": false,
            "md5_digest": "36da0407b7e13e8255c2e2ceaa109ab4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 67441,
            "upload_time": "2022-10-04T09:19:57",
            "upload_time_iso_8601": "2022-10-04T09:19:57.615892Z",
            "url": "https://files.pythonhosted.org/packages/32/1d/457b9d47267098668a691776c54e2bd5015fde35d14bf9eede97eb6d0722/tons-0.0.32.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-10-04 09:19:57",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "tons"
}
        
Elapsed time: 0.59015s