Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jberg
committed
Nov 16, 2017
0 parents
commit 413fc13
Showing
7 changed files
with
866 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.