Skip to main content

🐳 Ocean/Web3py wrapper.

Project description

banner

squid-py

💧 Python wrapper, allowing to integrate the basic Ocean/web3.py capabilities oceanprotocol.com

Travis (.com) Codacy coverage PyPI GitHub contributors


Table of Contents


Features

Squid-py include the methods to make easy the connection with contracts deployed in different networks. This repository include also the methods to encrypt and decrypt information.

Prerequisites

You should have running an instance of BigchainDB and ganache-cli. To get started quickly, you can start the docker instance in the docker directory:

docker-compose -f ./docker/docker-compose.yml up

The docker container has three main service images running;

  1. bigchaindb/bigchaindb:2.0.0-beta1 (with tendermint)
  2. oceanprotocol/keeper-contracts:0.1
  3. oceanprotocol/aquarius:0.1 (API documentation exposed at http://localhost:5000/api/v1/docs/)

Mac: if you are running on mac, gnu-sed needs to be installed

brew install --with-default-names gnu-sed

Quick-start

When you want to interact with the contracts you have to instantiate this class:

from squid_py.ocean_contracts import OceanContractsWrapper
ocean = OceanContractsWrapper(host='http://localhost', port=8545, config_path='config.ini')    
ocean.init_contracts()

If you do not pass the config_path you can pass using $CONFIG_FILE environment variable.

It is possible do not pass the config file, but you should be sure of provide the host, port and addresses. If you opt for this you can pass the addresses using the following environment variables:

  • MARKET_ADDRESS Address of your market contract deployed in the network
  • AUTH_ADDRESS Address of your auth contract deployed in the network.
  • TOKEN_ADDRESS Address of your token contract deployed in the network.
  • KEEPER_HOST You can pass the host of your keeper instead of call it explicitly in class.
  • KEEPER_PORT You can pass the port of your keeper instead of call it explicitly in class.

After that you have to init the contracts. And you can start to use the methods in the different contracts.

You will find as well two methods that allow you to register and consume an asset.

from squid_py.consumer import register, consume
register(publisher_account=ocean.web3.eth.accounts[1],
         aquarius_account=ocean.web3.eth.accounts[0],
         price=10,
         ocean_contracts_wrapper=ocean,
         json_metadata=json_consume
                          )
consume(resource=resouce_id,
        consumer_account=ocean.web3.eth.accounts[1],
        aquarius_account=ocean.web3.eth.accounts[0],
        ocean_contracts_wrapper=ocean,
        json_metadata=json_request_consume)

Configuration

[keeper-contracts]
market.address = # Address of your market contract deployed in the network. [Mandatory]
auth.address = # Address of your auth contract deployed in the network. [Mandatory]
token.address = # Address of your token contract deployed in the network. [Mandatory]
keeper.host = # You can pass the host of your keeper instead of call it explicitly in class.
keeper.port = 8545  # You can pass the port of your keeper instead of call it explicitly in class.
contracts.folder =  # You can pass the directory of your contracts instead of use the library.

Code style

The information about code style in python is documented in this two links python-developer-guide and python-style-guide.

Testing

Automatic tests are setup via Travis, executing tox. Our test use pytest framework.

New Version

The bumpversion.sh script helps to bump the project version. You can execute the script using as first argument {major|minor|patch} to bump accordingly the version.

License

Copyright 2018 Ocean Protocol Foundation Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.


Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

squid-py-0.1.3.2.tar.gz (26.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

squid_py-0.1.3.2-py2.py3-none-any.whl (20.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file squid-py-0.1.3.2.tar.gz.

File metadata

  • Download URL: squid-py-0.1.3.2.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.3.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5

File hashes

Hashes for squid-py-0.1.3.2.tar.gz
Algorithm Hash digest
SHA256 e5e6f9c467245a5a4ae936b3b9f11f7a2c8e776c0d5530c2779f9c1a96b99d78
MD5 e327c9ef9fd0d47660ae608b76d6f108
BLAKE2b-256 bf3334a5a07e9109f49f8745f22e2884391b7ed7fa850927a26e35ab40eeec0e

See more details on using hashes here.

File details

Details for the file squid_py-0.1.3.2-py2.py3-none-any.whl.

File metadata

  • Download URL: squid_py-0.1.3.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.3.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5

File hashes

Hashes for squid_py-0.1.3.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 83ab1ef1289a1e4157cb218069faf28a872d8fc717cd22235e7a7cf35e4ac3c3
MD5 695e39b2c6e6e3903a674230d2a28cca
BLAKE2b-256 2455b1f21e5380568de90af2f692079d85e3b01b63b28da34d3c5f40312d76c1

See more details on using hashes here.

Supported by

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