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'))
""" 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()))
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] """
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()))