Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jberg committed Nov 16, 2017
0 parents commit 413fc13
Show file tree
Hide file tree
Showing 7 changed files with 866 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
.DS_Store
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Jorrit van den Berg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
90 changes: 90 additions & 0 deletions README.md
@@ -0,0 +1,90 @@
# Sunny dApp
This repository contains a insurance smart contract that pays out based on a observed weather condition that can be signalled by an oracle. The decentralized application is build for the NEO blockchain using the Python tools (neo-boa and neo-pyton).

## Table of Contents

- [Disclaimer](#disclaimer)
- [Installation](#installation)
- [Usage](#usage)
- [Maintainer](#maintainer)
- [License](#license)

## Disclaimer
This smart contract is for experimenal purposes and requires rigorous testing before deployment on the Main Net.

## Installation

### Dependencies

1. Install GIT
[GIT installation guide] (https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)

2. Install Docker CE
[Docker CE installation guide] (https://docs.docker.com/engine/installation/)

3. To use Docker without sudo

``` bash
# Add your username to the Docker group
sudo usermod -aG docker $USER

# Logout and login again for this to take effect
logout
```

## Usage
To deploy the smart contract, it first needs to be set to the correct OWNER, which is a byte array of your hex script hash. Having done so, the script can be compiled with pip neo-boa and deployed with the neo-python container.

Having Docker installed, you could do it like this:

``` bash
# Clone the git repository
git clone https://github.com/JorritvandenBerg/sunny-dapp.git

# Go to the sunny_dapp directory
cd sunny-dapp

# Build the neo-boa docker-container
docker build -t neo-boa ./neo-boa

# Compile the sunny_dapp.py smart contract in the smartcontract directory
docker run -it -v /absolute/path/to/sunny_dapp/smartcontract:/python-contracts -v /absolute/path/to/sunny_dapp/smartcontract/compiled:/compiled-contracts neo-boa

# Check if there is a compiled .avm file in the smartcontract subdirectory
cd smartcontract

# Go back to the main directory
cd ..

# Build the neo-python docker container
docker build neo-python -t ./neo-python

# Run the neo-python Docker container
docker run -it -v /absolute/path/to/sunny_dap/smartcontract/compiled:/smartcontract neo-python

# Create or import a wallet
create wallet {/path}

# Import WIF of your OWNER address
import wif {wif}

# Import the contract (with storage enabled)
import contract /smartcontract/sunny_dapp.avm 0710 05 True

# Fill in the metadata form and optionally deploy with your wallet password after a succesful test invoke

# Wait a few minutes for deployment and grab the contract hash with
contract search <entered auhtor name>

```

## Maintainers

[@JorritvandenBerg](mailto:jorrit_van_den_berg@hotmail.com)

## License

[License](LICENSE)



9 changes: 9 additions & 0 deletions neo-boa/Dockerfile
@@ -0,0 +1,9 @@
FROM ubuntu:16.04

RUN apt-get update && apt-get -y install python3-dev python3-pip

RUN pip3 install neo-boa

COPY compiler.py /compiler.py

CMD python3 compiler.py
14 changes: 14 additions & 0 deletions neo-boa/compiler.py
@@ -0,0 +1,14 @@
import os
from boa.compiler import Compiler

input_file_dir = '/python-contracts'
output_file_dir = '/compiled-contracts'

for file in os.listdir(input_file_dir):
if file.endswith('.py'):
file_name = file.replace('.py','')
input_file_path = os.path.join(input_file_dir, file)
output_file = file_name + '.avm'
output_file_path = os.path.join(output_file_dir, output_file)
Compiler.load_and_save(path=input_file_path, output_path=output_file_path)
print('Compiled ' + file)
11 changes: 11 additions & 0 deletions neo-python/Dockerfile
@@ -0,0 +1,11 @@
FROM ubuntu:16.04

RUN apt-get update && apt-get -y install git python3-dev python3-pip libleveldb-dev libssl-dev

RUN git clone https://github.com/CityOfZion/neo-python.git

WORKDIR neo-python

RUN pip3 install -r requirements.txt

CMD python3 prompt.py

0 comments on commit 413fc13

Please sign in to comment.