newrl


Namenewrl JSON
Version 0.3.4 PyPI version JSON
download
home_pagehttps://github.com/asqi/newrl
SummaryPython SDK for Newrl blockchain
upload_time2023-01-19 11:31:59
maintainer
docs_urlNone
authorKousthub Raja
requires_python>=3.6
licenseMIT
keywords newrl blockchain client
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # newrl
This library contains wrapper functions for interacting with the Newrl blockchain. Off chain and on chain operations are available.

## Installation
Add `newrl` to your project requirements 
and/or run the installation with:
```shell
pip install newrl
```


## Usage

### Initialise a node connection
A node address along with port can be given to initialise a new node connection. If no address is provided, the default newrl foundation node at address `http://newrl.net:8090` will be used.

```python
node = Node('http://3.6.236.206:8090')
```

### Off chain operations
#### Get file hash
Certain Newrl operations use document hashes for verification purpose. A file hash can be obtained with the below command.

```python
from newrl import get_file_hash

file_hash = get_file_hash('/Users/admin/Documents/Tokenisation_Agreement1.pdf')
print(file_hash)
```

#### Generate new wallet
A wallet address generation can be done off-chain. The result is a dictionary containing public, private and address of the new wallet. A wallet once generated should be added to the chain to make it available for use.

```python
from newrl import generate_wallet_address

wallet = generate_wallet_address()
```

#### Sign transaction
A transaction need to be signed with the applicable wallet for addition to chain.
```python
from newrl import sign_transaction

signed_wallet_add_transaction = sign_transaction(wallet, wallet_add_transaction)
print(signed_wallet_add_transaction)
```

### On chain operations
#### Add wallet to chain
A wallet address once genearated need to be signed and then added to the chain.
```python
def add_wallet(
    custodian_address: str,
    jurisdiction: str,
    public_key: str,
    ownertype: str = '1',
    kyc_docs: list = [],
    specific_data: dict = {},
)
```
Example
```python
wallet_add_transaction = node.add_wallet(
    wallet['address'], '910', wallet['public'], 1)

print(wallet_add_transaction)
```

#### Add token to chain
A token can be created, signed and then validated to add to the chain.
```python
def add_token(
        token_name: str,
        token_type: str,
        first_owner: str,
        custodian: str,
        legal_doc_hash: str,
        amount_created: int,
        value_created: int,
        disallowed_regions: list = [],
        token_attributes: dict = {},
        is_smart_contract_token: bool = False,
    )
```
Example
```python
    token_add_transaction = node.add_token(
        'my_new_token',
        '1',
        '0x16031ef543619a8569f0d7c3e73feb66114bf6a0',
        '0x16031ef543619a8569f0d7c3e73feb66114bf6a0',
        'fhdkfhldkhf',
        10000,
        10000,
    )
```

#### Add transfer
A transfer can be created between two wallets either unilaterally or bilaterally depending on the transfer type.
```python
def add_transfer(
        self,
        asset1_code: int,
        asset2_code: int,
        wallet1_address: str,
        wallet2_address: str,
        asset1_qty: int,
        asset2_qty: int,
        transfer_type: int = 4,
    )
```
Example
```python
    transfer_transaction = node.add_transfer(
        9, 10, '0x16031ef543619a8569f0d7c3e73feb66114bf6a0', '0x16031ef543619a8569f0d7c3e73feb66114bf6a0', 10, 10, 4)
    signed_transfer = sign_transaction(wallet, transfer_transaction)
    print(signed_transfer)
```

#### Get balance
The balance of a given token in a wallet, across wallets or all tokens in a wallet can be obtained with get balance function.
```python
    node.get_balance(balance_type, wallet_address, token_code)
```
Example
```python
    node.get_balance('TOKEN_IN_WALLET', '0xc29193dbab0fe018d878e258c93064f01210ec1a', 9)
```

#### Validate transaction
A singed transaction need to be validated to be added to the chain.
```python
    validate_result = node.validate_transaction(signed_transfer)
    print(validate_result)
```

#### Run updater
Run the miner to create a new block out of the transactions. If no valid transactions are found then an empty block will be created. This operation is not meant to be called and supposed to be run automatically by a chosen node at different intervals of time.
```python
    response = node.run_updater()
    print(response)
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/asqi/newrl",
    "name": "newrl",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "newrl,blockchain,client",
    "author": "Kousthub Raja",
    "author_email": "kousthub@asqi.in",
    "download_url": "https://files.pythonhosted.org/packages/2c/9c/1c835cf1607d8f3b4cb41547d9703e91cf2c1537da11491c478192ece9ad/newrl-0.3.4.tar.gz",
    "platform": null,
    "description": "# newrl\nThis library contains wrapper functions for interacting with the Newrl blockchain. Off chain and on chain operations are available.\n\n## Installation\nAdd `newrl` to your project requirements \nand/or run the installation with:\n```shell\npip install newrl\n```\n\n\n## Usage\n\n### Initialise a node connection\nA node address along with port can be given to initialise a new node connection. If no address is provided, the default newrl foundation node at address `http://newrl.net:8090` will be used.\n\n```python\nnode = Node('http://3.6.236.206:8090')\n```\n\n### Off chain operations\n#### Get file hash\nCertain Newrl operations use document hashes for verification purpose. A file hash can be obtained with the below command.\n\n```python\nfrom newrl import get_file_hash\n\nfile_hash = get_file_hash('/Users/admin/Documents/Tokenisation_Agreement1.pdf')\nprint(file_hash)\n```\n\n#### Generate new wallet\nA wallet address generation can be done off-chain. The result is a dictionary containing public, private and address of the new wallet. A wallet once generated should be added to the chain to make it available for use.\n\n```python\nfrom newrl import generate_wallet_address\n\nwallet = generate_wallet_address()\n```\n\n#### Sign transaction\nA transaction need to be signed with the applicable wallet for addition to chain.\n```python\nfrom newrl import sign_transaction\n\nsigned_wallet_add_transaction = sign_transaction(wallet, wallet_add_transaction)\nprint(signed_wallet_add_transaction)\n```\n\n### On chain operations\n#### Add wallet to chain\nA wallet address once genearated need to be signed and then added to the chain.\n```python\ndef add_wallet(\n    custodian_address: str,\n    jurisdiction: str,\n    public_key: str,\n    ownertype: str = '1',\n    kyc_docs: list = [],\n    specific_data: dict = {},\n)\n```\nExample\n```python\nwallet_add_transaction = node.add_wallet(\n    wallet['address'], '910', wallet['public'], 1)\n\nprint(wallet_add_transaction)\n```\n\n#### Add token to chain\nA token can be created, signed and then validated to add to the chain.\n```python\ndef add_token(\n        token_name: str,\n        token_type: str,\n        first_owner: str,\n        custodian: str,\n        legal_doc_hash: str,\n        amount_created: int,\n        value_created: int,\n        disallowed_regions: list = [],\n        token_attributes: dict = {},\n        is_smart_contract_token: bool = False,\n    )\n```\nExample\n```python\n    token_add_transaction = node.add_token(\n        'my_new_token',\n        '1',\n        '0x16031ef543619a8569f0d7c3e73feb66114bf6a0',\n        '0x16031ef543619a8569f0d7c3e73feb66114bf6a0',\n        'fhdkfhldkhf',\n        10000,\n        10000,\n    )\n```\n\n#### Add transfer\nA transfer can be created between two wallets either unilaterally or bilaterally depending on the transfer type.\n```python\ndef add_transfer(\n        self,\n        asset1_code: int,\n        asset2_code: int,\n        wallet1_address: str,\n        wallet2_address: str,\n        asset1_qty: int,\n        asset2_qty: int,\n        transfer_type: int = 4,\n    )\n```\nExample\n```python\n    transfer_transaction = node.add_transfer(\n        9, 10, '0x16031ef543619a8569f0d7c3e73feb66114bf6a0', '0x16031ef543619a8569f0d7c3e73feb66114bf6a0', 10, 10, 4)\n    signed_transfer = sign_transaction(wallet, transfer_transaction)\n    print(signed_transfer)\n```\n\n#### Get balance\nThe balance of a given token in a wallet, across wallets or all tokens in a wallet can be obtained with get balance function.\n```python\n    node.get_balance(balance_type, wallet_address, token_code)\n```\nExample\n```python\n    node.get_balance('TOKEN_IN_WALLET', '0xc29193dbab0fe018d878e258c93064f01210ec1a', 9)\n```\n\n#### Validate transaction\nA singed transaction need to be validated to be added to the chain.\n```python\n    validate_result = node.validate_transaction(signed_transfer)\n    print(validate_result)\n```\n\n#### Run updater\nRun the miner to create a new block out of the transactions. If no valid transactions are found then an empty block will be created. This operation is not meant to be called and supposed to be run automatically by a chosen node at different intervals of time.\n```python\n    response = node.run_updater()\n    print(response)\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python SDK for Newrl blockchain",
    "version": "0.3.4",
    "split_keywords": [
        "newrl",
        "blockchain",
        "client"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2c9c1c835cf1607d8f3b4cb41547d9703e91cf2c1537da11491c478192ece9ad",
                "md5": "1297891ff323823356f0986e55a41087",
                "sha256": "a8c0e68e4db6005c1da627c63d09c6055f999344c7918621015920a6cb3adf81"
            },
            "downloads": -1,
            "filename": "newrl-0.3.4.tar.gz",
            "has_sig": false,
            "md5_digest": "1297891ff323823356f0986e55a41087",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 9588,
            "upload_time": "2023-01-19T11:31:59",
            "upload_time_iso_8601": "2023-01-19T11:31:59.191852Z",
            "url": "https://files.pythonhosted.org/packages/2c/9c/1c835cf1607d8f3b4cb41547d9703e91cf2c1537da11491c478192ece9ad/newrl-0.3.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-19 11:31:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "asqi",
    "github_project": "newrl",
    "lcname": "newrl"
}
        
Elapsed time: 0.03293s