Beispiel #1
0
    def __init__(self, connection_manager, contract_address=None):

        network = connection_manager.network
        app_mode = connection_manager.options['networks'][network]['app_mode']

        if app_mode == "RRC20":
            self.contract_MoC = RDOCMoC(connection_manager,
                                        contract_address=contract_address,
                                        contracts_discovery=True)
        else:
            self.contract_MoC = MoC(connection_manager,
                                    contract_address=contract_address,
                                    contracts_discovery=True)

        if network in [
                'mocTestnetAlpha', 'mocTestnet', 'rdocTestnetAlpha',
                'rdocTestnet'
        ]:
            self.sc_Price_Provider = CoinPairPrice(
                connection_manager,
                contract_address=self.contract_MoC.sc_moc_state.price_provider(
                ))
        else:
            if app_mode == "RRC20":
                self.sc_Price_Provider = MoCMedianizer(
                    connection_manager,
                    contract_address=self.contract_MoC.sc_moc_state.
                    price_provider())
            else:
                self.sc_Price_Provider = RDOCMoCMedianizer(
                    connection_manager,
                    contract_address=self.contract_MoC.sc_moc_state.
                    price_provider())
Where replace with your PK, and also you need to have funds in this account
"""

from decimal import Decimal
from web3 import Web3
from moneyonchain.manager import ConnectionManager
from moneyonchain.moc import MoC

network = 'mocTestnet'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print(
    "Connected: {conectado}".format(conectado=connection_manager.is_connected))

moc_main = MoC(connection_manager)

amount = Decimal(10.0)
print("Reedem Free Doc: {0}".format(amount))

# This transaction is not async, you have to wait to the transaction is mined
print("Please wait to the transaction be mined!...")
tx_hash, tx_receipt, tx_logs = moc_main.reedeem_free_doc(amount)
print("Tx hash: [{0}]".format(Web3.toHex(tx_hash)))
print("Transaction done!")
if tx_logs:
    amount_doc = Decimal(Web3.fromWei(tx_logs[0]['args']['amount'], 'ether'))
    amount_btc = Decimal(
        Web3.fromWei(tx_logs[0]['args']['reserveTotal'], 'ether'))
    amount_commision = Decimal(
        Web3.fromWei(tx_logs[0]['args']['commission'], 'ether'))
Beispiel #3
0
import logging
import logging.config

logging.basicConfig(
    level=logging.DEBUG,
    format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
    datefmt='%Y-%m-%d %H:%M:%S')
log = logging.getLogger('default')

network = 'mocMainnet2'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print(
    "Connected: {conectado}".format(conectado=connection_manager.is_connected))

moc_main = MoC(connection_manager)

amount_want_to_mint = Decimal(0.00001)

total_amount, commission_value, interest_value = moc_main.amount_mint_btc2x(
    amount_want_to_mint)
print("To mint {0} BTC2X need {1} RBTC. Commision: {2} Interest: {3}".format(
    format(amount_want_to_mint, '.18f'), format(total_amount, '.18f'),
    format(commission_value, '.18f'), format(interest_value, '.18f')))

# Mint BTC2X
# This transaction is not async, you have to wait to the transaction is mined
print("Please wait to the transaction be mined!...")
tx_hash, tx_receipt, tx_logs, tx_logs_formatted = moc_main.mint_btc2x(
    amount_want_to_mint)
print("Tx hash: [{0}]".format(Web3.toHex(tx_hash)))
Beispiel #4
0
import logging
import logging.config

logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
    datefmt='%Y-%m-%d %H:%M:%S')
log = logging.getLogger('default')

network = 'mocTestnetAlpha'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print(
    "Connected: {conectado}".format(conectado=connection_manager.is_connected))

contract_moc = MoC(connection_manager)
contract_stopper = MoCStopper(connection_manager)

contract_to_pause = contract_moc.address()
tx_hash, tx_receipt = contract_stopper.pause(contract_to_pause)
if tx_receipt:
    print("Stop Contract Address: {address} successfully!".format(
        address=contract_to_pause))
else:
    print("Error Stopping contract")
"""
Connecting to mocTestnetAlpha...
Connected: True
Stop Contract Address: 0x01AD6f8E884ed4DDC089fA3efC075E9ba45C9039 successfully!
2020-10-08 10:02:39 root         INFO     Successfully paused contract 0x01AD6f8E884ed4DDC089fA3efC075E9ba45C9039 in Block [1240607] Hash: [0x159193398e0981a3f91f383cfd272d372d0fffd80c0de2fa2b4cbb1bf8f29f60] Gas used: [24926] From: [0xB7d4B3c37d17D66B88da41e8A87561323A6DBDA0]
"""
Beispiel #5
0
from moneyonchain.manager import ConnectionManager
from moneyonchain.moc import MoC

network = 'mocMainnet2'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print(
    "Connected: {conectado}".format(conectado=connection_manager.is_connected))

moc_main = MoC(connection_manager)
l_info = moc_main.settlement_info()
for info in l_info:
    print("{0}:{1}".format(info[0], info[1]))
Beispiel #6
0
"""
Oracle price get current oracle from MOC
"""

from moneyonchain.manager import ConnectionManager
from moneyonchain.moc import MoC
from moneyonchain.moc import MoCMedianizer

# Network types
#
# mocTestnet: Testnet
# mocMainnet2: Production Mainnet

network = 'mocTestnet'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print(
    "Connected: {conectado}".format(conectado=connection_manager.is_connected))

print("Connecting to MoC Main Contract")
moc_contract = MoC(connection_manager)

oracle_provider = moc_contract.sc_moc_state.price_provider()
print("Oracle address: {0}".format(oracle_provider))

oracle = MoCMedianizer(connection_manager, contract_address=oracle_provider)

print("Bitcoin Price in USD: {0}".format(oracle.price()))
Where replace with your PK, and also you need to have funds in this account
"""

from decimal import Decimal
from web3 import Web3
from moneyonchain.manager import ConnectionManager
from moneyonchain.moc import MoC

network = 'mocTestnet'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print(
    "Connected: {conectado}".format(conectado=connection_manager.is_connected))

moc_main = MoC(connection_manager)

amount_want_to_mint = Decimal(0.001)

total_amount, commission_value, interest_value = moc_main.amount_mint_btc2x(
    amount_want_to_mint)
print("To mint {0} BTC2X need {1} RBTC. Commision: {2} Interest: {3}".format(
    format(amount_want_to_mint, '.18f'), format(total_amount, '.18f'),
    format(commission_value, '.18f'), format(interest_value, '.18f')))

# Mint BTC2X
# This transaction is not async, you have to wait to the transaction is mined
print("Please wait to the transaction be mined!...")
tx_hash, tx_receipt, tx_logs = moc_main.mint_btc2x(amount_want_to_mint)
print("Tx hash: [{0}]".format(Web3.toHex(tx_hash)))
print("Transaction done!")
Beispiel #8
0
"""
Get BPRO Price
Get Bitcoin Price
Get BTCX Price
"""

from moneyonchain.manager import ConnectionManager
from moneyonchain.moc import MoC

network = 'mocMainnet2'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print("Connected: {conectado}".format(conectado=connection_manager.is_connected))

contract = MoC(connection_manager)
print("Bitcoin price in usd: {0}".format(contract.bitcoin_price()))
print("BPRO price in usd: {0}".format(contract.bpro_price()))
print("BTC2X price in usd: {0}".format(contract.btc2x_tec_price() * contract.bitcoin_price()))

Beispiel #9
0
"""
This script list all of the proxy and implementation addresses of the contracts
"""

from moneyonchain.manager import ConnectionManager
from moneyonchain.moc import MoC, MoCConverter, MoCSettlement, MoCExchange, MoCInrate, MoCBurnout, MoCBProxManager, \
    MoCState, MoCConnector, MoCMedianizer
from moneyonchain.token import DoCToken, BProToken


network = 'mocMainnet2'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print("Connected: {conectado}".format(conectado=connection_manager.is_connected))

moc_main = MoC(connection_manager)
addresses = moc_main.connector_addresses()

count = 0
lines = list()

md_header = '''
| Nº     | Contract                      | Address Proxy                  | Address Implementation           |
| :---:  | :---------------------------- | ----------------------------   | -------------------------------- |
'''

# MOC
count += 1
line = '| {0} | {1}  | {2}  | {3} |'.format(count, 'MOC', addresses['MoC'], moc_main.implementation())
lines.append(line)
Where replace with your PK, and also you need to have funds in this account
"""


from decimal import Decimal
from web3 import Web3
from moneyonchain.manager import ConnectionManager
from moneyonchain.moc import MoC


network = 'mocTestnet'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print("Connected: {conectado}".format(conectado=connection_manager.is_connected))

moc_main = MoC(connection_manager)

amount = Decimal(0.001)
print("Reedem BPro: {0}".format(amount))

# Reedeem BPro
# This transaction is not async, you have to wait to the transaction is mined
print("Please wait to the transaction be mined!...")
tx_hash, tx_receipt, tx_logs, tx_logs_formatted = moc_main.reedeem_bpro(amount)
print("Tx hash: [{0}]".format(Web3.toHex(tx_hash)))
print("Transaction done!")
if tx_logs:
    amount = Decimal(Web3.fromWei(tx_logs['RiskProRedeem'][0]['args']['amount'], 'ether'))
    amount_usd = moc_main.bpro_amount_in_usd(amount)
    print("You reedeem {0} BPro equivalent to {1} USD".format(format(amount, '.18f'), format(amount_usd, '.2f')))
    print(tx_logs_formatted['RiskProRedeem'].print_row())
Beispiel #11
0
from moneyonchain.manager import ConnectionManager
from moneyonchain.governance import MoCStopper
from moneyonchain.moc import MoC

import logging
import logging.config

logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
    datefmt='%Y-%m-%d %H:%M:%S')
log = logging.getLogger('default')

network = 'mocMainnet2'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print(
    "Connected: {conectado}".format(conectado=connection_manager.is_connected))

contract_moc = MoC(connection_manager)
contract_stopper = MoCStopper(connection_manager)

print("Paused: {0}".format(contract_moc.paused()))
print("Stoppable: {0}".format(contract_moc.stoppable()))
print("Stopper: {0}".format(contract_moc.stopper()))
print("Owner: {0}".format(contract_stopper.owner()))
Beispiel #12
0
"""
To run this script need private key, run this scripts with:

user> export ACCOUNT_PK_SECRET=fdas46f4dsafds7f89ds7f8dafd4fdsaf3dsA4ds5a
user> python ./example_moc_mint_bpro.py

Where replace with your PK, and also you need to have funds in this account
"""

from decimal import Decimal
from web3 import Web3
from moneyonchain.manager import ConnectionManager
from moneyonchain.moc import MoC

network = 'mocTestnet'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print(
    "Connected: {conectado}".format(conectado=connection_manager.is_connected))

moc_main = MoC(connection_manager)

# This transaction is not async, you have to wait to the transaction is mined
print("Please wait to the transaction be mined!...")
tx_hash, tx_receipt, tx_logs, tx_logs_formatted = moc_main.reedeem_all_doc()
print("Tx hash: [{0}]".format(Web3.toHex(tx_hash)))
print("Transaction done!")
print(tx_receipt)
print(tx_logs)
import logging
import logging.config

logging.basicConfig(
    level=logging.DEBUG,
    format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
    datefmt='%Y-%m-%d %H:%M:%S')
log = logging.getLogger('default')

network = 'mocTestnet'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print(
    "Connected: {conectado}".format(conectado=connection_manager.is_connected))

moc_main = MoC(connection_manager)

amount_want_to_mint = Decimal(0.001)

total_amount, commission_value = moc_main.amount_mint_bpro(amount_want_to_mint)
print("To mint {0} bitpro need {1} RBTC. Commision {2}".format(
    format(amount_want_to_mint, '.18f'), format(total_amount, '.18f'),
    format(commission_value, '.18f')))

# Mint BPro
print("Please wait to the transaction be mined!...")
tx_hash, tx_receipt, tx_logs, tx_logs_formatted = moc_main.mint_bpro(
    amount_want_to_mint)
print("Tx hash: [{0}]".format(Web3.toHex(tx_hash)))
print("Transaction done!")
if tx_logs:
from moneyonchain.manager import ConnectionManager
from moneyonchain.moc import MoC

network = 'mocTestnetAlpha'
connection_manager = ConnectionManager(network=network)
print("Connecting to %s..." % network)
print(
    "Connected: {conectado}".format(conectado=connection_manager.is_connected))

moc_moc = MoC(connection_manager, contracts_discovery=True)
print("Connector: {0}".format(moc_moc.connector()))

print("Addresses: {0}".format(moc_moc.connector_addresses()))