Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
Added WIP Ethereum contract and integrated minting to FUTURE
Browse files Browse the repository at this point in the history
  • Loading branch information
rtrevinnoc committed Feb 17, 2021
1 parent dae30a3 commit b097fdd
Show file tree
Hide file tree
Showing 14 changed files with 66,404 additions and 3 deletions.
17 changes: 17 additions & 0 deletions Monad.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,21 @@
from itertools import tee, islice, chain
from nltk.corpus import wordnet
from SPARQLWrapper import SPARQLWrapper, JSON
from web3 import Web3
from polyglot.detect import Detector

import os.path, os, shutil, json, random, smtplib, sys, socket, re, mimetypes, datetime, lmdb, hnswlib, time, bson, requests
bson.loads = bson.BSON.decode
bson.dumps = bson.BSON.encode

try:
from config import WEB3API, ETHEREUM_ACCOUNT, CONTRACT_CODE, CONTRACT_ADDRESS
WEB3API.eth.default_account = ETHEREUM_ACCOUNT
abi = json.load(open(CONTRACT_CODE))['abi']
contract = WEB3API.eth.contract(address=CONTRACT_ADDRESS, abi=abi)
except:
print("No connection to Ethereum network.")

sparql = SPARQLWrapper("http://dbpedia.org/sparql")
sparql.setReturnFormat(JSON)

Expand Down Expand Up @@ -477,6 +486,14 @@ def inferLanguage(string: str) -> str:
except:
return "Undefined"

def mintTokens(queryVec: np.array, answerVec: np.array) -> int:
if WEB3API.isConnected():
queryVec = (queryVec * 100).astype(int).tolist()
answerVec = (answerVec * 100).astype(int).tolist()
return contract.functions.mint(queryVec, answerVec).call()
else:
raise "Cannot connect to Ethereum network."


class Monad():
def __init__(self, database: str, mapSize=int(1e12)):
Expand Down
1 change: 1 addition & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pip3 install -U wordnet
pip3 install -U numexpr
pip3 install -U flask-caching
pip3 install -U pillow
pip3 install -U web3

python3 -m spacy download en_core_web_sm
python3 -c "import nltk; nltk.download('punkt')"
Expand Down
5 changes: 5 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ It is suggested to start with this configuration template, which is essentially
#!/usr/bin/env python3
# -*- coding: utf8 -*-
import secrets
from web3 import Web3
WTF_CSRF_ENABLED = True
SECRET_KEY = secrets.token_urlsafe(16)
Expand All @@ -65,6 +66,10 @@ It is suggested to start with this configuration template, which is essentially
COLABORATE = "<a href='https://github.com/rtrevinnoc/FUTURE'>COLABORATE</a>"
CACHE_TIMEOUT = 15
CACHE_THRESHOLD = 100
WEB3API = Web3(Web3.HTTPProvider('http://127.0.0.1:8545'))
ETHEREUM_ACCOUNT = WEB3API.eth.accounts[0]
CONTRACT_CODE = 'future-token/build/contracts/FUTURE.json'
CONTRACT_ADDRESS = "0x2ebDA3D6B2F24aE57164b0384daa9af2C0D17323"
After you have configurated your FUTURE instance, but before you can start the server, you will be required to add a minimum of ~25 urls to your local index, by executing:

Expand Down
30,397 changes: 30,397 additions & 0 deletions future-token/build/contracts/FUTURE.json

Large diffs are not rendered by default.

16,851 changes: 16,851 additions & 0 deletions future-token/build/contracts/IERC20.json

Large diffs are not rendered by default.

0 comments on commit b097fdd

Please sign in to comment.