Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
iammortimer committed Jan 11, 2020
1 parent e63651a commit 836b07a
Showing 1 changed file with 74 additions and 29 deletions.
103 changes: 74 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# PyWaves
PyWaves is an object-oriented Python interface to the Waves blockchain platform.
# PyCWaves
PyCWaves is an object-oriented Python class interface to the Waves blockchain platform. It is based on PyWaves and enabled multiple instances of PyWaves within the same script.

## Getting Started

You can install PyWaves using:
<!-- You can install PyWaves using:
pip install pywaves
pip install pywaves -->

Copy the .py files to your script location, there will be a pip install package at a later date

## Documentation

Expand All @@ -15,10 +17,13 @@ The library utilizes classes to represent various Waves data structures:
- pywaves.Asset
- pywaves.AssetPair
- pywaves.Order
- pywaves.Contract
- pywaves.Oracle

#### Code Example
```python
import pywaves as pw
from pycwaves import PyCWaves
pw = PyCWaves()

myAddress = pw.Address(privateKey='CtMQWJZqfc7PRzSWiMKaGmWFm4q2VN5fMcYyKDBPDx6S')
otherAddress = pw.Address('3PNTcNiUzppQXDL9RZrK3BcftbujiFqrAfM')
Expand Down Expand Up @@ -205,7 +210,8 @@ The fees for waves/asset transfers, asset issue/reissue/burn and matcher transac
#### Playing with addresses:

```python
import pywaves as pw
from pycwaves import PyCWaves
pw = PyCWaves()

# generate a new address
myAddress = pw.Address()
Expand All @@ -228,7 +234,8 @@ myAddress = pw.Address(seed='seven wrist bargain hope pattern banner plastic map

#### Balances:
```python
import pywaves as pw
from pycwaves import PyCWaves
pw = PyCWaves()

myAddress = pw.Address('3P6WfA4qYtkgwVAsWiiB6yaea2X8zyXncJh')

Expand All @@ -244,7 +251,8 @@ print("Your asset balance is %18d" % myAddress.balance('DHgwrRvVyqJsepd32YbBqUeD

#### Waves and asset transfers:
```python
import pywaves as pw
from pycwaves import PyCWaves
pw = PyCWaves()

myAddress = pw.Address(privateKey='CtMQWJZqfc7PRzSWiMKaGmWFm4q2VN5fMcYyKDBPDx6S')

Expand All @@ -261,7 +269,8 @@ myAddress.sendAsset(recipient = pw.Address('3PNTcNiUzppQXDL9RZrK3BcftbujiFqrAfM'

#### Issuing an asset:
```python
import pywaves as pw
from pycwaves import PyCWaves
pw = PyCWaves()

myToken = myAddress.issueAsset( name = "MyToken",
description = "This is my first token",
Expand All @@ -271,7 +280,8 @@ myToken = myAddress.issueAsset( name = "MyToken",

#### Create an alias:
```python
import pywaves as pw
from pycwaves import PyCWaves
pw = PyCWaves()

pw.setNode(node = 'http://127.0.0.1:6869', chain = 'testnet')

Expand All @@ -281,7 +291,8 @@ myAddress.createAlias("MYALIAS1")

#### Mass payment:
```python
import pywaves as pw
from pycwaves import PyCWaves
pw = PyCWaves()

recipients = ['3PBbp6bg2YEnHfdJtYM7jzzXYQeb7sx5oFg',
'3P4A27aCd3skNja46pcgrLYEnK36TkSzgUp',
Expand All @@ -297,7 +308,8 @@ for address in recipients:

#### Mass transfer of Waves (feature 11)
```python
import pywaves as pw
from pycwaves import PyCWaves
pw = PyCWaves()

transfers = [
{ 'recipient': '3N1xca2DY8AEwqRDAJpzUgY99eq8J9h4rB3', 'amount': 1 },
Expand All @@ -311,7 +323,8 @@ address.massTransferWaves(transfers)

#### Mass transfer of Assets (feature 11)
```python
import pywaves as pw
from pycwaves import PyCWaves
pw = PyCWaves()

transfers = [
{ 'recipient': '3N1xca2DY8AEwqRDAJpzUgY99eq8J9h4rB3', 'amount': 1 },
Expand Down Expand Up @@ -339,7 +352,8 @@ myAddress.dataTransaction(data)
```
#### Token airdrop:
```python
import pywaves as pw
from pycwaves import PyCWaves
pw = PyCWaves()

myAddress = pw.Address(privateKey = '`')
myToken = pw.Asset('4ZzED8WJXsvuo2MEm2BmZ87Azw8Sx7TVC6ufSUA5LyTV')
Expand All @@ -353,7 +367,8 @@ for address in lines:

#### Add a script to an account:
```python
import pywaves as pw
from pycwaves import PyCWaves
pw = PyCWaves()
import base64

pw.setNode(node='<node>', chain='testnet')
Expand Down Expand Up @@ -381,7 +396,8 @@ tx = address.issueSmartAsset('smartTestAsset', 'an asset for testingsmart assets

#### Set a new script for a Smart Asset
```python
import pywaves as pw
from pycwaves import PyCWaves
pw = PyCWaves()
import base64

pw.setNode(node='<node>', chain='testnet')
Expand All @@ -395,7 +411,8 @@ tx = address.setAssetScript(pw.Asset('<asset id>'), script)

#### Invoking a script on a dapp address
```python
import pywaves as pw
from pycwaves import PyCWaves
pw = PyCWaves()

pw.setNode(node='<node>', chain='testnet')

Expand All @@ -405,7 +422,8 @@ tx = address.invokeScript('3N5Wq22bLSf3gt5VwHTCRbRnETeSwpuT8kK', 'fundRecipient'

#### Working with contracts
```python
import pywaves as pw
from pycwaves import PyCWaves
pw = PyCWaves()

pw.setNode(node = '<node>', 'T')

Expand All @@ -416,7 +434,8 @@ contract.faucet()
#### Working with oracles
Querrying oracles:
```python
import pywaves as pw
from pycwaves import PyCWaves
pw = PyCWaves()

oracle = pw.Oracle(oracleAddress = '3P4PCxsJqMzQBALo8zANHtBDZRRquobHQp7')
# getting all data entries for an oracle
Expand All @@ -428,7 +447,8 @@ print(oracle.getData(regex = '^order_total_.*$'))
```
Storing data in an oracle:
```python
import pywaves as pw
from pycwaves import PyCWaves
pw = PyCWaves()

pw.setNode('https://testnode1.wavesnodes.com', 'T')

Expand All @@ -438,7 +458,8 @@ print(oracle.storeData('oracle_test', 'string', 'test entry from oracle class'))

#### Playing with Waves Matcher node (DEX):
```python
import pywaves as pw
from pycwaves import PyCWaves
pw = PyCWaves()

# set Matcher node to use
pw.setMatcher(node = 'http://127.0.0.1:6886')
Expand Down Expand Up @@ -469,7 +490,8 @@ myAddress.cancelOrder(assetPair, myOrder)

#### Getting Market Data from Waves Data Feed (WDF):
```python
import pywaves as pw
from pycwaves import PyCWaves
pw = PyCWaves()

# set the asset pair
WAVES_BTC = pw.AssetPair(pw.WAVES, pw.BTC)
Expand All @@ -495,7 +517,8 @@ for t in ohlcv:

#### LPOS
```python
import pywaves as pw
from pycwaves import PyCWaves
pw = PyCWaves()

# connect to a local testnet node
pw.setNode(node = 'http://127.0.0.1:6869', chain = 'testnet')
Expand All @@ -516,7 +539,8 @@ myAddress.leaseCancel(leaseId)

#### Check an address balance:
```
>>> import pywaves as pw
>>> from pycwaves import PyCWaves
>>> pw = PyCWaves()
>>> pw.Address('3P31zvGdh6ai6JK6zZ18TjYzJsa1B83YPoj')
address = 3P31zvGdh6ai6JK6zZ18TjYzJsa1B83YPoj
publicKey =
Expand All @@ -538,7 +562,8 @@ balances:

#### Generate a new address:
```
>>> import pywaves as pw
>>> from pycwaves import PyCWaves
>>> pw = PyCWaves()
>>> pw.Address()
address = 3P6WfA4qYtkgwVAsWiiB6yaea2X8zyXncJh
publicKey = EYNuSmW4Adtcc6AMCZyxkiHMPmF2BZ2XxvjpBip3UFZL
Expand All @@ -551,7 +576,8 @@ balances:

#### Check an asset:
```
>>> import pywaves as pw
>>> from pycwaves import PyCWaves
>>> pw = PyCWaves()
>>> pw.Asset('DHgwrRvVyqJsepd32YbBqUeDH4GJ1N984X8QoekjgH8J')
status = Issued
assetId = DHgwrRvVyqJsepd32YbBqUeDH4GJ1N984X8QoekjgH8J
Expand Down Expand Up @@ -593,7 +619,8 @@ matcher = http://127.0.0.1:6886

#### Offline signing a future transaction:
```
>>> import pywaves as pw
>>> from pycwaves import PyCWaves
>>> pw = PyCWaves()
>>> pw.setOffline()
>>> myAddress=pw.Address(privateKey="F2jVbjrKzjUsZ1AQRdnd8MmxFc85NQz5jwvZX4BXswXv")
>>> recipient=pw.Address("3P8Ya6Ary5gzwnzbBXDp3xjeNG97JEiPcdA")
Expand All @@ -613,7 +640,8 @@ matcher = http://127.0.0.1:6886

#### Offline signing time lock/unlock transactions:
```
>>> import pywaves as pw
>>> from pycwaves import PyCWaves
>>> pw = PyCWaves()
>>> pw.setOffline()
>>> myAddress=pw.Address(privateKey="F2jVbjrKzjUsZ1AQRdnd8MmxFc85NQz5jwvZX4BXswXv")
# generate a lockbox address
Expand Down Expand Up @@ -649,7 +677,8 @@ matcher = http://127.0.0.1:6886
PyWaves supports both mainnet and testnet chains. By default, PyWaves connects to the mainnet RPC server at https://nodes.wavesnodes.com. It's possible to specify a different server and chain with the setNode() function

```python
import pywaves as pw
from pycwaves import PyCWaves
pw = PyCWaves()

# connects to a local testnet node
pw.setNode(node = 'http://127.0.0.1:6869', chain = 'testnet')
Expand All @@ -659,6 +688,22 @@ pw.setNode(node = 'http://127.0.0.1:6869', chain = 'mainnet')

```

## Connecting to a multiple nodes or chains

PyCWaves supports both mainnet and testnet chains. By default, PyWaves connects to the mainnet RPC server at https://nodes.wavesnodes.com. It's possible to specify multiple servers and chains by invoking PyCWaves multple times

```python
from pycwaves import PyCWaves
pw = PyCWaves()

# connects to a local testnet node
pw.setNode(node = 'http://127.0.0.1:6869', chain = 'testnet')

pw2 = PyCWaves()
# connects to a local mainnet node
pw2.setNode(node = 'http://127.0.0.1:6869', chain = 'mainnet')

```

## License
Code released under the [MIT License](https://github.com/PyWaves/PyWaves/blob/master/LICENSE).
Expand Down

0 comments on commit 836b07a

Please sign in to comment.